[Pkg-php-commits] [php/upstream-sid] Imported Upstream version 5.3.5

Ondřej Surý ondrej at sury.org
Wed Feb 16 15:13:29 UTC 2011


---
 INSTALL                                            |   36 +-
 LICENSE                                            |    2 +-
 Makefile.global                                    |    1 +
 NEWS                                               |  362 +-
 TSRM/tsrm_virtual_cwd.c                            |  301 +-
 TSRM/tsrm_virtual_cwd.h                            |   24 +-
 UPGRADING                                          |   15 +-
 UPGRADING.INTERNALS                                |   23 +
 Zend/acinclude.m4                                  |    4 +-
 Zend/tests/bug45180.phpt                           |    8 +-
 Zend/tests/bug45186.phpt                           |    8 +-
 Zend/tests/bug51176.phpt                           |    6 +-
 Zend/tests/bug52361.phpt                           |   35 +
 Zend/tests/bug52484.phpt                           |   19 +
 Zend/tests/bug52484_2.phpt                         |   19 +
 Zend/tests/bug52484_3.phpt                         |   19 +
 Zend/tests/bug52508.phpt                           |   20 +
 Zend/tests/bug52879.phpt                           |   16 +
 Zend/tests/bug52939.phpt                           |   40 +
 Zend/tests/bug53305.phpt                           |   19 +
 Zend/tests/bug53632.phpt                           |   10 +
 Zend/tests/call_static_003.phpt                    |    4 +-
 Zend/tests/call_static_007.phpt                    |    2 +-
 Zend/tests/declare_001.phpt                        |    6 +
 Zend/tests/gc_032.phpt                             |   40 +
 Zend/tests/multibyte/multibyte_encoding_006.phpt   |  Bin 0 -> 599 bytes
 Zend/tests/objects_032.phpt                        |   40 +
 Zend/tests/unset_cv05.phpt                         |    2 +-
 Zend/tests/unset_cv06.phpt                         |    2 +-
 Zend/zend_API.c                                    |    4 +-
 Zend/zend_compile.c                                |   17 +-
 Zend/zend_constants.c                              |   14 +-
 Zend/zend_exceptions.c                             |   13 +-
 Zend/zend_execute.c                                |    4 +-
 Zend/zend_execute_API.c                            |    5 +-
 Zend/zend_gc.c                                     |   44 +-
 Zend/zend_hash.c                                   |    5 +-
 Zend/zend_hash.h                                   |   10 +-
 Zend/zend_ini_scanner.c                            | 2440 ++--
 Zend/zend_ini_scanner.l                            |    4 +-
 Zend/zend_ini_scanner_defs.h                       |    2 +-
 Zend/zend_language_scanner.c                       |  341 +-
 Zend/zend_language_scanner.l                       |    6 +-
 Zend/zend_language_scanner_defs.h                  |    3 +-
 Zend/zend_object_handlers.c                        |   56 +-
 Zend/zend_objects.c                                |   10 +-
 Zend/zend_strtod.c                                 |    4 +-
 Zend/zend_variables.c                              |   13 +-
 Zend/zend_variables.h                              |   13 +-
 Zend/zend_vm_execute.h                             |   44 +
 acinclude.m4                                       |   37 +-
 aclocal.m4                                         |   37 +-
 configure                                          | 6302 +++----
 configure.in                                       |   12 +-
 ext/bz2/bz2.c                                      |    7 +-
 ext/calendar/calendar.c                            |   13 +-
 ext/calendar/tests/bug52744.phpt                   |   12 +
 ext/com_dotnet/com_persist.c                       |    9 +-
 ext/curl/interface.c                               |   34 +-
 ext/curl/php_curl.h                                |    4 +-
 ext/curl/tests/bug52202.phpt                       |   16 +
 ext/curl/tests/bug52827.phpt                       |   32 +
 ext/curl/tests/curl_multi_getcontent_basic3.phpt   |    7 +-
 ext/curl/tests/curl_multi_getcontent_error1.phpt   |    4 +-
 ext/curl/tests/curl_multi_getcontent_error2.phpt   |    4 +-
 ext/curl/tests/curl_multi_getcontent_error3.phpt   |    4 +-
 ext/curl/tests/curl_multi_getcontent_error4.phpt   |    4 +-
 ext/curl/tests/curl_setopt_basic001.phpt           |    2 +-
 ext/curl/tests/curl_setopt_error.phpt              |    1 +
 ext/date/lib/parse_date.c                          |   12 +-
 ext/date/lib/parse_date.c.orig                     |  206 +-
 ext/date/lib/parse_date.re                         |   10 +-
 ext/date/lib/parse_iso_intervals.c                 |    4 +-
 ext/date/lib/timelib.c                             |   17 +-
 ext/date/lib/timelib.h                             |    3 +-
 ext/date/lib/timezonedb.h                          | 1333 +-
 ext/date/lib/tm2unixtime.c                         |    3 +-
 ext/date/lib/unixtime2tm.c                         |    8 +-
 ext/date/php_date.c                                |   65 +-
 ext/date/php_date.h                                |    8 +-
 ext/date/tests/010.phpt                            |  603 +-
 ext/date/tests/DateTime_modify_variation1.phpt     |  232 +-
 ext/date/tests/big_year.phpt                       |   17 +
 ext/date/tests/bug33415-2.phpt                     |    4 +-
 ext/date/tests/bug46874.phpt                       |   31 +
 ext/date/tests/bug52342.phpt                       |   23 +
 ext/date/tests/bug52430.phpt                       |   37 +
 ext/date/tests/bug52454.phpt                       |   22 +
 ext/date/tests/bug52577.phpt                       |   19 +
 ext/date/tests/bug52668.phpt                       |   25 +
 ext/date/tests/date_modify_variation2.phpt         |  232 +-
 .../tests/timezone_abbreviations_list_basic1.phpt  |    4 +-
 ext/dba/config.m4                                  |    4 +-
 ext/dba/tests/dba_cdb_make.phpt                    |    2 +-
 ext/dom/tests/bug52656.phpt                        |   14 +
 ext/dom/text.c                                     |    4 +-
 ext/enchant/enchant.c                              |   12 +-
 ext/exif/tests/exif006.phpt                        |    2 +-
 ext/ext_skel                                       |    4 +-
 ext/fileinfo/fileinfo.c                            |    5 +-
 ext/filter/logical_filters.c                       |   49 +-
 ext/filter/tests/030.phpt                          |   55 +-
 ext/filter/tests/bug39763.phpt                     |    2 +-
 ext/filter/tests/bug52929.phpt                     |   18 +
 ext/gd/gd.c                                        |   18 +-
 ext/gd/gd_ctx.c                                    |    5 +-
 ext/gmp/gmp.c                                      |   55 +-
 ext/gmp/tests/005.phpt                             |   10 +-
 ext/gmp/tests/040.phpt                             |    2 +-
 ext/gmp/tests/bug50283.phpt                        |    9 +-
 ext/gmp/tests/bug52906.phpt                        |   46 +
 ext/gmp/tests/gmp_nextprime.phpt                   |    2 +-
 ext/hash/php_hash_tiger.h                          |    4 +-
 ext/iconv/iconv.c                                  |   53 +-
 ext/iconv/tests/bug51250.phpt                      |   29 +
 ext/iconv/tests/bug52941.phpt                      |   41 +
 ext/iconv/tests/bug53304.phpt                      |   13 +
 ext/iconv/tests/iconv_stream_filter_delimiter.phpt |    2 +-
 ext/imap/php_imap.c                                |   16 +-
 ext/interbase/config.w32                           |    5 +-
 ext/intl/dateformat/dateformat_attr.c              |    1 +
 ext/intl/dateformat/dateformat_format.c            |   26 +-
 ext/intl/dateformat/dateformat_parse.c             |   13 +-
 ext/intl/formatter/formatter_attr.c                |    9 +-
 ext/intl/tests/bug50590.phpt                       |   13 +
 ext/intl/tests/dateformat_format.phpt              |  138 +-
 ext/intl/tests/dateformat_format_parse.phpt        |   20 +-
 ext/intl/tests/dateformat_get_locale.phpt          |    6 +
 .../tests/dateformat_parse_timestamp_parsepos.phpt |    6 +-
 ext/intl/tests/formatter_get_set_symbol.phpt       |    7 +-
 ext/json/json.c                                    |    4 +-
 ext/ldap/config.w32                                |   13 +-
 ext/mbstring/libmbfl/mbfl/mbfilter.c               |    4 +
 ext/mbstring/mbstring.c                            |   12 +-
 ext/mbstring/tests/bug43301.phpt                   |    4 +-
 ext/mbstring/tests/bug52861.phpt                   |   26 +
 ext/mbstring/tests/bug52931.phpt                   |   22 +
 ext/mbstring/tests/bug52981.phpt                   |   23 +
 .../tests/mb_decode_mimeheader_variation1.phpt     |    9 +-
 ext/mbstring/tests/mb_send_mail01.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail02.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail03.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail04.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail05.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail06.phpt             |    4 +-
 ext/mbstring/tests/mb_send_mail07.phpt             |    4 +-
 .../tests/mb_strcut_missing_boundary_check.phpt    |   31 +
 ext/mbstring/ucgendat/OPENLDAP_LICENSE             |   47 +
 ext/mbstring/ucgendat/README                       |    9 +
 ext/mbstring/ucgendat/ucgendat.c                   | 1985 ++
 ext/mbstring/unicode_data.h                        | 7004 ++++---
 ext/mssql/php_mssql.c                              |   12 +-
 ext/mysql/php_mysql.c                              |  164 +-
 ext/mysql/tests/mysql_trace_mode.phpt              |    2 +
 ext/mysqli/config.m4                               |    3 +-
 ext/mysqli/mysqli.c                                |  199 +-
 ext/mysqli/mysqli_api.c                            |  159 +-
 ext/mysqli/mysqli_driver.c                         |    6 +-
 ext/mysqli/mysqli_embedded.c                       |    6 +-
 ext/mysqli/mysqli_exception.c                      |    5 +-
 ext/mysqli/mysqli_fe.c                             |   29 +-
 ext/mysqli/mysqli_fe.h                             |  135 +
 ext/mysqli/mysqli_libmysql.h                       |    2 +-
 ext/mysqli/mysqli_nonapi.c                         |  105 +-
 ext/mysqli/mysqli_priv.h                           |  156 +
 ext/mysqli/mysqli_prop.c                           |   77 +-
 ext/mysqli/mysqli_report.c                         |   12 +-
 ext/mysqli/mysqli_report.h                         |    4 +-
 ext/mysqli/mysqli_warning.c                        |   19 +-
 ext/mysqli/php_mysqli.h                            |    2 +-
 ext/mysqli/php_mysqli_structs.h                    |  260 +-
 ext/mysqli/tests/002.phpt                          |    6 +-
 ext/mysqli/tests/003.phpt                          |    6 +-
 ext/mysqli/tests/004.phpt                          |    6 +-
 ext/mysqli/tests/005.phpt                          |    8 +-
 ext/mysqli/tests/006.phpt                          |    6 +-
 ext/mysqli/tests/007.phpt                          |    6 +-
 ext/mysqli/tests/008.phpt                          |    6 +-
 ext/mysqli/tests/009.phpt                          |   12 +-
 ext/mysqli/tests/010.phpt                          |    6 +-
 ext/mysqli/tests/011.phpt                          |    6 +-
 ext/mysqli/tests/012.phpt                          |    6 +-
 ext/mysqli/tests/013.phpt                          |    8 +-
 ext/mysqli/tests/016.phpt                          |    6 +-
 ext/mysqli/tests/017.phpt                          |    6 +-
 ext/mysqli/tests/018.phpt                          |    6 +-
 ext/mysqli/tests/019.phpt                          |   10 +-
 ext/mysqli/tests/020.phpt                          |   10 +-
 ext/mysqli/tests/021.phpt                          |   10 +-
 ext/mysqli/tests/022.phpt                          |   10 +-
 ext/mysqli/tests/023.phpt                          |   10 +-
 ext/mysqli/tests/024.phpt                          |   10 +-
 ext/mysqli/tests/025.phpt                          |   10 +-
 ext/mysqli/tests/026.phpt                          |   16 +-
 ext/mysqli/tests/042.phpt                          |    4 +-
 ext/mysqli/tests/043.phpt                          |    6 +-
 ext/mysqli/tests/045.phpt                          |   10 +-
 ext/mysqli/tests/046.phpt                          |    4 +-
 ext/mysqli/tests/047.phpt                          |    6 +-
 ext/mysqli/tests/050.phpt                          |    2 +-
 ext/mysqli/tests/051.phpt                          |    2 +-
 ext/mysqli/tests/052.phpt                          |    2 +-
 ext/mysqli/tests/057.phpt                          |   12 +-
 ext/mysqli/tests/058.phpt                          |   18 +-
 ext/mysqli/tests/059.phpt                          |   10 +-
 ext/mysqli/tests/065.phpt                          |    4 +-
 ext/mysqli/tests/bug35759.phpt                     |    2 +-
 ext/mysqli/tests/bug52891.phpt                     |  160 +
 ext/mysqli/tests/bug_mysql_49406.phpt              |  107 +
 ext/mysqli/tests/connect.inc                       |   95 +
 ext/mysqli/tests/mysqli_change_user_set_names.phpt |    4 +-
 ext/mysqli/tests/mysqli_character_set.phpt         |   22 +-
 ext/mysqli/tests/mysqli_character_set_name.phpt    |    6 +-
 ext/mysqli/tests/mysqli_character_set_name_oo.phpt |    4 +-
 .../tests/mysqli_class_mysqli_interface.phpt       |    1 +
 .../tests/mysqli_class_mysqli_reflection.phpt      |   51 +
 ext/mysqli/tests/mysqli_constants.phpt             |    6 +
 ext/mysqli/tests/mysqli_fetch_array_large.phpt     |   79 +-
 ext/mysqli/tests/mysqli_fetch_field.phpt           |   38 +-
 ext/mysqli/tests/mysqli_fetch_field_oo.phpt        |   34 +-
 ext/mysqli/tests/mysqli_fetch_fields.phpt          |   24 +-
 ext/mysqli/tests/mysqli_field_seek.phpt            |   26 +-
 ext/mysqli/tests/mysqli_get_client_stats.phpt      |   83 +-
 ext/mysqli/tests/mysqli_get_client_stats_off.phpt  |   18 +-
 .../tests/mysqli_insert_packet_overflow.phpt       |    4 +-
 ext/mysqli/tests/mysqli_magic_quotes.phpt          |  128 +
 ext/mysqli/tests/mysqli_options.phpt               |   91 +-
 .../tests/mysqli_options_int_and_float_native.phpt |  109 +
 ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt   |    3 -
 ext/mysqli/tests/mysqli_pconn_disabled.phpt        |    3 -
 ext/mysqli/tests/mysqli_pconn_kill.phpt            |    2 -
 ext/mysqli/tests/mysqli_pconn_limits.phpt          |    3 -
 ext/mysqli/tests/mysqli_pconn_max_links.phpt       |   22 +-
 ext/mysqli/tests/mysqli_pconn_reuse.phpt           |    3 -
 ext/mysqli/tests/mysqli_pconn_twice.phpt           |    2 -
 ext/mysqli/tests/mysqli_pconnect.phpt              |    3 -
 ext/mysqli/tests/mysqli_prepare.phpt               |   10 +-
 ext/mysqli/tests/mysqli_set_charset.phpt           |    2 +-
 ext/mysqli/tests/mysqli_stmt_attr_set.phpt         |    6 +
 ext/mysqli/tests/mysqli_stmt_bind_param.phpt       |    2 +-
 ...sqli_stmt_bind_param_check_param_no_change.phpt |    1 +
 ext/mysqli/tests/mysqli_stmt_bind_result.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_fetch.phpt            |    2 +-
 ...ysqli_stmt_get_result_metadata_fetch_field.phpt |   42 +-
 ext/mysqli/tests/mysqli_stmt_num_rows.phpt         |    6 +-
 ext/mysqli/tests/mysqli_stmt_param_count.phpt      |    2 +-
 ext/mysqli/tests/mysqli_stmt_result_metadata.phpt  |    2 +-
 ext/mysqli/tests/mysqli_stmt_send_long_data.phpt   |    2 +-
 ext/mysqlnd/config9.m4                             |    9 +-
 ext/mysqlnd/mysqlnd.c                              |  130 +-
 ext/mysqlnd/mysqlnd.h                              |   16 +-
 ext/mysqlnd/mysqlnd_block_alloc.c                  |    3 +-
 ext/mysqlnd/mysqlnd_charset.c                      |  425 +-
 ext/mysqlnd/mysqlnd_debug.c                        |  218 +-
 ext/mysqlnd/mysqlnd_debug.h                        |   81 +-
 ext/mysqlnd/mysqlnd_enum_n_def.h                   |   33 +-
 ext/mysqlnd/mysqlnd_loaddata.c                     |    8 +-
 ext/mysqlnd/mysqlnd_net.c                          |    9 +-
 ext/mysqlnd/mysqlnd_portability.h                  |   12 +-
 ext/mysqlnd/mysqlnd_priv.h                         |   25 +-
 ext/mysqlnd/mysqlnd_ps.c                           |  130 +-
 ext/mysqlnd/mysqlnd_ps_codec.c                     |  211 +-
 ext/mysqlnd/mysqlnd_result.c                       |  190 +-
 ext/mysqlnd/mysqlnd_result_meta.c                  |   25 +-
 ext/mysqlnd/mysqlnd_statistics.c                   |   18 +-
 ext/mysqlnd/mysqlnd_statistics.h                   |    4 +-
 ext/mysqlnd/mysqlnd_structs.h                      |   17 +-
 ext/mysqlnd/mysqlnd_wireprotocol.c                 |  105 +-
 ext/mysqlnd/mysqlnd_wireprotocol.h                 |    4 +-
 ext/mysqlnd/php_mysqlnd.c                          |    8 +-
 ext/oci8/oci8.c                                    |   24 +-
 ext/oci8/oci8_interface.c                          |   34 +-
 ext/oci8/package.xml                               |   68 +-
 ext/oci8/php_oci8.h                                |    4 +-
 ext/oci8/tests/bind_char_1.phpt                    |   11 +-
 ext/oci8/tests/bind_char_2.phpt                    |   11 +-
 ext/oci8/tests/bind_char_3.phpt                    |   11 +-
 ext/oci8/tests/bind_char_4.phpt                    |   11 +-
 ext/oci8/tests/bug27303_1.phpt                     |   11 +-
 ext/oci8/tests/bug27303_2.phpt                     |   11 +-
 ext/oci8/tests/bug27303_4.phpt                     |   11 +-
 ext/oci8/tests/connect_without_oracle_home.phpt    |    4 +
 ext/oci8/tests/connect_without_oracle_home_11.phpt |   41 +
 .../tests/connect_without_oracle_home_old.phpt     |    4 +
 .../tests/connect_without_oracle_home_old_11.phpt  |   41 +
 ext/oci8/tests/debug.phpt                          |   56 +-
 ext/oci8/tests/null_byte_1.phpt                    |   38 +
 ext/oci8/tests/null_byte_2.phpt                    |   69 +
 ext/oci8/tests/oci8safemode.phpt                   |    2 +-
 ext/odbc/php_odbc.c                                |   52 +-
 ext/openssl/openssl.c                              |   62 +-
 ext/openssl/xp_ssl.c                               |    3 +-
 ext/pcntl/pcntl.c                                  |  138 +-
 ext/pcntl/php_pcntl.h                              |    7 +-
 ext/pcntl/php_signal.c                             |   15 +-
 ext/pcntl/php_signal.h                             |    3 +-
 ext/pcntl/tests/pcntl_get_last_error.phpt          |   17 +
 ext/pcre/pcrelib/ChangeLog                         |   95 +
 ext/pcre/pcrelib/NEWS                              |   11 +
 ext/pcre/pcrelib/NON-UNIX-USE                      |    8 +-
 ext/pcre/pcrelib/config.h                          |   19 +-
 ext/pcre/pcrelib/doc/pcre.txt                      | 1466 +-
 ext/pcre/pcrelib/pcre.h                            |    9 +-
 ext/pcre/pcrelib/pcre_chartables.c                 |    2 +-
 ext/pcre/pcrelib/pcre_compile.c                    |  748 +-
 ext/pcre/pcrelib/pcre_exec.c                       | 1047 +-
 ext/pcre/pcrelib/pcre_internal.h                   |   77 +-
 ext/pcre/pcrelib/pcre_printint.src                 |    8 +
 ext/pcre/pcrelib/pcre_study.c                      |  274 +-
 ext/pcre/pcrelib/pcre_tables.c                     |   22 +-
 ext/pcre/pcrelib/pcre_xclass.c                     |   36 +-
 ext/pcre/pcrelib/pcreposix.c                       |   20 +-
 ext/pcre/pcrelib/pcreposix.h                       |    1 +
 ext/pcre/pcrelib/testdata/testinput10              |   13 +-
 ext/pcre/pcrelib/testdata/testinput2               |  271 +-
 ext/pcre/pcrelib/testdata/testinput5               |   49 +
 ext/pcre/pcrelib/testdata/testinput6               |   50 +
 ext/pcre/pcrelib/testdata/testinput9               |  139 +
 ext/pcre/pcrelib/testdata/testoutput10             |   43 +-
 ext/pcre/pcrelib/testdata/testoutput2              |  484 +-
 ext/pcre/pcrelib/testdata/testoutput5              |  146 +
 ext/pcre/pcrelib/testdata/testoutput6              |   68 +
 ext/pcre/pcrelib/testdata/testoutput9              |  360 +
 ext/pcre/php_pcre.c                                |   18 +-
 ext/pcre/tests/backtrack_limit.phpt                |    2 +-
 ext/pcre/tests/bug33200.phpt                       |    2 +-
 ext/pcre/tests/bug52732.phpt                       |   13 +
 ext/pcre/tests/bug52971.phpt                       |   43 +
 ext/pcre/tests/invalid_utf8_offset.phpt            |    2 +-
 ext/pcre/tests/recursion_limit.phpt                |    2 +-
 ext/pdo/pdo_stmt.c                                 |   14 +-
 ext/pdo/tests/bug47769.phpt                        |    5 +
 ext/pdo/tests/bug_38253.phpt                       |    8 +-
 ext/pdo/tests/bug_43139.phpt                       |    7 +-
 ext/pdo/tests/pdo_018.phpt                         |    8 +-
 ext/pdo/tests/pdo_021.phpt                         |    2 -
 ext/pdo/tests/pdo_034.phpt                         |    4 +-
 ext/pdo_dblib/dblib_stmt.c                         |    6 +-
 ext/pdo_firebird/config.w32                        |    6 +-
 ext/pdo_firebird/firebird_driver.c                 |    8 +-
 ext/pdo_firebird/firebird_statement.c              |   35 +-
 ext/pdo_firebird/tests/rowCount.phpt               |   48 +
 ext/pdo_mysql/mysql_statement.c                    |    4 +-
 ext/pdo_mysql/php_pdo_mysql_int.h                  |    6 +-
 ext/pdo_mysql/tests/bug_42499.phpt                 |    4 +-
 ext/pdo_mysql/tests/bug_44454.phpt                 |   12 +-
 ext/pdo_mysql/tests/bug_pecl_12925.phpt            |    6 +-
 ext/pdo_mysql/tests/mysql_pdo_test.inc             |    4 +-
 ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt |    2 +-
 ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt       |   10 +-
 .../tests/pdo_mysql_attr_oracle_nulls.phpt         |    6 +-
 .../tests/pdo_mysql_attr_server_info.phpt          |    2 +-
 .../tests/pdo_mysql_begintransaction.phpt          |    4 +-
 ext/pdo_mysql/tests/pdo_mysql_commit.phpt          |    4 +-
 ext/pdo_mysql/tests/pdo_mysql_exec.phpt            |   18 +-
 ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt  |    2 +-
 ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt     |    8 +-
 ext/pdo_mysql/tests/pdo_mysql_interface.phpt       |   23 +-
 ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt  |   12 +-
 .../tests/pdo_mysql_prepare_emulated.phpt          |    8 +-
 .../pdo_mysql_prepare_emulated_anonymous.phpt      |    4 +-
 ...ql_prepare_emulated_placeholder_everywhere.phpt |    2 +-
 .../tests/pdo_mysql_prepare_load_data.phpt         |    6 +-
 ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt  |    8 +-
 .../pdo_mysql_prepare_native_clear_error.phpt      |    2 +-
 ...mysql_prepare_native_dup_named_placeholder.phpt |    2 +-
 ...pdo_mysql_prepare_native_named_placeholder.phpt |    4 +-
 ...ysql_prepare_native_placeholder_everywhere.phpt |    2 +-
 ext/pdo_mysql/tests/pdo_mysql_rollback.phpt        |    4 +-
 .../tests/pdo_mysql_stmt_columncount.phpt          |    4 +-
 .../tests/pdo_mysql_stmt_fetch_non_select.phpt     |    6 +-
 .../pdo_mysql_stmt_fetch_serialize_simple.phpt     |    2 +-
 .../tests/pdo_mysql_stmt_fetchobject.phpt          |   16 +-
 .../tests/pdo_mysql_stmt_getcolumnmeta.phpt        |   15 +-
 ext/pdo_mysql/tests/pdo_mysql_subclass.phpt        |    2 +-
 ext/pdo_mysql/tests/pdo_mysql_types.phpt           |    4 +-
 ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt  |    9 +-
 ext/pdo_oci/tests/pdo_oci_attr_client.phpt         |    2 +-
 ext/pdo_pgsql/tests/bug36727.phpt                  |    2 +-
 ext/pdo_sqlite/tests/bug52487.phpt                 |   21 +
 ext/pgsql/pgsql.c                                  |   26 +-
 ext/pgsql/tests/bug47199.phpt                      |   67 +
 ext/phar/phar.c                                    |    8 +-
 ext/phar/phar_object.c                             |    8 +-
 ext/phar/stream.c                                  |    2 +-
 ext/phar/tests/phpinfo_001.phpt                    |    4 +-
 ext/phar/tests/phpinfo_002.phpt                    |    2 +-
 ext/phar/tests/phpinfo_003.phpt                    |    2 +-
 ext/phar/tests/phpinfo_004.phpt                    |    4 +-
 ext/posix/posix.c                                  |   16 +-
 ext/posix/tests/posix_access.phpt                  |    2 +-
 ext/posix/tests/posix_access_error_modes.phpt      |    2 +-
 .../tests/posix_access_error_wrongparams.phpt      |    2 +-
 ext/posix/tests/posix_access_safemode.phpt         |    2 +-
 ext/posix/tests/posix_mkfifo_safemode.phpt         |    2 +-
 ext/pspell/pspell.c                                |   14 +-
 ext/recode/CREDITS                                 |    2 +-
 ext/reflection/php_reflection.c                    |   42 +-
 .../ReflectionClass_getConstructor_basic.phpt      |    7 +-
 .../tests/ReflectionClass_isIterateable_001.phpt   |   28 +-
 .../tests/ReflectionMethod_constructor_basic.phpt  |    2 -
 .../ReflectionObject_getConstructor_basic.phpt     |    5 +-
 .../tests/ReflectionParameter_isDefault.phpt       |   34 +
 ext/reflection/tests/bug52854.phpt                 |   28 +
 ext/reflection/tests/bug53366.phpt                 |   25 +
 ext/session/config.m4                              |    3 +-
 ext/session/session.c                              |    6 +-
 ext/session/tests/001.phpt                         |    2 +-
 ext/session/tests/003.phpt                         |    2 +-
 ext/session/tests/004.phpt                         |    2 +-
 ext/session/tests/005.phpt                         |    2 +-
 ext/session/tests/006.phpt                         |    2 +-
 ext/session/tests/007.phpt                         |    4 +-
 ext/session/tests/008-php4.2.3.phpt                |    2 +-
 ext/session/tests/009.phpt                         |    2 +-
 ext/session/tests/012.phpt                         |    2 +-
 ext/session/tests/013.phpt                         |    2 +-
 ext/session/tests/014.phpt                         |    2 +-
 ext/session/tests/019.phpt                         |    2 +-
 ext/session/tests/bug53141.phpt                    |   26 +
 ext/simplexml/simplexml.c                          |    4 +-
 ext/soap/php_encoding.c                            |   10 +-
 ext/soap/php_http.c                                |    9 +-
 ext/soap/php_packet_soap.c                         |    4 +-
 ext/soap/php_sdl.c                                 |   21 +-
 ext/soap/tests/bugs/bug50698_1.phpt                |    2 +
 ext/soap/tests/bugs/bug50698_2.phpt                |    2 +
 ext/soap/tests/bugs/bug50698_3.phpt                |    2 +
 ext/soap/tests/bugs/bug50698_4.phpt                |    2 +
 ext/soap/tests/bugs/bug50762.phpt                  |    2 +
 ext/spl/php_spl.c                                  |   17 +-
 ext/spl/spl_array.c                                |   52 +-
 ext/spl/spl_directory.c                            |  165 +-
 ext/spl/spl_dllist.c                               |   26 +-
 ext/spl/spl_fixedarray.c                           |   11 +-
 ext/spl/spl_heap.c                                 |   25 +-
 ext/spl/spl_iterators.c                            |  238 +-
 ext/spl/spl_observer.c                             |  134 +-
 .../SplFileObject_fgetcsv_escape_default.phpt      |   24 +
 ext/spl/tests/arrayObject_count_basic1.phpt        |    8 +-
 ext/spl/tests/bug50579.phpt                        |   40 +
 ext/spl/tests/bug52573.phpt                        |   18 +
 ext/spl/tests/bug53071.phpt                        |   26 +
 ext/spl/tests/bug53144.phpt                        |   20 +
 ext/spl/tests/bug53362.phpt                        |   22 +
 ext/spl/tests/fileobject_005.phpt                  |    6 +-
 .../tests/spl_fileinfo_getlinktarget_basic.phpt    |    2 +-
 ext/sqlite/sqlite.c                                |   14 +-
 ext/sqlite3/libsqlite/sqlite3.c                    |20987 ++++++++++++++------
 ext/sqlite3/libsqlite/sqlite3.h                    | 1125 +-
 ext/sqlite3/sqlite3.c                              |   13 +-
 ext/sqlite3/tests/bug53463.phpt                    |   28 +
 ext/sqlite3/tests/sqlite3_15_open_error.phpt       |    4 +-
 ext/standard/array.c                               |   10 +-
 ext/standard/base64.c                              |    4 +-
 ext/standard/basic_functions.c                     |   41 +-
 ext/standard/credits.c                             |    6 +-
 ext/standard/dir.c                                 |   14 +-
 ext/standard/dns.c                                 |    8 +-
 ext/standard/dns_win32.c                           |    5 +-
 ext/standard/file.c                                |  103 +-
 ext/standard/file.h                                |    5 +-
 ext/standard/filestat.c                            |   29 +-
 ext/standard/formatted_print.c                     |    4 +-
 ext/standard/ftok.c                                |    6 +-
 ext/standard/ftp_fopen_wrapper.c                   |    8 +-
 ext/standard/html.c                                |  111 +-
 ext/standard/http_fopen_wrapper.c                  |   65 +-
 ext/standard/iptc.c                                |    6 +-
 ext/standard/link.c                                |   24 +-
 ext/standard/link_win32.c                          |   71 +-
 ext/standard/math.c                                |   16 +-
 ext/standard/proc_open.c                           |  102 +-
 ext/standard/quot_print.c                          |    4 +-
 ext/standard/rand.c                                |   12 +-
 ext/standard/streamsfuncs.c                        |   32 +-
 ext/standard/string.c                              |   26 +-
 ext/standard/tests/array/bug52534.phpt             |   14 +
 ext/standard/tests/array/extract_safety.phpt       |   24 +
 ext/standard/tests/assert/assert02.phpt            |    2 +-
 ext/standard/tests/file/bug52820.phpt              |   49 +
 ext/standard/tests/file/bug53241.phpt              |   23 +
 ext/standard/tests/file/copy_variation12.phpt      |    4 +-
 ext/standard/tests/file/copy_variation4.phpt       |  Bin 4654 -> 4467 bytes
 .../tests/file/disk_free_space_variation.phpt      |   16 +-
 .../file/file_get_contents_variation8-win32.phpt   |    2 -
 .../tests/file/file_get_contents_variation8.phpt   |    2 -
 .../tests/file/file_put_contents_variation8.phpt   |  Bin 2302 -> 2228 bytes
 ext/standard/tests/file/filegroup_variation3.phpt  |    4 +-
 ext/standard/tests/file/fileinode_variation3.phpt  |    4 +-
 ext/standard/tests/file/fileowner_variation3.phpt  |    4 +-
 ext/standard/tests/file/fileperms_variation3.phpt  |    4 +-
 ext/standard/tests/file/fnmatch_variation.phpt     |   30 +-
 ext/standard/tests/file/glob_variation.phpt        |   23 +-
 ext/standard/tests/file/is_dir_variation4.phpt     |    4 +-
 .../tests/file/is_executable_variation1.phpt       |    4 +-
 ext/standard/tests/file/is_file_variation4.phpt    |    4 +-
 .../tests/file/is_readable_variation1.phpt         |    6 +-
 .../tests/file/is_writable_variation1.phpt         |   12 +-
 .../tests/file/mkdir_rmdir_variation2.phpt         |    4 +-
 .../tests/file/readfile_variation10-win32.phpt     |   14 +-
 ext/standard/tests/file/readfile_variation10.phpt  |  Bin 1786 -> 1847 bytes
 .../tests/file/rename_variation13-win32.phpt       |  Bin 3947 -> 3805 bytes
 ext/standard/tests/file/rename_variation13.phpt    |    4 -
 ext/standard/tests/file/stream_rfc2397_006.phpt    |    4 +-
 .../tests/file/tempnam_variation3-win32.phpt       |    5 +-
 ext/standard/tests/file/tempnam_variation3.phpt    |    6 +-
 .../tests/file/tempnam_variation7-win32.phpt       |    6 +-
 ext/standard/tests/file/tempnam_variation7.phpt    |    6 +-
 .../tests/general_functions/bug44394_2.phpt        |    1 +
 ext/standard/tests/general_functions/bug46587.phpt |   16 +
 .../general_functions/get_cfg_var_variation8.phpt  |   40 +-
 .../tests/general_functions/putenv_error1.phpt     |    2 +-
 .../tests/general_functions/putenv_error2.phpt     |    2 +-
 ext/standard/tests/http/bug53198.phpt              |   56 +
 ext/standard/tests/math/log_variation2.phpt        |    6 +-
 .../tests/misc/syslog_vars_variation1.phpt         |    2 +-
 ext/standard/tests/streams/bug46024.phpt           |    2 +-
 ext/standard/tests/strings/bug47168.phpt           |   12 +
 ext/standard/tests/strings/bug49785.phpt           |    2 +-
 ext/standard/tests/strings/bug53021.phpt           |   34 +
 ext/standard/tests/strings/bug53319.phpt           |   17 +
 .../get_html_translation_table_basic1-win32.phpt   |  269 -
 .../strings/get_html_translation_table_basic1.phpt |  540 +-
 .../get_html_translation_table_basic2-win32.phpt   |  673 -
 .../strings/get_html_translation_table_basic2.phpt | 1541 ++-
 .../get_html_translation_table_basic3-win32.phpt   |   79 -
 .../strings/get_html_translation_table_basic3.phpt |   43 +-
 .../strings/get_html_translation_table_basic4.phpt |  289 +
 .../strings/get_html_translation_table_error.phpt  |    6 +-
 ...et_html_translation_table_variation1-win32.phpt | 1117 --
 .../get_html_translation_table_variation1.phpt     |  924 +-
 ...et_html_translation_table_variation2-win32.phpt |  220 -
 .../get_html_translation_table_variation2.phpt     |   48 +-
 ext/standard/tests/strings/htmlentities-utf-2.phpt |    4 +-
 ext/standard/tests/strings/htmlentities-utf-3.phpt |   83 +
 ext/standard/tests/strings/htmlentities-utf.phpt   |    4 +-
 ext/standard/tests/strings/htmlentities17.phpt     |    3 -
 ext/standard/tests/strings/parse_str_basic3.phpt   |    2 +-
 ext/standard/tests/url/bug52327.phpt               |   12 +
 ext/standard/tests/url/bug53248.phpt               |   12 +
 ext/standard/url.c                                 |    4 +-
 ext/standard/var.c                                 |   14 +-
 ext/standard/var_unserializer.c                    |    6 +-
 ext/standard/var_unserializer.c.orig               |    6 +-
 ext/standard/var_unserializer.re                   |    4 +-
 ext/sybase_ct/config.m4                            |    6 +-
 ext/sysvmsg/sysvmsg.c                              |   48 +-
 ext/tidy/tidy.c                                    |   20 +-
 ext/wddx/tests/bug52468.phpt                       |   20 +
 ext/wddx/wddx.c                                    |    3 +-
 ext/xml/tests/bug49687.phpt                        |   24 +
 ext/xml/xml.c                                      |  142 +-
 ext/xsl/xsltprocessor.c                            |    7 +-
 ext/zip/php_zip.c                                  |   39 +-
 ext/zip/zip_stream.c                               |   83 +-
 ext/zlib/tests/bug_52944.phpt                      |  157 +
 ext/zlib/zlib_filter.c                             |    5 +-
 ext/zlib/zlib_fopen_wrapper.c                      |    4 +-
 main/SAPI.c                                        |    6 +-
 main/fopen_wrappers.c                              |   56 +-
 main/main.c                                        |   11 +-
 main/network.c                                     |   82 +-
 main/output.c                                      |  282 +-
 main/php_config.h.in                               |   19 +-
 main/php_ini.c                                     |   37 +-
 main/php_streams.h                                 |   10 +-
 main/php_version.h                                 |    6 +-
 main/rfc1867.c                                     |   47 +-
 main/streams/cast.c                                |   52 +-
 main/streams/glob_wrapper.c                        |    4 +-
 main/streams/php_streams_int.h                     |    9 +-
 main/streams/plain_wrapper.c                       |   23 +-
 main/streams/streams.c                             |   23 +-
 main/win95nt.h                                     |    6 +-
 php.ini-development                                |   10 +-
 php.ini-production                                 |   11 +-
 run-tests.php                                      |   32 +-
 sapi/cli/config.w32                                |    4 +-
 sapi/cli/php_cli.c                                 |    3 +-
 sapi/fpm/Makefile.frag                             |    6 +-
 sapi/fpm/config.m4                                 |  287 +-
 sapi/fpm/fpm/fpm.c                                 |   24 +-
 sapi/fpm/fpm/fpm.h                                 |    7 +-
 sapi/fpm/fpm/fpm_atomic.h                          |   22 +-
 sapi/fpm/fpm/fpm_children.c                        |   46 +-
 sapi/fpm/fpm/fpm_children.h                        |   10 +-
 sapi/fpm/fpm/fpm_clock.c                           |    8 +-
 sapi/fpm/fpm/fpm_conf.c                            |  507 +-
 sapi/fpm/fpm/fpm_conf.h                            |    7 +-
 sapi/fpm/fpm/fpm_config.h                          |   75 +-
 sapi/fpm/fpm/fpm_env.c                             |   96 +
 sapi/fpm/fpm/fpm_env.h                             |    3 +
 sapi/fpm/fpm/fpm_events.c                          |  399 +-
 sapi/fpm/fpm/fpm_events.h                          |   28 +-
 sapi/fpm/fpm/fpm_main.c                            |   42 +-
 sapi/fpm/fpm/fpm_php.c                             |    2 +
 sapi/fpm/fpm/fpm_php.h                             |   20 +
 sapi/fpm/fpm/fpm_php_trace.c                       |    6 +-
 sapi/fpm/fpm/fpm_process_ctl.c                     |  141 +-
 sapi/fpm/fpm/fpm_process_ctl.h                     |   17 +-
 sapi/fpm/fpm/fpm_request.c                         |   17 +-
 sapi/fpm/fpm/fpm_shm.c                             |    2 +-
 sapi/fpm/fpm/fpm_signals.c                         |   10 +-
 sapi/fpm/fpm/fpm_sockets.c                         |  109 +-
 sapi/fpm/fpm/fpm_sockets.h                         |   10 +
 sapi/fpm/fpm/fpm_status.c                          |  129 +-
 sapi/fpm/fpm/fpm_status.h                          |    9 +-
 sapi/fpm/fpm/fpm_stdio.c                           |   57 +-
 sapi/fpm/fpm/fpm_stdio.h                           |    2 +-
 sapi/fpm/fpm/fpm_trace_mach.c                      |    6 +-
 sapi/fpm/fpm/fpm_trace_pread.c                     |    6 +-
 sapi/fpm/fpm/fpm_trace_ptrace.c                    |    8 +-
 sapi/fpm/fpm/fpm_unix.c                            |   36 +-
 sapi/fpm/fpm/fpm_worker_pool.h                     |    1 +
 sapi/fpm/fpm/zlog.c                                |   16 +-
 sapi/fpm/fpm/zlog.h                                |    6 +-
 sapi/fpm/init.d.php-fpm.in                         |    4 +-
 sapi/fpm/php-fpm.1.in                              |  186 -
 sapi/fpm/php-fpm.8.in                              |  199 +
 sapi/fpm/php-fpm.conf.in                           |   77 +-
 scripts/phpize.m4                                  |    2 +-
 tests/basic/021.phpt                               |    2 +-
 tests/basic/bug46313-win.phpt                      |    5 +-
 tests/basic/bug51709_1.phpt                        |    2 +-
 tests/basic/bug51709_2.phpt                        |    2 +-
 tests/basic/bug53180.phpt                          |   19 +
 .../rfc1867_max_file_uploads_empty_files.phpt      |  101 +
 ...rfc1867_max_file_uploads_empty_files_debug.phpt |  102 +
 tests/classes/constants_error_004.phpt             |    2 +-
 tests/output/bug46897.phpt                         |    4 +-
 tests/output/ob_clean_basic_001.phpt               |    4 +-
 tests/output/ob_end_clean_basic_001.phpt           |    4 +-
 tests/output/ob_end_flush_basic_001.phpt           |    6 +-
 tests/output/ob_flush_basic_001.phpt               |    4 +-
 tests/output/ob_get_level_basic_001.phpt           |    4 +-
 tests/output/ob_start_basic_unerasable_002.phpt    |    8 +-
 tests/output/ob_start_basic_unerasable_003.phpt    |    4 +-
 tests/output/ob_start_basic_unerasable_004.phpt    |    2 +-
 tests/output/ob_start_basic_unerasable_005.phpt    |    4 +-
 tests/output/ob_start_callbacks.phpt               |   39 +
 tests/security/bug53226.phpt                       |   29 +
 win32/build/Makefile                               |    6 +-
 win32/build/config.w32                             |   14 +-
 win32/build/config.w32.h.in                        |    3 +-
 win32/build/template.rc                            |    4 +-
 win32/glob.c                                       |   60 +-
 win32/php5dll.dsp                                  |    4 -
 win32/php5dllts.dsp                                |    4 -
 win32/time.c                                       |    4 +-
 win32/wfile.c                                      |   17 -
 win32/wfile.h                                      |   16 -
 win32/winutil.c                                    |   15 +-
 653 files changed, 44362 insertions(+), 25380 deletions(-)
 create mode 100644 UPGRADING.INTERNALS
 create mode 100644 Zend/tests/bug52361.phpt
 create mode 100644 Zend/tests/bug52484.phpt
 create mode 100644 Zend/tests/bug52484_2.phpt
 create mode 100644 Zend/tests/bug52484_3.phpt
 create mode 100644 Zend/tests/bug52508.phpt
 create mode 100644 Zend/tests/bug52879.phpt
 create mode 100644 Zend/tests/bug52939.phpt
 create mode 100644 Zend/tests/bug53305.phpt
 create mode 100644 Zend/tests/bug53632.phpt
 create mode 100644 Zend/tests/gc_032.phpt
 create mode 100644 Zend/tests/multibyte/multibyte_encoding_006.phpt
 create mode 100644 Zend/tests/objects_032.phpt
 create mode 100644 ext/calendar/tests/bug52744.phpt
 create mode 100644 ext/curl/tests/bug52202.phpt
 create mode 100644 ext/curl/tests/bug52827.phpt
 create mode 100644 ext/date/tests/big_year.phpt
 create mode 100644 ext/date/tests/bug46874.phpt
 create mode 100644 ext/date/tests/bug52342.phpt
 create mode 100644 ext/date/tests/bug52430.phpt
 create mode 100644 ext/date/tests/bug52454.phpt
 create mode 100644 ext/date/tests/bug52577.phpt
 create mode 100644 ext/date/tests/bug52668.phpt
 create mode 100644 ext/dom/tests/bug52656.phpt
 create mode 100644 ext/filter/tests/bug52929.phpt
 create mode 100644 ext/gmp/tests/bug52906.phpt
 create mode 100644 ext/iconv/tests/bug51250.phpt
 create mode 100644 ext/iconv/tests/bug52941.phpt
 create mode 100644 ext/iconv/tests/bug53304.phpt
 create mode 100644 ext/intl/tests/bug50590.phpt
 create mode 100644 ext/mbstring/tests/bug52861.phpt
 create mode 100644 ext/mbstring/tests/bug52931.phpt
 create mode 100644 ext/mbstring/tests/bug52981.phpt
 create mode 100644 ext/mbstring/tests/mb_strcut_missing_boundary_check.phpt
 create mode 100644 ext/mbstring/ucgendat/OPENLDAP_LICENSE
 create mode 100644 ext/mbstring/ucgendat/README
 create mode 100644 ext/mbstring/ucgendat/ucgendat.c
 create mode 100644 ext/mysqli/mysqli_fe.h
 create mode 100644 ext/mysqli/mysqli_priv.h
 create mode 100644 ext/mysqli/tests/bug52891.phpt
 create mode 100644 ext/mysqli/tests/bug_mysql_49406.phpt
 create mode 100644 ext/mysqli/tests/mysqli_magic_quotes.phpt
 create mode 100644 ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
 create mode 100644 ext/oci8/tests/connect_without_oracle_home_11.phpt
 create mode 100644 ext/oci8/tests/connect_without_oracle_home_old_11.phpt
 create mode 100644 ext/oci8/tests/null_byte_1.phpt
 create mode 100644 ext/oci8/tests/null_byte_2.phpt
 create mode 100644 ext/pcntl/tests/pcntl_get_last_error.phpt
 create mode 100644 ext/pcre/tests/bug52732.phpt
 create mode 100644 ext/pcre/tests/bug52971.phpt
 create mode 100644 ext/pdo_firebird/tests/rowCount.phpt
 create mode 100644 ext/pdo_sqlite/tests/bug52487.phpt
 create mode 100644 ext/pgsql/tests/bug47199.phpt
 create mode 100644 ext/reflection/tests/ReflectionParameter_isDefault.phpt
 create mode 100644 ext/reflection/tests/bug52854.phpt
 create mode 100644 ext/reflection/tests/bug53366.phpt
 create mode 100644 ext/session/tests/bug53141.phpt
 create mode 100644 ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
 create mode 100644 ext/spl/tests/bug50579.phpt
 create mode 100644 ext/spl/tests/bug52573.phpt
 create mode 100644 ext/spl/tests/bug53071.phpt
 create mode 100644 ext/spl/tests/bug53144.phpt
 create mode 100644 ext/spl/tests/bug53362.phpt
 create mode 100644 ext/sqlite3/tests/bug53463.phpt
 create mode 100644 ext/standard/tests/array/bug52534.phpt
 create mode 100644 ext/standard/tests/array/extract_safety.phpt
 create mode 100644 ext/standard/tests/file/bug52820.phpt
 create mode 100644 ext/standard/tests/file/bug53241.phpt
 create mode 100644 ext/standard/tests/general_functions/bug46587.phpt
 create mode 100644 ext/standard/tests/http/bug53198.phpt
 create mode 100644 ext/standard/tests/strings/bug47168.phpt
 create mode 100644 ext/standard/tests/strings/bug53021.phpt
 create mode 100644 ext/standard/tests/strings/bug53319.phpt
 delete mode 100644 ext/standard/tests/strings/get_html_translation_table_basic1-win32.phpt
 delete mode 100644 ext/standard/tests/strings/get_html_translation_table_basic2-win32.phpt
 delete mode 100644 ext/standard/tests/strings/get_html_translation_table_basic3-win32.phpt
 create mode 100644 ext/standard/tests/strings/get_html_translation_table_basic4.phpt
 delete mode 100644 ext/standard/tests/strings/get_html_translation_table_variation1-win32.phpt
 delete mode 100644 ext/standard/tests/strings/get_html_translation_table_variation2-win32.phpt
 create mode 100644 ext/standard/tests/strings/htmlentities-utf-3.phpt
 create mode 100644 ext/standard/tests/url/bug52327.phpt
 create mode 100644 ext/standard/tests/url/bug53248.phpt
 create mode 100644 ext/wddx/tests/bug52468.phpt
 create mode 100644 ext/xml/tests/bug49687.phpt
 create mode 100644 ext/zlib/tests/bug_52944.phpt
 delete mode 100644 sapi/fpm/php-fpm.1.in
 create mode 100644 sapi/fpm/php-fpm.8.in
 create mode 100644 tests/basic/bug53180.phpt
 create mode 100644 tests/basic/rfc1867_max_file_uploads_empty_files.phpt
 create mode 100644 tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt
 create mode 100644 tests/output/ob_start_callbacks.phpt
 create mode 100644 tests/security/bug53226.phpt
 delete mode 100644 win32/wfile.c
 delete mode 100644 win32/wfile.h

diff --git a/INSTALL b/INSTALL
index f9c16f6..0683900 100644
--- a/INSTALL
+++ b/INSTALL
@@ -279,7 +279,15 @@ ir if
     it is your first install then you need to "make install" as well)
 
 13. cd ../php-5.x.y
-14. cp php.ini-dist /usr/local/lib/php.ini
+
+14. The PHP distribution provides two sample php.ini files, you can use them
+    by
+      cp php.ini-development /usr/local/lib/php.ini
+    or
+      cp php.ini-production  /usr/local/lib/php.ini
+
+    If you choose one of these php.ini files be certain to read the list
+    of changes within, as they affect how PHP behaves.
 
 15. You can edit /usr/local/lib/php.ini file to set PHP options.
     Edit your httpd.conf or srm.conf file and add:
@@ -451,15 +459,19 @@ Apache 2.0 on Unix systems
 
 13. Setup your php.ini
 
-    cp php.ini-dist /usr/local/lib/php.ini
+    The PHP distribution provides two sample php.ini files, you can use them
+    by
+      cp php.ini-development /usr/local/lib/php.ini
+    or
+      cp php.ini-production  /usr/local/lib/php.ini
+
+    If you choose one of these php.ini files be certain to read the list
+    of changes within, as they affect how PHP behaves.
 
     You may edit your .ini file to set PHP options.  If you prefer having
     php.ini in another location, use --with-config-file-path=/some/path in
     step 10.
 
-    If you instead choose php.ini-recommended, be certain to read the list
-    of changes within, as they affect how PHP behaves.
-
 14. Edit your httpd.conf to load the PHP module.  The path on the right hand
     side of the LoadModule statement must point to the path of the PHP
     module on your system.  The make install from above may have already
@@ -858,7 +870,7 @@ Using Binary Packages
    Example 2-6. OpenBSD Package Install Example
 # pkg_add php4-core-4.3.8.tgz
 # /usr/local/sbin/phpxs -s
-# cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
+# cp /usr/local/share/doc/php4/php.ini-development /var/www/conf/php.ini
   (add in mysql)
 # pkg_add php4-mysql-4.3.8.tgz
 # /usr/local/sbin/phpxs -a mysql
@@ -1242,10 +1254,10 @@ setenv OPTIM=-O2
        back to the root of the Apache source directory and run the above
        configure command again. That'll bring the link table up to date.
        Run make and make install again.
-    7. Copy and rename the php.ini-dist file to your bin directory from
-       your PHP 4 source directory: cp php.ini-dist /usr/local/bin/php.ini
-       or (if your don't have a local directory) cp php.ini-dist
-       /usr/bin/php.ini.
+    7. Copy and rename the php.ini-development or php.ini-production file to
+       your bin directory from your PHP 4 source directory:
+       cp php.ini-development /usr/local/bin/php.ini or (if your don't have a
+       local directory) cp php.ini-development /usr/bin/php.ini.
      __________________________________________________________________
 
 Compiling for MacOS X Client
@@ -1735,8 +1747,8 @@ cgi error:
    example, set it with something like:
    --with-config-file-path=/etc
 
-   And then you would copy php.ini-dist from the distribution to
-   /etc/php.ini and edit it to make any local changes you want.
+   And then you would copy php.ini-development or php.ini-production from the
+   distribution to /etc/php.ini and edit it to make any local changes you want.
    --with-config-file-scan-dir=PATH
 
    On Windows the default path for the php.ini file is the Windows
diff --git a/LICENSE b/LICENSE
index 249cbc9..3cc8b77 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 -------------------------------------------------------------------- 
                   The PHP License, version 3.01
-Copyright (c) 1999 - 2009 The PHP Group. All rights reserved.
+Copyright (c) 1999 - 2010 The PHP Group. All rights reserved.
 -------------------------------------------------------------------- 
 
 Redistribution and use in source and binary forms, with or without
diff --git a/Makefile.global b/Makefile.global
index 4f7d6d9..8dad0e4 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -98,6 +98,7 @@ test: all
 		TEST_PHP_SRCDIR=$(top_srcdir) \
 		CC="$(CC)" \
 			$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
+		rm $(top_builddir)/tmp-php.ini; \
 	else \
 		echo "ERROR: Cannot run tests without CLI sapi."; \
 	fi
diff --git a/NEWS b/NEWS
index 01ec754..19818ad 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,361 @@
-PHP                                                                        NEWS
+PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+06 Jan 2011, PHP 5.3.5
+- Fixed Bug #53632 (infinite loop with x87 fpu). (Scott, Rasmus)
+
+09 Dec 2010, PHP 5.3.4
+- Upgraded bundled Sqlite3 to version 3.7.3. (Ilia)
+- Upgraded bundled PCRE to version 8.10. (Ilia)
+
+- Security enhancements:
+  . Fixed crash in zip extract method (possible CWE-170). 
+    (Maksymilian Arciemowicz, Pierre)
+  . Paths with NULL in them (foo\0bar.txt) are now considered as invalid. (Rasmus)
+  . Fixed a possible double free in imap extension (Identified by Mateusz 
+    Kocielski). (CVE-2010-4150). (Ilia)
+  . Fixed NULL pointer dereference in ZipArchive::getArchiveComment.
+    (CVE-2010-3709). (Maksymilian Arciemowicz)
+  . Fixed possible flaw in open_basedir (CVE-2010-3436). (Pierre)
+  . Fixed MOPS-2010-24, fix string validation. (CVE-2010-2950). (Pierre)
+  . Fixed symbolic resolution support when the target is a DFS share. (Pierre)
+  . Fixed bug #52929 (Segfault in filter_var with FILTER_VALIDATE_EMAIL with
+    large amount of data) (CVE-2010-3710). (Adam)
+
+- General improvements:
+  . Added stat support for zip stream. (Pierre)
+  . Added follow_location (enabled by default) option for the http stream 
+    support. (Pierre)
+  . Improved support for is_link and related functions on Windows. (Pierre)
+  . Added a 3rd parameter to get_html_translation_table. It now takes a charset
+    hint, like htmlentities et al. (Gustavo)
+ 
+- Implemented feature requests:
+  . Implemented FR #52348, added new constant ZEND_MULTIBYTE to detect
+    zend multibyte at runtime. (Kalle)
+  . Implemented FR #52173, added functions pcntl_get_last_error() and 
+     pcntl_strerror(). (nick dot telford at gmail dot com, Arnaud)
+  . Implemented symbolic links support for open_basedir checks. (Pierre)
+  . Implemented FR #51804, SplFileInfo::getLinkTarget on Windows. (Pierre)
+  . Implemented FR #50692, not uploaded files don't count towards
+    max_file_uploads limit. As a side improvement, temporary files are not opened
+    for empty uploads and, in debug mode, 0-length uploads. (Gustavo)
+    
+- Improved MySQLnd:
+  . Added new character sets to mysqlnd, which are available in MySQL 5.5
+    (Andrey)
+
+- Improved PHP-FPM SAPI:
+  . Added '-p/--prefix' to php-fpm to use a custom prefix and run multiple
+    instances. (fat)
+  . Added custom process title for FPM. (fat)
+  . Added '-t/--test' to php-fpm to check and validate FPM conf file. (fat)
+  . Added statistics about listening socket queue length for FPM.
+    (andrei dot nigmatulin at gmail dot com, fat)
+    
+- Core:
+  . Fixed extract() to do not overwrite $GLOBALS and $this when using
+    EXTR_OVERWRITE. (jorto at redhat dot com)
+  . Fixed bug in the Windows implementation of dns_get_record, where the two
+    last parameters wouldn't be filled unless the type were DNS_ANY (Gustavo).
+  . Changed the $context parameter on copy() to actually have an effect. (Kalle)
+  . Fixed htmlentities/htmlspecialchars accepting certain ill-formed UTF-8
+    sequences. (Gustavo)
+  . Fixed bug #53409 (sleep() returns NULL on Windows). (Pierre)
+  . Fixed bug #53319 (strip_tags() may strip '<br />' incorrectly). (Felipe)
+  . Fixed bug #53304 (quot_print_decode does not handle lower-case hex digits).
+    (Ilia, daniel dot mueller at inexio dot net)
+  . Fixed bug #53248 (rawurlencode RFC 3986 EBCDIC support misses tilde char).
+    (Justin Martin)  
+  . Fixed bug #53226 (file_exists fails on big filenames). (Adam)
+  . Fixed bug #53198 (changing INI setting "from" with ini_set did not have any
+    effect). (Gustavo)
+  . Fixed bug #53180 (post_max_size=0 not disabling the limit when the content
+    type is application/x-www-form-urlencoded or is not registered with PHP).
+    (gm at tlink dot de, Gustavo)
+  . Fixed bug #53141 (autoload misbehaves if called from closing session).
+    (ladislav at marek dot su)
+  . Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities
+    with ENT_NOQUOTES and ISO-8859-1). Fixed and extended the fix of ENT_NOQUOTES 
+    in html_entity_decode that had introduced the bug (rev #185591) to other
+    encodings. Additionaly, html_entity_decode() now doesn't decode " if
+    ENT_NOQUOTES is given. (Gustavo)
+  . Fixed bug #52931 (strripos not overloaded with function overloading enabled).
+    (Felipe)
+  . Fixed bug #52772 (var_dump() doesn't check for the existence of 
+    get_class_name before calling it). (Kalle, Gustavo)
+  . Fixed bug #52534 (var_export array with negative key). (Felipe)
+  . Fixed bug #52327 (base64_decode() improper handling of leading padding in
+    strict mode). (Ilia)
+  . Fixed bug #52260 (dns_get_record fails with non-existing domain on Windows).
+    (a_jelly_doughnut at phpbb dot com, Pierre)
+  . Fixed bug #50953 (socket will not connect to IPv4 address when the host has
+    both IPv4 and IPv6 addresses, on Windows). (Gustavo, Pierre)
+  . Fixed bug #50524 (proc_open on Windows does not respect cwd as it does on
+    other platforms). (Pierre)
+  . Fixed bug #49687 (utf8_decode vulnerabilities and deficiencies in the number
+    of reported malformed sequences). (CVE-2010-3870) (Gustavo)
+  . Fixed bug #49407 (get_html_translation_table doesn't handle UTF-8). (Gustavo)
+  . Fixed bug #48831 (php -i has different output to php --ini). (Richard, 
+    Pierre)
+  . Fixed bug #47643 (array_diff() takes over 3000 times longer than php 5.2.4).
+    (Felipe)
+  . Fixed bug #47168 (printf of floating point variable prints maximum of 40 
+    decimal places). (Ilia)
+  . Fixed bug #46587 (mt_rand() does not check that max is greater than min).
+    (Ilia)
+  . Fixed bug #29085 (bad default include_path on Windows). (Pierre)
+  . Fixed bug #25927 (get_html_translation_table calls the ' ' instead of
+    '). (Gustavo)
+    
+- Zend engine:
+  . Reverted fix for bug #51176 (Static calling in non-static method behaves
+    like $this->). (Felipe)
+  . Changed deprecated ini options on startup from E_WARNING to E_DEPRECATED. 
+    (Kalle)
+  . Fixed NULL dereference in lex_scan on zend multibyte builds where the script
+    had a flex incompatible encoding and there was no converter. (Gustavo)
+  . Fixed covariance of return-by-ref constraints. (Etienne)
+  . Fixed bug #53305 (E_NOTICE when defining a constant starts with
+    __COMPILER_HALT_OFFSET__). (Felipe)
+  . Fixed bug #52939 (zend_call_function does not respect ZEND_SEND_PREFER_REF).
+    (Dmitry)
+  . Fixed bug #52879 (Objects unreferenced in __get, __set, __isset or __unset
+    can be freed too early). (mail_ben_schmidt at yahoo dot com dot au, Dmitry)
+  . Fixed bug #52786 (PHP should reset section to [PHP] after ini sections).
+    (Fedora at famillecollet dot com)
+  . Fixed bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW).
+    (Felipe)
+  . Fixed bug #52484 (__set() ignores setting properties with empty names).
+    (Felipe)
+  . Fixed bug #52361 (Throwing an exception in a destructor causes invalid
+    catching). (Dmitry)
+  . Fixed bug #51008 (Zend/tests/bug45877.phpt fails). (Dmitry)
+  
+- Build issues:
+  . Fixed bug #52436 (Compile error if systems do not have stdint.h)
+    (Sriram Natarajan)
+  . Fixed bug #50345 (nanosleep not detected properly on some solaris versions).
+    (Ulf, Tony)
+  . Fixed bug #49215 (make fails on glob_wrapper). (Felipe)
+
+- Calendar extension:
+  . Fixed bug #52744 (cal_days_in_month incorrect for December 1 BCE).
+   (gpap at internet dot gr, Adam)
+    
+- cURL extension:
+  . Fixed bug #52828 (curl_setopt does not accept persistent streams).
+    (Gustavo, Ilia)
+  . Fixed bug #52827 (cURL leaks handle and causes assertion error
+    (CURLOPT_STDERR)). (Gustavo)
+  . Fixed bug #52202 (CURLOPT_PRIVATE gets corrupted). (Ilia)
+  . Fixed bug #50410 (curl extension slows down PHP on Windows). (Pierre)
+    
+- DateTime extension:
+  . Fixed bug #53297 (gettimeofday implementation in php/win32/time.c can return
+    1 million microsecs). (ped at 7gods dot org)
+  . Fixed bug #52668 (Iterating over a dateperiod twice is broken). (Derick)
+  . Fixed bug #52454 (Relative dates and getTimestamp increments by one day).
+    (Derick)
+  . Fixed bug #52430 (date_parse parse 24:xx:xx as valid time). (Derick)
+  . Added support for the ( and ) delimiters/separators to
+    DateTime::createFromFormat(). (Derick)
+
+- DBA extension:
+  . Added Berkeley DB 5.1 support to the DBA extension. (Oracle Corp.)
+
+- DOM extension:
+  . Fixed bug #52656 (DOMCdataSection does not work with splitText). (Ilia)
+
+- Filter extension:
+  . Fixed the filter extension accepting IPv4 octets with a leading 0 as that
+    belongs to the unsupported "dotted octal" representation. (Gustavo)
+  . Fixed bug #53236 (problems in the validation of IPv6 addresses with leading
+    and trailing :: in the filter extension). (Gustavo)
+  . Fixed bug #50117 (problems in the validation of IPv6 addresses with IPv4
+    addresses and ::). (Gustavo)
+
+- GD extension:
+  . Fixed bug #53492 (fix crash if anti-aliasing steps are invalid). (Pierre)
+
+- GMP extension:
+  . Fixed bug #52906 (gmp_mod returns negative result when non-negative is 
+    expected). (Stas)
+  . Fixed bug #52849 (GNU MP invalid version match). (Adam)
+
+- Hash extension:
+  . Fixed bug #51003 (unaligned memory access in ext/hash/hash_tiger.c).
+    (Mike, Ilia)
+
+- Iconv extension:
+  . Fixed bug #52941 (The 'iconv_mime_decode_headers' function is skipping
+    headers). (Adam)
+  . Fixed bug #52599 (iconv output handler outputs incorrect content type
+    when flags are used). (Ilia)
+  . Fixed bug #51250 (iconv_mime_decode() does not ignore malformed Q-encoded 
+    words). (Ilia)
+
+- Intl extension:
+  . Fixed crashes on invalid parameters in intl extension. (CVE-2010-4409). (Stas, Maksymilian
+    Arciemowicz)
+  . Added support for formatting the timestamp stored in a DateTime object.
+    (Stas)
+  . Fixed bug #50590 (IntlDateFormatter::parse result is limited to the integer
+    range). (Stas)
+    
+- Mbstring extension:
+  . Fixed bug #53273 (mb_strcut() returns garbage with the excessive length
+    parameter). (CVE-2010-4156) (Mateusz Kocielski, Pierre, Moriyoshi)
+  . Fixed bug #52981 (Unicode casing table was out-of-date. Updated with
+    UnicodeData-6.0.0d7.txt and included the source of the generator program with
+    the distribution) (Gustavo).
+  . Fixed bug #52681 (mb_send_mail() appends an extra MIME-Version header).
+    (Adam)
+ 
+- MSSQL extension:
+  . Fixed possible crash in mssql_fetch_batch(). (Kalle)
+  . Fixed bug #52843 (Segfault when optional parameters are not passed in to
+    mssql_connect). (Felipe)
+    
+- MySQL extension:
+  . Fixed bug #52636 (php_mysql_fetch_hash writes long value into int). 
+    (Kalle, rein at basefarm dot no)
+    
+- MySQLi extension:
+  . Fixed bug #52891 (Wrong data inserted with mysqli/mysqlnd when using
+    mysqli_stmt_bind_param and value> PHP_INT_MAX). (Andrey)
+  . Fixed bug #52686 (mysql_stmt_attr_[gs]et argument points to incorrect type).
+    (rein at basefarm dot no)
+  . Fixed bug #52654 (mysqli doesn't install headers with structures it uses).
+    (Andrey)
+  . Fixed bug #52433 (Call to undefined method mysqli::poll() - must be static).
+    (Andrey)
+  . Fixed bug #52417 (MySQLi build failure with mysqlnd on MacOS X). (Andrey)
+  . Fixed bug #52413 (MySQLi/libmysql build failure on OS X, FreeBSD). (Andrey)
+  . Fixed bug #52390 (mysqli_report() should be per-request setting). (Kalle)
+  . Fixed bug #52302 (mysqli_fetch_all does not work with MYSQLI_USE_RESULT).
+    (Andrey)
+  . Fixed bug #52221 (Misbehaviour of magic_quotes_runtime (get/set)). (Andrey)
+  . Fixed bug #45921 (Can't initialize character set hebrew). (Andrey)
+  
+- MySQLnd:
+  . Fixed bug #52613 (crash in mysqlnd after hitting memory limit). (Andrey)
+     
+- ODBC extension:
+  - Fixed bug #52512 (Broken error handling in odbc_execute).
+    (mkoegler at auto dot tuwien dot ac dot at)
+
+- Openssl extension:
+  . Fixed possible blocking behavior in openssl_random_pseudo_bytes on Windows.
+    (Pierre)
+  . Fixed bug #53136 (Invalid read on openssl_csr_new()). (Felipe)
+  . Fixed bug #52947 (segfault when ssl stream option capture_peer_cert_chain
+    used). (Felipe)
+
+- Oracle Database extension (OCI8):
+  . Fixed bug #53284 (Valgrind warnings in oci_set_* functions) (Oracle Corp.)
+  . Fixed bug #51610 (Using oci_connect causes PHP to take a long time to
+    exit).  Requires Oracle 11.2.0.2 client libraries (or Oracle bug fix
+    9891199) for this patch to have an effect. (Oracle Corp.)
+      
+- PCNTL extension:
+  . Fixed bug #52784 (Race condition when handling many concurrent signals).
+    (nick dot telford at gmail dot com, Arnaud)
+    
+- PCRE extension:
+  . Fixed bug #52971 (PCRE-Meta-Characters not working with utf-8). (Felipe)
+  . Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it
+    returns int(0)). (slugonamission at gmail dot com)
+
+- PHAR extension:
+  . Fixed bug #50987 (unaligned memory access in phar.c).
+    (geissert at debian dot org, Ilia)
+
+- PHP-FPM SAPI:
+  . Fixed bug #53412 (segfault when using -y). (fat)
+  . Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat)
+  . Fixed bug #52501 (libevent made FPM crashed when forking -- libevent has
+    been removed). (fat)
+  . Fixed bug #52725 (gcc builtin atomic functions were sometimes used when they
+    were not available). (fat)
+  . Fixed bug #52693 (configuration file errors are not logged to stderr). (fat)
+  . Fixed bug #52674 (FPM Status page returns inconsistent Content-Type headers).
+    (fat)
+  . Fixed bug #52498 (libevent was not only linked to php-fpm). (fat)
+
+- PDO:
+  . Fixed bug #52699 (PDO bindValue writes long int 32bit enum).
+    (rein at basefarm dot no) 
+  . Fixed bug #52487 (PDO::FETCH_INTO leaks memory). (Felipe)
+  
+- PDO DBLib driver:
+  . Fixed bug #52546 (pdo_dblib segmentation fault when iterating MONEY values).
+    (Felipe)
+    
+- PDO Firebird driver:
+  . Restored firebird support (VC9 builds only). (Pierre)
+  . Fixed bug #53335 (pdo_firebird did not implement rowCount()).
+    (preeves at ibphoenix dot com)
+  . Fixed bug #53323 (pdo_firebird getAttribute() crash).
+    (preeves at ibphoenix dot com)
+    
+- PDO MySQL driver:
+  . Fixed bug #52745 (Binding params doesn't work when selecting a date inside a
+    CASE-WHEN). (Andrey)
+    
+- PostgreSQL extension:
+  . Fixed bug #47199 (pg_delete() fails on NULL). (ewgraf at gmail dot com)
+  
+- Reflection extension:
+  . Fixed ReflectionProperty::isDefault() giving a wrong result for properties
+    obtained with ReflectionClass::getProperties(). (Gustavo)
+- Reflection extension:
+  . Fixed bug #53366 (Reflection doesnt get dynamic property value from
+    getProperty()). (Felipe)
+  . Fixed bug #52854 (ReflectionClass::newInstanceArgs does not work for classes
+    without constructors). (Johannes)
+  
+- SOAP extension:
+  . Fixed bug #44248 (RFC2616 transgression while HTTPS request through proxy
+    with SoapClient object). (Dmitry)
+    
+- SPL extension:
+  . Fixed bug #53362 (Segmentation fault when extending SplFixedArray). (Felipe)
+  . Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape
+    character). (Adam)
+  . Fixed bug #53144 (Segfault in SplObjectStorage::removeAll()). (Felipe)
+  . Fixed bug #53071 (SPLObjectStorage defeats gc_collect_cycles). (Gustavo)
+  . Fixed bug #52573 (SplFileObject::fscanf Segmentation fault). (Felipe)
+  . Fixed bug #51763 (SplFileInfo::getType() does not work symbolic link 
+    and directory). (Pierre)
+  . Fixed bug #50481 (Storing many SPLFixedArray in an array crashes). (Felipe)
+  . Fixed bug #50579 (RegexIterator::REPLACE doesn't work). (Felipe)
+
+- SQLite3 extension:
+  . Fixed bug #53463 (sqlite3 columnName() segfaults on bad column_number).
+    (Felipe)
+    
+- Streams:
+  . Fixed forward stream seeking emulation in streams that don't support seeking
+    in situations where the read operation gives back less data than requested
+    and when there was data in the buffer before the emulation started. Also made
+    more consistent its behavior -- should return failure every time less data
+    than was requested was skipped. (Gustavo)
+  . Fixed bug #53241 (stream casting that relies on fdopen/fopencookie fails
+    with streams opened with, inter alia, the 'xb' mode). (Gustavo)
+  . Fixed bug #53006 (stream_get_contents has an unpredictable behavior when the
+    underlying stream does not support seeking). (Gustavo)
+  . Fixed bug #52944 (Invalid write on second and subsequent reads with an
+    inflate filter fed invalid data). (Gustavo)
+  . Fixed bug #52820 (writes to fopencookie FILE* not commited when seeking the
+    stream). (Gustavo)
+
+- WDDX extension:
+  . Fixed bug #52468 (wddx_deserialize corrupts integer field value when left
+    empty). (Felipe)
+     
+- Zlib extension:
+  . Fixed bug #52926 (zlib fopen wrapper does not use context). (Gustavo)
+
 22 Jul 2010, PHP 5.3.3
 - Upgraded bundled sqlite to version 3.6.23.1. (Ilia)
 - Upgraded bundled PCRE to version 8.02. (Ilia)
@@ -234,8 +590,6 @@ PHP                                                                        NEWS
   com, Pierre)
 - Fixed bug #50578 (incorrect shebang in phar.phar). (Fedora at FamilleCollet
   dot com)
-- Fixed bug #50555 (DateTime::sub() allows 'relative' time modifications).
-  (Derick)
 - Fixed bug #50392 (date_create_from_format enforces 6 digits for 'u' format
   character). (Derick)
 - Fixed bug #50383 (Exceptions thrown in __call / __callStatic do not include
@@ -243,6 +597,8 @@ PHP                                                                        NEWS
 - Fixed bug #50358 (Compile failure compiling ext/phar/util.lo). (Felipe)
 - Fixed bug #50101 (name clash between global and local variable).
   (patch by yoarvi at gmail dot com)
+- Fixed bug #50055 (DateTime::sub() allows 'relative' time modifications).
+  (Derick)
 - Fixed bug #51002 (fix possible memory corruption with very long names).
   (Pierre)
 - Fixed bug #49893 (Crash while creating an instance of Zend_Mail_Storage_Pop3).
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 0ff3c64..30f42b1 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -14,10 +14,11 @@
    +----------------------------------------------------------------------+
    | Authors: Andi Gutmans <andi at zend.com>                                |
    |          Sascha Schumann <sascha at schumann.cx>                        |
+   |          Pierre Joye <pierre at php.net>                                |
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.c 300276 2010-06-08 13:27:30Z tony2001 $ */
+/* $Id: tsrm_virtual_cwd.c 305070 2010-11-04 01:16:20Z pajoye $ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -38,6 +39,18 @@
 # ifndef IO_REPARSE_TAG_SYMLINK
 #  define IO_REPARSE_TAG_SYMLINK 0xA000000C
 # endif
+
+# ifndef VOLUME_NAME_NT
+#  define VOLUME_NAME_NT 0x2
+# endif
+
+# ifndef VOLUME_NAME_DOS
+#  define VOLUME_NAME_DOS 0x0
+# endif
+#endif
+
+#ifndef S_IFLNK
+# define S_IFLNK 0120000
 #endif
 
 #ifdef NETWARE
@@ -83,14 +96,14 @@ cwd_state main_cwd_state; /* True global */
 #include <tchar.h>
 #define tsrm_strtok_r(a,b,c) _tcstok((a),(b))
 #define TOKENIZER_STRING "/\\"
-	
-static int php_check_dots(const char *element, int n) 
+
+static int php_check_dots(const char *element, int n)
 {
 	while (n-- > 0) if (element[n] != '.') break;
 
 	return (n != -1);
 }
-	
+
 #define IS_DIRECTORY_UP(element, len) \
 	(len >= 2 && !php_check_dots(element, len))
 
@@ -124,7 +137,7 @@ static int php_check_dots(const char *element, int n)
 
 /* define this to check semantics */
 #define IS_DIR_OK(s) (1)
-	
+
 #ifndef IS_DIR_OK
 #define IS_DIR_OK(state) (php_is_dir_ok(state) == 0)
 #endif
@@ -137,7 +150,7 @@ static int php_check_dots(const char *element, int n)
 
 #define CWD_STATE_FREE(s)			\
 	free((s)->cwd);
-	
+
 #ifdef TSRM_WIN32
 
 #ifdef CTL_CODE
@@ -202,21 +215,98 @@ static inline time_t FileTimeToUnixTime(const FILETIME FileTime)
 	return (time_t)UnixTime;
 }
 
+CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ /* {{{ */
+	HINSTANCE kernel32;
+	HANDLE hFile;
+	DWORD dwRet;
+
+	typedef BOOL (WINAPI *gfpnh_func)(HANDLE, LPTSTR, DWORD, DWORD);
+	gfpnh_func pGetFinalPathNameByHandle;
+
+	kernel32 = LoadLibrary("kernel32.dll");
+
+	if (kernel32) {
+		pGetFinalPathNameByHandle = (gfpnh_func)GetProcAddress(kernel32, "GetFinalPathNameByHandleA");
+		if (pGetFinalPathNameByHandle == NULL) {
+			return -1;
+		}
+	} else {
+		return -1;
+	}
+
+	hFile = CreateFile(link,            // file to open
+				 GENERIC_READ,          // open for reading
+				 FILE_SHARE_READ,       // share for reading
+				 NULL,                  // default security
+				 OPEN_EXISTING,         // existing file only
+				 FILE_FLAG_BACKUP_SEMANTICS, // normal file
+				 NULL);                 // no attr. template
+
+	if( hFile == INVALID_HANDLE_VALUE) {
+			return -1;
+	}
+
+	dwRet = pGetFinalPathNameByHandle(hFile, target, MAXPATHLEN, VOLUME_NAME_DOS);
+	if(dwRet >= MAXPATHLEN) {
+		return -1;
+	}
+
+	CloseHandle(hFile);
+
+	if(dwRet > 4) {
+		/* Skip first 4 characters if they are "\??\" */
+		if(target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] ==  '\\') {
+			char tmp[MAXPATHLEN];
+			unsigned int offset = 4;
+			dwRet -= 4;
+
+			/* \??\UNC\ */
+			if (dwRet > 7 && target[4] == 'U' && target[5] == 'N' && target[6] == 'C') {
+				offset += 2;
+				dwRet -= 2;
+				target[offset] = '\\';
+			}
+
+			memcpy(tmp, target + offset, dwRet);
+			memcpy(target, tmp, dwRet);
+		}
+	}
+
+	target[dwRet] = '\0';
+	return dwRet;
+}
+/* }}} */
+
 CWD_API int php_sys_stat(const char *path, struct stat *buf) /* {{{ */
 {
+	return php_sys_stat_ex(path, buf, 0);
+}
+/* }}} */
+
+CWD_API int php_sys_lstat(const char *path, struct stat *buf) /* {{{ */
+{
+	return php_sys_stat_ex(path, buf, 1);
+}
+/* }}} */
+
+CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */
+{
 	WIN32_FILE_ATTRIBUTE_DATA data;
 	__int64 t;
+	const size_t path_len = strlen(path);
 
 	if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) {
 		return stat(path, buf);
 	}
 
-	if (path[1] == ':') {
+	if (path_len >= 1 && path[1] == ':') {
 		if (path[0] >= 'A' && path[0] <= 'Z') {
 			buf->st_dev = buf->st_rdev = path[0] - 'A';
 		} else {
 			buf->st_dev = buf->st_rdev = path[0] - 'a';
 		}
+	} else if (IS_UNC_PATH(path, path_len)) {
+		buf->st_dev = buf->st_rdev = 0;
 	} else {
 		char  cur_path[MAXPATHLEN+1];
 		DWORD len = sizeof(cur_path);
@@ -245,19 +335,56 @@ CWD_API int php_sys_stat(const char *path, struct stat *buf) /* {{{ */
 		}
 		if (tmp != cur_path) {
 			free(tmp);
-		}		    	
+		}
 	}
+
 	buf->st_uid = buf->st_gid = buf->st_ino = 0;
-	buf->st_mode = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)) : S_IFREG;
-	buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
+
+	if (lstat && data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+		/* File is a reparse point. Get the target */
+		HANDLE hLink = NULL;
+		REPARSE_DATA_BUFFER * pbuffer;
+		unsigned int retlength = 0;
+		TSRM_ALLOCA_FLAG(use_heap_large);
+
+		hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
+		if(hLink == INVALID_HANDLE_VALUE) {
+			return -1;
+		}
+
+		pbuffer = (REPARSE_DATA_BUFFER *)tsrm_do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large);
+		if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer,  MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
+			tsrm_free_alloca(pbuffer, use_heap_large);
+			CloseHandle(hLink);
+			return -1;
+		}
+
+		CloseHandle(hLink);
+
+		if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+			buf->st_mode = S_IFLNK;
+			buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
+		}
+
+#if 0 /* Not used yet */
+		else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
+			buf->st_mode |=;
+		}
+#endif
+		tsrm_free_alloca(pbuffer, use_heap_large);
+	} else {
+		buf->st_mode = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)) : S_IFREG;
+		buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
+	}
+
 	if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
 		int len = strlen(path);
 
 		if (path[len-4] == '.') {
 			if (_memicmp(path+len-3, "exe", 3) == 0 ||
-			    _memicmp(path+len-3, "com", 3) == 0 ||
-			    _memicmp(path+len-3, "bat", 3) == 0 ||
-			    _memicmp(path+len-3, "cmd", 3) == 0) {
+				_memicmp(path+len-3, "com", 3) == 0 ||
+				_memicmp(path+len-3, "bat", 3) == 0 ||
+				_memicmp(path+len-3, "cmd", 3) == 0) {
 				buf->st_mode  |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
 			}
 		}
@@ -332,7 +459,7 @@ CWD_API void virtual_cwd_startup(void) /* {{{ */
 		}
 	}
 #else
-	result = getcwd(cwd, sizeof(cwd));	
+	result = getcwd(cwd, sizeof(cwd));
 #endif
 	if (!result) {
 		cwd[0] = '\0';
@@ -383,7 +510,7 @@ CWD_API char *virtual_getcwd_ex(size_t *length TSRMLS_DC) /* {{{ */
 		*length = 1;
 		retval = (char *) malloc(2);
 		retval[0] = DEFAULT_SLASH;
-		retval[1] = '\0';	
+		retval[1] = '\0';
 		return retval;
 	}
 
@@ -493,7 +620,7 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{
 
 	while (*bucket != NULL) {
 		if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
-		           memcmp(path, (*bucket)->path, path_len) == 0) {
+					memcmp(path, (*bucket)->path, path_len) == 0) {
 			realpath_cache_bucket *r = *bucket;
 			*bucket = (*bucket)->next;
 			CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
@@ -510,9 +637,9 @@ static inline void realpath_cache_add(const char *path, int path_len, const char
 {
 	long size = sizeof(realpath_cache_bucket) + path_len + 1;
 	int same = 1;
-	
+
 	if (realpath_len != path_len ||
-	    memcmp(path, realpath, path_len) != 0) {
+		memcmp(path, realpath, path_len) != 0) {
 		size += realpath_len + 1;
 		same = 0;
 	}
@@ -570,7 +697,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
 			CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
 			free(r);
 		} else if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
-		           memcmp(path, (*bucket)->path, path_len) == 0) {
+					memcmp(path, (*bucket)->path, path_len) == 0) {
 			return *bucket;
 		} else {
 			bucket = &(*bucket)->next;
@@ -582,21 +709,21 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
 
 CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */
 {
-    return realpath_cache_find(path, path_len, t TSRMLS_CC);
+	return realpath_cache_find(path, path_len, t TSRMLS_CC);
 }
 /* }}} */
 
-CWD_API int realpath_cache_size(TSRMLS_D) 
+CWD_API int realpath_cache_size(TSRMLS_D)
 {
 	return CWDG(realpath_cache_size);
 }
 
-CWD_API int realpath_cache_max_buckets(TSRMLS_D) 
+CWD_API int realpath_cache_max_buckets(TSRMLS_D)
 {
 	return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0]));
 }
 
-CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D) 
+CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D)
 {
 	return CWDG(realpath_cache);
 }
@@ -650,14 +777,14 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 				if (!start) {
 					/* leading '..' must not be removed in case of relative path */
 					if (j == 0 && path[0] == '.' && path[1] == '.' &&
-					    IS_SLASH(path[2])) {
+							IS_SLASH(path[2])) {
 						path[3] = '.';
 						path[4] = '.';
 						path[5] = DEFAULT_SLASH;
 						j = 5;
-					} else if (j > 0 && 
-				               path[j+1] == '.' && path[j+2] == '.' &&
-				               IS_SLASH(path[j+3])) {
+					} else if (j > 0 &&
+							path[j+1] == '.' && path[j+2] == '.' &&
+							IS_SLASH(path[j+3])) {
 						j += 4;
 						path[j++] = '.';
 						path[j++] = '.';
@@ -673,7 +800,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 			}
 			return j;
 		}
-	
+
 		path[len] = 0;
 
 		save = (use_realpath != CWD_EXPAND);
@@ -683,18 +810,18 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 			if (!*t) {
 				*t = time(0);
 			}
-		    if ((bucket = realpath_cache_find(path, len, *t TSRMLS_CC)) != NULL) {
-		    	if (is_dir && !bucket->is_dir) {
+			if ((bucket = realpath_cache_find(path, len, *t TSRMLS_CC)) != NULL) {
+				if (is_dir && !bucket->is_dir) {
 					/* not a directory */
 					return -1;
-		    	} else {
-		    		if (link_is_dir) {
-		    			*link_is_dir = bucket->is_dir;
-		    		}
+				} else {
+					if (link_is_dir) {
+						*link_is_dir = bucket->is_dir;
+					}
 					memcpy(path, bucket->realpath, bucket->realpath_len + 1);
-				    return bucket->realpath_len;
+					return bucket->realpath_len;
 				}
-	    	}
+			}
 		}
 
 #ifdef TSRM_WIN32
@@ -706,7 +833,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 			/* continue resolution anyway but don't save result in the cache */
 			save = 0;
 		}
-		
+
 		if (save) {
 			FindClose(hFind);
 		}
@@ -714,9 +841,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 		tmp = tsrm_do_alloca(len+1, use_heap);
 		memcpy(tmp, path, len+1);
 
-		if(save && 
-		!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
-		(data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
+		if(save &&
+				!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
+				(data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
 			/* File is a reparse point. Get the target */
 			HANDLE hLink = NULL;
 			REPARSE_DATA_BUFFER * pbuffer;
@@ -751,7 +878,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 				reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
 				printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
 				isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
-				if (!WideCharToMultiByte(CP_THREAD_ACP, 0, 
+				if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
 					reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset  / sizeof(WCHAR),
 					printname_len + 1,
 					printname, MAX_PATH, NULL, NULL
@@ -763,7 +890,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 				printname[printname_len] = 0;
 
 				substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
-				if (!WideCharToMultiByte(CP_THREAD_ACP, 0, 
+				if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
 					reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
 					substitutename_len + 1,
 					substitutename, MAX_PATH, NULL, NULL
@@ -777,7 +904,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 				isabsolute = 1;
 				reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
 				printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
-				if (!WideCharToMultiByte(CP_THREAD_ACP, 0, 
+				if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
 					reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset  / sizeof(WCHAR),
 					printname_len + 1,
 					printname, MAX_PATH, NULL, NULL
@@ -788,7 +915,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 				printname[pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)] = 0;
 
 				substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
-				if (!WideCharToMultiByte(CP_THREAD_ACP, 0, 
+				if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
 					reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
 					substitutename_len + 1,
 					substitutename, MAX_PATH, NULL, NULL
@@ -803,20 +930,22 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 			}
 
 			if(isabsolute && substitutename_len > 4) {
-				/* Do not resolve volumes (for now). A mounted point can 
+				/* Do not resolve volumes (for now). A mounted point can
 				   target a volume without a drive, it is not certain that
-				   all IO functions we use in php and its deps support 
+				   all IO functions we use in php and its deps support
 				   path with volume GUID instead of the DOS way, like:
 				   d:\test\mnt\foo
 				   \\?\Volume{62d1c3f8-83b9-11de-b108-806e6f6e6963}\foo
 				*/
-				if (strncmp(substitutename, "\\??\\Volume{",11) == 0 
-					|| strncmp(substitutename, "\\\\?\\Volume{",11) == 0) {
-					isVolume = TRUE;					
+				if (strncmp(substitutename, "\\??\\Volume{",11) == 0
+					|| strncmp(substitutename, "\\\\?\\Volume{",11) == 0
+					|| strncmp(substitutename, "\\??\\UNC\\", 8) == 0
+					) {
+					isVolume = TRUE;
 					substitutename_off = 0;
 				} else
 					/* do not use the \??\ and \\?\ prefix*/
-					if (strncmp(substitutename, "\\??\\", 4) == 0 
+					if (strncmp(substitutename, "\\??\\", 4) == 0
 						|| strncmp(substitutename, "\\\\?\\", 4) == 0) {
 					substitutename_off = 4;
 				}
@@ -887,7 +1016,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 		tmp = tsrm_do_alloca(len+1, use_heap);
 		memcpy(tmp, path, len+1);
 #else
-		if (save && lstat(path, &st) < 0) {
+		if (save && php_sys_lstat(path, &st) < 0) {
 			if (use_realpath == CWD_REALPATH) {
 				/* file not found */
 				return -1;
@@ -900,8 +1029,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 		memcpy(tmp, path, len+1);
 
 		if (save && S_ISLNK(st.st_mode)) {
-			if (++(*ll) > LINK_MAX || (j = readlink(tmp, path, MAXPATHLEN)) < 0) {
-			    /* too many links or broken symlinks */
+			if (++(*ll) > LINK_MAX || (j = php_sys_readlink(tmp, path, MAXPATHLEN)) < 0) {
+				/* too many links or broken symlinks */
 				tsrm_free_alloca(tmp, use_heap);
 				return -1;
 			}
@@ -913,10 +1042,10 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
 					return -1;
 				}
 			} else {
-			    if (i + j >= MAXPATHLEN-1) {
+				if (i + j >= MAXPATHLEN-1) {
 					tsrm_free_alloca(tmp, use_heap);
 					return -1; /* buffer overflow */
-			    }
+				}
 				memmove(path+i, path, j+1);
 				memcpy(path, tmp, i-1);
 				path[i-1] = DEFAULT_SLASH;
@@ -1038,18 +1167,18 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
 					state_cwd_length = 2;
 					while (IS_SLASH(state->cwd[state_cwd_length])) {
 						state_cwd_length++;
-					}						 
+					}
 					while (state->cwd[state_cwd_length] &&
-					       !IS_SLASH(state->cwd[state_cwd_length])) {
+							!IS_SLASH(state->cwd[state_cwd_length])) {
 						state_cwd_length++;
-					}						 
+					}
 					while (IS_SLASH(state->cwd[state_cwd_length])) {
 						state_cwd_length++;
-					}						 
+					}
 					while (state->cwd[state_cwd_length] &&
-					       !IS_SLASH(state->cwd[state_cwd_length])) {
+							!IS_SLASH(state->cwd[state_cwd_length])) {
 						state_cwd_length++;
-					}						 
+					}
 				}
 			}
 #endif
@@ -1061,7 +1190,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
 			memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1);
 			path_length += state_cwd_length + 1;
 		}
-	} else {		
+	} else {
 #ifdef TSRM_WIN32
 		if (path_length > 2 && path[1] == ':' && !IS_SLASH(path[2])) {
 			resolved_path[0] = path[0];
@@ -1072,11 +1201,11 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
 		} else
 #endif
 		memcpy(resolved_path, path, path_length + 1);
-	} 
+	}
 
 #ifdef TSRM_WIN32
 	if (memchr(resolved_path, '*', path_length) ||
-	    memchr(resolved_path, '?', path_length)) {
+		memchr(resolved_path, '?', path_length)) {
 		return 1;
 	}
 #endif
@@ -1126,12 +1255,12 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
 	add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]);
 	t = CWDG(realpath_cache_ttl) ? 0 : -1;
 	path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL TSRMLS_CC);
-	
+
 	if (path_length < 0) {
 		errno = ENOENT;
 		return 1;
 	}
-	
+
 	if (!start && !path_length) {
 		resolved_path[path_length++] = '.';
 	}
@@ -1184,7 +1313,7 @@ verify:
 		memcpy(state->cwd, resolved_path, state->cwd_length+1);
 		ret = 0;
 	}
-	
+
 #if VIRTUAL_CWD_DEBUG
 	fprintf (stderr, "virtual_file_ex() = %s\n",state->cwd);
 #endif
@@ -1207,7 +1336,7 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
 
 	if (length == 0) {
 		return 1; /* Can't cd to empty string */
-	}	
+	}
 	while(--length >= 0 && !IS_SLASH(path[length])) {
 	}
 
@@ -1242,16 +1371,16 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
 	if (!*path) {
 		new_state.cwd = (char*)malloc(1);
 		new_state.cwd[0] = '\0';
-		new_state.cwd_length = 0;		
-	    if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
-		    path = cwd;
+		new_state.cwd_length = 0;
+		if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
+			path = cwd;
 		}
 	} else if (!IS_ABSOLUTE_PATH(path, strlen(path))) {
 		CWD_STATE_COPY(&new_state, &CWDG(cwd));
 	} else {
 		new_state.cwd = (char*)malloc(1);
 		new_state.cwd[0] = '\0';
-		new_state.cwd_length = 0;		
+		new_state.cwd_length = 0;
 	}
 
 	if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)==0) {
@@ -1317,7 +1446,7 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
 {
 	cwd_state new_state;
 	int ret;
-	
+
 	CWD_STATE_COPY(&new_state, &CWDG(cwd));
 	if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
 		CWD_STATE_FREE(&new_state);
@@ -1329,9 +1458,9 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
 #else
 	ret = access(new_state.cwd, mode);
 #endif
-	
+
 	CWD_STATE_FREE(&new_state);
-	
+
 	return ret;
 }
 /* }}} */
@@ -1352,12 +1481,12 @@ static void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* {{{ */
 TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
 {
 	FILETIME mtime, atime;
-	HANDLE hFile; 
+	HANDLE hFile;
 
 	hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
 				 OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 
-	/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but 
+	/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
 	   the CreateFile operation succeeds */
 	if (GetLastError() == ERROR_ALREADY_EXISTS) {
 		SetLastError(0);
@@ -1477,7 +1606,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */
 		f = open(new_state.cwd, flags, mode);
 	} else {
 		f = open(new_state.cwd, flags);
-	}	
+	}
 	CWD_STATE_FREE(&new_state);
 	return f;
 }
@@ -1556,7 +1685,6 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-#if !defined(TSRM_WIN32)
 CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
 {
 	cwd_state new_state;
@@ -1568,13 +1696,12 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ *
 		return -1;
 	}
 
-	retval = lstat(new_state.cwd, buf);
+	retval = php_sys_lstat(new_state.cwd, buf);
 
 	CWD_STATE_FREE(&new_state);
 	return retval;
 }
 /* }}} */
-#endif
 
 CWD_API int virtual_unlink(const char *path TSRMLS_DC) /* {{{ */
 {
@@ -1738,7 +1865,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
 		}
 		*ptr++ = '\'';
 	}
-	
+
 	*ptr++ = ' ';
 	*ptr++ = ';';
 	*ptr++ = ' ';
@@ -1761,18 +1888,18 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
 	if (!*path) {
 		new_state.cwd = (char*)malloc(1);
 		new_state.cwd[0] = '\0';
-		new_state.cwd_length = 0;		
-	    if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
-		    path = cwd;
+		new_state.cwd_length = 0;
+		if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
+			path = cwd;
 		}
 	} else if (!IS_ABSOLUTE_PATH(path, strlen(path)) &&
-	    VCWD_GETCWD(cwd, MAXPATHLEN)) {
+					VCWD_GETCWD(cwd, MAXPATHLEN)) {
 		new_state.cwd = strdup(cwd);
 		new_state.cwd_length = strlen(cwd);
 	} else {
 		new_state.cwd = (char*)malloc(1);
 		new_state.cwd[0] = '\0';
-		new_state.cwd_length = 0;		
+		new_state.cwd_length = 0;
 	}
 
 	if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index c18bc0f..d1bdd68 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -14,10 +14,11 @@
    +----------------------------------------------------------------------+
    | Authors: Andi Gutmans <andi at zend.com>                                |
    |          Sascha Schumann <sascha at schumann.cx>                        |
+   |          Pierre Joye <pierre at php.net>                                |
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: tsrm_virtual_cwd.h 305070 2010-11-04 01:16:20Z pajoye $ */
 
 #ifndef VIRTUAL_CWD_H
 #define VIRTUAL_CWD_H
@@ -107,7 +108,7 @@ typedef unsigned short mode_t;
 #define COPY_WHEN_ABSOLUTE(path) 0
 #endif
 
-#ifndef IS_ABSOLUTE_PATH	
+#ifndef IS_ABSOLUTE_PATH
 #define IS_ABSOLUTE_PATH(path, len) \
 	(IS_SLASH(path[0]))
 #endif
@@ -129,9 +130,16 @@ 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(const char *path, struct stat *buf);
+CWD_API int php_sys_lstat(const char *path, struct stat *buf);
+CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len);
 #else
 # define php_sys_stat stat
+# define php_sys_lstat lstat
+# ifdef HAVE_SYMLINK
+# define php_sys_readlink(link, target, target_len) readlink(link, target, target_len)
+# endif
 #endif
 
 typedef struct _cwd_state {
@@ -155,9 +163,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...);
 CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC);
 CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC);
 CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC);
-#if !defined(TSRM_WIN32)
 CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC);
-#endif
 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);
@@ -188,7 +194,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
 CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int link TSRMLS_DC);
 #endif
 
-/* One of the following constants must be used as the last argument 
+/* One of the following constants must be used as the last argument
    in virtual_file_ex() call. */
 
 #define CWD_EXPAND   0 /* expand "." and ".." but dont resolve symlinks      */
@@ -216,7 +222,7 @@ typedef struct _realpath_cache_bucket {
 	unsigned char                  is_wvalid;
 	unsigned char                  is_writable;
 #endif
-	struct _realpath_cache_bucket *next;	
+	struct _realpath_cache_bucket *next;
 } realpath_cache_bucket;
 
 typedef struct _virtual_cwd_globals {
@@ -244,7 +250,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
 
 /* The actual macros to be used in programs using TSRM
  * If the program defines VIRTUAL_DIR it will use the
- * virtual_* functions 
+ * virtual_* functions
  */
 
 #ifdef VIRTUAL_DIR
@@ -261,9 +267,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
 #define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
 #define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
 #define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
-#if !defined(TSRM_WIN32)
-# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
-#endif
+#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
 #define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
 #define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC)
 #define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
diff --git a/UPGRADING b/UPGRADING
index 9b797a8..bf88494 100755
--- a/UPGRADING
+++ b/UPGRADING
@@ -1,4 +1,4 @@
-$Id: UPGRADING 282950 2009-06-28 16:14:30Z johannes $
+$Id: UPGRADING 306076 2010-12-08 09:38:47Z pajoye $
 
 UPGRADE NOTES - PHP 5.3
 
@@ -40,6 +40,9 @@ UPGRADE NOTES - PHP 5.3
 2. Changes made to existing functions
 =====================================
 
+- Paths containing NULL (like /some/path\0foo.txt) are now considered invalid. 
+  See http://news.php.net/php.internals/50191
+
 - The HTTP stream wrapper now considers all status codes from 200 to 399 to be
   successful.
 
@@ -273,6 +276,8 @@ UPGRADE NOTES - PHP 5.3
         - MySQLi: Now supports persistent connections by prepending the hostname 
           with "p:".
 
+        - imagepstext now rejects invalid antialiasing steps and raises a warning.
+
      d. no longer possible to disable
 
         - PCRE
@@ -457,6 +462,14 @@ UPGRADE NOTES - PHP 5.3
 - Firebird and SNMP support are no longer available on Windows. Firebird support
   may be reintroduced in the future.
 
+=====================
+11.1 New in PHP 5.3.4
+=====================
+
+- open_basedir supports now symbolic links (checks the target).
+- is_link and SplFileInfo symbolic links related method are now fully supported
+  (on Windows Vista or later).
+
 ===================
 12. New in PHP 5.3:
 ===================
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
new file mode 100644
index 0000000..86ab778
--- /dev/null
+++ b/UPGRADING.INTERNALS
@@ -0,0 +1,23 @@
+$Id$
+
+UPGRADE NOTES - PHP 5.3.4
+
+1. Internal API changes
+
+========================
+1. Internal API changes
+========================
+
+	a. stat/lstat support
+
+lstat is now available on all platforms. On unix-like platform
+php_sys_lstat is an alias to lstat (when avaible). On Windows it is now 
+available using php_sys_lstat. php_sys_stat and php_sys_lstat usage is recommended 
+instead of calling lstat directly, to ensure portability.
+
+	b. readlink support
+
+readlink is now available on all platforms. On unix-like platform
+php_sys_readlink is an alias to readlink (when avaible). On Windows it is now 
+available using php_sys_readlink. php_sys_readlink usage is recommended 
+instead of calling readlink directly, to ensure portability.
diff --git a/Zend/acinclude.m4 b/Zend/acinclude.m4
index 643ae2b..efd9cc9 100644
--- a/Zend/acinclude.m4
+++ b/Zend/acinclude.m4
@@ -1,10 +1,10 @@
-dnl $Id: acinclude.m4 298893 2010-05-03 09:05:30Z pajoye $
+dnl $Id: acinclude.m4 304193 2010-10-07 21:44:41Z felipe $
 dnl
 dnl This file contains local autoconf functions.
 
 AC_DEFUN([LIBZEND_BISON_CHECK],[
   # we only support certain bison versions
-  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2"
+  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3"
 
   # for standalone build of Zend Engine
   test -z "$SED" && SED=sed
diff --git a/Zend/tests/bug45180.phpt b/Zend/tests/bug45180.phpt
index 4e1ab9e..f1ca434 100644
--- a/Zend/tests/bug45180.phpt
+++ b/Zend/tests/bug45180.phpt
@@ -43,11 +43,11 @@ __call:
 string(3) "ABC"
 __call:
 string(3) "ABC"
-__callstatic:
+__call:
 string(3) "XYZ"
-__callstatic:
+__call:
 string(3) "WWW"
-__callstatic:
+__call:
 string(3) "ABC"
 __callstatic:
 string(1) "A"
@@ -58,4 +58,4 @@ string(1) "C"
 __callstatic:
 string(3) "FOO"
 __callstatic:
-string(3) "FOO"
+string(3) "FOO"
\ No newline at end of file
diff --git a/Zend/tests/bug45186.phpt b/Zend/tests/bug45186.phpt
index da7ac73..bcf88a1 100644
--- a/Zend/tests/bug45186.phpt
+++ b/Zend/tests/bug45186.phpt
@@ -35,17 +35,17 @@ call_user_func('self::y');
 
 ?>
 --EXPECTF--
-__callstatic:
+__call:
 string(3) "ABC"
-__callstatic:
+__call:
 string(3) "ABC"
 __call:
 string(3) "xyz"
-__callstatic:
+__call:
 string(3) "www"
 __call:
 string(1) "y"
-__callstatic:
+__call:
 string(1) "y"
 ok
 __callstatic:
diff --git a/Zend/tests/bug51176.phpt b/Zend/tests/bug51176.phpt
index 436378e..1b0e285 100644
--- a/Zend/tests/bug51176.phpt
+++ b/Zend/tests/bug51176.phpt
@@ -27,6 +27,6 @@ $foo->start();
 
 ?>
 --EXPECT--
-static
-static
-static
+instance
+instance
+instance
\ No newline at end of file
diff --git a/Zend/tests/bug52361.phpt b/Zend/tests/bug52361.phpt
new file mode 100644
index 0000000..3c2dffa
--- /dev/null
+++ b/Zend/tests/bug52361.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #52361 (Throwing an exception in a destructor causes invalid catching)
+--FILE--
+<?php
+class aaa {
+	public function __destruct() {
+		try {
+			throw new Exception(__CLASS__);
+		} catch(Exception $ex) {
+			echo "1. $ex\n";
+		}
+	}
+}
+function bbb() {
+	$a = new aaa();
+	throw new Exception(__FUNCTION__);
+}
+try {
+	bbb();
+	echo "must be skipped !!!";
+} catch(Exception $ex) {
+	echo "2. $ex\n";
+}
+?>
+--EXPECTF--
+1. exception 'Exception' with message 'aaa' in %sbug52361.php:5
+Stack trace:
+#0 %sbug52361.php(16): aaa->__destruct()
+#1 %sbug52361.php(16): bbb()
+#2 {main}
+2. exception 'Exception' with message 'bbb' in %sbug52361.php:13
+Stack trace:
+#0 %sbug52361.php(16): bbb()
+#1 {main}
+
diff --git a/Zend/tests/bug52484.phpt b/Zend/tests/bug52484.phpt
new file mode 100644
index 0000000..ccdf858
--- /dev/null
+++ b/Zend/tests/bug52484.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #52484 (__set() ignores setting properties with empty names)
+--FILE--
+<?php
+
+class A {	
+	function __unset($prop) {
+		unset($this->$prop);
+	}
+}
+
+$a = new A();
+$prop = null;
+
+unset($a->$prop);
+
+?>
+--EXPECTF--
+Fatal error: Cannot access empty property in %s on line %d
diff --git a/Zend/tests/bug52484_2.phpt b/Zend/tests/bug52484_2.phpt
new file mode 100644
index 0000000..1639c81
--- /dev/null
+++ b/Zend/tests/bug52484_2.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #52484.2 (__set() ignores setting properties with empty names)
+--FILE--
+<?php
+
+class A {
+	function __set($prop, $val) {
+		$this->$prop = $val;
+	}
+}
+
+$a = new A();
+$prop = null;
+
+$a->$prop = 2;
+
+?>
+--EXPECTF--
+Fatal error: Cannot access empty property in %s on line %d
diff --git a/Zend/tests/bug52484_3.phpt b/Zend/tests/bug52484_3.phpt
new file mode 100644
index 0000000..20dde3d
--- /dev/null
+++ b/Zend/tests/bug52484_3.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #52484.3 (__set() ignores setting properties with empty names)
+--FILE--
+<?php
+
+class A {	
+	function __get($prop) {
+		var_dump($this->$prop);
+	}
+}
+
+$a = new A();
+$prop = null;
+
+var_dump($a->$prop);
+
+?>
+--EXPECTF--
+Fatal error: Cannot access empty property in %s on line %d
diff --git a/Zend/tests/bug52508.phpt b/Zend/tests/bug52508.phpt
new file mode 100644
index 0000000..83292a5
--- /dev/null
+++ b/Zend/tests/bug52508.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #52508 (newline problem with parse_ini_file+INI_SCANNER_RAW)
+--FILE--
+<?php
+
+$file = dirname(__FILE__) .'/bug52508.ini';
+
+file_put_contents($file, "a = 1");
+
+$ini_array = parse_ini_file($file, true, INI_SCANNER_RAW);
+var_dump($ini_array);
+
+unlink($file);
+
+?>
+--EXPECT--
+array(1) {
+  ["a"]=>
+  string(1) "1"
+}
diff --git a/Zend/tests/bug52879.phpt b/Zend/tests/bug52879.phpt
new file mode 100644
index 0000000..0193be4
--- /dev/null
+++ b/Zend/tests/bug52879.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #52879 (Objects unreferenced in __get, __set, __isset or __unset can be freed too early)
+--FILE--
+<?php
+class MyClass {
+	public $myRef;
+	public function __set($property,$value) {
+		$this->myRef = $value;
+	}
+}
+$myGlobal=new MyClass($myGlobal);
+$myGlobal->myRef=&$myGlobal;
+$myGlobal->myNonExistentProperty="ok\n";
+echo $myGlobal;
+--EXPECT--
+ok
diff --git a/Zend/tests/bug52939.phpt b/Zend/tests/bug52939.phpt
new file mode 100644
index 0000000..91bd27b
--- /dev/null
+++ b/Zend/tests/bug52939.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #52939 (zend_call_function_array does not respect ZEND_SEND_PREFER_REF)
+--FILE--
+<?php
+$ar1 = array("row1" => 2, "row2" => 1);
+var_dump(array_multisort($ar1));
+var_dump($ar1);
+
+$ar1 = array("row1" => 2, "row2" => 1);
+$args = array(&$ar1);
+var_dump(call_user_func_array("array_multisort", $args));
+var_dump($ar1);
+
+$ar1 = array("row1" => 2, "row2" => 1);
+$args = array($ar1);
+var_dump(call_user_func_array("array_multisort", $args));
+var_dump($ar1);
+?>
+--EXPECT--
+bool(true)
+array(2) {
+  ["row2"]=>
+  int(1)
+  ["row1"]=>
+  int(2)
+}
+bool(true)
+array(2) {
+  ["row2"]=>
+  int(1)
+  ["row1"]=>
+  int(2)
+}
+bool(true)
+array(2) {
+  ["row1"]=>
+  int(2)
+  ["row2"]=>
+  int(1)
+}
diff --git a/Zend/tests/bug53305.phpt b/Zend/tests/bug53305.phpt
new file mode 100644
index 0000000..c922ac6
--- /dev/null
+++ b/Zend/tests/bug53305.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #53305 (E_NOTICE when defining a constant starts with __COMPILER_HALT_OFFSET__)
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+define('__COMPILER_HALT_OFFSET__1', 1);
+define('__COMPILER_HALT_OFFSET__2', 2);
+define('__COMPILER_HALT_OFFSET__', 3);
+define('__COMPILER_HALT_OFFSET__1'.chr(0), 4);
+
+var_dump(__COMPILER_HALT_OFFSET__1);
+var_dump(constant('__COMPILER_HALT_OFFSET__1'.chr(0)));
+
+?>
+--EXPECTF--
+Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d
+int(1)
+int(4)
diff --git a/Zend/tests/bug53632.phpt b/Zend/tests/bug53632.phpt
new file mode 100644
index 0000000..9a6dade
--- /dev/null
+++ b/Zend/tests/bug53632.phpt
@@ -0,0 +1,10 @@
+--TEST--
+zend_strtod() hangs with 2.2250738585072011e-308
+--FILE--
+<?php
+$d = 2.2250738585072011e-308;
+
+echo "Done\n";
+?>
+--EXPECTF--	
+Done
diff --git a/Zend/tests/call_static_003.phpt b/Zend/tests/call_static_003.phpt
index d5e2b75..566ff0f 100644
--- a/Zend/tests/call_static_003.phpt
+++ b/Zend/tests/call_static_003.phpt
@@ -28,9 +28,9 @@ foo::BAZ();
 --EXPECT--
 nonstatic
 string(6) "fOoBaR"
-static
+nonstatic
 string(6) "foOBAr"
-static
+nonstatic
 string(6) "fOOBAr"
 static
 string(3) "bAr"
diff --git a/Zend/tests/call_static_007.phpt b/Zend/tests/call_static_007.phpt
index 7668020..419f102 100644
--- a/Zend/tests/call_static_007.phpt
+++ b/Zend/tests/call_static_007.phpt
@@ -30,5 +30,5 @@ a::Foo();
 --EXPECT--
 __callstatic: Test
 __call: Test
-__callstatic: Bar
+__call: Bar
 __callstatic: Foo
diff --git a/Zend/tests/declare_001.phpt b/Zend/tests/declare_001.phpt
index 8f6f733..14c9a45 100644
--- a/Zend/tests/declare_001.phpt
+++ b/Zend/tests/declare_001.phpt
@@ -1,5 +1,11 @@
 --TEST--
 Testing declare statement with several type values
+--SKIPIF--
+<?php
+if (in_array("detect_unicode", array_keys(ini_get_all()))) {
+  die("skip");
+}
+?>
 --FILE--
 <?php
 
diff --git a/Zend/tests/gc_032.phpt b/Zend/tests/gc_032.phpt
new file mode 100644
index 0000000..615b008
--- /dev/null
+++ b/Zend/tests/gc_032.phpt
@@ -0,0 +1,40 @@
+--TEST--
+GC 032: Crash in GC because of invalid reference counting
+--FILE--
+<?php
+$a = array();
+$b =& $a;
+$a[0] = $a;
+debug_zval_dump($a);
+$a = array(array());
+$b =& $a;
+$a[0][0] = $a;
+debug_zval_dump($a);
+?>
+--EXPECT--
+array(1) refcount(1){
+  [0]=>
+  array(1) refcount(3){
+    [0]=>
+    array(1) refcount(3){
+      [0]=>
+      *RECURSION*
+    }
+  }
+}
+array(1) refcount(1){
+  [0]=>
+  array(1) refcount(3){
+    [0]=>
+    array(1) refcount(1){
+      [0]=>
+      array(1) refcount(3){
+        [0]=>
+        array(1) refcount(1){
+          [0]=>
+          *RECURSION*
+        }
+      }
+    }
+  }
+}
diff --git a/Zend/tests/multibyte/multibyte_encoding_006.phpt b/Zend/tests/multibyte/multibyte_encoding_006.phpt
new file mode 100644
index 0000000000000000000000000000000000000000..da5b8a22b87a5f2f9bb5899cfc31e55080aa7a97
GIT binary patch
literal 599
zcmZWn!EW0y4E5Px!TIC at 6EJMIwO9^?0|e`#SW;j&L$T<Xh(dW1y)+y4>)R;D-3}G-
zK$FiRpY&wRuG#L4DYspuQ4*X<2IxIL8{#gUMk}=U2&jo8KFoZW1kyxeGt&kBjxkYS
zND{5!;Zhp2{k(bHthMjmY8=LrdZ^zJw>Cz5sVj$qowO5^cE#!~%=Pw&msAr|dq8Qe
z_w|h~_*nut!n#UF8sQ6mn<!$+b9*{W5y2SbEXDjlcIGsBm3$F|Fp8?GZf?t8vjBV+
z<SexH!8&wxb=s?BJyrE;%x*w<Vd39K=qz&(*dvUp0a>6A5oDkQf=RBkR-g0&)|-b$
zkN at X)QQQ?pu~LkRVTq+iRCG%%Xaq&I<eBpeUbwU7`8zIkr!oJ3tH}LyYV-B6xzBc%
zYb(|R#u(y9xDS(ekd<HE5|xaQX3L?E;WX!0SJ3 at 8yL#HK&4>37O$8Fb>h9MMf*79o
P$l=VOPrwr+yet0#I|{MK

literal 0
HcmV?d00001

diff --git a/Zend/tests/objects_032.phpt b/Zend/tests/objects_032.phpt
new file mode 100644
index 0000000..e5e3eca
--- /dev/null
+++ b/Zend/tests/objects_032.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Covariant return-by-ref constraints
+--FILE--
+<?php
+
+class A implements ArrayAccess {
+    public $foo = array();
+
+    public function &offsetGet($n) {
+        return $this->foo[$n];
+    }
+
+    public function offsetSet($n, $v) {
+    }
+    public function offsetUnset($n) {
+    }
+    public function offsetExists($n) {
+    }
+}
+
+$a = new A;
+
+$a['foo']['bar'] = 2;
+
+var_dump($a);
+
+?>
+==DONE==
+--EXPECTF--
+object(A)#1 (1) {
+  ["foo"]=>
+  array(1) {
+    ["foo"]=>
+    array(1) {
+      ["bar"]=>
+      int(2)
+    }
+  }
+}
+==DONE==
diff --git a/Zend/tests/unset_cv05.phpt b/Zend/tests/unset_cv05.phpt
index 8e3c634..90ebc6b 100644
--- a/Zend/tests/unset_cv05.phpt
+++ b/Zend/tests/unset_cv05.phpt
@@ -19,7 +19,7 @@ echo $HTTP_SESSION_VARS;
 echo "\nok\n";
 ?>
 --EXPECTF--
-Warning: Directive 'register_long_arrays' is deprecated in PHP %d.%d and greater in Unknown on line 0
+Deprecated: Directive 'register_long_arrays' is deprecated in PHP %d.%d and greater in Unknown on line 0
 ok
 
 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at %sunset_cv05.php on line %d
diff --git a/Zend/tests/unset_cv06.phpt b/Zend/tests/unset_cv06.phpt
index b1ef0cc..ba21cf4 100644
--- a/Zend/tests/unset_cv06.phpt
+++ b/Zend/tests/unset_cv06.phpt
@@ -19,7 +19,7 @@ echo $x;
 echo "ok\n";
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP %d.%d and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP %d.%d and greater in Unknown on line 0
 1
 
 Deprecated: Function session_register() is deprecated in %s on line %d
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index cf74a9b..ea00d44 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c 299395 2010-05-14 23:48:03Z felipe $ */
+/* $Id: zend_API.c 302137 2010-08-12 07:58:14Z sas $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -1082,7 +1082,7 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type
 		} else {
 			ALLOC_HASHTABLE_REL(object->properties);
 			zend_hash_init(object->properties, zend_hash_num_elements(&class_type->default_properties), NULL, ZVAL_PTR_DTOR, 0);
-			zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+			zend_hash_copy(object->properties, &class_type->default_properties, zval_copy_property_ctor(class_type), (void *) &tmp, sizeof(zval *));
 		}
 	} else {
 		Z_OBJVAL_P(arg) = class_type->create_object(class_type TSRMLS_CC);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 8b8a84e..af450b8 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c 300817 2010-06-28 16:37:57Z felipe $ */
+/* $Id: zend_compile.c 305057 2010-11-03 15:40:24Z colder $ */
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -2551,12 +2551,14 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
 		return 0;
 	}
 
-	if (proto->common.pass_rest_by_reference
+	if (fe->common.type != ZEND_USER_FUNCTION
+		&& proto->common.pass_rest_by_reference
 		&& !fe->common.pass_rest_by_reference) {
 		return 0;
 	}
 
-	if (fe->common.return_reference != proto->common.return_reference) {
+	/* by-ref constraints on return values are covariant */
+	if (proto->common.return_reference && !fe->common.return_reference) {
 		return 0;
 	}
 
@@ -2580,6 +2582,8 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
 			/* Only one has an array type hint and the other one doesn't */
 			return 0;
 		}
+
+		/* by-ref constraints on arguments are invariant */
 		if (fe->common.arg_info[i].pass_by_reference != proto->common.arg_info[i].pass_by_reference) {
 			return 0;
 		}
@@ -2817,6 +2821,9 @@ static int inherit_static_prop(zval **p TSRMLS_DC, int num_args, va_list args, c
 }
 /* }}} */
 
+#define zval_property_ctor(parent_ce, ce) \
+	((copy_ctor_func_t) (((parent_ce)->type != (ce)->type) ? zval_shared_property_ctor : zval_add_ref))
+
 ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce TSRMLS_DC) /* {{{ */
 {
 	if ((ce->ce_flags & ZEND_ACC_INTERFACE)
@@ -2840,7 +2847,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
 	zend_do_inherit_interfaces(ce, parent_ce TSRMLS_CC);
 
 	/* Inherit properties */
-	zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
+	zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0);
 	if (parent_ce->type != ce->type) {
 		/* User class extends internal class */
 		zend_update_class_constants(parent_ce  TSRMLS_CC);
@@ -2850,7 +2857,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
 	}
 	zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce);
 
-	zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0);
+	zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, zval_property_ctor(parent_ce, ce), NULL, sizeof(zval *), 0);
 	zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce);
 	do_inherit_parent_constructor(ce);
 
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index 2713019..8a49b2f 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_constants.c 293155 2010-01-05 20:46:53Z sebastian $ */
+/* $Id: zend_constants.c 305332 2010-11-14 01:38:52Z felipe $ */
 
 #include "zend.h"
 #include "zend_constants.h"
@@ -434,8 +434,16 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
 		}
 	}
 
-	if ((strncmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) ||
-			zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
+	/* Check if the user is trying to define the internal pseudo constant name __COMPILER_HALT_OFFSET__ */
+	if ((c->name_len == sizeof("__COMPILER_HALT_OFFSET__")
+		&& !memcmp(name, "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1))
+		|| zend_hash_add(EG(zend_constants), name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
+		
+		/* The internal __COMPILER_HALT_OFFSET__ is prefixed by NULL byte */
+		if (c->name[0] == '\0' && c->name_len > sizeof("\0__COMPILER_HALT_OFFSET__")
+			&& memcmp(name, "\0__COMPILER_HALT_OFFSET__", sizeof("\0__COMPILER_HALT_OFFSET__")) == 0) {
+			name++;
+		}
 		zend_error(E_NOTICE,"Constant %s already defined", name);
 		free(c->name);
 		if (!(c->flags & CONST_PERSISTENT)) {
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index fcd9f25..aa2a366 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_exceptions.c 293155 2010-01-05 20:46:53Z sebastian $ */
+/* $Id: zend_exceptions.c 302311 2010-08-16 08:11:08Z dmitry $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -137,7 +137,7 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t
 
 	ALLOC_HASHTABLE(object->properties);
 	zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-	zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+	zend_hash_copy(object->properties, &class_type->default_properties, zval_copy_property_ctor(class_type), (void *) &tmp, sizeof(zval *));
 
 	ALLOC_ZVAL(trace);
 	Z_UNSET_ISREF_P(trace);
@@ -572,6 +572,7 @@ ZEND_METHOD(exception, __toString)
 		zend_call_function(&fci, NULL TSRMLS_CC);
 
 		if (Z_TYPE_P(trace) != IS_STRING) {
+			zval_ptr_dtor(&trace);
 			trace = NULL;
 		}
 
@@ -592,6 +593,10 @@ ZEND_METHOD(exception, __toString)
 		zval_dtor(&line);
 
 		exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 0 TSRMLS_CC);
+
+		if (trace) {
+			zval_ptr_dtor(&trace);
+		}
 	}
 	zval_dtor(&fname);
 
@@ -599,10 +604,6 @@ ZEND_METHOD(exception, __toString)
 	 * the result in uncaught exception handlers without memleaks. */
 	zend_update_property_string(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
 
-	if (trace) {
-		zval_ptr_dtor(&trace);
-	}
-
 	RETURN_STRINGL(str, len, 0);
 }
 /* }}} */
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 0573bb3..d7a2e2c 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c 298213 2010-04-20 12:30:35Z dmitry $ */
+/* $Id: zend_execute.c 303895 2010-09-30 14:11:51Z dmitry $ */
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -714,8 +714,8 @@ static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value
 					ALLOC_ZVAL(variable_ptr);
 					*variable_ptr_ptr = variable_ptr;
 					*variable_ptr = *value;
-					zval_copy_ctor(variable_ptr);
 					Z_SET_REFCOUNT_P(variable_ptr, 1);
+					zval_copy_ctor(variable_ptr);
 				} else {
 					*variable_ptr_ptr = value;
 					Z_ADDREF_P(value);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 6e6a2ca..8996abf 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c 299766 2010-05-26 00:00:58Z felipe $ */
+/* $Id: zend_execute_API.c 304364 2010-10-13 08:51:39Z dmitry $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -870,7 +870,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
 			if (Z_REFCOUNT_PP(fci->params[i]) > 1) {
 				zval *new_zval;
 
-				if (fci->no_separation) {
+				if (fci->no_separation &&
+				    !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
 					if(i) {
 						/* hack to clean up the stack */
 						zend_vm_stack_push_nocheck((void *) (zend_uintptr_t)i TSRMLS_CC);
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c
index 16c31ea..7e6e153 100644
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.c 297307 2010-04-01 22:54:03Z stas $ */
+/* $Id: zend_gc.c 303016 2010-09-03 09:27:47Z dmitry $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -414,19 +414,21 @@ static void gc_mark_roots(TSRMLS_D)
 	gc_root_buffer *current = GC_G(roots).next;
 
 	while (current != &GC_G(roots)) {
-		if (current->handle && EG(objects_store).object_buckets) {
-			struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;
+		if (current->handle) {
+			if (EG(objects_store).object_buckets) {
+				struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;
 
-			if (GC_GET_COLOR(obj->buffered) == GC_PURPLE) {
-				zval z;
+				if (GC_GET_COLOR(obj->buffered) == GC_PURPLE) {
+					zval z;
 
-				INIT_PZVAL(&z);
-				Z_OBJ_HANDLE(z) = current->handle;
-				Z_OBJ_HT(z) = current->u.handlers;
-				zobj_mark_grey(obj, &z TSRMLS_CC);
-			} else {
-				GC_SET_ADDRESS(obj->buffered, NULL);
-				GC_REMOVE_FROM_BUFFER(current);
+					INIT_PZVAL(&z);
+					Z_OBJ_HANDLE(z) = current->handle;
+					Z_OBJ_HT(z) = current->u.handlers;
+					zobj_mark_grey(obj, &z TSRMLS_CC);
+				} else {
+					GC_SET_ADDRESS(obj->buffered, NULL);
+					GC_REMOVE_FROM_BUFFER(current);
+				}
 			}
 		} else {
 			if (GC_ZVAL_GET_COLOR(current->u.pz) == GC_PURPLE) {
@@ -623,15 +625,17 @@ static void gc_collect_roots(TSRMLS_D)
 	gc_root_buffer *current = GC_G(roots).next;
 
 	while (current != &GC_G(roots)) {
-		if (current->handle && EG(objects_store).object_buckets) {
-			struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;
-			zval z;
+		if (current->handle) {
+			if (EG(objects_store).object_buckets) {
+				struct _store_object *obj = &EG(objects_store).object_buckets[current->handle].bucket.obj;
+				zval z;
 
-			GC_SET_ADDRESS(obj->buffered, NULL);
-			INIT_PZVAL(&z);
-			Z_OBJ_HANDLE(z) = current->handle;
-			Z_OBJ_HT(z) = current->u.handlers;
-			zobj_collect_white(&z TSRMLS_CC);
+				GC_SET_ADDRESS(obj->buffered, NULL);
+				INIT_PZVAL(&z);
+				Z_OBJ_HANDLE(z) = current->handle;
+				Z_OBJ_HT(z) = current->u.handlers;
+				zobj_collect_white(&z TSRMLS_CC);
+			}
 		} else {
 			GC_ZVAL_SET_ADDRESS(current->u.pz, NULL);
 			zval_collect_white(current->u.pz TSRMLS_CC);
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 854ac2b..674347b 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_hash.c 298914 2010-05-03 16:36:04Z felipe $ */
+/* $Id: zend_hash.c 303364 2010-09-14 14:26:37Z johannes $ */
 
 #include "zend.h"
 
@@ -63,6 +63,9 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int lin
 		case HT_CLEANING:
 			zend_output_debug_string(1, "%s(%d) : ht=%p is being cleaned", file, line, ht);
 			break;
+		default:
+			zend_output_debug_string(1, "%s(%d) : ht=%p is inconsistent", file, line, ht);
+			break;
 	}
 	zend_bailout();
 }
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index 166003b..64e9c19 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_hash.h 293155 2010-01-05 20:46:53Z sebastian $ */
+/* $Id: zend_hash.h 304083 2010-10-05 11:28:56Z dmitry $ */
 
 #ifndef ZEND_HASH_H
 #define ZEND_HASH_H
@@ -312,7 +312,7 @@ END_EXTERN_C()
 	}																		\
 	if (*tmp >= '0' && *tmp <= '9') { /* possibly a numeric index */		\
 		const char *end = key + length - 1;									\
-		long idx;															\
+		ulong idx;															\
 																			\
 		if ((*end != '\0') /* not a null terminated string */				\
 		 || (*tmp == '0' && length > 2) /* numbers with leading zeros */	\
@@ -328,11 +328,11 @@ END_EXTERN_C()
 		}																	\
 		if (tmp == end) {													\
 			if (*key == '-') {												\
-				idx = -idx;													\
-				if (idx > 0) { /* overflow */								\
+				if (idx-1 > LONG_MAX) { /* overflow */						\
 					break;													\
 				}															\
-			} else if (idx < 0) { /* overflow */							\
+				idx = (ulong)(-(long)idx);									\
+			} else if (idx > LONG_MAX) { /* overflow */						\
 				break;														\
 			}																\
 			return func;													\
diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c
index 25a9c52..1911329 100644
--- a/Zend/zend_ini_scanner.c
+++ b/Zend/zend_ini_scanner.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Tue May 25 22:53:58 2010 */
+/* Generated by re2c 0.13.5 on Sun Aug  1 12:07:43 2010 */
 #line 1 "Zend/zend_ini_scanner.l"
 /*
    +----------------------------------------------------------------------+
@@ -22,7 +22,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.c 299767 2010-05-26 02:18:17Z felipe $ */
+/* $Id: zend_ini_scanner.c 301758 2010-08-01 15:26:54Z felipe $ */
 
 #include <errno.h>
 #include "zend.h"
@@ -1826,7 +1826,7 @@ yy134:
 yyc_ST_RAW:
 	{
 		static const unsigned char yybm[] = {
-			160, 160, 160, 160, 160, 160, 160, 160, 
+			 32, 160, 160, 160, 160, 160, 160, 160, 
 			160, 224,   0, 160, 160,   0, 160, 160, 
 			160, 160, 160, 160, 160, 160, 160, 160, 
 			160, 160, 160, 160, 160, 160, 160, 160, 
@@ -1862,27 +1862,42 @@ yyc_ST_RAW:
 		YYDEBUG(135, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
-		if (yych <= '\r') {
-			if (yych <= '\t') {
-				if (yych >= '\t') goto yy139;
+		if (yych <= '\f') {
+			if (yych <= 0x08) {
+				if (yych >= 0x01) goto yy139;
 			} else {
-				if (yych <= '\n') goto yy140;
-				if (yych >= '\r') goto yy142;
+				if (yych <= '\t') goto yy141;
+				if (yych <= '\n') goto yy142;
+				goto yy139;
 			}
 		} else {
 			if (yych <= ' ') {
-				if (yych >= ' ') goto yy139;
+				if (yych <= '\r') goto yy144;
+				if (yych <= 0x1F) goto yy139;
+				goto yy141;
 			} else {
-				if (yych == ';') goto yy143;
+				if (yych == ';') goto yy145;
+				goto yy139;
 			}
 		}
 		YYDEBUG(137, *YYCURSOR);
 		++YYCURSOR;
-		yych = *YYCURSOR;
-		goto yy155;
-yy138:
 		YYDEBUG(138, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
+#line 567 "Zend/zend_ini_scanner.l"
+		{ /* End of option value (if EOF is reached before EOL */
+	BEGIN(INITIAL);
+	return END_OF_LINE;
+}
+#line 1893 "Zend/zend_ini_scanner.c"
+yy139:
+		YYDEBUG(139, *YYCURSOR);
+		++YYCURSOR;
+		yych = *YYCURSOR;
+		goto yy156;
+yy140:
+		YYDEBUG(140, *YYCURSOR);
+		yyleng = YYCURSOR - SCNG(yy_text);
 #line 445 "Zend/zend_ini_scanner.l"
 		{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
 	/* Eat leading and trailing double quotes */
@@ -1892,27 +1907,27 @@ yy138:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 1896 "Zend/zend_ini_scanner.c"
-yy139:
-		YYDEBUG(139, *YYCURSOR);
+#line 1911 "Zend/zend_ini_scanner.c"
+yy141:
+		YYDEBUG(141, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy151;
+			goto yy152;
 		}
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy150;
-			goto yy154;
+			if (yych == '\n') goto yy151;
+			goto yy156;
 		} else {
-			if (yych <= '\r') goto yy153;
-			if (yych == ';') goto yy145;
-			goto yy154;
+			if (yych <= '\r') goto yy154;
+			if (yych == ';') goto yy146;
+			goto yy156;
 		}
-yy140:
-		YYDEBUG(140, *YYCURSOR);
+yy142:
+		YYDEBUG(142, *YYCURSOR);
 		++YYCURSOR;
-yy141:
-		YYDEBUG(141, *YYCURSOR);
+yy143:
+		YYDEBUG(143, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 458 "Zend/zend_ini_scanner.l"
 		{ /* End of option value */
@@ -1920,41 +1935,33 @@ yy141:
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 1924 "Zend/zend_ini_scanner.c"
-yy142:
-		YYDEBUG(142, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy150;
-		goto yy141;
-yy143:
-		YYDEBUG(143, *YYCURSOR);
-		yyaccept = 1;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy146;
+#line 1939 "Zend/zend_ini_scanner.c"
+yy144:
 		YYDEBUG(144, *YYCURSOR);
-		yyleng = YYCURSOR - SCNG(yy_text);
-#line 567 "Zend/zend_ini_scanner.l"
-		{ /* End of option value (if EOF is reached before EOL */
-	BEGIN(INITIAL);
-	return END_OF_LINE;
-}
-#line 1942 "Zend/zend_ini_scanner.c"
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy151;
+		goto yy143;
 yy145:
 		YYDEBUG(145, *YYCURSOR);
+		yyaccept = 1;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy147;
+yy146:
+		YYDEBUG(146, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy146:
-		YYDEBUG(146, *YYCURSOR);
-		if (yybm[0+yych] & 32) {
-			goto yy145;
-		}
-		if (yych >= '\r') goto yy149;
 yy147:
 		YYDEBUG(147, *YYCURSOR);
-		++YYCURSOR;
+		if (yybm[0+yych] & 32) {
+			goto yy146;
+		}
+		if (yych >= '\r') goto yy150;
 yy148:
 		YYDEBUG(148, *YYCURSOR);
+		++YYCURSOR;
+yy149:
+		YYDEBUG(149, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 554 "Zend/zend_ini_scanner.l"
 		{ /* Comment */
@@ -1962,50 +1969,51 @@ yy148:
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 1966 "Zend/zend_ini_scanner.c"
-yy149:
-		YYDEBUG(149, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy147;
-		goto yy148;
+#line 1973 "Zend/zend_ini_scanner.c"
 yy150:
 		YYDEBUG(150, *YYCURSOR);
 		yych = *++YYCURSOR;
-		goto yy141;
+		if (yych == '\n') goto yy148;
+		goto yy149;
 yy151:
 		YYDEBUG(151, *YYCURSOR);
+		yych = *++YYCURSOR;
+		goto yy143;
+yy152:
+		YYDEBUG(152, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-		YYDEBUG(152, *YYCURSOR);
+		YYDEBUG(153, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy151;
+			goto yy152;
 		}
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy150;
-			goto yy154;
+			if (yych <= 0x00) goto yy140;
+			if (yych == '\n') goto yy151;
+			goto yy155;
 		} else {
-			if (yych <= '\r') goto yy153;
-			if (yych == ';') goto yy145;
-			goto yy154;
+			if (yych <= '\r') goto yy154;
+			if (yych == ';') goto yy146;
+			goto yy155;
 		}
-yy153:
-		YYDEBUG(153, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy150;
-		goto yy141;
 yy154:
 		YYDEBUG(154, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy151;
+		goto yy143;
+yy155:
+		YYDEBUG(155, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy155:
-		YYDEBUG(155, *YYCURSOR);
+yy156:
+		YYDEBUG(156, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy154;
+			goto yy155;
 		}
-		goto yy138;
+		goto yy140;
 	}
 /* *********************************** */
 yyc_ST_SECTION_RAW:
@@ -2044,44 +2052,44 @@ yyc_ST_SECTION_RAW:
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 		};
-		YYDEBUG(156, *YYCURSOR);
+		YYDEBUG(157, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
 		if (yych <= '\f') {
-			if (yych == '\n') goto yy160;
+			if (yych == '\n') goto yy161;
 		} else {
-			if (yych <= '\r') goto yy160;
-			if (yych == ']') goto yy162;
+			if (yych <= '\r') goto yy161;
+			if (yych == ']') goto yy163;
 		}
-		YYDEBUG(158, *YYCURSOR);
+		YYDEBUG(159, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy169;
-yy159:
-		YYDEBUG(159, *YYCURSOR);
+		goto yy170;
+yy160:
+		YYDEBUG(160, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 454 "Zend/zend_ini_scanner.l"
 		{ /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 2068 "Zend/zend_ini_scanner.c"
-yy160:
-		YYDEBUG(160, *YYCURSOR);
-		++YYCURSOR;
+#line 2076 "Zend/zend_ini_scanner.c"
+yy161:
 		YYDEBUG(161, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(162, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 2078 "Zend/zend_ini_scanner.c"
-yy162:
-		YYDEBUG(162, *YYCURSOR);
-		++YYCURSOR;
-		yych = *YYCURSOR;
-		goto yy165;
+#line 2086 "Zend/zend_ini_scanner.c"
 yy163:
 		YYDEBUG(163, *YYCURSOR);
+		++YYCURSOR;
+		yych = *YYCURSOR;
+		goto yy166;
+yy164:
+		YYDEBUG(164, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 374 "Zend/zend_ini_scanner.l"
 		{ /* End of section */
@@ -2089,40 +2097,40 @@ yy163:
 	SCNG(lineno)++;
 	return ']';
 }
-#line 2093 "Zend/zend_ini_scanner.c"
-yy164:
-		YYDEBUG(164, *YYCURSOR);
+#line 2101 "Zend/zend_ini_scanner.c"
+yy165:
+		YYDEBUG(165, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy165:
-		YYDEBUG(165, *YYCURSOR);
-		if (yybm[0+yych] & 64) {
-			goto yy164;
-		}
-		if (yych == '\n') goto yy166;
-		if (yych == '\r') goto yy167;
-		goto yy163;
 yy166:
 		YYDEBUG(166, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy163;
+		if (yybm[0+yych] & 64) {
+			goto yy165;
+		}
+		if (yych == '\n') goto yy167;
+		if (yych == '\r') goto yy168;
+		goto yy164;
 yy167:
 		YYDEBUG(167, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy166;
-		goto yy163;
+		goto yy164;
 yy168:
 		YYDEBUG(168, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy167;
+		goto yy164;
+yy169:
+		YYDEBUG(169, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy169:
-		YYDEBUG(169, *YYCURSOR);
+yy170:
+		YYDEBUG(170, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy168;
+			goto yy169;
 		}
-		goto yy159;
+		goto yy160;
 	}
 /* *********************************** */
 yyc_ST_SECTION_VALUE:
@@ -2161,203 +2169,203 @@ yyc_ST_SECTION_VALUE:
 			132, 132, 132, 132, 132, 132, 132, 132, 
 			132, 132, 132, 132, 132, 132, 132, 132, 
 		};
-		YYDEBUG(170, *YYCURSOR);
+		YYDEBUG(171, *YYCURSOR);
 		YYFILL(3);
 		yych = *YYCURSOR;
 		if (yych <= '-') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x08) goto yy172;
-					if (yych <= '\t') goto yy174;
-					goto yy175;
+					if (yych <= 0x08) goto yy173;
+					if (yych <= '\t') goto yy175;
+					goto yy176;
 				} else {
-					if (yych == '\r') goto yy175;
-					if (yych >= ' ') goto yy174;
+					if (yych == '\r') goto yy176;
+					if (yych >= ' ') goto yy175;
 				}
 			} else {
 				if (yych <= '$') {
-					if (yych == '"') goto yy177;
-					if (yych >= '$') goto yy179;
+					if (yych == '"') goto yy178;
+					if (yych >= '$') goto yy180;
 				} else {
-					if (yych == '\'') goto yy180;
-					if (yych >= '-') goto yy181;
+					if (yych == '\'') goto yy181;
+					if (yych >= '-') goto yy182;
 				}
 			}
 		} else {
 			if (yych <= 'Z') {
 				if (yych <= '9') {
-					if (yych <= '.') goto yy182;
-					if (yych >= '0') goto yy183;
+					if (yych <= '.') goto yy183;
+					if (yych >= '0') goto yy184;
 				} else {
-					if (yych == ';') goto yy175;
-					if (yych >= 'A') goto yy185;
+					if (yych == ';') goto yy176;
+					if (yych >= 'A') goto yy186;
 				}
 			} else {
 				if (yych <= '^') {
-					if (yych <= '[') goto yy172;
-					if (yych <= '\\') goto yy187;
-					if (yych <= ']') goto yy188;
+					if (yych <= '[') goto yy173;
+					if (yych <= '\\') goto yy188;
+					if (yych <= ']') goto yy189;
 				} else {
-					if (yych == '`') goto yy172;
-					if (yych <= 'z') goto yy185;
+					if (yych == '`') goto yy173;
+					if (yych <= 'z') goto yy186;
 				}
 			}
 		}
-yy172:
-		YYDEBUG(172, *YYCURSOR);
-		yyaccept = 0;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy195;
 yy173:
 		YYDEBUG(173, *YYCURSOR);
+		yyaccept = 0;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy196;
+yy174:
+		YYDEBUG(174, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 490 "Zend/zend_ini_scanner.l"
 		{ /* Get rest as section/offset value */
 	RETURN_TOKEN(TC_STRING, yytext, yyleng);
 }
-#line 2219 "Zend/zend_ini_scanner.c"
-yy174:
-		YYDEBUG(174, *YYCURSOR);
+#line 2227 "Zend/zend_ini_scanner.c"
+yy175:
+		YYDEBUG(175, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 0x1F) {
-			if (yych == '\t') goto yy221;
-			goto yy195;
+			if (yych == '\t') goto yy222;
+			goto yy196;
 		} else {
-			if (yych <= ' ') goto yy221;
-			if (yych == '"') goto yy223;
-			goto yy195;
+			if (yych <= ' ') goto yy222;
+			if (yych == '"') goto yy224;
+			goto yy196;
 		}
-yy175:
-		YYDEBUG(175, *YYCURSOR);
-		++YYCURSOR;
 yy176:
 		YYDEBUG(176, *YYCURSOR);
+		++YYCURSOR;
+yy177:
+		YYDEBUG(177, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 2242 "Zend/zend_ini_scanner.c"
-yy177:
-		YYDEBUG(177, *YYCURSOR);
-		++YYCURSOR;
+#line 2250 "Zend/zend_ini_scanner.c"
 yy178:
 		YYDEBUG(178, *YYCURSOR);
+		++YYCURSOR;
+yy179:
+		YYDEBUG(179, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 494 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string start */
 	yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
 	return '"';
 }
-#line 2254 "Zend/zend_ini_scanner.c"
-yy179:
-		YYDEBUG(179, *YYCURSOR);
+#line 2262 "Zend/zend_ini_scanner.c"
+yy180:
+		YYDEBUG(180, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy176;
-			if (yych <= '[') goto yy194;
-			goto yy199;
+			if (yych <= 0x00) goto yy177;
+			if (yych <= '[') goto yy195;
+			goto yy200;
 		} else {
-			if (yych == '{') goto yy219;
-			goto yy194;
+			if (yych == '{') goto yy220;
+			goto yy195;
 		}
-yy180:
-		YYDEBUG(180, *YYCURSOR);
+yy181:
+		YYDEBUG(181, *YYCURSOR);
 		yyaccept = 1;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy215;
+			goto yy216;
 		}
-		goto yy176;
-yy181:
-		YYDEBUG(181, *YYCURSOR);
-		yyaccept = 0;
-		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy195;
-		if (yych <= '9') goto yy213;
-		goto yy195;
+		goto yy177;
 yy182:
 		YYDEBUG(182, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy195;
-		if (yych <= '9') goto yy211;
-		goto yy195;
+		if (yych <= '/') goto yy196;
+		if (yych <= '9') goto yy214;
+		goto yy196;
 yy183:
 		YYDEBUG(183, *YYCURSOR);
+		yyaccept = 0;
+		yych = *(YYMARKER = ++YYCURSOR);
+		if (yych <= '/') goto yy196;
+		if (yych <= '9') goto yy212;
+		goto yy196;
+yy184:
+		YYDEBUG(184, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy184;
-				if (yych <= '\f') goto yy195;
+				if (yych == '\n') goto yy185;
+				if (yych <= '\f') goto yy196;
 			} else {
-				if (yych == '"') goto yy184;
-				if (yych <= '&') goto yy195;
+				if (yych == '"') goto yy185;
+				if (yych <= '&') goto yy196;
 			}
 		} else {
 			if (yych <= '9') {
-				if (yych == '.') goto yy207;
-				if (yych <= '/') goto yy195;
-				goto yy209;
+				if (yych == '.') goto yy208;
+				if (yych <= '/') goto yy196;
+				goto yy210;
 			} else {
 				if (yych <= ';') {
-					if (yych <= ':') goto yy195;
+					if (yych <= ':') goto yy196;
 				} else {
-					if (yych != ']') goto yy195;
+					if (yych != ']') goto yy196;
 				}
 			}
 		}
-yy184:
-		YYDEBUG(184, *YYCURSOR);
+yy185:
+		YYDEBUG(185, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 468 "Zend/zend_ini_scanner.l"
 		{ /* Get number option value as string */
 	RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
 }
-#line 2320 "Zend/zend_ini_scanner.c"
-yy185:
-		YYDEBUG(185, *YYCURSOR);
+#line 2328 "Zend/zend_ini_scanner.c"
+yy186:
+		YYDEBUG(186, *YYCURSOR);
 		yyaccept = 3;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy205;
+			goto yy206;
 		}
 		if (yych <= '"') {
 			if (yych <= '\f') {
-				if (yych != '\n') goto yy195;
+				if (yych != '\n') goto yy196;
 			} else {
-				if (yych <= '\r') goto yy186;
-				if (yych <= '!') goto yy195;
+				if (yych <= '\r') goto yy187;
+				if (yych <= '!') goto yy196;
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych != '\'') goto yy195;
+				if (yych != '\'') goto yy196;
 			} else {
-				if (yych <= ';') goto yy186;
-				if (yych != ']') goto yy195;
+				if (yych <= ';') goto yy187;
+				if (yych != ']') goto yy196;
 			}
 		}
-yy186:
-		YYDEBUG(186, *YYCURSOR);
+yy187:
+		YYDEBUG(187, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 464 "Zend/zend_ini_scanner.l"
 		{ /* Get constant option value */
 	RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
 }
-#line 2350 "Zend/zend_ini_scanner.c"
-yy187:
-		YYDEBUG(187, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy194;
+#line 2358 "Zend/zend_ini_scanner.c"
 yy188:
 		YYDEBUG(188, *YYCURSOR);
-		++YYCURSOR;
-		yych = *YYCURSOR;
-		goto yy191;
+		yych = *++YYCURSOR;
+		goto yy195;
 yy189:
 		YYDEBUG(189, *YYCURSOR);
+		++YYCURSOR;
+		yych = *YYCURSOR;
+		goto yy192;
+yy190:
+		YYDEBUG(190, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 374 "Zend/zend_ini_scanner.l"
 		{ /* End of section */
@@ -2365,317 +2373,317 @@ yy189:
 	SCNG(lineno)++;
 	return ']';
 }
-#line 2369 "Zend/zend_ini_scanner.c"
-yy190:
-		YYDEBUG(190, *YYCURSOR);
+#line 2377 "Zend/zend_ini_scanner.c"
+yy191:
+		YYDEBUG(191, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy191:
-		YYDEBUG(191, *YYCURSOR);
-		if (yybm[0+yych] & 2) {
-			goto yy190;
-		}
-		if (yych == '\n') goto yy192;
-		if (yych == '\r') goto yy193;
-		goto yy189;
 yy192:
 		YYDEBUG(192, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy189;
+		if (yybm[0+yych] & 2) {
+			goto yy191;
+		}
+		if (yych == '\n') goto yy193;
+		if (yych == '\r') goto yy194;
+		goto yy190;
 yy193:
 		YYDEBUG(193, *YYCURSOR);
 		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy192;
-		goto yy189;
+		goto yy190;
 yy194:
 		YYDEBUG(194, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy193;
+		goto yy190;
+yy195:
+		YYDEBUG(195, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy195:
-		YYDEBUG(195, *YYCURSOR);
-		if (yybm[0+yych] & 4) {
-			goto yy194;
-		}
-		if (yych == '$') goto yy197;
-		if (yych != '\\') goto yy173;
 yy196:
 		YYDEBUG(196, *YYCURSOR);
+		if (yybm[0+yych] & 4) {
+			goto yy195;
+		}
+		if (yych == '$') goto yy198;
+		if (yych != '\\') goto yy174;
+yy197:
+		YYDEBUG(197, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		goto yy194;
-yy197:
-		YYDEBUG(197, *YYCURSOR);
+		goto yy195;
+yy198:
+		YYDEBUG(198, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy198;
-			if (yych <= '[') goto yy194;
-			goto yy199;
+			if (yych <= 0x00) goto yy199;
+			if (yych <= '[') goto yy195;
+			goto yy200;
 		} else {
-			if (yych != '{') goto yy194;
+			if (yych != '{') goto yy195;
 		}
-yy198:
-		YYDEBUG(198, *YYCURSOR);
+yy199:
+		YYDEBUG(199, *YYCURSOR);
 		YYCURSOR = YYMARKER;
 		if (yyaccept <= 1) {
 			if (yyaccept <= 0) {
-				goto yy173;
+				goto yy174;
 			} else {
-				goto yy176;
+				goto yy177;
 			}
 		} else {
 			if (yyaccept <= 2) {
-				goto yy184;
+				goto yy185;
 			} else {
-				goto yy186;
+				goto yy187;
 			}
 		}
-yy199:
-		YYDEBUG(199, *YYCURSOR);
+yy200:
+		YYDEBUG(200, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy200;
+			goto yy201;
 		}
-		if (yych == '\\') goto yy202;
-		goto yy194;
-yy200:
-		YYDEBUG(200, *YYCURSOR);
+		if (yych == '\\') goto yy203;
+		goto yy195;
+yy201:
+		YYDEBUG(201, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(201, *YYCURSOR);
+		YYDEBUG(202, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy200;
+			goto yy201;
 		}
-		if (yych == '\\') goto yy204;
-		goto yy194;
-yy202:
-		YYDEBUG(202, *YYCURSOR);
+		if (yych == '\\') goto yy205;
+		goto yy195;
+yy203:
+		YYDEBUG(203, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(203, *YYCURSOR);
+		YYDEBUG(204, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy200;
+			goto yy201;
 		}
-		if (yych == '\\') goto yy202;
-		goto yy194;
-yy204:
-		YYDEBUG(204, *YYCURSOR);
+		if (yych == '\\') goto yy203;
+		goto yy195;
+yy205:
+		YYDEBUG(205, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy200;
+			goto yy201;
 		}
-		if (yych == '\\') goto yy202;
-		goto yy194;
-yy205:
-		YYDEBUG(205, *YYCURSOR);
+		if (yych == '\\') goto yy203;
+		goto yy195;
+yy206:
+		YYDEBUG(206, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(206, *YYCURSOR);
+		YYDEBUG(207, *YYCURSOR);
 		if (yybm[0+yych] & 32) {
-			goto yy205;
+			goto yy206;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy186;
-				if (yych <= '\f') goto yy194;
-				goto yy186;
+				if (yych == '\n') goto yy187;
+				if (yych <= '\f') goto yy195;
+				goto yy187;
 			} else {
-				if (yych == '"') goto yy186;
-				if (yych <= '#') goto yy194;
-				goto yy197;
+				if (yych == '"') goto yy187;
+				if (yych <= '#') goto yy195;
+				goto yy198;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy186;
-				if (yych <= ':') goto yy194;
-				goto yy186;
+				if (yych == '\'') goto yy187;
+				if (yych <= ':') goto yy195;
+				goto yy187;
 			} else {
-				if (yych <= '[') goto yy194;
-				if (yych <= '\\') goto yy196;
-				if (yych <= ']') goto yy186;
-				goto yy194;
+				if (yych <= '[') goto yy195;
+				if (yych <= '\\') goto yy197;
+				if (yych <= ']') goto yy187;
+				goto yy195;
 			}
 		}
-yy207:
-		YYDEBUG(207, *YYCURSOR);
+yy208:
+		YYDEBUG(208, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(208, *YYCURSOR);
+		YYDEBUG(209, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy207;
+			goto yy208;
 		}
 		if (yych <= '$') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy184;
-				if (yych <= '\f') goto yy194;
-				goto yy184;
+				if (yych == '\n') goto yy185;
+				if (yych <= '\f') goto yy195;
+				goto yy185;
 			} else {
-				if (yych == '"') goto yy184;
-				if (yych <= '#') goto yy194;
-				goto yy197;
+				if (yych == '"') goto yy185;
+				if (yych <= '#') goto yy195;
+				goto yy198;
 			}
 		} else {
 			if (yych <= ';') {
-				if (yych == '\'') goto yy184;
-				if (yych <= ':') goto yy194;
-				goto yy184;
+				if (yych == '\'') goto yy185;
+				if (yych <= ':') goto yy195;
+				goto yy185;
 			} else {
-				if (yych <= '[') goto yy194;
-				if (yych <= '\\') goto yy196;
-				if (yych <= ']') goto yy184;
-				goto yy194;
+				if (yych <= '[') goto yy195;
+				if (yych <= '\\') goto yy197;
+				if (yych <= ']') goto yy185;
+				goto yy195;
 			}
 		}
-yy209:
-		YYDEBUG(209, *YYCURSOR);
+yy210:
+		YYDEBUG(210, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(210, *YYCURSOR);
+		YYDEBUG(211, *YYCURSOR);
 		if (yych <= '\'') {
 			if (yych <= '!') {
 				if (yych <= '\n') {
-					if (yych <= '\t') goto yy194;
-					goto yy184;
+					if (yych <= '\t') goto yy195;
+					goto yy185;
 				} else {
-					if (yych == '\r') goto yy184;
-					goto yy194;
+					if (yych == '\r') goto yy185;
+					goto yy195;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= '"') goto yy184;
-					goto yy194;
+					if (yych <= '"') goto yy185;
+					goto yy195;
 				} else {
-					if (yych <= '$') goto yy197;
-					if (yych <= '&') goto yy194;
-					goto yy184;
+					if (yych <= '$') goto yy198;
+					if (yych <= '&') goto yy195;
+					goto yy185;
 				}
 			}
 		} else {
 			if (yych <= ':') {
 				if (yych <= '.') {
-					if (yych <= '-') goto yy194;
-					goto yy207;
+					if (yych <= '-') goto yy195;
+					goto yy208;
 				} else {
-					if (yych <= '/') goto yy194;
-					if (yych <= '9') goto yy209;
-					goto yy194;
+					if (yych <= '/') goto yy195;
+					if (yych <= '9') goto yy210;
+					goto yy195;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy184;
-					goto yy194;
+					if (yych <= ';') goto yy185;
+					goto yy195;
 				} else {
-					if (yych <= '\\') goto yy196;
-					if (yych <= ']') goto yy184;
-					goto yy194;
+					if (yych <= '\\') goto yy197;
+					if (yych <= ']') goto yy185;
+					goto yy195;
 				}
 			}
 		}
-yy211:
-		YYDEBUG(211, *YYCURSOR);
+yy212:
+		YYDEBUG(212, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(212, *YYCURSOR);
+		YYDEBUG(213, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy184;
-				if (yych <= '\f') goto yy194;
-				goto yy184;
+				if (yych == '\n') goto yy185;
+				if (yych <= '\f') goto yy195;
+				goto yy185;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy194;
-					goto yy184;
+					if (yych <= '!') goto yy195;
+					goto yy185;
 				} else {
-					if (yych == '$') goto yy197;
-					goto yy194;
+					if (yych == '$') goto yy198;
+					goto yy195;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy184;
-				if (yych <= '/') goto yy194;
-				if (yych <= '9') goto yy211;
-				goto yy194;
+				if (yych <= '\'') goto yy185;
+				if (yych <= '/') goto yy195;
+				if (yych <= '9') goto yy212;
+				goto yy195;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy184;
-					goto yy194;
+					if (yych <= ';') goto yy185;
+					goto yy195;
 				} else {
-					if (yych <= '\\') goto yy196;
-					if (yych <= ']') goto yy184;
-					goto yy194;
+					if (yych <= '\\') goto yy197;
+					if (yych <= ']') goto yy185;
+					goto yy195;
 				}
 			}
 		}
-yy213:
-		YYDEBUG(213, *YYCURSOR);
+yy214:
+		YYDEBUG(214, *YYCURSOR);
 		yyaccept = 2;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(214, *YYCURSOR);
+		YYDEBUG(215, *YYCURSOR);
 		if (yych <= '&') {
 			if (yych <= '\r') {
-				if (yych == '\n') goto yy184;
-				if (yych <= '\f') goto yy194;
-				goto yy184;
+				if (yych == '\n') goto yy185;
+				if (yych <= '\f') goto yy195;
+				goto yy185;
 			} else {
 				if (yych <= '"') {
-					if (yych <= '!') goto yy194;
-					goto yy184;
+					if (yych <= '!') goto yy195;
+					goto yy185;
 				} else {
-					if (yych == '$') goto yy197;
-					goto yy194;
+					if (yych == '$') goto yy198;
+					goto yy195;
 				}
 			}
 		} else {
 			if (yych <= ':') {
-				if (yych <= '\'') goto yy184;
-				if (yych <= '/') goto yy194;
-				if (yych <= '9') goto yy213;
-				goto yy194;
+				if (yych <= '\'') goto yy185;
+				if (yych <= '/') goto yy195;
+				if (yych <= '9') goto yy214;
+				goto yy195;
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy184;
-					goto yy194;
+					if (yych <= ';') goto yy185;
+					goto yy195;
 				} else {
-					if (yych <= '\\') goto yy196;
-					if (yych <= ']') goto yy184;
-					goto yy194;
+					if (yych <= '\\') goto yy197;
+					if (yych <= ']') goto yy185;
+					goto yy195;
 				}
 			}
 		}
-yy215:
-		YYDEBUG(215, *YYCURSOR);
+yy216:
+		YYDEBUG(216, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(216, *YYCURSOR);
+		YYDEBUG(217, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy215;
+			goto yy216;
 		}
-		YYDEBUG(217, *YYCURSOR);
-		++YYCURSOR;
 		YYDEBUG(218, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(219, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 365 "Zend/zend_ini_scanner.l"
 		{ /* Raw string */
@@ -2686,65 +2694,65 @@ yy215:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 2690 "Zend/zend_ini_scanner.c"
-yy219:
-		YYDEBUG(219, *YYCURSOR);
-		++YYCURSOR;
+#line 2698 "Zend/zend_ini_scanner.c"
+yy220:
 		YYDEBUG(220, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(221, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 2701 "Zend/zend_ini_scanner.c"
-yy221:
-		YYDEBUG(221, *YYCURSOR);
+#line 2709 "Zend/zend_ini_scanner.c"
+yy222:
+		YYDEBUG(222, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(222, *YYCURSOR);
+		YYDEBUG(223, *YYCURSOR);
 		if (yych <= '"') {
 			if (yych <= '\f') {
-				if (yych <= 0x08) goto yy194;
-				if (yych <= '\t') goto yy221;
-				if (yych <= '\n') goto yy173;
-				goto yy194;
+				if (yych <= 0x08) goto yy195;
+				if (yych <= '\t') goto yy222;
+				if (yych <= '\n') goto yy174;
+				goto yy195;
 			} else {
 				if (yych <= 0x1F) {
-					if (yych <= '\r') goto yy173;
-					goto yy194;
+					if (yych <= '\r') goto yy174;
+					goto yy195;
 				} else {
-					if (yych <= ' ') goto yy221;
-					if (yych <= '!') goto yy194;
+					if (yych <= ' ') goto yy222;
+					if (yych <= '!') goto yy195;
 				}
 			}
 		} else {
 			if (yych <= ':') {
 				if (yych <= '$') {
-					if (yych <= '#') goto yy194;
-					goto yy197;
+					if (yych <= '#') goto yy195;
+					goto yy198;
 				} else {
-					if (yych == '\'') goto yy173;
-					goto yy194;
+					if (yych == '\'') goto yy174;
+					goto yy195;
 				}
 			} else {
 				if (yych <= '[') {
-					if (yych <= ';') goto yy173;
-					goto yy194;
+					if (yych <= ';') goto yy174;
+					goto yy195;
 				} else {
-					if (yych <= '\\') goto yy196;
-					if (yych <= ']') goto yy173;
-					goto yy194;
+					if (yych <= '\\') goto yy197;
+					if (yych <= ']') goto yy174;
+					goto yy195;
 				}
 			}
 		}
-yy223:
-		YYDEBUG(223, *YYCURSOR);
+yy224:
+		YYDEBUG(224, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy178;
+		goto yy179;
 	}
 /* *********************************** */
 yyc_ST_VALUE:
@@ -2783,27 +2791,27 @@ yyc_ST_VALUE:
 			162, 162, 162, 162, 162, 162, 162, 162, 
 			162, 162, 162, 162, 162, 162, 162, 162, 
 		};
-		YYDEBUG(224, *YYCURSOR);
+		YYDEBUG(225, *YYCURSOR);
 		YYFILL(6);
 		yych = *YYCURSOR;
 		YYDEBUG(-1, yych);
 		switch (yych) {
-		case 0x00:	goto yy226;
+		case 0x00:	goto yy227;
 		case '\t':
-		case ' ':	goto yy230;
-		case '\n':	goto yy232;
-		case '\r':	goto yy234;
+		case ' ':	goto yy231;
+		case '\n':	goto yy233;
+		case '\r':	goto yy235;
 		case '!':
 		case '&':
 		case '(':
 		case ')':
 		case '|':
-		case '~':	goto yy235;
-		case '"':	goto yy237;
-		case '$':	goto yy239;
-		case '\'':	goto yy240;
-		case '-':	goto yy241;
-		case '.':	goto yy242;
+		case '~':	goto yy236;
+		case '"':	goto yy238;
+		case '$':	goto yy240;
+		case '\'':	goto yy241;
+		case '-':	goto yy242;
+		case '.':	goto yy243;
 		case '0':
 		case '1':
 		case '2':
@@ -2813,9 +2821,9 @@ yyc_ST_VALUE:
 		case '6':
 		case '7':
 		case '8':
-		case '9':	goto yy243;
-		case ';':	goto yy245;
-		case '=':	goto yy246;
+		case '9':	goto yy244;
+		case ';':	goto yy246;
+		case '=':	goto yy247;
 		case 'A':
 		case 'B':
 		case 'C':
@@ -2858,62 +2866,62 @@ yyc_ST_VALUE:
 		case 'v':
 		case 'w':
 		case 'x':
-		case 'z':	goto yy248;
+		case 'z':	goto yy249;
 		case 'F':
-		case 'f':	goto yy250;
+		case 'f':	goto yy251;
 		case 'N':
-		case 'n':	goto yy251;
+		case 'n':	goto yy252;
 		case 'O':
-		case 'o':	goto yy252;
+		case 'o':	goto yy253;
 		case 'T':
-		case 't':	goto yy253;
+		case 't':	goto yy254;
 		case 'Y':
-		case 'y':	goto yy254;
-		default:	goto yy228;
+		case 'y':	goto yy255;
+		default:	goto yy229;
 		}
-yy226:
-		YYDEBUG(226, *YYCURSOR);
-		++YYCURSOR;
 yy227:
 		YYDEBUG(227, *YYCURSOR);
+		++YYCURSOR;
+yy228:
+		YYDEBUG(228, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 567 "Zend/zend_ini_scanner.l"
 		{ /* End of option value (if EOF is reached before EOL */
 	BEGIN(INITIAL);
 	return END_OF_LINE;
 }
-#line 2886 "Zend/zend_ini_scanner.c"
-yy228:
-		YYDEBUG(228, *YYCURSOR);
-		yyaccept = 0;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy256;
+#line 2894 "Zend/zend_ini_scanner.c"
 yy229:
 		YYDEBUG(229, *YYCURSOR);
+		yyaccept = 0;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy257;
+yy230:
+		YYDEBUG(230, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 486 "Zend/zend_ini_scanner.l"
 		{ /* Get everything else as option/offset value */
 	RETURN_TOKEN(TC_STRING, yytext, yyleng);
 }
-#line 2899 "Zend/zend_ini_scanner.c"
-yy230:
-		YYDEBUG(230, *YYCURSOR);
-		yyaccept = 1;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy306;
+#line 2907 "Zend/zend_ini_scanner.c"
 yy231:
 		YYDEBUG(231, *YYCURSOR);
+		yyaccept = 1;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy307;
+yy232:
+		YYDEBUG(232, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 540 "Zend/zend_ini_scanner.l"
 		{
 	RETURN_TOKEN(TC_WHITESPACE, yytext, yyleng);
 }
-#line 2912 "Zend/zend_ini_scanner.c"
-yy232:
-		YYDEBUG(232, *YYCURSOR);
-		++YYCURSOR;
+#line 2920 "Zend/zend_ini_scanner.c"
 yy233:
 		YYDEBUG(233, *YYCURSOR);
+		++YYCURSOR;
+yy234:
+		YYDEBUG(234, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 458 "Zend/zend_ini_scanner.l"
 		{ /* End of option value */
@@ -2921,126 +2929,126 @@ yy233:
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 2925 "Zend/zend_ini_scanner.c"
-yy234:
-		YYDEBUG(234, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy304;
-		goto yy233;
+#line 2933 "Zend/zend_ini_scanner.c"
 yy235:
 		YYDEBUG(235, *YYCURSOR);
-		++YYCURSOR;
-		yych = *YYCURSOR;
-		goto yy303;
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy305;
+		goto yy234;
 yy236:
 		YYDEBUG(236, *YYCURSOR);
+		++YYCURSOR;
+		yych = *YYCURSOR;
+		goto yy304;
+yy237:
+		YYDEBUG(237, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 476 "Zend/zend_ini_scanner.l"
 		{ /* Boolean operators */
 	return yytext[0];
 }
-#line 2943 "Zend/zend_ini_scanner.c"
-yy237:
-		YYDEBUG(237, *YYCURSOR);
-		++YYCURSOR;
+#line 2951 "Zend/zend_ini_scanner.c"
 yy238:
 		YYDEBUG(238, *YYCURSOR);
+		++YYCURSOR;
+yy239:
+		YYDEBUG(239, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 494 "Zend/zend_ini_scanner.l"
 		{ /* Double quoted '"' string start */
 	yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC);
 	return '"';
 }
-#line 2955 "Zend/zend_ini_scanner.c"
-yy239:
-		YYDEBUG(239, *YYCURSOR);
+#line 2963 "Zend/zend_ini_scanner.c"
+yy240:
+		YYDEBUG(240, *YYCURSOR);
 		yych = *++YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy227;
-			if (yych <= '[') goto yy255;
-			goto yy262;
+			if (yych <= 0x00) goto yy228;
+			if (yych <= '[') goto yy256;
+			goto yy263;
 		} else {
-			if (yych == '{') goto yy300;
-			goto yy255;
+			if (yych == '{') goto yy301;
+			goto yy256;
 		}
-yy240:
-		YYDEBUG(240, *YYCURSOR);
+yy241:
+		YYDEBUG(241, *YYCURSOR);
 		yyaccept = 2;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy296;
+			goto yy297;
 		}
-		goto yy227;
-yy241:
-		YYDEBUG(241, *YYCURSOR);
-		yyaccept = 0;
-		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy256;
-		if (yych <= '9') goto yy294;
-		goto yy256;
+		goto yy228;
 yy242:
 		YYDEBUG(242, *YYCURSOR);
 		yyaccept = 0;
 		yych = *(YYMARKER = ++YYCURSOR);
-		if (yych <= '/') goto yy256;
-		if (yych <= '9') goto yy292;
-		goto yy256;
+		if (yych <= '/') goto yy257;
+		if (yych <= '9') goto yy295;
+		goto yy257;
 yy243:
 		YYDEBUG(243, *YYCURSOR);
+		yyaccept = 0;
+		yych = *(YYMARKER = ++YYCURSOR);
+		if (yych <= '/') goto yy257;
+		if (yych <= '9') goto yy293;
+		goto yy257;
+yy244:
+		YYDEBUG(244, *YYCURSOR);
 		yyaccept = 3;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '.') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych >= 0x01) goto yy256;
+					if (yych >= 0x01) goto yy257;
 				} else {
-					if (yych <= '\n') goto yy244;
-					if (yych <= '\f') goto yy256;
+					if (yych <= '\n') goto yy245;
+					if (yych <= '\f') goto yy257;
 				}
 			} else {
 				if (yych <= '%') {
-					if (yych <= 0x1F) goto yy256;
-					if (yych >= '#') goto yy256;
+					if (yych <= 0x1F) goto yy257;
+					if (yych >= '#') goto yy257;
 				} else {
-					if (yych <= ')') goto yy244;
-					if (yych <= '-') goto yy256;
-					goto yy288;
+					if (yych <= ')') goto yy245;
+					if (yych <= '-') goto yy257;
+					goto yy289;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy256;
-					goto yy290;
+					if (yych <= '/') goto yy257;
+					goto yy291;
 				} else {
-					if (yych != ';') goto yy256;
+					if (yych != ';') goto yy257;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy244;
-					if (yych <= '{') goto yy256;
+					if (yych <= '=') goto yy245;
+					if (yych <= '{') goto yy257;
 				} else {
-					if (yych != '~') goto yy256;
+					if (yych != '~') goto yy257;
 				}
 			}
 		}
-yy244:
-		YYDEBUG(244, *YYCURSOR);
+yy245:
+		YYDEBUG(245, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 468 "Zend/zend_ini_scanner.l"
 		{ /* Get number option value as string */
 	RETURN_TOKEN(TC_NUMBER, yytext, yyleng);
 }
-#line 3035 "Zend/zend_ini_scanner.c"
-yy245:
-		YYDEBUG(245, *YYCURSOR);
-		yyaccept = 2;
-		yych = *(YYMARKER = ++YYCURSOR);
-		goto yy284;
+#line 3043 "Zend/zend_ini_scanner.c"
 yy246:
 		YYDEBUG(246, *YYCURSOR);
-		++YYCURSOR;
+		yyaccept = 2;
+		yych = *(YYMARKER = ++YYCURSOR);
+		goto yy285;
+yy247:
 		YYDEBUG(247, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(248, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 480 "Zend/zend_ini_scanner.l"
 		{ /* Make = used in option value to trigger error */
@@ -3048,1121 +3056,1121 @@ yy246:
 	BEGIN(INITIAL);
 	return END_OF_LINE;
 }
-#line 3052 "Zend/zend_ini_scanner.c"
-yy248:
-		YYDEBUG(248, *YYCURSOR);
+#line 3060 "Zend/zend_ini_scanner.c"
+yy249:
+		YYDEBUG(249, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy257;
+			goto yy258;
 		}
 		if (yych <= ')') {
 			if (yych <= '\f') {
-				if (yych <= 0x00) goto yy249;
-				if (yych <= 0x08) goto yy256;
-				if (yych >= '\v') goto yy256;
+				if (yych <= 0x00) goto yy250;
+				if (yych <= 0x08) goto yy257;
+				if (yych >= '\v') goto yy257;
 			} else {
 				if (yych <= 0x1F) {
-					if (yych >= 0x0E) goto yy256;
+					if (yych >= 0x0E) goto yy257;
 				} else {
-					if (yych <= '"') goto yy249;
-					if (yych <= '%') goto yy256;
+					if (yych <= '"') goto yy250;
+					if (yych <= '%') goto yy257;
 				}
 			}
 		} else {
 			if (yych <= '=') {
-				if (yych == ';') goto yy249;
-				if (yych <= '<') goto yy256;
+				if (yych == ';') goto yy250;
+				if (yych <= '<') goto yy257;
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy256;
+					if (yych <= '{') goto yy257;
 				} else {
-					if (yych != '~') goto yy256;
+					if (yych != '~') goto yy257;
 				}
 			}
 		}
-yy249:
-		YYDEBUG(249, *YYCURSOR);
+yy250:
+		YYDEBUG(250, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 464 "Zend/zend_ini_scanner.l"
 		{ /* Get constant option value */
 	RETURN_TOKEN(TC_CONSTANT, yytext, yyleng);
 }
-#line 3092 "Zend/zend_ini_scanner.c"
-yy250:
-		YYDEBUG(250, *YYCURSOR);
+#line 3100 "Zend/zend_ini_scanner.c"
+yy251:
+		YYDEBUG(251, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '<') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '/') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					goto yy256;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					goto yy257;
 				} else {
-					if (yych <= '9') goto yy257;
-					if (yych == ';') goto yy249;
-					goto yy256;
+					if (yych <= '9') goto yy258;
+					if (yych == ';') goto yy250;
+					goto yy257;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'A') {
-					if (yych <= '=') goto yy249;
-					if (yych <= '@') goto yy256;
-					goto yy280;
+					if (yych <= '=') goto yy250;
+					if (yych <= '@') goto yy257;
+					goto yy281;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych <= 'a') goto yy280;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych <= 'a') goto yy281;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy251:
-		YYDEBUG(251, *YYCURSOR);
+yy252:
+		YYDEBUG(252, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 'N') {
 			if (yych <= '%') {
 				if (yych <= '\f') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					if (yych <= '\n') goto yy249;
-					goto yy256;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					if (yych <= '\n') goto yy250;
+					goto yy257;
 				} else {
-					if (yych <= '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					if (yych <= '"') goto yy249;
-					goto yy256;
+					if (yych <= '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					if (yych <= '"') goto yy250;
+					goto yy257;
 				}
 			} else {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					if (yych <= '9') goto yy257;
-					goto yy256;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					if (yych <= '9') goto yy258;
+					goto yy257;
 				} else {
 					if (yych <= '<') {
-						if (yych <= ';') goto yy249;
-						goto yy256;
-					} else {
-						if (yych <= '=') goto yy249;
-						if (yych <= '@') goto yy256;
+						if (yych <= ';') goto yy250;
 						goto yy257;
+					} else {
+						if (yych <= '=') goto yy250;
+						if (yych <= '@') goto yy257;
+						goto yy258;
 					}
 				}
 			}
 		} else {
 			if (yych <= 'n') {
 				if (yych <= 'Z') {
-					if (yych <= 'O') goto yy276;
-					if (yych == 'U') goto yy277;
-					goto yy257;
+					if (yych <= 'O') goto yy277;
+					if (yych == 'U') goto yy278;
+					goto yy258;
 				} else {
-					if (yych == '_') goto yy257;
-					if (yych <= '`') goto yy256;
-					goto yy257;
+					if (yych == '_') goto yy258;
+					if (yych <= '`') goto yy257;
+					goto yy258;
 				}
 			} else {
 				if (yych <= 'z') {
-					if (yych <= 'o') goto yy276;
-					if (yych == 'u') goto yy277;
-					goto yy257;
+					if (yych <= 'o') goto yy277;
+					if (yych == 'u') goto yy278;
+					goto yy258;
 				} else {
 					if (yych <= '|') {
-						if (yych <= '{') goto yy256;
-						goto yy249;
+						if (yych <= '{') goto yy257;
+						goto yy250;
 					} else {
-						if (yych == '~') goto yy249;
-						goto yy256;
+						if (yych == '~') goto yy250;
+						goto yy257;
 					}
 				}
 			}
 		}
-yy252:
-		YYDEBUG(252, *YYCURSOR);
+yy253:
+		YYDEBUG(253, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= 'E') {
 			if (yych <= '%') {
 				if (yych <= '\f') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					if (yych <= '\n') goto yy249;
-					goto yy256;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					if (yych <= '\n') goto yy250;
+					goto yy257;
 				} else {
-					if (yych <= '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					if (yych <= '"') goto yy249;
-					goto yy256;
+					if (yych <= '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					if (yych <= '"') goto yy250;
+					goto yy257;
 				}
 			} else {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					if (yych <= '9') goto yy257;
-					goto yy256;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					if (yych <= '9') goto yy258;
+					goto yy257;
 				} else {
 					if (yych <= '<') {
-						if (yych <= ';') goto yy249;
-						goto yy256;
-					} else {
-						if (yych <= '=') goto yy249;
-						if (yych <= '@') goto yy256;
+						if (yych <= ';') goto yy250;
 						goto yy257;
+					} else {
+						if (yych <= '=') goto yy250;
+						if (yych <= '@') goto yy257;
+						goto yy258;
 					}
 				}
 			}
 		} else {
 			if (yych <= 'e') {
 				if (yych <= 'Z') {
-					if (yych <= 'F') goto yy271;
-					if (yych == 'N') goto yy265;
-					goto yy257;
+					if (yych <= 'F') goto yy272;
+					if (yych == 'N') goto yy266;
+					goto yy258;
 				} else {
-					if (yych == '_') goto yy257;
-					if (yych <= '`') goto yy256;
-					goto yy257;
+					if (yych == '_') goto yy258;
+					if (yych <= '`') goto yy257;
+					goto yy258;
 				}
 			} else {
 				if (yych <= 'z') {
-					if (yych <= 'f') goto yy271;
-					if (yych == 'n') goto yy265;
-					goto yy257;
+					if (yych <= 'f') goto yy272;
+					if (yych == 'n') goto yy266;
+					goto yy258;
 				} else {
 					if (yych <= '|') {
-						if (yych <= '{') goto yy256;
-						goto yy249;
+						if (yych <= '{') goto yy257;
+						goto yy250;
 					} else {
-						if (yych == '~') goto yy249;
-						goto yy256;
+						if (yych == '~') goto yy250;
+						goto yy257;
 					}
 				}
 			}
 		}
-yy253:
-		YYDEBUG(253, *YYCURSOR);
+yy254:
+		YYDEBUG(254, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'R') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'Q') goto yy257;
-					goto yy269;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'Q') goto yy258;
+					goto yy270;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'r') goto yy269;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'r') goto yy270;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy254:
-		YYDEBUG(254, *YYCURSOR);
+yy255:
+		YYDEBUG(255, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'D') goto yy257;
-					goto yy259;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'D') goto yy258;
+					goto yy260;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy259;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'e') goto yy260;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy255:
-		YYDEBUG(255, *YYCURSOR);
+yy256:
+		YYDEBUG(256, *YYCURSOR);
 		yyaccept = 0;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy256:
-		YYDEBUG(256, *YYCURSOR);
-		if (yybm[0+yych] & 2) {
-			goto yy255;
-		}
-		if (yych == '$') goto yy260;
-		goto yy229;
 yy257:
 		YYDEBUG(257, *YYCURSOR);
+		if (yybm[0+yych] & 2) {
+			goto yy256;
+		}
+		if (yych == '$') goto yy261;
+		goto yy230;
+yy258:
+		YYDEBUG(258, *YYCURSOR);
 		yyaccept = 4;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(258, *YYCURSOR);
+		YYDEBUG(259, *YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy257;
+			goto yy258;
 		}
 		if (yych <= '%') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy249;
-					goto yy255;
+					if (yych <= 0x00) goto yy250;
+					goto yy256;
 				} else {
-					if (yych <= '\n') goto yy249;
-					if (yych <= '\f') goto yy255;
-					goto yy249;
+					if (yych <= '\n') goto yy250;
+					if (yych <= '\f') goto yy256;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '"') {
-					if (yych <= 0x1F) goto yy255;
-					goto yy249;
+					if (yych <= 0x1F) goto yy256;
+					goto yy250;
 				} else {
-					if (yych == '$') goto yy260;
-					goto yy255;
+					if (yych == '$') goto yy261;
+					goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy249;
-					goto yy255;
+					if (yych <= ')') goto yy250;
+					goto yy256;
 				} else {
-					if (yych == '<') goto yy255;
-					goto yy249;
+					if (yych == '<') goto yy256;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy255;
-					goto yy249;
+					if (yych <= '{') goto yy256;
+					goto yy250;
 				} else {
-					if (yych == '~') goto yy249;
-					goto yy255;
+					if (yych == '~') goto yy250;
+					goto yy256;
 				}
 			}
 		}
-yy259:
-		YYDEBUG(259, *YYCURSOR);
+yy260:
+		YYDEBUG(260, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'S') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'R') goto yy257;
-					goto yy265;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'R') goto yy258;
+					goto yy266;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 's') goto yy265;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 's') goto yy266;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy260:
-		YYDEBUG(260, *YYCURSOR);
+yy261:
+		YYDEBUG(261, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yych <= '\\') {
-			if (yych <= 0x00) goto yy261;
-			if (yych <= '[') goto yy255;
-			goto yy262;
+			if (yych <= 0x00) goto yy262;
+			if (yych <= '[') goto yy256;
+			goto yy263;
 		} else {
-			if (yych != '{') goto yy255;
+			if (yych != '{') goto yy256;
 		}
-yy261:
-		YYDEBUG(261, *YYCURSOR);
+yy262:
+		YYDEBUG(262, *YYCURSOR);
 		YYCURSOR = YYMARKER;
 		if (yyaccept <= 3) {
 			if (yyaccept <= 1) {
 				if (yyaccept <= 0) {
-					goto yy229;
+					goto yy230;
 				} else {
-					goto yy231;
+					goto yy232;
 				}
 			} else {
 				if (yyaccept <= 2) {
-					goto yy227;
+					goto yy228;
 				} else {
-					goto yy244;
+					goto yy245;
 				}
 			}
 		} else {
 			if (yyaccept <= 5) {
 				if (yyaccept <= 4) {
-					goto yy249;
+					goto yy250;
 				} else {
-					goto yy266;
+					goto yy267;
 				}
 			} else {
-				goto yy273;
+				goto yy274;
 			}
 		}
-yy262:
-		YYDEBUG(262, *YYCURSOR);
+yy263:
+		YYDEBUG(263, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
 		if (yybm[0+yych] & 8) {
-			goto yy263;
+			goto yy264;
 		}
-		goto yy255;
-yy263:
-		YYDEBUG(263, *YYCURSOR);
+		goto yy256;
+yy264:
+		YYDEBUG(264, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(264, *YYCURSOR);
+		YYDEBUG(265, *YYCURSOR);
 		if (yybm[0+yych] & 8) {
-			goto yy263;
+			goto yy264;
 		}
-		if (yych <= 0x00) goto yy229;
-		if (yych == '\\') goto yy262;
-		goto yy255;
-yy265:
-		YYDEBUG(265, *YYCURSOR);
+		if (yych <= 0x00) goto yy230;
+		if (yych == '\\') goto yy263;
+		goto yy256;
+yy266:
+		YYDEBUG(266, *YYCURSOR);
 		yyaccept = 5;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy267;
+			goto yy268;
 		}
 		if (yych <= ';') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy266;
-					if (yych <= '\t') goto yy256;
+					if (yych <= 0x00) goto yy267;
+					if (yych <= '\t') goto yy257;
 				} else {
-					if (yych != '\r') goto yy256;
+					if (yych != '\r') goto yy257;
 				}
 			} else {
 				if (yych <= ')') {
-					if (yych <= '"') goto yy266;
-					if (yych <= '%') goto yy256;
+					if (yych <= '"') goto yy267;
+					if (yych <= '%') goto yy257;
 				} else {
-					if (yych <= '/') goto yy256;
-					if (yych <= '9') goto yy257;
-					if (yych <= ':') goto yy256;
+					if (yych <= '/') goto yy257;
+					if (yych <= '9') goto yy258;
+					if (yych <= ':') goto yy257;
 				}
 			}
 		} else {
 			if (yych <= '_') {
 				if (yych <= '@') {
-					if (yych != '=') goto yy256;
+					if (yych != '=') goto yy257;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych <= '^') goto yy256;
-					goto yy257;
+					if (yych <= 'Z') goto yy258;
+					if (yych <= '^') goto yy257;
+					goto yy258;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych <= '`') goto yy256;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych <= '`') goto yy257;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych >= 0x7F) goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych >= 0x7F) goto yy257;
 				}
 			}
 		}
-yy266:
-		YYDEBUG(266, *YYCURSOR);
+yy267:
+		YYDEBUG(267, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 418 "Zend/zend_ini_scanner.l"
 		{ /* TRUE value (when used outside option value/offset this causes parse error!) */
 	RETURN_TOKEN(BOOL_TRUE, "1", 1);
 }
-#line 3588 "Zend/zend_ini_scanner.c"
-yy267:
-		YYDEBUG(267, *YYCURSOR);
+#line 3596 "Zend/zend_ini_scanner.c"
+yy268:
+		YYDEBUG(268, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(268, *YYCURSOR);
+		YYDEBUG(269, *YYCURSOR);
 		if (yybm[0+yych] & 16) {
-			goto yy267;
+			goto yy268;
 		}
-		goto yy266;
-yy269:
-		YYDEBUG(269, *YYCURSOR);
+		goto yy267;
+yy270:
+		YYDEBUG(270, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'U') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'T') goto yy257;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'T') goto yy258;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'u') goto yy270;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'u') goto yy271;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy270:
-		YYDEBUG(270, *YYCURSOR);
+yy271:
+		YYDEBUG(271, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'D') goto yy257;
-					goto yy265;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'D') goto yy258;
+					goto yy266;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy265;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'e') goto yy266;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy271:
-		YYDEBUG(271, *YYCURSOR);
+yy272:
+		YYDEBUG(272, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'F') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'E') goto yy257;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'E') goto yy258;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'f') goto yy272;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'f') goto yy273;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy272:
-		YYDEBUG(272, *YYCURSOR);
+yy273:
+		YYDEBUG(273, *YYCURSOR);
 		yyaccept = 6;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yybm[0+yych] & 4) {
-			goto yy257;
+			goto yy258;
 		}
 		if (yych <= '%') {
 			if (yych <= '\f') {
 				if (yych <= 0x08) {
-					if (yych >= 0x01) goto yy256;
+					if (yych >= 0x01) goto yy257;
 				} else {
-					if (yych <= '\t') goto yy274;
-					if (yych >= '\v') goto yy256;
+					if (yych <= '\t') goto yy275;
+					if (yych >= '\v') goto yy257;
 				}
 			} else {
 				if (yych <= 0x1F) {
-					if (yych >= 0x0E) goto yy256;
+					if (yych >= 0x0E) goto yy257;
 				} else {
-					if (yych <= ' ') goto yy274;
-					if (yych >= '#') goto yy256;
+					if (yych <= ' ') goto yy275;
+					if (yych >= '#') goto yy257;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych >= '*') goto yy256;
+					if (yych >= '*') goto yy257;
 				} else {
-					if (yych == '<') goto yy256;
+					if (yych == '<') goto yy257;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy256;
+					if (yych <= '{') goto yy257;
 				} else {
-					if (yych != '~') goto yy256;
+					if (yych != '~') goto yy257;
 				}
 			}
 		}
-yy273:
-		YYDEBUG(273, *YYCURSOR);
+yy274:
+		YYDEBUG(274, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 422 "Zend/zend_ini_scanner.l"
 		{ /* FALSE value (when used outside option value/offset this causes parse error!)*/
 	RETURN_TOKEN(BOOL_FALSE, "", 0);
 }
-#line 3792 "Zend/zend_ini_scanner.c"
-yy274:
-		YYDEBUG(274, *YYCURSOR);
+#line 3800 "Zend/zend_ini_scanner.c"
+yy275:
+		YYDEBUG(275, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(275, *YYCURSOR);
-		if (yych == '\t') goto yy274;
-		if (yych == ' ') goto yy274;
-		goto yy273;
-yy276:
 		YYDEBUG(276, *YYCURSOR);
+		if (yych == '\t') goto yy275;
+		if (yych == ' ') goto yy275;
+		goto yy274;
+yy277:
+		YYDEBUG(277, *YYCURSOR);
 		yyaccept = 6;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '<') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy273;
-					if (yych <= 0x08) goto yy256;
-					if (yych <= '\t') goto yy274;
-					goto yy273;
-				} else {
-					if (yych == '\r') goto yy273;
-					if (yych <= 0x1F) goto yy256;
+					if (yych <= 0x00) goto yy274;
+					if (yych <= 0x08) goto yy257;
+					if (yych <= '\t') goto yy275;
 					goto yy274;
+				} else {
+					if (yych == '\r') goto yy274;
+					if (yych <= 0x1F) goto yy257;
+					goto yy275;
 				}
 			} else {
 				if (yych <= '/') {
-					if (yych <= '"') goto yy273;
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy273;
-					goto yy256;
+					if (yych <= '"') goto yy274;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy274;
+					goto yy257;
 				} else {
-					if (yych <= '9') goto yy257;
-					if (yych == ';') goto yy273;
-					goto yy256;
+					if (yych <= '9') goto yy258;
+					if (yych == ';') goto yy274;
+					goto yy257;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'N') {
-					if (yych <= '=') goto yy273;
-					if (yych <= '@') goto yy256;
-					if (yych <= 'M') goto yy257;
-					goto yy279;
+					if (yych <= '=') goto yy274;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'M') goto yy258;
+					goto yy280;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'n') goto yy279;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'n') goto yy280;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy273;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy274;
+					goto yy257;
 				}
 			}
 		}
-yy277:
-		YYDEBUG(277, *YYCURSOR);
+yy278:
+		YYDEBUG(278, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'K') goto yy257;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'K') goto yy258;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy278;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'l') goto yy279;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy278:
-		YYDEBUG(278, *YYCURSOR);
+yy279:
+		YYDEBUG(279, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'K') goto yy257;
-					goto yy272;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'K') goto yy258;
+					goto yy273;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy272;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'l') goto yy273;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy279:
-		YYDEBUG(279, *YYCURSOR);
+yy280:
+		YYDEBUG(280, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'D') goto yy257;
-					goto yy272;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'D') goto yy258;
+					goto yy273;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy272;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'e') goto yy273;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy280:
-		YYDEBUG(280, *YYCURSOR);
+yy281:
+		YYDEBUG(281, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'L') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'K') goto yy257;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'K') goto yy258;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'l') goto yy281;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'l') goto yy282;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy281:
-		YYDEBUG(281, *YYCURSOR);
+yy282:
+		YYDEBUG(282, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'S') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'R') goto yy257;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'R') goto yy258;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 's') goto yy282;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 's') goto yy283;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy282:
-		YYDEBUG(282, *YYCURSOR);
+yy283:
+		YYDEBUG(283, *YYCURSOR);
 		yyaccept = 4;
 		yych = *(YYMARKER = ++YYCURSOR);
 		if (yych <= '=') {
 			if (yych <= '"') {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy249;
-					if (yych <= 0x08) goto yy256;
-					goto yy249;
+					if (yych <= 0x00) goto yy250;
+					if (yych <= 0x08) goto yy257;
+					goto yy250;
 				} else {
-					if (yych == '\r') goto yy249;
-					if (yych <= 0x1F) goto yy256;
-					goto yy249;
+					if (yych == '\r') goto yy250;
+					if (yych <= 0x1F) goto yy257;
+					goto yy250;
 				}
 			} else {
 				if (yych <= '9') {
-					if (yych <= '%') goto yy256;
-					if (yych <= ')') goto yy249;
-					if (yych <= '/') goto yy256;
-					goto yy257;
+					if (yych <= '%') goto yy257;
+					if (yych <= ')') goto yy250;
+					if (yych <= '/') goto yy257;
+					goto yy258;
 				} else {
-					if (yych == ';') goto yy249;
-					if (yych <= '<') goto yy256;
-					goto yy249;
+					if (yych == ';') goto yy250;
+					if (yych <= '<') goto yy257;
+					goto yy250;
 				}
 			}
 		} else {
 			if (yych <= '`') {
 				if (yych <= 'E') {
-					if (yych <= '@') goto yy256;
-					if (yych <= 'D') goto yy257;
-					goto yy272;
+					if (yych <= '@') goto yy257;
+					if (yych <= 'D') goto yy258;
+					goto yy273;
 				} else {
-					if (yych <= 'Z') goto yy257;
-					if (yych == '_') goto yy257;
-					goto yy256;
+					if (yych <= 'Z') goto yy258;
+					if (yych == '_') goto yy258;
+					goto yy257;
 				}
 			} else {
 				if (yych <= '{') {
-					if (yych == 'e') goto yy272;
-					if (yych <= 'z') goto yy257;
-					goto yy256;
+					if (yych == 'e') goto yy273;
+					if (yych <= 'z') goto yy258;
+					goto yy257;
 				} else {
-					if (yych == '}') goto yy256;
-					if (yych <= '~') goto yy249;
-					goto yy256;
+					if (yych == '}') goto yy257;
+					if (yych <= '~') goto yy250;
+					goto yy257;
 				}
 			}
 		}
-yy283:
-		YYDEBUG(283, *YYCURSOR);
+yy284:
+		YYDEBUG(284, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy284:
-		YYDEBUG(284, *YYCURSOR);
-		if (yybm[0+yych] & 32) {
-			goto yy283;
-		}
-		if (yych >= '\r') goto yy287;
 yy285:
 		YYDEBUG(285, *YYCURSOR);
-		++YYCURSOR;
+		if (yybm[0+yych] & 32) {
+			goto yy284;
+		}
+		if (yych >= '\r') goto yy288;
 yy286:
 		YYDEBUG(286, *YYCURSOR);
+		++YYCURSOR;
+yy287:
+		YYDEBUG(287, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 554 "Zend/zend_ini_scanner.l"
 		{ /* Comment */
@@ -4170,217 +4178,217 @@ yy286:
 	SCNG(lineno)++;
 	return END_OF_LINE;
 }
-#line 4174 "Zend/zend_ini_scanner.c"
-yy287:
-		YYDEBUG(287, *YYCURSOR);
-		yych = *++YYCURSOR;
-		if (yych == '\n') goto yy285;
-		goto yy286;
+#line 4182 "Zend/zend_ini_scanner.c"
 yy288:
 		YYDEBUG(288, *YYCURSOR);
+		yych = *++YYCURSOR;
+		if (yych == '\n') goto yy286;
+		goto yy287;
+yy289:
+		YYDEBUG(289, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(289, *YYCURSOR);
+		YYDEBUG(290, *YYCURSOR);
 		if (yybm[0+yych] & 64) {
-			goto yy288;
+			goto yy289;
 		}
 		if (yych <= '%') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy244;
-					goto yy255;
+					if (yych <= 0x00) goto yy245;
+					goto yy256;
 				} else {
-					if (yych <= '\n') goto yy244;
-					if (yych <= '\f') goto yy255;
-					goto yy244;
+					if (yych <= '\n') goto yy245;
+					if (yych <= '\f') goto yy256;
+					goto yy245;
 				}
 			} else {
 				if (yych <= '"') {
-					if (yych <= 0x1F) goto yy255;
-					goto yy244;
+					if (yych <= 0x1F) goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '$') goto yy260;
-					goto yy255;
+					if (yych == '$') goto yy261;
+					goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '=') {
 				if (yych <= ':') {
-					if (yych <= ')') goto yy244;
-					goto yy255;
+					if (yych <= ')') goto yy245;
+					goto yy256;
 				} else {
-					if (yych == '<') goto yy255;
-					goto yy244;
+					if (yych == '<') goto yy256;
+					goto yy245;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '{') goto yy255;
-					goto yy244;
+					if (yych <= '{') goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '~') goto yy244;
-					goto yy255;
+					if (yych == '~') goto yy245;
+					goto yy256;
 				}
 			}
 		}
-yy290:
-		YYDEBUG(290, *YYCURSOR);
+yy291:
+		YYDEBUG(291, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(291, *YYCURSOR);
+		YYDEBUG(292, *YYCURSOR);
 		if (yych <= '-') {
 			if (yych <= 0x1F) {
 				if (yych <= '\n') {
-					if (yych <= 0x00) goto yy244;
-					if (yych <= 0x08) goto yy255;
-					goto yy244;
+					if (yych <= 0x00) goto yy245;
+					if (yych <= 0x08) goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '\r') goto yy244;
-					goto yy255;
+					if (yych == '\r') goto yy245;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '$') {
-					if (yych <= '"') goto yy244;
-					if (yych <= '#') goto yy255;
-					goto yy260;
+					if (yych <= '"') goto yy245;
+					if (yych <= '#') goto yy256;
+					goto yy261;
 				} else {
-					if (yych <= '%') goto yy255;
-					if (yych <= ')') goto yy244;
-					goto yy255;
+					if (yych <= '%') goto yy256;
+					if (yych <= ')') goto yy245;
+					goto yy256;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '.') goto yy288;
-					if (yych <= '/') goto yy255;
-					goto yy290;
+					if (yych <= '.') goto yy289;
+					if (yych <= '/') goto yy256;
+					goto yy291;
 				} else {
-					if (yych == ';') goto yy244;
-					goto yy255;
+					if (yych == ';') goto yy245;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy244;
-					if (yych <= '{') goto yy255;
-					goto yy244;
+					if (yych <= '=') goto yy245;
+					if (yych <= '{') goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '~') goto yy244;
-					goto yy255;
+					if (yych == '~') goto yy245;
+					goto yy256;
 				}
 			}
 		}
-yy292:
-		YYDEBUG(292, *YYCURSOR);
+yy293:
+		YYDEBUG(293, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(293, *YYCURSOR);
+		YYDEBUG(294, *YYCURSOR);
 		if (yych <= ')') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy244;
-					goto yy255;
+					if (yych <= 0x00) goto yy245;
+					goto yy256;
 				} else {
-					if (yych <= '\n') goto yy244;
-					if (yych <= '\f') goto yy255;
-					goto yy244;
+					if (yych <= '\n') goto yy245;
+					if (yych <= '\f') goto yy256;
+					goto yy245;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= 0x1F) goto yy255;
-					if (yych <= '"') goto yy244;
-					goto yy255;
+					if (yych <= 0x1F) goto yy256;
+					if (yych <= '"') goto yy245;
+					goto yy256;
 				} else {
-					if (yych <= '$') goto yy260;
-					if (yych <= '%') goto yy255;
-					goto yy244;
+					if (yych <= '$') goto yy261;
+					if (yych <= '%') goto yy256;
+					goto yy245;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy255;
-					goto yy292;
+					if (yych <= '/') goto yy256;
+					goto yy293;
 				} else {
-					if (yych == ';') goto yy244;
-					goto yy255;
+					if (yych == ';') goto yy245;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy244;
-					if (yych <= '{') goto yy255;
-					goto yy244;
+					if (yych <= '=') goto yy245;
+					if (yych <= '{') goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '~') goto yy244;
-					goto yy255;
+					if (yych == '~') goto yy245;
+					goto yy256;
 				}
 			}
 		}
-yy294:
-		YYDEBUG(294, *YYCURSOR);
+yy295:
+		YYDEBUG(295, *YYCURSOR);
 		yyaccept = 3;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(295, *YYCURSOR);
+		YYDEBUG(296, *YYCURSOR);
 		if (yych <= ')') {
 			if (yych <= '\r') {
 				if (yych <= 0x08) {
-					if (yych <= 0x00) goto yy244;
-					goto yy255;
+					if (yych <= 0x00) goto yy245;
+					goto yy256;
 				} else {
-					if (yych <= '\n') goto yy244;
-					if (yych <= '\f') goto yy255;
-					goto yy244;
+					if (yych <= '\n') goto yy245;
+					if (yych <= '\f') goto yy256;
+					goto yy245;
 				}
 			} else {
 				if (yych <= '#') {
-					if (yych <= 0x1F) goto yy255;
-					if (yych <= '"') goto yy244;
-					goto yy255;
+					if (yych <= 0x1F) goto yy256;
+					if (yych <= '"') goto yy245;
+					goto yy256;
 				} else {
-					if (yych <= '$') goto yy260;
-					if (yych <= '%') goto yy255;
-					goto yy244;
+					if (yych <= '$') goto yy261;
+					if (yych <= '%') goto yy256;
+					goto yy245;
 				}
 			}
 		} else {
 			if (yych <= '<') {
 				if (yych <= '9') {
-					if (yych <= '/') goto yy255;
-					goto yy294;
+					if (yych <= '/') goto yy256;
+					goto yy295;
 				} else {
-					if (yych == ';') goto yy244;
-					goto yy255;
+					if (yych == ';') goto yy245;
+					goto yy256;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '=') goto yy244;
-					if (yych <= '{') goto yy255;
-					goto yy244;
+					if (yych <= '=') goto yy245;
+					if (yych <= '{') goto yy256;
+					goto yy245;
 				} else {
-					if (yych == '~') goto yy244;
-					goto yy255;
+					if (yych == '~') goto yy245;
+					goto yy256;
 				}
 			}
 		}
-yy296:
-		YYDEBUG(296, *YYCURSOR);
+yy297:
+		YYDEBUG(297, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-		YYDEBUG(297, *YYCURSOR);
+		YYDEBUG(298, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy296;
+			goto yy297;
 		}
-		YYDEBUG(298, *YYCURSOR);
-		++YYCURSOR;
 		YYDEBUG(299, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(300, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 365 "Zend/zend_ini_scanner.l"
 		{ /* Raw string */
@@ -4391,66 +4399,66 @@ yy296:
 	}
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
-#line 4395 "Zend/zend_ini_scanner.c"
-yy300:
-		YYDEBUG(300, *YYCURSOR);
-		++YYCURSOR;
+#line 4403 "Zend/zend_ini_scanner.c"
+yy301:
 		YYDEBUG(301, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(302, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 398 "Zend/zend_ini_scanner.l"
 		{ /* Variable start */
 	yy_push_state(ST_VARNAME TSRMLS_CC);
 	return TC_DOLLAR_CURLY;
 }
-#line 4406 "Zend/zend_ini_scanner.c"
-yy302:
-		YYDEBUG(302, *YYCURSOR);
+#line 4414 "Zend/zend_ini_scanner.c"
+yy303:
+		YYDEBUG(303, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy303:
-		YYDEBUG(303, *YYCURSOR);
-		if (yych == '\t') goto yy302;
-		if (yych == ' ') goto yy302;
-		goto yy236;
 yy304:
 		YYDEBUG(304, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy233;
+		if (yych == '\t') goto yy303;
+		if (yych == ' ') goto yy303;
+		goto yy237;
 yy305:
 		YYDEBUG(305, *YYCURSOR);
+		yych = *++YYCURSOR;
+		goto yy234;
+yy306:
+		YYDEBUG(306, *YYCURSOR);
 		yyaccept = 1;
 		YYMARKER = ++YYCURSOR;
 		YYFILL(2);
 		yych = *YYCURSOR;
-yy306:
-		YYDEBUG(306, *YYCURSOR);
+yy307:
+		YYDEBUG(307, *YYCURSOR);
 		if (yych <= 0x1F) {
 			if (yych <= '\n') {
-				if (yych <= 0x08) goto yy231;
-				if (yych <= '\t') goto yy305;
-				goto yy304;
+				if (yych <= 0x08) goto yy232;
+				if (yych <= '\t') goto yy306;
+				goto yy305;
 			} else {
-				if (yych == '\r') goto yy308;
-				goto yy231;
+				if (yych == '\r') goto yy309;
+				goto yy232;
 			}
 		} else {
 			if (yych <= '"') {
-				if (yych <= ' ') goto yy305;
-				if (yych <= '!') goto yy231;
+				if (yych <= ' ') goto yy306;
+				if (yych <= '!') goto yy232;
 			} else {
-				if (yych == ';') goto yy283;
-				goto yy231;
+				if (yych == ';') goto yy284;
+				goto yy232;
 			}
 		}
-		YYDEBUG(307, *YYCURSOR);
-		yych = *++YYCURSOR;
-		goto yy238;
-yy308:
 		YYDEBUG(308, *YYCURSOR);
+		yych = *++YYCURSOR;
+		goto yy239;
+yy309:
+		YYDEBUG(309, *YYCURSOR);
 		++YYCURSOR;
-		if ((yych = *YYCURSOR) == '\n') goto yy304;
-		goto yy233;
+		if ((yych = *YYCURSOR) == '\n') goto yy305;
+		goto yy234;
 	}
 /* *********************************** */
 yyc_ST_VARNAME:
@@ -4489,47 +4497,47 @@ yyc_ST_VARNAME:
 			128, 128, 128, 128, 128, 128, 128, 128, 
 			128, 128, 128, 128, 128, 128, 128, 128, 
 		};
-		YYDEBUG(309, *YYCURSOR);
+		YYDEBUG(310, *YYCURSOR);
 		YYFILL(2);
 		yych = *YYCURSOR;
 		if (yych <= '\'') {
 			if (yych <= ' ') {
 				if (yych <= '\n') {
-					if (yych >= '\t') goto yy313;
+					if (yych >= '\t') goto yy314;
 				} else {
-					if (yych == '\r') goto yy313;
+					if (yych == '\r') goto yy314;
 				}
 			} else {
 				if (yych <= '$') {
-					if (yych != '#') goto yy313;
+					if (yych != '#') goto yy314;
 				} else {
-					if (yych == '&') goto yy313;
+					if (yych == '&') goto yy314;
 				}
 			}
 		} else {
 			if (yych <= 'Z') {
 				if (yych <= ';') {
-					if (yych <= ')') goto yy313;
-					if (yych >= ';') goto yy313;
+					if (yych <= ')') goto yy314;
+					if (yych >= ';') goto yy314;
 				} else {
-					if (yych == '=') goto yy313;
+					if (yych == '=') goto yy314;
 				}
 			} else {
 				if (yych <= '|') {
-					if (yych <= '[') goto yy313;
-					if (yych >= '{') goto yy313;
+					if (yych <= '[') goto yy314;
+					if (yych >= '{') goto yy314;
 				} else {
-					if (yych <= '}') goto yy315;
-					if (yych <= '~') goto yy313;
+					if (yych <= '}') goto yy316;
+					if (yych <= '~') goto yy314;
 				}
 			}
 		}
-		YYDEBUG(311, *YYCURSOR);
+		YYDEBUG(312, *YYCURSOR);
 		++YYCURSOR;
 		yych = *YYCURSOR;
-		goto yy318;
-yy312:
-		YYDEBUG(312, *YYCURSOR);
+		goto yy319;
+yy313:
+		YYDEBUG(313, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 403 "Zend/zend_ini_scanner.l"
 		{ /* Variable name */
@@ -4541,39 +4549,39 @@ yy312:
 
 	RETURN_TOKEN(TC_VARNAME, yytext, yyleng);
 }
-#line 4545 "Zend/zend_ini_scanner.c"
-yy313:
-		YYDEBUG(313, *YYCURSOR);
-		++YYCURSOR;
+#line 4553 "Zend/zend_ini_scanner.c"
+yy314:
 		YYDEBUG(314, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(315, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 572 "Zend/zend_ini_scanner.l"
 		{
 	return 0;
 }
-#line 4555 "Zend/zend_ini_scanner.c"
-yy315:
-		YYDEBUG(315, *YYCURSOR);
-		++YYCURSOR;
+#line 4563 "Zend/zend_ini_scanner.c"
+yy316:
 		YYDEBUG(316, *YYCURSOR);
+		++YYCURSOR;
+		YYDEBUG(317, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
 #line 413 "Zend/zend_ini_scanner.l"
 		{ /* Variable end */
 	yy_pop_state(TSRMLS_C);
 	return '}';
 }
-#line 4566 "Zend/zend_ini_scanner.c"
-yy317:
-		YYDEBUG(317, *YYCURSOR);
+#line 4574 "Zend/zend_ini_scanner.c"
+yy318:
+		YYDEBUG(318, *YYCURSOR);
 		++YYCURSOR;
 		YYFILL(1);
 		yych = *YYCURSOR;
-yy318:
-		YYDEBUG(318, *YYCURSOR);
+yy319:
+		YYDEBUG(319, *YYCURSOR);
 		if (yybm[0+yych] & 128) {
-			goto yy317;
+			goto yy318;
 		}
-		goto yy312;
+		goto yy313;
 	}
 }
 #line 576 "Zend/zend_ini_scanner.l"
diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l
index e88b45e..3910bff 100644
--- a/Zend/zend_ini_scanner.l
+++ b/Zend/zend_ini_scanner.l
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_ini_scanner.l 299767 2010-05-26 02:18:17Z felipe $ */
+/* $Id: zend_ini_scanner.l 301758 2010-08-01 15:26:54Z felipe $ */
 
 #include <errno.h>
 #include "zend.h"
@@ -344,7 +344,7 @@ DOLLAR_CURLY "${"
 
 SECTION_RAW_CHARS [^\]\n\r]
 SINGLE_QUOTED_CHARS [^']
-RAW_VALUE_CHARS [^\n\r;]
+RAW_VALUE_CHARS [^\n\r;\000]
 
 LITERAL_DOLLAR ("$"([^{\000]|("\\"{ANY_CHAR})))
 VALUE_CHARS         ([^$= \t\n\r;&|~()!"'\000]|{LITERAL_DOLLAR})
diff --git a/Zend/zend_ini_scanner_defs.h b/Zend/zend_ini_scanner_defs.h
index 4107238..6dc3fd7 100644
--- a/Zend/zend_ini_scanner_defs.h
+++ b/Zend/zend_ini_scanner_defs.h
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Tue May 25 22:53:58 2010 */
+/* Generated by re2c 0.13.5 on Sun Aug  1 12:07:43 2010 */
 #line 3 "Zend/zend_ini_scanner_defs.h"
 
 enum YYCONDTYPE {
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index c71f2ba..8b0be1c 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -1,5 +1,4 @@
-/* Generated by re2c 0.13.5 on Tue Jun 29 23:22:29 2010 */
-#line 1 "Zend/zend_language_scanner.l"
+/* Generated by re2c 0.13.5 on Wed Jan  5 17:41:40 2011 */
 /*
    +----------------------------------------------------------------------+
    | Zend Engine                                                          |
@@ -23,7 +22,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.c 300871 2010-06-30 02:45:10Z felipe $ */
+/* $Id: zend_language_scanner.l 305464 2010-11-17 16:46:19Z pajoye $ */
 
 #if 0
 # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
@@ -286,6 +285,10 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
 			SCNG(script_filtered_size) = SCNG(script_org_size);
 		} else {
 			SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
+			if (SCNG(script_filtered) == NULL) {
+				zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
+						"encoding \"%s\" to a compatible encoding", LANG_SCNG(script_encoding)->name);
+			}
 		}
 		SCNG(yy_start) = SCNG(script_filtered) - offset;
 		yy_scan_buffer((char *)SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);
@@ -846,7 +849,6 @@ restart:
 yymore_restart:
 
 
-#line 850 "Zend/zend_language_scanner.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -945,7 +947,6 @@ yyc_INITIAL:
 yy3:
 		YYDEBUG(3, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1574 "Zend/zend_language_scanner.l"
 		{
 	if (YYCURSOR > YYLIMIT) {
 		return 0;
@@ -1010,7 +1011,6 @@ inline_html:
 	HANDLE_NEWLINES(yytext, yyleng);
 	return T_INLINE_HTML;
 }
-#line 1014 "Zend/zend_language_scanner.c"
 yy4:
 		YYDEBUG(4, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1028,7 +1028,6 @@ yy5:
 yy6:
 		YYDEBUG(6, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1562 "Zend/zend_language_scanner.l"
 		{
 	if (CG(short_tags)) {
 		zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1040,14 +1039,12 @@ yy6:
 		goto inline_char_handler;
 	}
 }
-#line 1044 "Zend/zend_language_scanner.c"
 yy7:
 		YYDEBUG(7, *YYCURSOR);
 		++YYCURSOR;
 		if ((yych = *YYCURSOR) == '=') goto yy43;
 		YYDEBUG(8, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1539 "Zend/zend_language_scanner.l"
 		{
 	if (CG(asp_tags)) {
 		zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1059,7 +1056,6 @@ yy7:
 		goto inline_char_handler;
 	}
 }
-#line 1063 "Zend/zend_language_scanner.c"
 yy9:
 		YYDEBUG(9, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1245,7 +1241,6 @@ yy35:
 		++YYCURSOR;
 		YYDEBUG(38, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1495 "Zend/zend_language_scanner.l"
 		{
 	YYCTYPE *bracket = zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1));
 
@@ -1262,7 +1257,6 @@ yy35:
 	BEGIN(ST_IN_SCRIPTING);
 	return T_OPEN_TAG;
 }
-#line 1266 "Zend/zend_language_scanner.c"
 yy39:
 		YYDEBUG(39, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1289,7 +1283,6 @@ yy43:
 		++YYCURSOR;
 		YYDEBUG(44, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1513 "Zend/zend_language_scanner.l"
 		{
 	if (CG(asp_tags)) {
 		zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1301,13 +1294,11 @@ yy43:
 		goto inline_char_handler;
 	}
 }
-#line 1305 "Zend/zend_language_scanner.c"
 yy45:
 		YYDEBUG(45, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(46, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1526 "Zend/zend_language_scanner.l"
 		{
 	if (CG(short_tags)) {
 		zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1319,7 +1310,6 @@ yy45:
 		goto inline_char_handler;
 	}
 }
-#line 1323 "Zend/zend_language_scanner.c"
 yy47:
 		YYDEBUG(47, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1346,7 +1336,6 @@ yy50:
 yy51:
 		YYDEBUG(51, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1552 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.str.val = yytext; /* no copying - intentional */
 	zendlval->value.str.len = yyleng;
@@ -1355,7 +1344,6 @@ yy51:
 	BEGIN(ST_IN_SCRIPTING);
 	return T_OPEN_TAG;
 }
-#line 1359 "Zend/zend_language_scanner.c"
 yy52:
 		YYDEBUG(52, *YYCURSOR);
 		++YYCURSOR;
@@ -1426,7 +1414,6 @@ yyc_ST_BACKQUOTE:
 yy56:
 		YYDEBUG(56, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 2032 "Zend/zend_language_scanner.l"
 		{
 	if (YYCURSOR > YYLIMIT) {
 		return 0;
@@ -1467,7 +1454,6 @@ yy56:
 	zend_scan_escape_string(zendlval, yytext, yyleng, '`' TSRMLS_CC);
 	return T_ENCAPSED_AND_WHITESPACE;
 }
-#line 1471 "Zend/zend_language_scanner.c"
 yy57:
 		YYDEBUG(57, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1478,12 +1464,10 @@ yy58:
 		++YYCURSOR;
 		YYDEBUG(59, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1976 "Zend/zend_language_scanner.l"
 		{
 	BEGIN(ST_IN_SCRIPTING);
 	return '`';
 }
-#line 1487 "Zend/zend_language_scanner.c"
 yy60:
 		YYDEBUG(60, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1493,14 +1477,12 @@ yy61:
 		++YYCURSOR;
 		YYDEBUG(62, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1963 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.lval = (long) '{';
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	yyless(1);
 	return T_CURLY_OPEN;
 }
-#line 1504 "Zend/zend_language_scanner.c"
 yy63:
 		YYDEBUG(63, *YYCURSOR);
 		yyaccept = 0;
@@ -1516,24 +1498,20 @@ yy63:
 yy65:
 		YYDEBUG(65, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1661 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, (yytext+1), (yyleng-1));
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1526 "Zend/zend_language_scanner.c"
 yy66:
 		YYDEBUG(66, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(67, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1288 "Zend/zend_language_scanner.l"
 		{
 	yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC);
 	return T_DOLLAR_OPEN_CURLY_BRACES;
 }
-#line 1537 "Zend/zend_language_scanner.c"
 yy68:
 		YYDEBUG(68, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1547,7 +1525,6 @@ yy70:
 		++YYCURSOR;
 		YYDEBUG(71, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1653 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 1);
 	yy_push_state(ST_VAR_OFFSET TSRMLS_CC);
@@ -1555,7 +1532,6 @@ yy70:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1559 "Zend/zend_language_scanner.c"
 yy72:
 		YYDEBUG(72, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1573,7 +1549,6 @@ yy73:
 		++YYCURSOR;
 		YYDEBUG(74, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1643 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 3);
 	yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
@@ -1581,7 +1556,6 @@ yy73:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1585 "Zend/zend_language_scanner.c"
 	}
 /* *********************************** */
 yyc_ST_DOUBLE_QUOTES:
@@ -1649,7 +1623,6 @@ yy77:
 yy78:
 		YYDEBUG(78, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1982 "Zend/zend_language_scanner.l"
 		{
 	if (GET_DOUBLE_QUOTES_SCANNED_LENGTH()) {
 		YYCURSOR += GET_DOUBLE_QUOTES_SCANNED_LENGTH() - 1;
@@ -1698,7 +1671,6 @@ double_quotes_scan_done:
 	zend_scan_escape_string(zendlval, yytext, yyleng, '"' TSRMLS_CC);
 	return T_ENCAPSED_AND_WHITESPACE;
 }
-#line 1702 "Zend/zend_language_scanner.c"
 yy79:
 		YYDEBUG(79, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1709,12 +1681,10 @@ yy80:
 		++YYCURSOR;
 		YYDEBUG(81, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1971 "Zend/zend_language_scanner.l"
 		{
 	BEGIN(ST_IN_SCRIPTING);
 	return '"';
 }
-#line 1718 "Zend/zend_language_scanner.c"
 yy82:
 		YYDEBUG(82, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1724,14 +1694,12 @@ yy83:
 		++YYCURSOR;
 		YYDEBUG(84, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1963 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.lval = (long) '{';
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	yyless(1);
 	return T_CURLY_OPEN;
 }
-#line 1735 "Zend/zend_language_scanner.c"
 yy85:
 		YYDEBUG(85, *YYCURSOR);
 		yyaccept = 0;
@@ -1747,24 +1715,20 @@ yy85:
 yy87:
 		YYDEBUG(87, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1661 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, (yytext+1), (yyleng-1));
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1757 "Zend/zend_language_scanner.c"
 yy88:
 		YYDEBUG(88, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(89, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1288 "Zend/zend_language_scanner.l"
 		{
 	yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC);
 	return T_DOLLAR_OPEN_CURLY_BRACES;
 }
-#line 1768 "Zend/zend_language_scanner.c"
 yy90:
 		YYDEBUG(90, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1778,7 +1742,6 @@ yy92:
 		++YYCURSOR;
 		YYDEBUG(93, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1653 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 1);
 	yy_push_state(ST_VAR_OFFSET TSRMLS_CC);
@@ -1786,7 +1749,6 @@ yy92:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1790 "Zend/zend_language_scanner.c"
 yy94:
 		YYDEBUG(94, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1804,7 +1766,6 @@ yy95:
 		++YYCURSOR;
 		YYDEBUG(96, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1643 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 3);
 	yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
@@ -1812,7 +1773,6 @@ yy95:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 1816 "Zend/zend_language_scanner.c"
 	}
 /* *********************************** */
 yyc_ST_END_HEREDOC:
@@ -1823,7 +1783,6 @@ yyc_ST_END_HEREDOC:
 	++YYCURSOR;
 	YYDEBUG(100, *YYCURSOR);
 	yyleng = YYCURSOR - SCNG(yy_text);
-#line 1950 "Zend/zend_language_scanner.l"
 	{
 	YYCURSOR += CG(heredoc_len) - 1;
 	yyleng = CG(heredoc_len);
@@ -1835,7 +1794,6 @@ yyc_ST_END_HEREDOC:
 	BEGIN(ST_IN_SCRIPTING);
 	return T_END_HEREDOC;
 }
-#line 1839 "Zend/zend_language_scanner.c"
 /* *********************************** */
 yyc_ST_HEREDOC:
 	{
@@ -1897,7 +1855,6 @@ yy103:
 yy104:
 		YYDEBUG(104, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 2074 "Zend/zend_language_scanner.l"
 		{
 	int newline = 0;
 
@@ -1968,7 +1925,6 @@ heredoc_scan_done:
 	zend_scan_escape_string(zendlval, yytext, yyleng - newline, 0 TSRMLS_CC);
 	return T_ENCAPSED_AND_WHITESPACE;
 }
-#line 1972 "Zend/zend_language_scanner.c"
 yy105:
 		YYDEBUG(105, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -1983,14 +1939,12 @@ yy107:
 		++YYCURSOR;
 		YYDEBUG(108, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1963 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.lval = (long) '{';
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	yyless(1);
 	return T_CURLY_OPEN;
 }
-#line 1994 "Zend/zend_language_scanner.c"
 yy109:
 		YYDEBUG(109, *YYCURSOR);
 		yyaccept = 0;
@@ -2006,24 +1960,20 @@ yy109:
 yy111:
 		YYDEBUG(111, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1661 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, (yytext+1), (yyleng-1));
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 2016 "Zend/zend_language_scanner.c"
 yy112:
 		YYDEBUG(112, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(113, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1288 "Zend/zend_language_scanner.l"
 		{
 	yy_push_state(ST_LOOKING_FOR_VARNAME TSRMLS_CC);
 	return T_DOLLAR_OPEN_CURLY_BRACES;
 }
-#line 2027 "Zend/zend_language_scanner.c"
 yy114:
 		YYDEBUG(114, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -2037,7 +1987,6 @@ yy116:
 		++YYCURSOR;
 		YYDEBUG(117, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1653 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 1);
 	yy_push_state(ST_VAR_OFFSET TSRMLS_CC);
@@ -2045,7 +1994,6 @@ yy116:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 2049 "Zend/zend_language_scanner.c"
 yy118:
 		YYDEBUG(118, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -2063,7 +2011,6 @@ yy119:
 		++YYCURSOR;
 		YYDEBUG(120, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1643 "Zend/zend_language_scanner.l"
 		{
 	yyless(yyleng - 3);
 	yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
@@ -2071,7 +2018,6 @@ yy119:
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 2075 "Zend/zend_language_scanner.c"
 	}
 /* *********************************** */
 yyc_ST_IN_SCRIPTING:
@@ -2252,13 +2198,11 @@ yy123:
 yy124:
 		YYDEBUG(124, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1684 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, yytext, yyleng);
 	zendlval->type = IS_STRING;
 	return T_STRING;
 }
-#line 2262 "Zend/zend_language_scanner.c"
 yy125:
 		YYDEBUG(125, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -2484,11 +2428,9 @@ yy137:
 yy138:
 		YYDEBUG(138, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1277 "Zend/zend_language_scanner.l"
 		{
 	return yytext[0];
 }
-#line 2492 "Zend/zend_language_scanner.c"
 yy139:
 		YYDEBUG(139, *YYCURSOR);
 		++YYCURSOR;
@@ -2497,7 +2439,6 @@ yy139:
 yy140:
 		YYDEBUG(140, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1012 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.str.val = yytext; /* no copying - intentional */
 	zendlval->value.str.len = yyleng;
@@ -2505,7 +2446,6 @@ yy140:
 	HANDLE_NEWLINES(yytext, yyleng);
 	return T_WHITESPACE;
 }
-#line 2509 "Zend/zend_language_scanner.c"
 yy141:
 		YYDEBUG(141, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -2516,11 +2456,9 @@ yy142:
 		++YYCURSOR;
 		YYDEBUG(143, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1041 "Zend/zend_language_scanner.l"
 		{
 	return T_NS_SEPARATOR;
 }
-#line 2524 "Zend/zend_language_scanner.c"
 yy144:
 		YYDEBUG(144, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -2748,18 +2686,15 @@ yy167:
 		++YYCURSOR;
 		YYDEBUG(168, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1282 "Zend/zend_language_scanner.l"
 		{
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	return '{';
 }
-#line 2757 "Zend/zend_language_scanner.c"
 yy169:
 		YYDEBUG(169, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(170, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1294 "Zend/zend_language_scanner.l"
 		{
 	RESET_DOC_COMMENT();
 	if (!zend_stack_is_empty(&SCNG(state_stack))) {
@@ -2767,7 +2702,6 @@ yy169:
 	}
 	return '}';
 }
-#line 2771 "Zend/zend_language_scanner.c"
 yy171:
 		YYDEBUG(171, *YYCURSOR);
 		yyaccept = 2;
@@ -2790,7 +2724,6 @@ yy171:
 yy172:
 		YYDEBUG(172, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1320 "Zend/zend_language_scanner.l"
 		{
 	if (yyleng < MAX_LENGTH_OF_LONG - 1) { /* Won't overflow */
 		zendlval->value.lval = strtol(yytext, NULL, 0);
@@ -2811,7 +2744,6 @@ yy172:
 	zendlval->type = IS_LONG;
 	return T_LNUMBER;
 }
-#line 2815 "Zend/zend_language_scanner.c"
 yy173:
 		YYDEBUG(173, *YYCURSOR);
 		yyaccept = 2;
@@ -2839,7 +2771,6 @@ yy175:
 yy176:
 		YYDEBUG(176, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1691 "Zend/zend_language_scanner.l"
 		{
 	while (YYCURSOR < YYLIMIT) {
 		switch (*YYCURSOR++) {
@@ -2873,14 +2804,12 @@ yy176:
 
 	return T_COMMENT;
 }
-#line 2877 "Zend/zend_language_scanner.c"
 yy177:
 		YYDEBUG(177, *YYCURSOR);
 		++YYCURSOR;
 yy178:
 		YYDEBUG(178, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1782 "Zend/zend_language_scanner.l"
 		{
 	register char *s, *t;
 	char *end;
@@ -2950,14 +2879,12 @@ yy178:
 #endif /* ZEND_MULTIBYTE */
 	return T_CONSTANT_ENCAPSED_STRING;
 }
-#line 2954 "Zend/zend_language_scanner.c"
 yy179:
 		YYDEBUG(179, *YYCURSOR);
 		++YYCURSOR;
 yy180:
 		YYDEBUG(180, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1853 "Zend/zend_language_scanner.l"
 		{
 	int bprefix = (yytext[0] != '"') ? 1 : 0;
 
@@ -2998,24 +2925,20 @@ yy180:
 	BEGIN(ST_DOUBLE_QUOTES);
 	return '"';
 }
-#line 3002 "Zend/zend_language_scanner.c"
 yy181:
 		YYDEBUG(181, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(182, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1944 "Zend/zend_language_scanner.l"
 		{
 	BEGIN(ST_BACKQUOTE);
 	return '`';
 }
-#line 3013 "Zend/zend_language_scanner.c"
 yy183:
 		YYDEBUG(183, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(184, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 2202 "Zend/zend_language_scanner.l"
 		{
 	if (YYCURSOR > YYLIMIT) {
 		return 0;
@@ -3024,7 +2947,6 @@ yy183:
 	zend_error(E_COMPILE_WARNING,"Unexpected character in input:  '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
 	goto restart;
 }
-#line 3028 "Zend/zend_language_scanner.c"
 yy185:
 		YYDEBUG(185, *YYCURSOR);
 		++YYCURSOR;
@@ -3051,13 +2973,11 @@ yy187:
 yy189:
 		YYDEBUG(189, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1381 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.dval = zend_strtod(yytext, NULL);
 	zendlval->type = IS_DOUBLE;
 	return T_DNUMBER;
 }
-#line 3061 "Zend/zend_language_scanner.c"
 yy190:
 		YYDEBUG(190, *YYCURSOR);
 		yyaccept = 2;
@@ -3142,7 +3062,6 @@ yy198:
 		}
 		YYDEBUG(200, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1341 "Zend/zend_language_scanner.l"
 		{
 	char *hex = yytext + 2; /* Skip "0x" */
 	int len = yyleng - 2;
@@ -3163,7 +3082,6 @@ yy198:
 		return T_DNUMBER;
 	}
 }
-#line 3167 "Zend/zend_language_scanner.c"
 yy201:
 		YYDEBUG(201, *YYCURSOR);
 		++YYCURSOR;
@@ -3172,7 +3090,6 @@ yy201:
 yy202:
 		YYDEBUG(202, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1759 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.str.val = yytext; /* no copying - intentional */
 	zendlval->value.str.len = yyleng;
@@ -3180,7 +3097,6 @@ yy202:
 	BEGIN(INITIAL);
 	return T_CLOSE_TAG;  /* implicit ';' at php-end tag */
 }
-#line 3184 "Zend/zend_language_scanner.c"
 yy203:
 		YYDEBUG(203, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3214,13 +3130,11 @@ yy205:
 yy207:
 		YYDEBUG(207, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1661 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, (yytext+1), (yyleng-1));
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 3224 "Zend/zend_language_scanner.c"
 yy208:
 		YYDEBUG(208, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3234,11 +3148,9 @@ yy209:
 		}
 		YYDEBUG(210, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1265 "Zend/zend_language_scanner.l"
 		{
 	return T_LOGICAL_XOR;
 }
-#line 3242 "Zend/zend_language_scanner.c"
 yy211:
 		YYDEBUG(211, *YYCURSOR);
 		++YYCURSOR;
@@ -3247,61 +3159,49 @@ yy211:
 		}
 		YYDEBUG(212, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1257 "Zend/zend_language_scanner.l"
 		{
 	return T_LOGICAL_OR;
 }
-#line 3255 "Zend/zend_language_scanner.c"
 yy213:
 		YYDEBUG(213, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(214, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1245 "Zend/zend_language_scanner.l"
 		{
 	return T_XOR_EQUAL;
 }
-#line 3265 "Zend/zend_language_scanner.c"
 yy215:
 		YYDEBUG(215, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(216, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1249 "Zend/zend_language_scanner.l"
 		{
 	return T_BOOLEAN_OR;
 }
-#line 3275 "Zend/zend_language_scanner.c"
 yy217:
 		YYDEBUG(217, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(218, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1241 "Zend/zend_language_scanner.l"
 		{
 	return T_OR_EQUAL;
 }
-#line 3285 "Zend/zend_language_scanner.c"
 yy219:
 		YYDEBUG(219, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(220, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1253 "Zend/zend_language_scanner.l"
 		{
 	return T_BOOLEAN_AND;
 }
-#line 3295 "Zend/zend_language_scanner.c"
 yy221:
 		YYDEBUG(221, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(222, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1237 "Zend/zend_language_scanner.l"
 		{
 	return T_AND_EQUAL;
 }
-#line 3305 "Zend/zend_language_scanner.c"
 yy223:
 		YYDEBUG(223, *YYCURSOR);
 		++YYCURSOR;
@@ -3310,7 +3210,6 @@ yy223:
 yy224:
 		YYDEBUG(224, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1768 "Zend/zend_language_scanner.l"
 		{
 	if (CG(asp_tags)) {
 		BEGIN(INITIAL);
@@ -3323,17 +3222,14 @@ yy224:
 		return yytext[0];
 	}
 }
-#line 3327 "Zend/zend_language_scanner.c"
 yy225:
 		YYDEBUG(225, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(226, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1225 "Zend/zend_language_scanner.l"
 		{
 	return T_MOD_EQUAL;
 }
-#line 3337 "Zend/zend_language_scanner.c"
 yy227:
 		YYDEBUG(227, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3364,11 +3260,9 @@ yy231:
 		++YYCURSOR;
 		YYDEBUG(232, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1221 "Zend/zend_language_scanner.l"
 		{
 	return T_CONCAT_EQUAL;
 }
-#line 3372 "Zend/zend_language_scanner.c"
 yy233:
 		YYDEBUG(233, *YYCURSOR);
 		yyaccept = 4;
@@ -3377,7 +3271,6 @@ yy233:
 yy234:
 		YYDEBUG(234, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1725 "Zend/zend_language_scanner.l"
 		{
 	int doc_com;
 
@@ -3411,7 +3304,6 @@ yy234:
 
 	return T_COMMENT;
 }
-#line 3415 "Zend/zend_language_scanner.c"
 yy235:
 		YYDEBUG(235, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3421,11 +3313,9 @@ yy236:
 		++YYCURSOR;
 		YYDEBUG(237, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1217 "Zend/zend_language_scanner.l"
 		{
 	return T_DIV_EQUAL;
 }
-#line 3429 "Zend/zend_language_scanner.c"
 yy238:
 		YYDEBUG(238, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3448,42 +3338,34 @@ yy241:
 		++YYCURSOR;
 		YYDEBUG(242, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1213 "Zend/zend_language_scanner.l"
 		{
 	return T_MUL_EQUAL;
 }
-#line 3456 "Zend/zend_language_scanner.c"
 yy243:
 		YYDEBUG(243, *YYCURSOR);
 		++YYCURSOR;
 		if ((yych = *YYCURSOR) == '=') goto yy247;
 		YYDEBUG(244, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1273 "Zend/zend_language_scanner.l"
 		{
 	return T_SR;
 }
-#line 3467 "Zend/zend_language_scanner.c"
 yy245:
 		YYDEBUG(245, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(246, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1201 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_GREATER_OR_EQUAL;
 }
-#line 3477 "Zend/zend_language_scanner.c"
 yy247:
 		YYDEBUG(247, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(248, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1233 "Zend/zend_language_scanner.l"
 		{
 	return T_SR_EQUAL;
 }
-#line 3487 "Zend/zend_language_scanner.c"
 yy249:
 		YYDEBUG(249, *YYCURSOR);
 		yyaccept = 5;
@@ -3494,11 +3376,9 @@ yy249:
 yy250:
 		YYDEBUG(250, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1269 "Zend/zend_language_scanner.l"
 		{
 	return T_SL;
 }
-#line 3502 "Zend/zend_language_scanner.c"
 yy251:
 		YYDEBUG(251, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3510,22 +3390,18 @@ yy252:
 		++YYCURSOR;
 		YYDEBUG(253, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1197 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_SMALLER_OR_EQUAL;
 }
-#line 3518 "Zend/zend_language_scanner.c"
 yy254:
 		YYDEBUG(254, *YYCURSOR);
 		++YYCURSOR;
 yy255:
 		YYDEBUG(255, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1193 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_NOT_EQUAL;
 }
-#line 3529 "Zend/zend_language_scanner.c"
 yy256:
 		YYDEBUG(256, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3576,11 +3452,9 @@ yy263:
 		++YYCURSOR;
 		YYDEBUG(264, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1229 "Zend/zend_language_scanner.l"
 		{
 	return T_SL_EQUAL;
 }
-#line 3584 "Zend/zend_language_scanner.c"
 yy265:
 		YYDEBUG(265, *YYCURSOR);
 		++YYCURSOR;
@@ -3685,7 +3559,6 @@ yy274:
 yy275:
 		YYDEBUG(275, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1895 "Zend/zend_language_scanner.l"
 		{
 	char *s;
 	int bprefix = (yytext[0] != '<') ? 1 : 0;
@@ -3733,7 +3606,6 @@ yy275:
 
 	return T_START_HEREDOC;
 }
-#line 3737 "Zend/zend_language_scanner.c"
 yy276:
 		YYDEBUG(276, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3773,31 +3645,25 @@ yy279:
 		++YYCURSOR;
 		YYDEBUG(281, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1185 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_NOT_IDENTICAL;
 }
-#line 3781 "Zend/zend_language_scanner.c"
 yy282:
 		YYDEBUG(282, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(283, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1205 "Zend/zend_language_scanner.l"
 		{
 	return T_PLUS_EQUAL;
 }
-#line 3791 "Zend/zend_language_scanner.c"
 yy284:
 		YYDEBUG(284, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(285, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1173 "Zend/zend_language_scanner.l"
 		{
 	return T_INC;
 }
-#line 3801 "Zend/zend_language_scanner.c"
 yy286:
 		YYDEBUG(286, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3816,42 +3682,34 @@ yy288:
 		}
 		YYDEBUG(289, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1165 "Zend/zend_language_scanner.l"
 		{
 	return T_LIST;
 }
-#line 3824 "Zend/zend_language_scanner.c"
 yy290:
 		YYDEBUG(290, *YYCURSOR);
 		++YYCURSOR;
 		if ((yych = *YYCURSOR) == '=') goto yy294;
 		YYDEBUG(291, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1189 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_EQUAL;
 }
-#line 3835 "Zend/zend_language_scanner.c"
 yy292:
 		YYDEBUG(292, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(293, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1161 "Zend/zend_language_scanner.l"
 		{
 	return T_DOUBLE_ARROW;
 }
-#line 3845 "Zend/zend_language_scanner.c"
 yy294:
 		YYDEBUG(294, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(295, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1181 "Zend/zend_language_scanner.l"
 		{
 	return T_IS_IDENTICAL;
 }
-#line 3855 "Zend/zend_language_scanner.c"
 yy296:
 		YYDEBUG(296, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -3973,7 +3831,6 @@ yy311:
 		}
 		YYDEBUG(314, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1485 "Zend/zend_language_scanner.l"
 		{
 	if (CG(current_namespace)) {
 		*zendlval = *CG(current_namespace);
@@ -3983,7 +3840,6 @@ yy311:
 	}
 	return T_NS_C;
 }
-#line 3987 "Zend/zend_language_scanner.c"
 yy315:
 		YYDEBUG(315, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4003,7 +3859,6 @@ yy316:
 		}
 		YYDEBUG(319, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1458 "Zend/zend_language_scanner.l"
 		{
 	char *filename = zend_get_compiled_filename(TSRMLS_C);
 	const size_t filename_len = strlen(filename);
@@ -4030,7 +3885,6 @@ yy316:
 	zendlval->type = IS_STRING;
 	return T_DIR;
 }
-#line 4034 "Zend/zend_language_scanner.c"
 yy320:
 		YYDEBUG(320, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4055,13 +3909,11 @@ yy322:
 		}
 		YYDEBUG(325, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1440 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.lval = CG(zend_lineno);
 	zendlval->type = IS_LONG;
 	return T_LINE;
 }
-#line 4065 "Zend/zend_language_scanner.c"
 yy326:
 		YYDEBUG(326, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4096,7 +3948,6 @@ yy330:
 		}
 		YYDEBUG(333, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1419 "Zend/zend_language_scanner.l"
 		{
 	char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL;
 	char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL;
@@ -4117,7 +3968,6 @@ yy330:
 	zendlval->type = IS_STRING;
 	return T_METHOD_C;
 }
-#line 4121 "Zend/zend_language_scanner.c"
 yy334:
 		YYDEBUG(334, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4168,7 +4018,6 @@ yy341:
 		}
 		YYDEBUG(344, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1403 "Zend/zend_language_scanner.l"
 		{
 	char *func_name = NULL;
 
@@ -4184,7 +4033,6 @@ yy341:
 	zendlval->type = IS_STRING;
 	return T_FUNC_C;
 }
-#line 4188 "Zend/zend_language_scanner.c"
 yy345:
 		YYDEBUG(345, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4204,7 +4052,6 @@ yy346:
 		}
 		YYDEBUG(349, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1446 "Zend/zend_language_scanner.l"
 		{
 	char *filename = zend_get_compiled_filename(TSRMLS_C);
 
@@ -4216,7 +4063,6 @@ yy346:
 	zendlval->type = IS_STRING;
 	return T_FILE;
 }
-#line 4220 "Zend/zend_language_scanner.c"
 yy350:
 		YYDEBUG(350, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4246,7 +4092,6 @@ yy353:
 		}
 		YYDEBUG(356, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1387 "Zend/zend_language_scanner.l"
 		{
 	char *class_name = NULL;
 
@@ -4262,7 +4107,6 @@ yy353:
 	zendlval->type = IS_STRING;
 	return T_CLASS_C;
 }
-#line 4266 "Zend/zend_language_scanner.c"
 yy357:
 		YYDEBUG(357, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4324,11 +4168,9 @@ yy368:
 		}
 		YYDEBUG(369, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1129 "Zend/zend_language_scanner.l"
 		{
 	return T_HALT_COMPILER;
 }
-#line 4332 "Zend/zend_language_scanner.c"
 yy370:
 		YYDEBUG(370, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4348,11 +4190,9 @@ yy372:
 		}
 		YYDEBUG(373, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1113 "Zend/zend_language_scanner.l"
 		{
 	return T_USE;
 }
-#line 4356 "Zend/zend_language_scanner.c"
 yy374:
 		YYDEBUG(374, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4371,11 +4211,9 @@ yy376:
 		}
 		YYDEBUG(377, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1157 "Zend/zend_language_scanner.l"
 		{
 	return T_UNSET;
 }
-#line 4379 "Zend/zend_language_scanner.c"
 yy378:
 		YYDEBUG(378, *YYCURSOR);
 		++YYCURSOR;
@@ -4547,11 +4385,9 @@ yy393:
 		++YYCURSOR;
 		YYDEBUG(395, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1057 "Zend/zend_language_scanner.l"
 		{
 	return T_INT_CAST;
 }
-#line 4555 "Zend/zend_language_scanner.c"
 yy396:
 		YYDEBUG(396, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4595,11 +4431,9 @@ yy401:
 		++YYCURSOR;
 		YYDEBUG(404, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1061 "Zend/zend_language_scanner.l"
 		{
 	return T_DOUBLE_CAST;
 }
-#line 4603 "Zend/zend_language_scanner.c"
 yy405:
 		YYDEBUG(405, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4669,11 +4503,9 @@ yy415:
 		++YYCURSOR;
 		YYDEBUG(418, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1065 "Zend/zend_language_scanner.l"
 		{
 	return T_STRING_CAST;
 }
-#line 4677 "Zend/zend_language_scanner.c"
 yy419:
 		YYDEBUG(419, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4706,11 +4538,9 @@ yy422:
 		++YYCURSOR;
 		YYDEBUG(425, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1073 "Zend/zend_language_scanner.l"
 		{
 	return T_ARRAY_CAST;
 }
-#line 4714 "Zend/zend_language_scanner.c"
 yy426:
 		YYDEBUG(426, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4748,11 +4578,9 @@ yy430:
 		++YYCURSOR;
 		YYDEBUG(433, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1077 "Zend/zend_language_scanner.l"
 		{
 	return T_OBJECT_CAST;
 }
-#line 4756 "Zend/zend_language_scanner.c"
 yy434:
 		YYDEBUG(434, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4793,11 +4621,9 @@ yy439:
 		++YYCURSOR;
 		YYDEBUG(441, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1081 "Zend/zend_language_scanner.l"
 		{
 	return T_BOOL_CAST;
 }
-#line 4801 "Zend/zend_language_scanner.c"
 yy442:
 		YYDEBUG(442, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4841,11 +4667,9 @@ yy447:
 		++YYCURSOR;
 		YYDEBUG(450, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1069 "Zend/zend_language_scanner.l"
 		{
 	return T_STRING_CAST;
 }
-#line 4849 "Zend/zend_language_scanner.c"
 yy451:
 		YYDEBUG(451, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4878,11 +4702,9 @@ yy454:
 		++YYCURSOR;
 		YYDEBUG(457, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1085 "Zend/zend_language_scanner.l"
 		{
 	return T_UNSET_CAST;
 }
-#line 4886 "Zend/zend_language_scanner.c"
 yy458:
 		YYDEBUG(458, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4896,11 +4718,9 @@ yy459:
 		}
 		YYDEBUG(460, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1053 "Zend/zend_language_scanner.l"
 		{
 	return T_VAR;
 }
-#line 4904 "Zend/zend_language_scanner.c"
 yy461:
 		YYDEBUG(461, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4920,11 +4740,9 @@ yy463:
 		}
 		YYDEBUG(464, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1045 "Zend/zend_language_scanner.l"
 		{
 	return T_NEW;
 }
-#line 4928 "Zend/zend_language_scanner.c"
 yy465:
 		YYDEBUG(465, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -4963,21 +4781,17 @@ yy471:
 		}
 		YYDEBUG(472, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1109 "Zend/zend_language_scanner.l"
 		{
 	return T_NAMESPACE;
 }
-#line 4971 "Zend/zend_language_scanner.c"
 yy473:
 		YYDEBUG(473, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(474, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1037 "Zend/zend_language_scanner.l"
 		{
 	return T_PAAMAYIM_NEKUDOTAYIM;
 }
-#line 4981 "Zend/zend_language_scanner.c"
 yy475:
 		YYDEBUG(475, *YYCURSOR);
 		++YYCURSOR;
@@ -4999,32 +4813,26 @@ yy477:
 		++YYCURSOR;
 		YYDEBUG(478, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1209 "Zend/zend_language_scanner.l"
 		{
 	return T_MINUS_EQUAL;
 }
-#line 5007 "Zend/zend_language_scanner.c"
 yy479:
 		YYDEBUG(479, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(480, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1177 "Zend/zend_language_scanner.l"
 		{
 	return T_DEC;
 }
-#line 5017 "Zend/zend_language_scanner.c"
 yy481:
 		YYDEBUG(481, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(482, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1007 "Zend/zend_language_scanner.l"
 		{
 	yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
 	return T_OBJECT_OPERATOR;
 }
-#line 5028 "Zend/zend_language_scanner.c"
 yy483:
 		YYDEBUG(483, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5069,11 +4877,9 @@ yy488:
 		}
 		YYDEBUG(489, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1153 "Zend/zend_language_scanner.l"
 		{
 	return T_PUBLIC;
 }
-#line 5077 "Zend/zend_language_scanner.c"
 yy490:
 		YYDEBUG(490, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5128,11 +4934,9 @@ yy497:
 		}
 		YYDEBUG(498, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1149 "Zend/zend_language_scanner.l"
 		{
 	return T_PROTECTED;
 }
-#line 5136 "Zend/zend_language_scanner.c"
 yy499:
 		YYDEBUG(499, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5162,11 +4966,9 @@ yy503:
 		}
 		YYDEBUG(504, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1145 "Zend/zend_language_scanner.l"
 		{
 	return T_PRIVATE;
 }
-#line 5170 "Zend/zend_language_scanner.c"
 yy505:
 		YYDEBUG(505, *YYCURSOR);
 		++YYCURSOR;
@@ -5175,11 +4977,9 @@ yy505:
 		}
 		YYDEBUG(506, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 987 "Zend/zend_language_scanner.l"
 		{
 	return T_PRINT;
 }
-#line 5183 "Zend/zend_language_scanner.c"
 yy507:
 		YYDEBUG(507, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5204,11 +5004,9 @@ yy510:
 		}
 		YYDEBUG(511, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 979 "Zend/zend_language_scanner.l"
 		{
 	return T_GOTO;
 }
-#line 5212 "Zend/zend_language_scanner.c"
 yy512:
 		YYDEBUG(512, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5232,11 +5030,9 @@ yy515:
 		}
 		YYDEBUG(516, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1117 "Zend/zend_language_scanner.l"
 		{
 	return T_GLOBAL;
 }
-#line 5240 "Zend/zend_language_scanner.c"
 yy517:
 		YYDEBUG(517, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5273,11 +5069,9 @@ yy523:
 		}
 		YYDEBUG(524, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 971 "Zend/zend_language_scanner.l"
 		{
 	return T_BREAK;
 }
-#line 5281 "Zend/zend_language_scanner.c"
 yy525:
 		YYDEBUG(525, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5317,11 +5111,9 @@ yy531:
 		}
 		YYDEBUG(532, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 955 "Zend/zend_language_scanner.l"
 		{
 	return T_SWITCH;
 }
-#line 5325 "Zend/zend_language_scanner.c"
 yy533:
 		YYDEBUG(533, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5345,11 +5137,9 @@ yy536:
 		}
 		YYDEBUG(537, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1133 "Zend/zend_language_scanner.l"
 		{
 	return T_STATIC;
 }
-#line 5353 "Zend/zend_language_scanner.c"
 yy538:
 		YYDEBUG(538, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5376,11 +5166,9 @@ yy541:
 		}
 		YYDEBUG(542, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 951 "Zend/zend_language_scanner.l"
 		{
 	return T_AS;
 }
-#line 5384 "Zend/zend_language_scanner.c"
 yy543:
 		YYDEBUG(543, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5399,11 +5187,9 @@ yy545:
 		}
 		YYDEBUG(546, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1169 "Zend/zend_language_scanner.l"
 		{
 	return T_ARRAY;
 }
-#line 5407 "Zend/zend_language_scanner.c"
 yy547:
 		YYDEBUG(547, *YYCURSOR);
 		++YYCURSOR;
@@ -5412,11 +5198,9 @@ yy547:
 		}
 		YYDEBUG(548, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1261 "Zend/zend_language_scanner.l"
 		{
 	return T_LOGICAL_AND;
 }
-#line 5420 "Zend/zend_language_scanner.c"
 yy549:
 		YYDEBUG(549, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5450,11 +5234,9 @@ yy554:
 		}
 		YYDEBUG(555, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1137 "Zend/zend_language_scanner.l"
 		{
 	return T_ABSTRACT;
 }
-#line 5458 "Zend/zend_language_scanner.c"
 yy556:
 		YYDEBUG(556, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5478,11 +5260,9 @@ yy559:
 		}
 		YYDEBUG(560, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 911 "Zend/zend_language_scanner.l"
 		{
 	return T_WHILE;
 }
-#line 5486 "Zend/zend_language_scanner.c"
 yy561:
 		YYDEBUG(561, *YYCURSOR);
 		++YYCURSOR;
@@ -5491,11 +5271,9 @@ yy561:
 		}
 		YYDEBUG(562, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 895 "Zend/zend_language_scanner.l"
 		{
 	return T_IF;
 }
-#line 5499 "Zend/zend_language_scanner.c"
 yy563:
 		YYDEBUG(563, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5547,11 +5325,9 @@ yy568:
 		}
 		YYDEBUG(569, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1121 "Zend/zend_language_scanner.l"
 		{
 	return T_ISSET;
 }
-#line 5555 "Zend/zend_language_scanner.c"
 yy570:
 		YYDEBUG(570, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5605,11 +5381,9 @@ yy576:
 yy577:
 		YYDEBUG(577, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1093 "Zend/zend_language_scanner.l"
 		{
 	return T_INCLUDE;
 }
-#line 5613 "Zend/zend_language_scanner.c"
 yy578:
 		YYDEBUG(578, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5638,11 +5412,9 @@ yy582:
 		}
 		YYDEBUG(583, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1097 "Zend/zend_language_scanner.l"
 		{
 	return T_INCLUDE_ONCE;
 }
-#line 5646 "Zend/zend_language_scanner.c"
 yy584:
 		YYDEBUG(584, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5676,11 +5448,9 @@ yy589:
 		}
 		YYDEBUG(590, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 995 "Zend/zend_language_scanner.l"
 		{
 	return T_INTERFACE;
 }
-#line 5684 "Zend/zend_language_scanner.c"
 yy591:
 		YYDEBUG(591, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5719,11 +5489,9 @@ yy597:
 		}
 		YYDEBUG(598, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 947 "Zend/zend_language_scanner.l"
 		{
 	return T_INSTANCEOF;
 }
-#line 5727 "Zend/zend_language_scanner.c"
 yy599:
 		YYDEBUG(599, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5767,11 +5535,9 @@ yy606:
 		}
 		YYDEBUG(607, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1003 "Zend/zend_language_scanner.l"
 		{
 	return T_IMPLEMENTS;
 }
-#line 5775 "Zend/zend_language_scanner.c"
 yy608:
 		YYDEBUG(608, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5791,11 +5557,9 @@ yy610:
 		}
 		YYDEBUG(611, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 883 "Zend/zend_language_scanner.l"
 		{
 	return T_TRY;
 }
-#line 5799 "Zend/zend_language_scanner.c"
 yy612:
 		YYDEBUG(612, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5814,11 +5578,9 @@ yy614:
 		}
 		YYDEBUG(615, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 891 "Zend/zend_language_scanner.l"
 		{
 	return T_THROW;
 }
-#line 5822 "Zend/zend_language_scanner.c"
 yy616:
 		YYDEBUG(616, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5879,11 +5641,9 @@ yy622:
 yy623:
 		YYDEBUG(623, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1101 "Zend/zend_language_scanner.l"
 		{
 	return T_REQUIRE;
 }
-#line 5887 "Zend/zend_language_scanner.c"
 yy624:
 		YYDEBUG(624, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5912,11 +5672,9 @@ yy628:
 		}
 		YYDEBUG(629, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1105 "Zend/zend_language_scanner.l"
 		{
 	return T_REQUIRE_ONCE;
 }
-#line 5920 "Zend/zend_language_scanner.c"
 yy630:
 		YYDEBUG(630, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -5935,11 +5693,9 @@ yy632:
 		}
 		YYDEBUG(633, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 879 "Zend/zend_language_scanner.l"
 		{
 	return T_RETURN;
 }
-#line 5943 "Zend/zend_language_scanner.c"
 yy634:
 		YYDEBUG(634, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6020,11 +5776,9 @@ yy643:
 		}
 		YYDEBUG(644, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 975 "Zend/zend_language_scanner.l"
 		{
 	return T_CONTINUE;
 }
-#line 6028 "Zend/zend_language_scanner.c"
 yy645:
 		YYDEBUG(645, *YYCURSOR);
 		++YYCURSOR;
@@ -6033,11 +5787,9 @@ yy645:
 		}
 		YYDEBUG(646, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 875 "Zend/zend_language_scanner.l"
 		{
 	return T_CONST;
 }
-#line 6041 "Zend/zend_language_scanner.c"
 yy647:
 		YYDEBUG(647, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6062,11 +5814,9 @@ yy650:
 		}
 		YYDEBUG(651, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1049 "Zend/zend_language_scanner.l"
 		{
 	return T_CLONE;
 }
-#line 6070 "Zend/zend_language_scanner.c"
 yy652:
 		YYDEBUG(652, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6080,11 +5830,9 @@ yy653:
 		}
 		YYDEBUG(654, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 991 "Zend/zend_language_scanner.l"
 		{
 	return T_CLASS;
 }
-#line 6088 "Zend/zend_language_scanner.c"
 yy655:
 		YYDEBUG(655, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6104,11 +5852,9 @@ yy657:
 		}
 		YYDEBUG(658, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 963 "Zend/zend_language_scanner.l"
 		{
 	return T_CASE;
 }
-#line 6112 "Zend/zend_language_scanner.c"
 yy659:
 		YYDEBUG(659, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6122,11 +5868,9 @@ yy660:
 		}
 		YYDEBUG(661, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 887 "Zend/zend_language_scanner.l"
 		{
 	return T_CATCH;
 }
-#line 6130 "Zend/zend_language_scanner.c"
 yy662:
 		YYDEBUG(662, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6177,11 +5921,9 @@ yy670:
 		}
 		YYDEBUG(671, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 871 "Zend/zend_language_scanner.l"
 		{
 	return T_FUNCTION;
 }
-#line 6185 "Zend/zend_language_scanner.c"
 yy672:
 		YYDEBUG(672, *YYCURSOR);
 		++YYCURSOR;
@@ -6205,11 +5947,9 @@ yy672:
 yy673:
 		YYDEBUG(673, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 923 "Zend/zend_language_scanner.l"
 		{
 	return T_FOR;
 }
-#line 6213 "Zend/zend_language_scanner.c"
 yy674:
 		YYDEBUG(674, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6233,11 +5973,9 @@ yy677:
 		}
 		YYDEBUG(678, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 931 "Zend/zend_language_scanner.l"
 		{
 	return T_FOREACH;
 }
-#line 6241 "Zend/zend_language_scanner.c"
 yy679:
 		YYDEBUG(679, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6256,11 +5994,9 @@ yy681:
 		}
 		YYDEBUG(682, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1141 "Zend/zend_language_scanner.l"
 		{
 	return T_FINAL;
 }
-#line 6264 "Zend/zend_language_scanner.c"
 yy683:
 		YYDEBUG(683, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6291,11 +6027,9 @@ yy685:
 		}
 		YYDEBUG(686, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 919 "Zend/zend_language_scanner.l"
 		{
 	return T_DO;
 }
-#line 6299 "Zend/zend_language_scanner.c"
 yy687:
 		YYDEBUG(687, *YYCURSOR);
 		++YYCURSOR;
@@ -6304,11 +6038,9 @@ yy687:
 		}
 		YYDEBUG(688, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 867 "Zend/zend_language_scanner.l"
 		{
 	return T_EXIT;
 }
-#line 6312 "Zend/zend_language_scanner.c"
 yy689:
 		YYDEBUG(689, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6343,11 +6075,9 @@ yy694:
 		}
 		YYDEBUG(695, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 967 "Zend/zend_language_scanner.l"
 		{
 	return T_DEFAULT;
 }
-#line 6351 "Zend/zend_language_scanner.c"
 yy696:
 		YYDEBUG(696, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6371,11 +6101,9 @@ yy699:
 		}
 		YYDEBUG(700, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 939 "Zend/zend_language_scanner.l"
 		{
 	return T_DECLARE;
 }
-#line 6379 "Zend/zend_language_scanner.c"
 yy701:
 		YYDEBUG(701, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6455,11 +6183,9 @@ yy712:
 		}
 		YYDEBUG(713, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 999 "Zend/zend_language_scanner.l"
 		{
 	return T_EXTENDS;
 }
-#line 6463 "Zend/zend_language_scanner.c"
 yy714:
 		YYDEBUG(714, *YYCURSOR);
 		++YYCURSOR;
@@ -6468,11 +6194,9 @@ yy714:
 		}
 		YYDEBUG(715, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 863 "Zend/zend_language_scanner.l"
 		{
 	return T_EXIT;
 }
-#line 6476 "Zend/zend_language_scanner.c"
 yy716:
 		YYDEBUG(716, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6486,11 +6210,9 @@ yy717:
 		}
 		YYDEBUG(718, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1089 "Zend/zend_language_scanner.l"
 		{
 	return T_EVAL;
 }
-#line 6494 "Zend/zend_language_scanner.c"
 yy719:
 		YYDEBUG(719, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6560,11 +6282,9 @@ yy728:
 		}
 		YYDEBUG(729, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 915 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDWHILE;
 }
-#line 6568 "Zend/zend_language_scanner.c"
 yy730:
 		YYDEBUG(730, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6593,11 +6313,9 @@ yy734:
 		}
 		YYDEBUG(735, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 959 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDSWITCH;
 }
-#line 6601 "Zend/zend_language_scanner.c"
 yy736:
 		YYDEBUG(736, *YYCURSOR);
 		++YYCURSOR;
@@ -6606,11 +6324,9 @@ yy736:
 		}
 		YYDEBUG(737, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 903 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDIF;
 }
-#line 6614 "Zend/zend_language_scanner.c"
 yy738:
 		YYDEBUG(738, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6639,11 +6355,9 @@ yy739:
 yy740:
 		YYDEBUG(740, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 927 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDFOR;
 }
-#line 6647 "Zend/zend_language_scanner.c"
 yy741:
 		YYDEBUG(741, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6667,11 +6381,9 @@ yy744:
 		}
 		YYDEBUG(745, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 935 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDFOREACH;
 }
-#line 6675 "Zend/zend_language_scanner.c"
 yy746:
 		YYDEBUG(746, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6705,11 +6417,9 @@ yy751:
 		}
 		YYDEBUG(752, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 943 "Zend/zend_language_scanner.l"
 		{
 	return T_ENDDECLARE;
 }
-#line 6713 "Zend/zend_language_scanner.c"
 yy753:
 		YYDEBUG(753, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6728,11 +6438,9 @@ yy755:
 		}
 		YYDEBUG(756, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1125 "Zend/zend_language_scanner.l"
 		{
 	return T_EMPTY;
 }
-#line 6736 "Zend/zend_language_scanner.c"
 yy757:
 		YYDEBUG(757, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6761,11 +6469,9 @@ yy758:
 yy759:
 		YYDEBUG(759, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 907 "Zend/zend_language_scanner.l"
 		{
 	return T_ELSE;
 }
-#line 6769 "Zend/zend_language_scanner.c"
 yy760:
 		YYDEBUG(760, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6779,11 +6485,9 @@ yy761:
 		}
 		YYDEBUG(762, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 899 "Zend/zend_language_scanner.l"
 		{
 	return T_ELSEIF;
 }
-#line 6787 "Zend/zend_language_scanner.c"
 yy763:
 		YYDEBUG(763, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6797,11 +6501,9 @@ yy764:
 		}
 		YYDEBUG(765, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 983 "Zend/zend_language_scanner.l"
 		{
 	return T_ECHO;
 }
-#line 6805 "Zend/zend_language_scanner.c"
 	}
 /* *********************************** */
 yyc_ST_LOOKING_FOR_PROPERTY:
@@ -6874,7 +6576,6 @@ yy768:
 yy769:
 		YYDEBUG(769, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1012 "Zend/zend_language_scanner.l"
 		{
 	zendlval->value.str.val = yytext; /* no copying - intentional */
 	zendlval->value.str.len = yyleng;
@@ -6882,7 +6583,6 @@ yy769:
 	HANDLE_NEWLINES(yytext, yyleng);
 	return T_WHITESPACE;
 }
-#line 6886 "Zend/zend_language_scanner.c"
 yy770:
 		YYDEBUG(770, *YYCURSOR);
 		++YYCURSOR;
@@ -6890,13 +6590,11 @@ yy770:
 yy771:
 		YYDEBUG(771, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1031 "Zend/zend_language_scanner.l"
 		{
 	yyless(0);
 	yy_pop_state(TSRMLS_C);
 	goto restart;
 }
-#line 6900 "Zend/zend_language_scanner.c"
 yy772:
 		YYDEBUG(772, *YYCURSOR);
 		++YYCURSOR;
@@ -6905,14 +6603,12 @@ yy772:
 yy773:
 		YYDEBUG(773, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1024 "Zend/zend_language_scanner.l"
 		{
 	yy_pop_state(TSRMLS_C);
 	zend_copy_value(zendlval, yytext, yyleng);
 	zendlval->type = IS_STRING;
 	return T_STRING;
 }
-#line 6916 "Zend/zend_language_scanner.c"
 yy774:
 		YYDEBUG(774, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -6933,11 +6629,9 @@ yy777:
 		++YYCURSOR;
 		YYDEBUG(778, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1020 "Zend/zend_language_scanner.l"
 		{
 	return T_OBJECT_OPERATOR;
 }
-#line 6941 "Zend/zend_language_scanner.c"
 yy779:
 		YYDEBUG(779, *YYCURSOR);
 		++YYCURSOR;
@@ -7007,7 +6701,6 @@ yy783:
 yy784:
 		YYDEBUG(784, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1303 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, yytext, yyleng);
 	zendlval->type = IS_STRING;
@@ -7015,20 +6708,17 @@ yy784:
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	return T_STRING_VARNAME;
 }
-#line 7019 "Zend/zend_language_scanner.c"
 yy785:
 		YYDEBUG(785, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(786, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1312 "Zend/zend_language_scanner.l"
 		{
 	yyless(0);
 	yy_pop_state(TSRMLS_C);
 	yy_push_state(ST_IN_SCRIPTING TSRMLS_CC);
 	goto restart;
 }
-#line 7032 "Zend/zend_language_scanner.c"
 yy787:
 		YYDEBUG(787, *YYCURSOR);
 		++YYCURSOR;
@@ -7050,7 +6740,6 @@ yyc_ST_NOWDOC:
 	++YYCURSOR;
 	YYDEBUG(792, *YYCURSOR);
 	yyleng = YYCURSOR - SCNG(yy_text);
-#line 2146 "Zend/zend_language_scanner.l"
 	{
 	int newline = 0;
 
@@ -7105,7 +6794,6 @@ nowdoc_scan_done:
 	HANDLE_NEWLINES(yytext, yyleng - newline);
 	return T_ENCAPSED_AND_WHITESPACE;
 }
-#line 7109 "Zend/zend_language_scanner.c"
 /* *********************************** */
 yyc_ST_VAR_OFFSET:
 	{
@@ -7205,7 +6893,6 @@ yy795:
 yy796:
 		YYDEBUG(796, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1362 "Zend/zend_language_scanner.l"
 		{ /* Offset could be treated as a long */
 	if (yyleng < MAX_LENGTH_OF_LONG - 1 || (yyleng == MAX_LENGTH_OF_LONG - 1 && strcmp(yytext, long_min_digits) < 0)) {
 		zendlval->value.lval = strtol(yytext, NULL, 10);
@@ -7217,7 +6904,6 @@ yy796:
 	}
 	return T_NUM_STRING;
 }
-#line 7221 "Zend/zend_language_scanner.c"
 yy797:
 		YYDEBUG(797, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -7237,23 +6923,19 @@ yy798:
 yy799:
 		YYDEBUG(799, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1672 "Zend/zend_language_scanner.l"
 		{
 	/* Only '[' can be valid, but returning other tokens will allow a more explicit parse error */
 	return yytext[0];
 }
-#line 7246 "Zend/zend_language_scanner.c"
 yy800:
 		YYDEBUG(800, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(801, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1667 "Zend/zend_language_scanner.l"
 		{
 	yy_pop_state(TSRMLS_C);
 	return ']';
 }
-#line 7257 "Zend/zend_language_scanner.c"
 yy802:
 		YYDEBUG(802, *YYCURSOR);
 		yych = *++YYCURSOR;
@@ -7263,14 +6945,12 @@ yy803:
 		++YYCURSOR;
 		YYDEBUG(804, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1677 "Zend/zend_language_scanner.l"
 		{
 	/* Invalid rule to return a more explicit parse error with proper line number */
 	yyless(0);
 	yy_pop_state(TSRMLS_C);
 	return T_ENCAPSED_AND_WHITESPACE;
 }
-#line 7274 "Zend/zend_language_scanner.c"
 yy805:
 		YYDEBUG(805, *YYCURSOR);
 		++YYCURSOR;
@@ -7279,19 +6959,16 @@ yy805:
 yy806:
 		YYDEBUG(806, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1684 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, yytext, yyleng);
 	zendlval->type = IS_STRING;
 	return T_STRING;
 }
-#line 7289 "Zend/zend_language_scanner.c"
 yy807:
 		YYDEBUG(807, *YYCURSOR);
 		++YYCURSOR;
 		YYDEBUG(808, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 2202 "Zend/zend_language_scanner.l"
 		{
 	if (YYCURSOR > YYLIMIT) {
 		return 0;
@@ -7300,7 +6977,6 @@ yy807:
 	zend_error(E_COMPILE_WARNING,"Unexpected character in input:  '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
 	goto restart;
 }
-#line 7304 "Zend/zend_language_scanner.c"
 yy809:
 		YYDEBUG(809, *YYCURSOR);
 		++YYCURSOR;
@@ -7336,13 +7012,11 @@ yy811:
 yy813:
 		YYDEBUG(813, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1661 "Zend/zend_language_scanner.l"
 		{
 	zend_copy_value(zendlval, (yytext+1), (yyleng-1));
 	zendlval->type = IS_STRING;
 	return T_VARIABLE;
 }
-#line 7346 "Zend/zend_language_scanner.c"
 yy814:
 		YYDEBUG(814, *YYCURSOR);
 		++YYCURSOR;
@@ -7374,14 +7048,12 @@ yy818:
 yy820:
 		YYDEBUG(820, *YYCURSOR);
 		yyleng = YYCURSOR - SCNG(yy_text);
-#line 1374 "Zend/zend_language_scanner.l"
 		{ /* Offset must be treated as a string */
 	zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
 	zendlval->value.str.len = yyleng;
 	zendlval->type = IS_STRING;
 	return T_NUM_STRING;
 }
-#line 7385 "Zend/zend_language_scanner.c"
 yy821:
 		YYDEBUG(821, *YYCURSOR);
 		++YYCURSOR;
@@ -7394,6 +7066,5 @@ yy821:
 		goto yy820;
 	}
 }
-#line 2211 "Zend/zend_language_scanner.l"
 
 }
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 3be8ed1..5252a65 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.l 300871 2010-06-30 02:45:10Z felipe $ */
+/* $Id: zend_language_scanner.l 305464 2010-11-17 16:46:19Z pajoye $ */
 
 #if 0
 # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
@@ -284,6 +284,10 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
 			SCNG(script_filtered_size) = SCNG(script_org_size);
 		} else {
 			SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
+			if (SCNG(script_filtered) == NULL) {
+				zend_error_noreturn(E_COMPILE_ERROR, "Could not convert the script from the detected "
+						"encoding \"%s\" to a compatible encoding", LANG_SCNG(script_encoding)->name);
+			}
 		}
 		SCNG(yy_start) = SCNG(script_filtered) - offset;
 		yy_scan_buffer((char *)SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);
diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h
index 55b23d6..17956ff 100644
--- a/Zend/zend_language_scanner_defs.h
+++ b/Zend/zend_language_scanner_defs.h
@@ -1,5 +1,4 @@
-/* Generated by re2c 0.13.5 on Tue Jun 29 08:18:52 2010 */
-#line 3 "Zend/zend_language_scanner_defs.h"
+/* Generated by re2c 0.13.5 on Wed Jan  5 17:41:40 2011 */
 
 enum YYCONDTYPE {
 	yycST_IN_SCRIPTING,
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index c7f5fbc..bf42923 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c 300407 2010-06-12 15:30:21Z felipe $ */
+/* $Id: zend_object_handlers.c 305043 2010-11-03 01:35:26Z felipe $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -340,13 +340,16 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) /*
 	property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__get != NULL) TSRMLS_CC);
 
 	if (!property_info || zend_hash_quick_find(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval) == FAILURE) {
-		zend_guard *guard;
+		zend_guard *guard = NULL;
 
 		if (zobj->ce->__get &&
 		    zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS &&
 		    !guard->in_get) {
 			/* have getter - try with it! */
 			Z_ADDREF_P(object);
+			if (PZVAL_IS_REF(object)) {
+				SEPARATE_ZVAL(&object);
+			}
 			guard->in_get = 1; /* prevent circular getting */
 			rv = zend_std_call_getter(object, member TSRMLS_CC);
 			guard->in_get = 0;
@@ -373,6 +376,15 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) /*
 			}
 			zval_ptr_dtor(&object);
 		} else {
+			if (zobj->ce->__get && guard && guard->in_get == 1) {
+				if (Z_STRVAL_P(member)[0] == '\0') {
+					if (Z_STRLEN_P(member) == 0) {
+						zend_error(E_ERROR, "Cannot access empty property");
+					} else {
+						zend_error(E_ERROR, "Cannot access property started with '\\0'");
+					}
+				}
+			}
 			if (!silent) {
 				zend_error(E_NOTICE,"Undefined property: %s::$%s", zobj->ce->name, Z_STRVAL_P(member));
 			}
@@ -436,22 +448,22 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM
 			}
 		}
 	} else {
-		int setter_done = 0;
-		zend_guard *guard;
+		zend_guard *guard = NULL;
 
 		if (zobj->ce->__set &&
 		    zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS &&
 		    !guard->in_set) {
 			Z_ADDREF_P(object);
+			if (PZVAL_IS_REF(object)) {
+				SEPARATE_ZVAL(&object);
+			}
 			guard->in_set = 1; /* prevent circular setting */
 			if (zend_std_call_setter(object, member, value TSRMLS_CC) != SUCCESS) {
 				/* for now, just ignore it - __set should take care of warnings, etc. */
 			}
-			setter_done = 1;
 			guard->in_set = 0;
 			zval_ptr_dtor(&object);
-		}
-		if (!setter_done && property_info) {
+		} else if (property_info) {
 			zval **foo;
 
 			/* if we assign referenced variable, we should separate it */
@@ -460,6 +472,14 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM
 				SEPARATE_ZVAL(&value);
 			}
 			zend_hash_quick_update(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, &value, sizeof(zval *), (void **) &foo);
+		} else if (zobj->ce->__set && guard && guard->in_set == 1) {
+			if (Z_STRVAL_P(member)[0] == '\0') {
+				if (Z_STRLEN_P(member) == 0) {
+					zend_error(E_ERROR, "Cannot access empty property");
+				} else {
+					zend_error(E_ERROR, "Cannot access property started with '\\0'");
+				}
+			}
 		}
 	}
 
@@ -619,17 +639,28 @@ static void zend_std_unset_property(zval *object, zval *member TSRMLS_DC) /* {{{
 	property_info = zend_get_property_info(zobj->ce, member, (zobj->ce->__unset != NULL) TSRMLS_CC);
 
 	if (!property_info || zend_hash_quick_del(zobj->properties, property_info->name, property_info->name_length+1, property_info->h) == FAILURE) {
-		zend_guard *guard;
+		zend_guard *guard = NULL;
 
 		if (zobj->ce->__unset &&
 		    zend_get_property_guard(zobj, property_info, member, &guard) == SUCCESS &&
 		    !guard->in_unset) {
 			/* have unseter - try with it! */
 			Z_ADDREF_P(object);
+			if (PZVAL_IS_REF(object)) {
+				SEPARATE_ZVAL(&object);
+			}
 			guard->in_unset = 1; /* prevent circular unsetting */
 			zend_std_call_unsetter(object, member TSRMLS_CC);
 			guard->in_unset = 0;
 			zval_ptr_dtor(&object);
+		} else if (zobj->ce->__unset && guard && guard->in_unset == 1) {
+			if (Z_STRVAL_P(member)[0] == '\0') {
+				if (Z_STRLEN_P(member) == 0) {
+					zend_error(E_ERROR, "Cannot access empty property");
+				} else {
+					zend_error(E_ERROR, "Cannot access property started with '\\0'");
+				}
+			}
 		}
 	}
 
@@ -953,13 +984,13 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *f
 	if (!fbc && zend_hash_find(&ce->function_table, lc_function_name, function_name_strlen+1, (void **) &fbc)==FAILURE) {
 		efree(lc_function_name);
 
-		if (ce->__callstatic) {
-			return zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
-		} else if (ce->__call &&
+		if (ce->__call &&
 		    EG(This) &&
 		    Z_OBJ_HT_P(EG(This))->get_class_entry &&
 		    instanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) {
 			return zend_get_user_call_function(ce, function_name_strval, function_name_strlen);
+		} else if (ce->__callstatic) {
+			return zend_get_user_callstatic_function(ce, function_name_strval, function_name_strlen);
 		} else {
 	   		return NULL;
 		}
@@ -1144,6 +1175,9 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists
 
 			/* have issetter - try with it! */
 			Z_ADDREF_P(object);
+			if (PZVAL_IS_REF(object)) {
+				SEPARATE_ZVAL(&object);
+			}
 			guard->in_isset = 1; /* prevent circular getting */
 			rv = zend_std_call_issetter(object, member TSRMLS_CC);
 			if (rv) {
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index da36efc..bf25114 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_objects.c 299254 2010-05-11 16:09:43Z dmitry $ */
+/* $Id: zend_objects.c 302323 2010-08-16 09:20:46Z dmitry $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -106,15 +106,13 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
 				zend_error(E_ERROR, "Attempt to destruct pending exception");
 			} else {
 				old_exception = EG(exception);
-				Z_ADDREF_P(old_exception);
+				EG(exception) = NULL;
 			}
 		}
-		zend_exception_save(TSRMLS_C);
 		zend_call_method_with_0_params(&obj, object->ce, &destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL);
-		zend_exception_restore(TSRMLS_C);
 		if (old_exception) {
 			if (EG(exception)) {
-				zval_ptr_dtor(&old_exception);				
+				zend_exception_set_previous(EG(exception), old_exception TSRMLS_CC);
 			} else {
 				EG(exception) = old_exception;
 			}
@@ -148,7 +146,7 @@ ZEND_API zend_object *zend_objects_get_address(const zval *zobject TSRMLS_DC)
 
 ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object_value new_obj_val, zend_object *old_object, zend_object_handle handle TSRMLS_DC)
 {
-	zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *));
+	zend_hash_copy(new_object->properties, old_object->properties, zval_copy_property_ctor(old_object->ce), (void *) NULL /* Not used anymore */, sizeof(zval *));
 
 	if (old_object->ce->clone) {
 		zval *new_obj;
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
index c3a86c6..7bcc98d 100644
--- a/Zend/zend_strtod.c
+++ b/Zend/zend_strtod.c
@@ -89,7 +89,7 @@
  *	directly -- and assumed always to succeed.
  */
 
-/* $Id: zend_strtod.c 277398 2009-03-18 10:18:10Z dmitry $ */
+/* $Id: zend_strtod.c 307119 2011-01-05 13:32:26Z johannes $ */
 
 #include <zend_operators.h>
 #include <zend_strtod.h>
@@ -2035,7 +2035,7 @@ ZEND_API double zend_strtod (CONST char *s00, char **se)
 	int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
 		e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
 	CONST char *s, *s0, *s1;
-	double aadj, aadj1, adj;
+	volatile double aadj, aadj1, adj;
 	volatile _double rv, rv0;
 	Long L;
 	ULong y, z;
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 76f184f..32a0a02 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_variables.c 293400 2010-01-11 10:07:10Z dmitry $ */
+/* $Id: zend_variables.c 302137 2010-08-12 07:58:14Z sas $ */
 
 #include <stdio.h>
 #include "zend.h"
@@ -159,6 +159,17 @@ ZEND_API void _zval_dtor_wrapper(zval *zvalue)
 	zval_dtor(zvalue);
 }
 
+ZEND_API void zval_property_ctor(zval **p) /* {{{ */
+{
+	zval *orig_ptr = *p;
+
+	ALLOC_ZVAL(*p);
+	**p = *orig_ptr;
+	zval_copy_ctor(*p);
+	Z_SET_REFCOUNT_PP(p, 1);
+	Z_UNSET_ISREF_PP(p);
+}
+/* }}} */
 
 #if ZEND_DEBUG
 ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h
index 9a7bbee..9eb7f52 100644
--- a/Zend/zend_variables.h
+++ b/Zend/zend_variables.h
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_variables.h 293400 2010-01-11 10:07:10Z dmitry $ */
+/* $Id: zend_variables.h 302152 2010-08-12 17:28:08Z sas $ */
 
 #ifndef ZEND_VARIABLES_H
 #define ZEND_VARIABLES_H
@@ -76,6 +76,17 @@ ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zvalue);
 
 ZEND_API void zval_add_ref(zval **p);
 
+ZEND_API void zval_property_ctor(zval **);
+
+#ifdef ZTS
+# define zval_shared_property_ctor zval_property_ctor
+#else
+# define zval_shared_property_ctor zval_add_ref
+#endif
+
+#define zval_copy_property_ctor(ce) ((copy_ctor_func_t) (((ce)->type == ZEND_INTERNAL_CLASS) ? zval_shared_property_ctor : zval_add_ref))
+
+
 END_EXTERN_C()
 
 #define ZVAL_DESTRUCTOR (void (*)(void *)) zval_dtor_wrapper
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 76a785c..4c6598c 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -1880,6 +1880,16 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA
 
 	return_value_used = RETURN_VALUE_USED(opline);
 
+	if (Z_LVAL(opline->op2.u.constant) != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
+		if (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE ||
+		    Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE) {
+			zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		} else {
+			zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		}
+		goto done;
+	}
+
 	switch (Z_LVAL(opline->op2.u.constant)) {
 		case ZEND_INCLUDE_ONCE:
 		case ZEND_REQUIRE_ONCE: {
@@ -1933,6 +1943,7 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HA
 			break;
 		EMPTY_SWITCH_DEFAULT_CASE()
 	}
+done:
 	if (inc_filename==&tmp_inc_filename) {
 		zval_dtor(&tmp_inc_filename);
 	}
@@ -5154,6 +5165,16 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND
 
 	return_value_used = RETURN_VALUE_USED(opline);
 
+	if (Z_LVAL(opline->op2.u.constant) != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
+		if (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE ||
+		    Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE) {
+			zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		} else {
+			zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		}
+		goto done;
+	}
+
 	switch (Z_LVAL(opline->op2.u.constant)) {
 		case ZEND_INCLUDE_ONCE:
 		case ZEND_REQUIRE_ONCE: {
@@ -5207,6 +5228,7 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HAND
 			break;
 		EMPTY_SWITCH_DEFAULT_CASE()
 	}
+done:
 	if (inc_filename==&tmp_inc_filename) {
 		zval_dtor(&tmp_inc_filename);
 	}
@@ -8524,6 +8546,16 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
 
 	return_value_used = RETURN_VALUE_USED(opline);
 
+	if (Z_LVAL(opline->op2.u.constant) != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
+		if (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE ||
+		    Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE) {
+			zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		} else {
+			zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		}
+		goto done;
+	}
+
 	switch (Z_LVAL(opline->op2.u.constant)) {
 		case ZEND_INCLUDE_ONCE:
 		case ZEND_REQUIRE_ONCE: {
@@ -8577,6 +8609,7 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
 			break;
 		EMPTY_SWITCH_DEFAULT_CASE()
 	}
+done:
 	if (inc_filename==&tmp_inc_filename) {
 		zval_dtor(&tmp_inc_filename);
 	}
@@ -22387,6 +22420,16 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
 
 	return_value_used = RETURN_VALUE_USED(opline);
 
+	if (Z_LVAL(opline->op2.u.constant) != ZEND_EVAL && strlen(Z_STRVAL_P(inc_filename)) != Z_STRLEN_P(inc_filename)) {
+		if (Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE_ONCE ||
+		    Z_LVAL(opline->op2.u.constant)==ZEND_INCLUDE) {
+			zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		} else {
+			zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, Z_STRVAL_P(inc_filename) TSRMLS_CC);
+		}
+		goto done;
+	}
+
 	switch (Z_LVAL(opline->op2.u.constant)) {
 		case ZEND_INCLUDE_ONCE:
 		case ZEND_REQUIRE_ONCE: {
@@ -22440,6 +22483,7 @@ static int ZEND_FASTCALL  ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
 			break;
 		EMPTY_SWITCH_DEFAULT_CASE()
 	}
+done:
 	if (inc_filename==&tmp_inc_filename) {
 		zval_dtor(&tmp_inc_filename);
 	}
diff --git a/acinclude.m4 b/acinclude.m4
index c3f1f8e..e168c98 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: acinclude.m4 299035 2010-05-05 21:55:44Z felipe $
+dnl $Id: acinclude.m4 305553 2010-11-19 08:26:47Z jani $
 dnl
 dnl This file contains local autoconf functions.
 dnl
@@ -711,10 +711,7 @@ ifelse([$2],,,[AC_MSG_CHECKING([$2])])
 AC_ARG_WITH($1,[$3],$5=[$]withval,
 [
   $5=ifelse($4,,no,$4)
-
-  if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
-    $5=$PHP_ENABLE_ALL
-  fi
+  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
 ])
 PHP_ARG_ANALYZE($5,[$2],$6)
 ])
@@ -739,10 +736,7 @@ ifelse([$2],,,[AC_MSG_CHECKING([$2])])
 AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
 [
   $5=ifelse($4,,no,$4)
-
-  if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
-    $5=$PHP_ENABLE_ALL
-  fi
+  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
 ])
 PHP_ARG_ANALYZE($5,[$2],$6)
 ])
@@ -884,6 +878,17 @@ dnl and optionally also the source-files for the SAPI-specific
 dnl objects.
 dnl
 AC_DEFUN([PHP_SELECT_SAPI],[
+  if test "$PHP_SAPI" != "default"; then
+AC_MSG_ERROR([
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+])
+  fi
+
   PHP_SAPI=$1
   
   case "$2" in
@@ -2661,13 +2666,13 @@ EOF
   for arg in $ac_configure_args; do
      if test `expr -- $arg : "'.*"` = 0; then
         if test `expr -- $arg : "--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "'[$]arg' \\" >> $1
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
      else
         if test `expr -- $arg : "'--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "[$]arg \\" >> $1
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
@@ -2687,19 +2692,19 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
   for arg in $ac_configure_args; do
     case $arg in
       --with-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
         ;;
       --without-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
         ;;
       --enable-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
         ;;
       --disable-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
         ;;
       *[)]
-      	continue
+        continue
         ;;
     esac
     case $arg_name in
diff --git a/aclocal.m4 b/aclocal.m4
index 1236ccf..a75affa 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: acinclude.m4 299035 2010-05-05 21:55:44Z felipe $
+dnl $Id: acinclude.m4 305553 2010-11-19 08:26:47Z jani $
 dnl
 dnl This file contains local autoconf functions.
 dnl
@@ -711,10 +711,7 @@ ifelse([$2],,,[AC_MSG_CHECKING([$2])])
 AC_ARG_WITH($1,[$3],$5=[$]withval,
 [
   $5=ifelse($4,,no,$4)
-
-  if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
-    $5=$PHP_ENABLE_ALL
-  fi
+  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
 ])
 PHP_ARG_ANALYZE($5,[$2],$6)
 ])
@@ -739,10 +736,7 @@ ifelse([$2],,,[AC_MSG_CHECKING([$2])])
 AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
 [
   $5=ifelse($4,,no,$4)
-
-  if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
-    $5=$PHP_ENABLE_ALL
-  fi
+  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
 ])
 PHP_ARG_ANALYZE($5,[$2],$6)
 ])
@@ -884,6 +878,17 @@ dnl and optionally also the source-files for the SAPI-specific
 dnl objects.
 dnl
 AC_DEFUN([PHP_SELECT_SAPI],[
+  if test "$PHP_SAPI" != "default"; then
+AC_MSG_ERROR([
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+])
+  fi
+
   PHP_SAPI=$1
   
   case "$2" in
@@ -2661,13 +2666,13 @@ EOF
   for arg in $ac_configure_args; do
      if test `expr -- $arg : "'.*"` = 0; then
         if test `expr -- $arg : "--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "'[$]arg' \\" >> $1
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
      else
         if test `expr -- $arg : "'--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "[$]arg \\" >> $1
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
@@ -2687,19 +2692,19 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
   for arg in $ac_configure_args; do
     case $arg in
       --with-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
         ;;
       --without-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
         ;;
       --enable-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
         ;;
       --disable-*[)]
-      	arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
         ;;
       *[)]
-      	continue
+        continue
         ;;
     esac
     case $arg_name in
diff --git a/configure b/configure
index b9cf7dc..ba58fa8 100755
--- a/configure
+++ b/configure
@@ -743,8 +743,6 @@ ac_help="$ac_help
 ac_help="$ac_help
   --enable-fpm              EXPERIMENTAL: Enable building of the fpm SAPI executable"
 ac_help="$ac_help
-  --with-libevent-dir[=PATH]  libevent install prefix, for fpm SAPI. (default: /usr/local)"
-ac_help="$ac_help
   --with-fpm-user[=USER]  Set the user for php-fpm to run as. (default: nobody)"
 ac_help="$ac_help
   --with-fpm-group[=GRP]  Set the group for php-fpm to run as. For a system user, this 
@@ -1890,12 +1888,12 @@ fi
 
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:1894: checking for Cygwin environment" >&5
+echo "configure:1892: checking for Cygwin environment" >&5
 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1899 "configure"
+#line 1897 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1906,7 +1904,7 @@ int main() {
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:1910: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -1923,19 +1921,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:1927: checking for mingw32 environment" >&5
+echo "configure:1925: checking for mingw32 environment" >&5
 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1932 "configure"
+#line 1930 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:1939: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1937: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -1954,7 +1952,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes
 
 
 echo $ac_n "checking for egrep""... $ac_c" 1>&6
-echo "configure:1958: checking for egrep" >&5
+echo "configure:1956: checking for egrep" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_egrep'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1969,7 +1967,7 @@ echo "$ac_t""$ac_cv_prog_egrep" 1>&6
  
 
 echo $ac_n "checking for a sed that does not truncate output""... $ac_c" 1>&6
-echo "configure:1973: checking for a sed that does not truncate output" >&5
+echo "configure:1971: checking for a sed that does not truncate output" >&5
 if eval "test \"`echo '$''{'lt_cv_path_SED'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2064,13 +2062,13 @@ EOF
   for arg in $ac_configure_args; do
      if test `expr -- $arg : "'.*"` = 0; then
         if test `expr -- $arg : "--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "'$arg' \\" >> config.nice
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '$arg'"
      else
         if test `expr -- $arg : "'--.*"` = 0; then
-       	  break;
+          break;
         fi
         echo "$arg \\" >> config.nice
         CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $arg"
@@ -2119,7 +2117,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:2123: checking host system type" >&5
+echo "configure:2121: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -2140,7 +2138,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:2144: checking target system type" >&5
+echo "configure:2142: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -2170,7 +2168,7 @@ echo "$ac_t""$target" 1>&6
 
 PHP_MAJOR_VERSION=5
 PHP_MINOR_VERSION=3
-PHP_RELEASE_VERSION=3
+PHP_RELEASE_VERSION=5
 PHP_EXTRA_VERSION=""
 PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
 PHP_VERSION_ID=`expr $PHP_MAJOR_VERSION \* 10000 + $PHP_MINOR_VERSION \* 100 + $PHP_RELEASE_VERSION`
@@ -2252,7 +2250,7 @@ rm -f libs/*
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2256: checking for $ac_word" >&5
+echo "configure:2254: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2282,7 +2280,7 @@ if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2286: checking for $ac_word" >&5
+echo "configure:2284: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2333,7 +2331,7 @@ fi
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2337: checking for $ac_word" >&5
+echo "configure:2335: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2365,7 +2363,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:2369: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2367: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -2376,12 +2374,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 2380 "configure"
+#line 2378 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:2385: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -2407,12 +2405,12 @@ if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:2411: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2409: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:2416: checking whether we are using GNU C" >&5
+echo "configure:2414: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2421,7 +2419,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2425: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2423: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -2440,7 +2438,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:2444: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:2442: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2472,7 +2470,7 @@ else
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2476: checking how to run the C preprocessor" >&5
+echo "configure:2474: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2487,13 +2485,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2491 "configure"
+#line 2489 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2497: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2495: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2504,13 +2502,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2508 "configure"
+#line 2506 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2514: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2512: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2521,13 +2519,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2525 "configure"
+#line 2523 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2531: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2529: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2554,9 +2552,9 @@ echo "$ac_t""$CPP" 1>&6
 
   ICC="no"
   echo $ac_n "checking for icc""... $ac_c" 1>&6
-echo "configure:2558: checking for icc" >&5
+echo "configure:2556: checking for icc" >&5
   cat > conftest.$ac_ext <<EOF
-#line 2560 "configure"
+#line 2558 "configure"
 #include "confdefs.h"
 __INTEL_COMPILER
 EOF
@@ -2578,9 +2576,9 @@ rm -f conftest*
 
   SUNCC="no"
   echo $ac_n "checking for suncc""... $ac_c" 1>&6
-echo "configure:2582: checking for suncc" >&5
+echo "configure:2580: checking for suncc" >&5
   cat > conftest.$ac_ext <<EOF
-#line 2584 "configure"
+#line 2582 "configure"
 #include "confdefs.h"
 __SUNPRO_C
 EOF
@@ -2603,10 +2601,10 @@ rm -f conftest*
 
 if test "x$CC" != xcc; then
   echo $ac_n "checking whether $CC and cc understand -c and -o together""... $ac_c" 1>&6
-echo "configure:2607: checking whether $CC and cc understand -c and -o together" >&5
+echo "configure:2605: checking whether $CC and cc understand -c and -o together" >&5
 else
   echo $ac_n "checking whether cc understands -c and -o together""... $ac_c" 1>&6
-echo "configure:2610: checking whether cc understands -c and -o together" >&5
+echo "configure:2608: checking whether cc understands -c and -o together" >&5
 fi
 set dummy $CC; ac_cc="`echo $2 |
 		       sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
@@ -2618,16 +2616,16 @@ else
 # We do the test twice because some compilers refuse to overwrite an
 # existing .o file with -o, though they will create one.
 ac_try='${CC-cc} -c conftest.c -o conftest.o 1>&5'
-if { (eval echo configure:2622: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
-   test -f conftest.o && { (eval echo configure:2623: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
+if { (eval echo configure:2620: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
+   test -f conftest.o && { (eval echo configure:2621: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
 then
   eval ac_cv_prog_cc_${ac_cc}_c_o=yes
   if test "x$CC" != xcc; then
     # Test first that cc exists at all.
-    if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:2628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+    if { ac_try='cc -c conftest.c 1>&5'; { (eval echo configure:2626: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
       ac_try='cc -c conftest.c -o conftest.o 1>&5'
-      if { (eval echo configure:2630: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
-	 test -f conftest.o && { (eval echo configure:2631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
+      if { (eval echo configure:2628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } &&
+	 test -f conftest.o && { (eval echo configure:2629: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; };
       then
         # cc works too.
         :
@@ -2654,7 +2652,7 @@ EOF
 fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2658: checking how to run the C preprocessor" >&5
+echo "configure:2656: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2669,13 +2667,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2673 "configure"
+#line 2671 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2679: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2677: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2686,13 +2684,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2690 "configure"
+#line 2688 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2696: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2694: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2703,13 +2701,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2707 "configure"
+#line 2705 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2713: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2734,9 +2732,9 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking for AIX""... $ac_c" 1>&6
-echo "configure:2738: checking for AIX" >&5
+echo "configure:2736: checking for AIX" >&5
 cat > conftest.$ac_ext <<EOF
-#line 2740 "configure"
+#line 2738 "configure"
 #include "confdefs.h"
 #ifdef _AIX
   yes
@@ -2758,7 +2756,7 @@ rm -f conftest*
 
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:2762: checking whether ln -s works" >&5
+echo "configure:2760: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2783,7 +2781,7 @@ fi
 php_with_libdir=lib
 
 echo $ac_n "checking for system library directory""... $ac_c" 1>&6
-echo "configure:2787: checking for system library directory" >&5
+echo "configure:2785: checking for system library directory" >&5
 # Check whether --with-libdir or --without-libdir was given.
 if test "${with_libdir+set}" = set; then
   withval="$with_libdir"
@@ -2791,10 +2789,7 @@ if test "${with_libdir+set}" = set; then
 else
   
   PHP_LIBDIR=lib
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBDIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -2809,7 +2804,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_rpath=yes
 
 echo $ac_n "checking whether to enable runpaths""... $ac_c" 1>&6
-echo "configure:2813: checking whether to enable runpaths" >&5
+echo "configure:2808: checking whether to enable runpaths" >&5
 # Check whether --enable-rpath or --disable-rpath was given.
 if test "${enable_rpath+set}" = set; then
   enableval="$enable_rpath"
@@ -2817,10 +2812,7 @@ if test "${enable_rpath+set}" = set; then
 else
   
   PHP_RPATH=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_RPATH=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -2833,7 +2825,7 @@ echo "$ac_t""$ext_output" 1>&6
 
 
 echo $ac_n "checking if compiler supports -R""... $ac_c" 1>&6
-echo "configure:2837: checking if compiler supports -R" >&5
+echo "configure:2829: checking if compiler supports -R" >&5
 if eval "test \"`echo '$''{'php_cv_cc_dashr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2841,14 +2833,14 @@ else
   SAVE_LIBS=$LIBS
   LIBS="-R /usr/$PHP_LIBDIR $LIBS"
   cat > conftest.$ac_ext <<EOF
-#line 2845 "configure"
+#line 2837 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   php_cv_cc_dashr=yes
 else
@@ -2866,7 +2858,7 @@ if test $php_cv_cc_dashr = "yes"; then
   ld_runpath_switch=-R
 else
   echo $ac_n "checking if compiler supports -Wl,-rpath,""... $ac_c" 1>&6
-echo "configure:2870: checking if compiler supports -Wl,-rpath," >&5
+echo "configure:2862: checking if compiler supports -Wl,-rpath," >&5
   if eval "test \"`echo '$''{'php_cv_cc_rpath'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2874,14 +2866,14 @@ else
     SAVE_LIBS=$LIBS
     LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
     cat > conftest.$ac_ext <<EOF
-#line 2878 "configure"
+#line 2870 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2877: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   php_cv_cc_rpath=yes
 else
@@ -2912,7 +2904,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2916: checking for $ac_word" >&5
+echo "configure:2908: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2953,7 +2945,7 @@ test -n "$AWK" || AWK="bork"
       ;;
     *)
       echo $ac_n "checking if $AWK is broken""... $ac_c" 1>&6
-echo "configure:2957: checking if $AWK is broken" >&5
+echo "configure:2949: checking if $AWK is broken" >&5
       if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
         echo "$ac_t""yes" 1>&6
         { echo "configure: error: You should install GNU awk" 1>&2; exit 1; }
@@ -2972,7 +2964,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2976: checking for $ac_word" >&5
+echo "configure:2968: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3004,7 +2996,7 @@ test -n "$YACC" || YACC="yacc"
 
   
   # we only support certain bison versions
-  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2"
+  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3"
 
   # for standalone build of Zend Engine
   test -z "$SED" && SED=sed
@@ -3012,7 +3004,7 @@ test -n "$YACC" || YACC="yacc"
   bison_version=none
   if test "$YACC"; then
     echo $ac_n "checking for bison version""... $ac_c" 1>&6
-echo "configure:3016: checking for bison version" >&5
+echo "configure:3008: checking for bison version" >&5
 if eval "test \"`echo '$''{'php_cv_bison_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3050,7 +3042,7 @@ echo "$ac_t""$php_cv_bison_version" 1>&6
   # Extract the first word of "re2c", so it can be a program name with args.
 set dummy re2c; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3054: checking for $ac_word" >&5
+echo "configure:3046: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RE2C'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3078,7 +3070,7 @@ fi
 
   if test -n "$RE2C"; then
     echo $ac_n "checking for re2c version""... $ac_c" 1>&6
-echo "configure:3082: checking for re2c version" >&5
+echo "configure:3074: checking for re2c version" >&5
 if eval "test \"`echo '$''{'php_cv_re2c_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3117,7 +3109,7 @@ esac
 php_enable_re2c_cgoto=no
 
 echo $ac_n "checking whether to enable computed goto gcc extension with re2c""... $ac_c" 1>&6
-echo "configure:3121: checking whether to enable computed goto gcc extension with re2c" >&5
+echo "configure:3113: checking whether to enable computed goto gcc extension with re2c" >&5
 # Check whether --enable-re2c-cgoto or --disable-re2c-cgoto was given.
 if test "${enable_re2c_cgoto+set}" = set; then
   enableval="$enable_re2c_cgoto"
@@ -3125,10 +3117,7 @@ if test "${enable_re2c_cgoto+set}" = set; then
 else
   
   PHP_RE2C_CGOTO=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_RE2C_CGOTO=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -3143,9 +3132,9 @@ if test "$PHP_RE2C_CGOTO" = "no"; then
   RE2C_FLAGS=""
 else
   echo $ac_n "checking whether re2c -g works""... $ac_c" 1>&6
-echo "configure:3147: checking whether re2c -g works" >&5
+echo "configure:3136: checking whether re2c -g works" >&5
   cat > conftest.$ac_ext <<EOF
-#line 3149 "configure"
+#line 3138 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -3163,7 +3152,7 @@ label2:
   
 ; return 0; }
 EOF
-if { (eval echo configure:3167: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3156: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     RE2C_FLAGS=""
@@ -3229,7 +3218,7 @@ case $host_alias in
       
   gcc_arg_name=ac_cv_gcc_arg_no_cpp_precomp
   echo $ac_n "checking whether $CC supports -no-cpp-precomp""... $ac_c" 1>&6
-echo "configure:3233: checking whether $CC supports -no-cpp-precomp" >&5
+echo "configure:3222: checking whether $CC supports -no-cpp-precomp" >&5
 if eval "test \"`echo '$''{'ac_cv_gcc_arg_no_cpp_precomp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3430,7 +3419,7 @@ esac
 # Disable PIC mode by default where it is known to be safe to do so,
 # to avoid the performance hit from the lost register
 echo $ac_n "checking whether to force non-PIC code in shared modules""... $ac_c" 1>&6
-echo "configure:3434: checking whether to force non-PIC code in shared modules" >&5
+echo "configure:3423: checking whether to force non-PIC code in shared modules" >&5
 case $host_alias in
   i?86-*-linux*|i?86-*-freebsd*)
     if test "${with_pic+set}" != "set" || test "$with_pic" = "no"; then
@@ -3460,7 +3449,7 @@ esac
 
 
 echo $ac_n "checking whether /dev/urandom exists""... $ac_c" 1>&6
-echo "configure:3464: checking whether /dev/urandom exists" >&5 
+echo "configure:3453: checking whether /dev/urandom exists" >&5 
 if test -r "/dev/urandom" && test -c "/dev/urandom"; then 
   cat >> confdefs.h <<\EOF
 #define HAVE_DEV_URANDOM 1
@@ -3521,7 +3510,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3525 "configure"
+#line 3514 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3539,7 +3528,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3543: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -3559,7 +3548,7 @@ fi
   CFLAGS=$save_CFLAGS
 
   echo $ac_n "checking for pthreads_cflags""... $ac_c" 1>&6
-echo "configure:3563: checking for pthreads_cflags" >&5
+echo "configure:3552: checking for pthreads_cflags" >&5
 if eval "test \"`echo '$''{'ac_cv_pthreads_cflags'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3581,7 +3570,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3585 "configure"
+#line 3574 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3599,7 +3588,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -3629,7 +3618,7 @@ fi
 echo "$ac_t""$ac_cv_pthreads_cflags" 1>&6
 
 echo $ac_n "checking for pthreads_lib""... $ac_c" 1>&6
-echo "configure:3633: checking for pthreads_lib" >&5
+echo "configure:3622: checking for pthreads_lib" >&5
 if eval "test \"`echo '$''{'ac_cv_pthreads_lib'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3651,7 +3640,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3655 "configure"
+#line 3644 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -3669,7 +3658,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:3673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -3788,10 +3777,7 @@ if test "${with_aolserver+set}" = set; then
 else
   
   PHP_AOLSERVER=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_AOLSERVER=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -3803,7 +3789,7 @@ ext_output=$PHP_AOLSERVER
 
 
 echo $ac_n "checking for AOLserver support""... $ac_c" 1>&6
-echo "configure:3807: checking for AOLserver support" >&5
+echo "configure:3793: checking for AOLserver support" >&5
 
 if test "$PHP_AOLSERVER" != "no"; then
   if test -d "$PHP_AOLSERVER/include"; then
@@ -3857,6 +3843,17 @@ if test "$PHP_AOLSERVER" != "no"; then
 EOF
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=aolserver
   
   case "shared" in
@@ -4045,10 +4042,7 @@ if test "${with_apxs+set}" = set; then
 else
   
   PHP_APXS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APXS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -4060,7 +4054,7 @@ ext_output=$PHP_APXS
 
 
 echo $ac_n "checking for Apache 1.x module support via DSO through APXS""... $ac_c" 1>&6
-echo "configure:4064: checking for Apache 1.x module support via DSO through APXS" >&5
+echo "configure:4058: checking for Apache 1.x module support via DSO through APXS" >&5
 
 if test "$PHP_APXS" != "no"; then
   if test "$PHP_APXS" = "yes"; then
@@ -4145,6 +4139,17 @@ IFS="- /.
   esac
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache
   
   case "$build_type" in
@@ -4368,10 +4373,7 @@ if test "${with_apache+set}" = set; then
 else
   
   PHP_APACHE=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APACHE=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -4383,7 +4385,7 @@ ext_output=$PHP_APACHE
 
 
 echo $ac_n "checking for Apache 1.x module support""... $ac_c" 1>&6
-echo "configure:4387: checking for Apache 1.x module support" >&5
+echo "configure:4389: checking for Apache 1.x module support" >&5
 
 if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
   
@@ -4415,6 +4417,17 @@ EOF
     APACHE_INCLUDE=-I$PHP_APACHE/src
     APACHE_TARGET=$PHP_APACHE/src
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache
   
   case "static" in
@@ -4606,6 +4619,17 @@ EOF
       mkdir $APACHE_TARGET
     fi
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache
   
   case "static" in
@@ -4808,6 +4832,17 @@ EOF
       mkdir $APACHE_TARGET
     fi
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache
   
   case "static" in
@@ -5006,6 +5041,17 @@ EOF
     APACHE_INCLUDE="-I$PHP_APACHE/apache -I$PHP_APACHE/ssl/include"
     APACHE_TARGET=$PHP_APACHE/apache
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache
   
   case "static" in
@@ -5216,7 +5262,7 @@ fi
 php_enable_mod_charset=no
 
 echo $ac_n "checking whether to enable Apache charset compatibility option""... $ac_c" 1>&6
-echo "configure:5220: checking whether to enable Apache charset compatibility option" >&5
+echo "configure:5266: checking whether to enable Apache charset compatibility option" >&5
 # Check whether --enable-mod-charset or --disable-mod-charset was given.
 if test "${enable_mod_charset+set}" = set; then
   enableval="$enable_mod_charset"
@@ -5224,10 +5270,7 @@ if test "${enable_mod_charset+set}" = set; then
 else
   
   PHP_MOD_CHARSET=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MOD_CHARSET=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -5251,7 +5294,7 @@ if test "$APACHE_MODULE" = "yes"; then
         
   gcc_arg_name=ac_cv_gcc_arg_rdynamic
   echo $ac_n "checking whether $CC supports -rdynamic""... $ac_c" 1>&6
-echo "configure:5255: checking whether $CC supports -rdynamic" >&5
+echo "configure:5298: checking whether $CC supports -rdynamic" >&5
 if eval "test \"`echo '$''{'ac_cv_gcc_arg_rdynamic'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5294,7 +5337,7 @@ if test -n "$APACHE_INSTALL"; then
 
   
 echo $ac_n "checking for member fd in BUFF *""... $ac_c" 1>&6
-echo "configure:5298: checking for member fd in BUFF *" >&5
+echo "configure:5341: checking for member fd in BUFF *" >&5
 if eval "test \"`echo '$''{'ac_cv_php_fd_in_buff'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5306,14 +5349,14 @@ else
     CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
   fi
   cat > conftest.$ac_ext <<EOF
-#line 5310 "configure"
+#line 5353 "configure"
 #include "confdefs.h"
 #include <httpd.h>
 int main() {
 conn_rec *c; int fd = c->client->fd;
 ; return 0; }
 EOF
-if { (eval echo configure:5317: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5360: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_php_fd_in_buff=yes
@@ -5374,10 +5417,7 @@ if test "${with_apxs2filter+set}" = set; then
 else
   
   PHP_APXS2FILTER=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APXS2FILTER=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -5389,7 +5429,7 @@ ext_output=$PHP_APXS2FILTER
 
 
 echo $ac_n "checking for Apache 2.0 filter-module support via DSO through APXS""... $ac_c" 1>&6
-echo "configure:5393: checking for Apache 2.0 filter-module support via DSO through APXS" >&5
+echo "configure:5433: checking for Apache 2.0 filter-module support via DSO through APXS" >&5
 
 if test "$PHP_APXS2FILTER" != "no"; then
   if test "$PHP_APXS2FILTER" = "yes"; then
@@ -5487,6 +5527,17 @@ IFS="- /.
   *aix*)
     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2filter
   
   case "shared" in
@@ -5670,6 +5721,17 @@ EOF
   PHP_VAR_SUBST="$PHP_VAR_SUBST MH_BUNDLE_FLAGS"
 
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2filter
   
   case "bundle" in
@@ -5847,6 +5909,17 @@ EOF
     `ln -s $APXS_BINDIR/httpd _APP_`
     EXTRA_LIBS="$EXTRA_LIBS _APP_"
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2filter
   
   case "shared" in
@@ -6020,6 +6093,17 @@ EOF
     ;;
   *)
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2filter
   
   case "shared" in
@@ -6222,10 +6306,7 @@ if test "${with_apxs2+set}" = set; then
 else
   
   PHP_APXS2=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APXS2=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -6237,7 +6318,7 @@ ext_output=$PHP_APXS2
 
 
 echo $ac_n "checking for Apache 2.0 handler-module support via DSO through APXS""... $ac_c" 1>&6
-echo "configure:6241: checking for Apache 2.0 handler-module support via DSO through APXS" >&5
+echo "configure:6322: checking for Apache 2.0 handler-module support via DSO through APXS" >&5
 
 if test "$PHP_APXS2" != "no"; then
   if test "$PHP_APXS2" = "yes"; then
@@ -6335,6 +6416,17 @@ IFS="- /.
   *aix*)
     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2handler
   
   case "shared" in
@@ -6518,6 +6610,17 @@ EOF
   PHP_VAR_SUBST="$PHP_VAR_SUBST MH_BUNDLE_FLAGS"
 
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2handler
   
   case "bundle" in
@@ -6695,6 +6798,17 @@ EOF
     `ln -s $APXS_BINDIR/httpd _APP_`
     EXTRA_LIBS="$EXTRA_LIBS _APP_"
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2handler
   
   case "shared" in
@@ -6868,6 +6982,17 @@ EOF
     ;;
   *)
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache2handler
   
   case "shared" in
@@ -7071,10 +7196,7 @@ if test "${with_apache_hooks+set}" = set; then
 else
   
   PHP_APACHE_HOOKS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APACHE_HOOKS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -7086,7 +7208,7 @@ ext_output=$PHP_APACHE_HOOKS
 
 
 echo $ac_n "checking for Apache 1.x (hooks) module support via DSO through APXS""... $ac_c" 1>&6
-echo "configure:7090: checking for Apache 1.x (hooks) module support via DSO through APXS" >&5
+echo "configure:7212: checking for Apache 1.x (hooks) module support via DSO through APXS" >&5
 
 if test "$PHP_APACHE_HOOKS" != "no"; then
   if test "$PHP_APACHE_HOOKS" = "yes"; then
@@ -7171,6 +7293,17 @@ IFS="- /.
   esac
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache_hooks
   
   case "$build_type" in
@@ -7394,10 +7527,7 @@ if test "${with_apache_hooks_static+set}" = set; then
 else
   
   PHP_APACHE_HOOKS_STATIC=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_APACHE_HOOKS_STATIC=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -7409,7 +7539,7 @@ ext_output=$PHP_APACHE_HOOKS_STATIC
 
 
 echo $ac_n "checking for Apache 1.x (hooks) module support""... $ac_c" 1>&6
-echo "configure:7413: checking for Apache 1.x (hooks) module support" >&5
+echo "configure:7543: checking for Apache 1.x (hooks) module support" >&5
 
 if test "$PHP_SAPI" != "apache" && test "$PHP_SAPI" != "apache_hooks" && test "$PHP_APACHE_HOOKS_STATIC" != "no"; then
 
@@ -7441,6 +7571,17 @@ EOF
     APACHE_INCLUDE=-I$PHP_APACHE_HOOKS_STATIC/src
     APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/src
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache_hooks
   
   case "static" in
@@ -7632,6 +7773,17 @@ EOF
       mkdir $APACHE_TARGET
     fi
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache_hooks
   
   case "static" in
@@ -7834,6 +7986,17 @@ EOF
       mkdir $APACHE_TARGET
     fi
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache_hooks
   
   case "static" in
@@ -8032,6 +8195,17 @@ EOF
     APACHE_INCLUDE="-I$PHP_APACHE_HOOKS_STATIC/apache -I$PHP_APACHE_HOOKS_STATIC/ssl/include"
     APACHE_TARGET=$PHP_APACHE_HOOKS_STATIC/apache
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=apache_hooks
   
   case "static" in
@@ -8242,7 +8416,7 @@ fi
 php_enable_mod_charset=no
 
 echo $ac_n "checking whether to enable Apache charset compatibility option""... $ac_c" 1>&6
-echo "configure:8246: checking whether to enable Apache charset compatibility option" >&5
+echo "configure:8420: checking whether to enable Apache charset compatibility option" >&5
 # Check whether --enable-mod-charset or --disable-mod-charset was given.
 if test "${enable_mod_charset+set}" = set; then
   enableval="$enable_mod_charset"
@@ -8250,10 +8424,7 @@ if test "${enable_mod_charset+set}" = set; then
 else
   
   PHP_MOD_CHARSET=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MOD_CHARSET=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -8277,7 +8448,7 @@ if test "$APACHE_HOOKS_MODULE" = "yes"; then
         
   gcc_arg_name=ac_cv_gcc_arg_rdynamic
   echo $ac_n "checking whether $CC supports -rdynamic""... $ac_c" 1>&6
-echo "configure:8281: checking whether $CC supports -rdynamic" >&5
+echo "configure:8452: checking whether $CC supports -rdynamic" >&5
 if eval "test \"`echo '$''{'ac_cv_gcc_arg_rdynamic'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8320,7 +8491,7 @@ if test -n "$APACHE_HOOKS_INSTALL"; then
 
   
 echo $ac_n "checking for member fd in BUFF *""... $ac_c" 1>&6
-echo "configure:8324: checking for member fd in BUFF *" >&5
+echo "configure:8495: checking for member fd in BUFF *" >&5
 if eval "test \"`echo '$''{'ac_cv_php_fd_in_buff'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8332,14 +8503,14 @@ else
     CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
   fi
   cat > conftest.$ac_ext <<EOF
-#line 8336 "configure"
+#line 8507 "configure"
 #include "confdefs.h"
 #include <httpd.h>
 int main() {
 conn_rec *c; int fd = c->client->fd;
 ; return 0; }
 EOF
-if { (eval echo configure:8343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_php_fd_in_buff=yes
@@ -8401,10 +8572,7 @@ if test "${with_caudium+set}" = set; then
 else
   
   PHP_CAUDIUM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CAUDIUM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -8416,7 +8584,7 @@ ext_output=$PHP_CAUDIUM
 
 
 echo $ac_n "checking for Caudium support""... $ac_c" 1>&6
-echo "configure:8420: checking for Caudium support" >&5
+echo "configure:8588: checking for Caudium support" >&5
 
 if test "$PHP_CAUDIUM" != "no"; then
   if test "$prefix" = "NONE"; then CPREF=/usr/local/; fi
@@ -8486,7 +8654,7 @@ if test "$PHP_CAUDIUM" != "no"; then
       PIKE_C_INCLUDE=/usr/local/include/`basename $PIKE`
     fi
     echo $ac_n "checking for C includes in $PIKE_C_INCLUDE""... $ac_c" 1>&6
-echo "configure:8490: checking for C includes in $PIKE_C_INCLUDE" >&5
+echo "configure:8658: checking for C includes in $PIKE_C_INCLUDE" >&5
     if test -f $PIKE_C_INCLUDE/version.h; then
       PIKE_TEST_VER=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'`
       ###### VERSION MATCH CHECK #######
@@ -8557,6 +8725,17 @@ echo "configure:8490: checking for C includes in $PIKE_C_INCLUDE" >&5
 EOF
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=caudium
   
   case "shared" in
@@ -8752,10 +8931,7 @@ if test "${enable_cli+set}" = set; then
 else
   
   PHP_CLI=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CLI=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -8767,7 +8943,7 @@ ext_output=$PHP_CLI
 
 
 echo $ac_n "checking for CLI build""... $ac_c" 1>&6
-echo "configure:8771: checking for CLI build" >&5
+echo "configure:8947: checking for CLI build" >&5
 if test "$PHP_CLI" != "no"; then
   
   src=$abs_srcdir/sapi/cli/Makefile.frag
@@ -8817,7 +8993,7 @@ echo "$ac_t""$PHP_CLI" 1>&6
 php_with_continuity=no
 
 echo $ac_n "checking for Continuity support""... $ac_c" 1>&6
-echo "configure:8821: checking for Continuity support" >&5
+echo "configure:8997: checking for Continuity support" >&5
 # Check whether --with-continuity or --without-continuity was given.
 if test "${with_continuity+set}" = set; then
   withval="$with_continuity"
@@ -8825,10 +9001,7 @@ if test "${with_continuity+set}" = set; then
 else
   
   PHP_CONTINUITY=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CONTINUITY=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -8844,7 +9017,7 @@ if test "$PHP_CONTINUITY" != "no"; then
     { echo "configure: error: Please specify the path to the root of your Continuity server using --with-continuity=DIR" 1>&2; exit 1; }
   fi
   echo $ac_n "checking for Continuity include files""... $ac_c" 1>&6
-echo "configure:8848: checking for Continuity include files" >&5
+echo "configure:9021: checking for Continuity include files" >&5
   if test -d $PHP_CONTINUITY/include ; then
     CAPI_INCLUDE=$PHP_CONTINUITY/include
     echo "$ac_t""Continuity Binary Distribution" 1>&6
@@ -8853,6 +9026,17 @@ echo "configure:8848: checking for Continuity include files" >&5
   fi
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=continuity
   
   case "shared" in
@@ -9079,10 +9263,7 @@ if test "${enable_embed+set}" = set; then
 else
   
   PHP_EMBED=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_EMBED=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -9094,7 +9275,7 @@ ext_output=$PHP_EMBED
 
 
 echo $ac_n "checking for embedded SAPI library support""... $ac_c" 1>&6
-echo "configure:9098: checking for embedded SAPI library support" >&5
+echo "configure:9279: checking for embedded SAPI library support" >&5
 
 if test "$PHP_EMBED" != "no"; then
   case "$PHP_EMBED" in
@@ -9112,6 +9293,17 @@ if test "$PHP_EMBED" != "no"; then
   esac
   if test "$PHP_EMBED_TYPE" != "no"; then
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=embed
   
   case "$PHP_EMBED_TYPE" in
@@ -9307,9 +9499,6 @@ fi
 
 
 
-fpm_version="0.6.5"
-minimum_libevent_version="1.4.11"
-
 
 php_enable_fpm=no
 
@@ -9321,10 +9510,7 @@ if test "${enable_fpm+set}" = set; then
 else
   
   PHP_FPM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FPM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -9347,464 +9533,21 @@ ext_output=$PHP_FPM
 
 
 
-
 echo $ac_n "checking for FPM build""... $ac_c" 1>&6
-echo "configure:9353: checking for FPM build" >&5
+echo "configure:9538: checking for FPM build" >&5
 if test "$PHP_FPM" != "no"; then
   echo "$ac_t""$PHP_FPM" 1>&6
 
   
-
-
-php_with_libevent_dir=/usr/local
-
-
-# Check whether --with-libevent-dir or --without-libevent-dir was given.
-if test "${with_libevent_dir+set}" = set; then
-  withval="$with_libevent_dir"
-  PHP_LIBEVENT_DIR=$withval
-else
-  
-  PHP_LIBEVENT_DIR=/usr/local
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_LIBEVENT_DIR=$PHP_ENABLE_ALL
-  fi
-
-fi
-
-
-
-ext_output="yes, shared"
-ext_shared=yes
-case $PHP_LIBEVENT_DIR in
-shared,*)
-  PHP_LIBEVENT_DIR=`echo "$PHP_LIBEVENT_DIR"|$SED 's/^shared,//'`
-  ;;
-shared)
-  PHP_LIBEVENT_DIR=yes
-  ;;
-no)
-  ext_output=no
-  ext_shared=no
-  ;;
-*)
-  ext_output=yes
-  ext_shared=no
-  ;;
-esac
-
-
-
-
-
-
-
-
-if test "$PHP_LIBEVENT_DIR" != "no"; then
-  WANT_LIBEVENT_VERSION=$minimum_libevent_version
-
-  echo $ac_n "checking for libevent >= $WANT_LIBEVENT_VERSION install prefix""... $ac_c" 1>&6
-echo "configure:9409: checking for libevent >= $WANT_LIBEVENT_VERSION install prefix" >&5
-
-  libevent_prefix=$ac_default_prefix
-  if test $prefix != "NONE" -a $prefix != "" -a $prefix != "no" ; then 
-    libevent_prefix=$prefix
-  fi
-
-  if test "$PHP_LIBEVENT_DIR" = "yes"; then
-    PHP_LIBEVENT_DIR=$libevent_prefix
-  fi
-
-  if test "$PHP_LIBEVENT_DIR" != "yes" && test "$PHP_LIBEVENT_DIR" != "/usr/local"; then
-        ac_libevent_path=$PHP_LIBEVENT_DIR
-    
-# Save our flags.
-CPPFLAGS_SAVED="$CPPFLAGS"
-LDFLAGS_SAVED="$LDFLAGS"
-LIBS_SAVED="$LIBS"
-LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
-
-# Set our flags if we are checking a specific directory.
-if test -n "$ac_libevent_path" ; then
-  LIBEVENT_CPPFLAGS="-I$ac_libevent_path/include"
- 
-  if test -z "$PHP_LIBDIR"; then
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/lib"
-  else 
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/$PHP_LIBDIR"
-  fi
-
-  LD_LIBRARY_PATH="$ac_libevent_path/lib:$LD_LIBRARY_PATH"
-else
-  LIBEVENT_CPPFLAGS=""
-  LIBEVENT_LDFLAGS=""
-fi
-
-# Required flag for libevent.
-LIBEVENT_LIBS="-levent"
-
-# Prepare the environment for compilation.
-CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
-LIBS="$LIBS $LIBEVENT_LIBS"
-export CPPFLAGS
-export LDFLAGS
-export LIBS
-export LD_LIBRARY_PATH
-
-success=no
-
-# Compile, link, and run the program.  This checks:
-# - event.h is available for including.
-# - event_get_version() is available for linking.
-# - The event version string is lexicographically greater
-#   than the required version.
-if test "$cross_compiling" = yes; then
-    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-  cat > conftest.$ac_ext <<EOF
-#line 9468 "configure"
-#include "confdefs.h"
-
-#include <sys/types.h>
-#include <event.h>
-
-int main(int argc, char *argv[])
-{
-	const char* lib_version = event_get_version();
-	const char* wnt_version = "$WANT_LIBEVENT_VERSION";
-	for (;;) {
-		/* If we reached the end of the want version.  We have it. */
-		if (*wnt_version == '\0' || *wnt_version == '-') {
-			return 0;
-		}
-		/* If the want version continues but the lib version does not, */
-		/* we are missing a letter.  We don't have it. */
-		if (*lib_version == '\0' || *lib_version == '-') {
-			return 1;
-		}
-
-		/* In the 1.4 version numbering style, if there are more digits */
-		/* in one version than the other, that one is higher. */
-		int lib_digits;
-		for (lib_digits = 0;
-		lib_version[lib_digits] >= '0' &&
-		lib_version[lib_digits] <= '9';
-		lib_digits++)
-		;
-		int wnt_digits;
-		for (wnt_digits = 0;
-		wnt_version[wnt_digits] >= '0' &&
-		wnt_version[wnt_digits] <= '9';
-		wnt_digits++)
-		;
-		if (lib_digits > wnt_digits) {
-			return 0;
-		}
-		if (lib_digits < wnt_digits) {
-			return 1;
-		}
-		/* If we have greater than what we want.  We have it. */
-		if (*lib_version > *wnt_version) {
-			return 0;
-		}
-		/* If we have less, we don't. */
-		if (*lib_version < *wnt_version) {
-			return 1;
-		}
-		lib_version++;
-		wnt_version++;
-	}
-	return 0;
-}
-
-EOF
-if { (eval echo configure:9524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  
-success=yes
-
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-fi
-rm -fr conftest*
-fi
-
-
-# Restore flags.
-CPPFLAGS="$CPPFLAGS_SAVED"
-LDFLAGS="$LDFLAGS_SAVED"
-LIBS="$LIBS_SAVED"
-LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
-
-    if test "$success" = "no"; then
-      { echo "configure: error: Could not find libevent >= $WANT_LIBEVENT_VERSION in $PHP_LIBEVENT_DIR" 1>&2; exit 1; }
-    fi
-   else 
-        for ac_libevent_path in "" $PHP_LIBEVENT_DIR /usr /usr/local /opt /opt/local /opt/libevent ; do
-      
-# Save our flags.
-CPPFLAGS_SAVED="$CPPFLAGS"
-LDFLAGS_SAVED="$LDFLAGS"
-LIBS_SAVED="$LIBS"
-LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
-
-# Set our flags if we are checking a specific directory.
-if test -n "$ac_libevent_path" ; then
-  LIBEVENT_CPPFLAGS="-I$ac_libevent_path/include"
- 
-  if test -z "$PHP_LIBDIR"; then
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/lib"
-  else 
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/$PHP_LIBDIR"
-  fi
-
-  LD_LIBRARY_PATH="$ac_libevent_path/lib:$LD_LIBRARY_PATH"
-else
-  LIBEVENT_CPPFLAGS=""
-  LIBEVENT_LDFLAGS=""
-fi
-
-# Required flag for libevent.
-LIBEVENT_LIBS="-levent"
-
-# Prepare the environment for compilation.
-CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
-LIBS="$LIBS $LIBEVENT_LIBS"
-export CPPFLAGS
-export LDFLAGS
-export LIBS
-export LD_LIBRARY_PATH
-
-success=no
-
-# Compile, link, and run the program.  This checks:
-# - event.h is available for including.
-# - event_get_version() is available for linking.
-# - The event version string is lexicographically greater
-#   than the required version.
-if test "$cross_compiling" = yes; then
-    { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
-else
-  cat > conftest.$ac_ext <<EOF
-#line 9594 "configure"
-#include "confdefs.h"
-
-#include <sys/types.h>
-#include <event.h>
-
-int main(int argc, char *argv[])
-{
-	const char* lib_version = event_get_version();
-	const char* wnt_version = "$WANT_LIBEVENT_VERSION";
-	for (;;) {
-		/* If we reached the end of the want version.  We have it. */
-		if (*wnt_version == '\0' || *wnt_version == '-') {
-			return 0;
-		}
-		/* If the want version continues but the lib version does not, */
-		/* we are missing a letter.  We don't have it. */
-		if (*lib_version == '\0' || *lib_version == '-') {
-			return 1;
-		}
-
-		/* In the 1.4 version numbering style, if there are more digits */
-		/* in one version than the other, that one is higher. */
-		int lib_digits;
-		for (lib_digits = 0;
-		lib_version[lib_digits] >= '0' &&
-		lib_version[lib_digits] <= '9';
-		lib_digits++)
-		;
-		int wnt_digits;
-		for (wnt_digits = 0;
-		wnt_version[wnt_digits] >= '0' &&
-		wnt_version[wnt_digits] <= '9';
-		wnt_digits++)
-		;
-		if (lib_digits > wnt_digits) {
-			return 0;
-		}
-		if (lib_digits < wnt_digits) {
-			return 1;
-		}
-		/* If we have greater than what we want.  We have it. */
-		if (*lib_version > *wnt_version) {
-			return 0;
-		}
-		/* If we have less, we don't. */
-		if (*lib_version < *wnt_version) {
-			return 1;
-		}
-		lib_version++;
-		wnt_version++;
-	}
-	return 0;
-}
-
-EOF
-if { (eval echo configure:9650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  
-success=yes
-
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-fi
-rm -fr conftest*
-fi
-
-
-# Restore flags.
-CPPFLAGS="$CPPFLAGS_SAVED"
-LDFLAGS="$LDFLAGS_SAVED"
-LIBS="$LIBS_SAVED"
-LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
-
-      if test "$success" = "yes"; then
-        break;
-      fi
-    done
-  fi
-
-  if test "$success" != "yes" ; then
-    echo "$ac_t""no" 1>&6
-    ac_have_libevent=no
-    { echo "configure: error: libevent >= $WANT_LIBEVENT_VERSION could not be found" 1>&2; exit 1; }
-  else
-    echo "$ac_t""$ac_libevent_path" 1>&6
-    ac_have_libevent=yes
-    cat >> confdefs.h <<\EOF
-#define HAVE_LIBEVENT 1
-EOF
-
-  fi
-
-  LIBEVENT_LIBS="-levent"
-
-  if test -n "$ac_libevent_path"; then
-    LIBEVENT_CFLAGS="-I$ac_libevent_path/include"
-    LIBEVENT_LIBS="-L$ac_libevent_path/$PHP_LIBDIR $LIBEVENT_LIBS"
-    LIBEVENT_PATH="$ac_libevent_path/$PHP_LIBDIR"
-  fi
-
-  
-  
-  
-
-else
-  { echo "configure: error: FPM requires libevent >= $WANT_LIBEVENT_VERSION. Please specify libevent install prefix with --with-libevent-dir=yes" 1>&2; exit 1; }
-fi
-
-
-
-  
-
-  if test -n "$LIBEVENT_PATH"; then
-    
-  if test "$LIBEVENT_PATH" != "/usr/$PHP_LIBDIR" && test "$LIBEVENT_PATH" != "/usr/lib"; then
-    
-  if test -z "$LIBEVENT_PATH" || echo "$LIBEVENT_PATH" | grep '^/' >/dev/null ; then
-    ai_p=$LIBEVENT_PATH
-  else
-    
-    ep_dir="`echo $LIBEVENT_PATH|$SED 's%/*[^/][^/]*/*$%%'`"
-    
-    ep_realdir="`(cd \"$ep_dir\" && pwd)`"
-    ai_p="$ep_realdir/`basename \"$LIBEVENT_PATH\"`"
-  fi
-
-    
-      
-  
-  
-  unique=`echo $ai_p|$SED 's/[^a-zA-Z0-9]/_/g'`
-  
-  cmd="echo $ac_n \"\$LIBPATH$unique$ac_c\""
-  if test -n "$unique" && test "`eval $cmd`" = "" ; then
-    eval "LIBPATH$unique=set"
-    
-    test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
-    LDFLAGS="$LDFLAGS -L$ai_p"
-    PHP_RPATHS="$PHP_RPATHS $ai_p"
-  
-  fi
-
-
-    
-  fi
-
-  fi
-  
-  
-  case event in
-  c|c_r|pthread*) ;;
-  *) 
-      LIBS="-levent $LIBS" 
-   ;;
-  esac
-
-
-
-
-
-  
-  old_LIBS=$LIBS
-  LIBS="$LIBEVENT_LIBS $LIBS"
-  if test "$cross_compiling" = yes; then
-  
-    LIBS=$old_LIBS
-  
-else
-  cat > conftest.$ac_ext <<EOF
-#line 9765 "configure"
-#include "confdefs.h"
-
-    
-    char event_init();
-    int main() {
-      event_init();
-      return 0;
-    }
-  
-EOF
-if { (eval echo configure:9776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
-  
-    LIBS=$old_LIBS
-     
-  
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  
-    LIBS=$old_LIBS
-    
-    echo "$ac_t""no" 1>&6
-    { echo "configure: error: build test failed. Please check the config.log for details." 1>&2; exit 1; }
-  
-  
-fi
-rm -fr conftest*
-fi
-
-
-
-  
-  for ac_func in setenv clearenv
+  for ac_func in setenv clearenv setproctitle
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:9803: checking for $ac_func" >&5
+echo "configure:9546: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9808 "configure"
+#line 9551 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -9827,7 +9570,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:9831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -9854,14 +9597,14 @@ done
 
   
 echo $ac_n "checking for library containing socket""... $ac_c" 1>&6
-echo "configure:9858: checking for library containing socket" >&5
+echo "configure:9601: checking for library containing socket" >&5
 if eval "test \"`echo '$''{'ac_cv_search_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_func_search_save_LIBS="$LIBS"
 ac_cv_search_socket="no"
 cat > conftest.$ac_ext <<EOF
-#line 9865 "configure"
+#line 9608 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9872,7 +9615,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:9876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_search_socket="none required"
 else
@@ -9883,7 +9626,7 @@ rm -f conftest*
 test "$ac_cv_search_socket" = "no" && for i in socket; do
 LIBS="-l$i  $ac_func_search_save_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 9887 "configure"
+#line 9630 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9894,7 +9637,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:9898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_search_socket="-l$i"
 break
@@ -9916,14 +9659,14 @@ else :
 fi
   
 echo $ac_n "checking for library containing inet_addr""... $ac_c" 1>&6
-echo "configure:9920: checking for library containing inet_addr" >&5
+echo "configure:9663: checking for library containing inet_addr" >&5
 if eval "test \"`echo '$''{'ac_cv_search_inet_addr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_func_search_save_LIBS="$LIBS"
 ac_cv_search_inet_addr="no"
 cat > conftest.$ac_ext <<EOF
-#line 9927 "configure"
+#line 9670 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9934,7 +9677,7 @@ int main() {
 inet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:9938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_search_inet_addr="none required"
 else
@@ -9945,7 +9688,7 @@ rm -f conftest*
 test "$ac_cv_search_inet_addr" = "no" && for i in nsl; do
 LIBS="-l$i  $ac_func_search_save_LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 9949 "configure"
+#line 9692 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -9956,7 +9699,7 @@ int main() {
 inet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:9960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_search_inet_addr="-l$i"
 break
@@ -9981,17 +9724,17 @@ fi
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:9985: checking for $ac_hdr" >&5
+echo "configure:9728: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 9990 "configure"
+#line 9733 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:9995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -10021,17 +9764,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10025: checking for $ac_hdr" >&5
+echo "configure:9768: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10030 "configure"
+#line 9773 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10035: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -10061,17 +9804,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:10065: checking for $ac_hdr" >&5
+echo "configure:9808: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 10070 "configure"
+#line 9813 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:10075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:9818: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -10100,17 +9843,17 @@ done
 
   
   echo $ac_n "checking for prctl""... $ac_c" 1>&6
-echo "configure:10104: checking for prctl" >&5
+echo "configure:9847: checking for prctl" >&5
 
   cat > conftest.$ac_ext <<EOF
-#line 10107 "configure"
+#line 9850 "configure"
 #include "confdefs.h"
  #include <sys/prctl.h> 
 int main() {
 prctl(0, 0, 0, 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:10114: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:9857: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     cat >> confdefs.h <<\EOF
@@ -10133,17 +9876,17 @@ rm -f conftest*
   have_clock_gettime=no
 
   echo $ac_n "checking for clock_gettime""... $ac_c" 1>&6
-echo "configure:10137: checking for clock_gettime" >&5
+echo "configure:9880: checking for clock_gettime" >&5
 
   cat > conftest.$ac_ext <<EOF
-#line 10140 "configure"
+#line 9883 "configure"
 #include "confdefs.h"
  #include <time.h> 
 int main() {
 struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
 ; return 0; }
 EOF
-if { (eval echo configure:10147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
     have_clock_gettime=yes
@@ -10161,20 +9904,20 @@ rm -f conftest*
 
   if test "$have_clock_gettime" = "no"; then
     echo $ac_n "checking for clock_gettime in -lrt""... $ac_c" 1>&6
-echo "configure:10165: checking for clock_gettime in -lrt" >&5
+echo "configure:9908: checking for clock_gettime in -lrt" >&5
 
     SAVED_LIBS="$LIBS"
     LIBS="$LIBS -lrt"
 
     cat > conftest.$ac_ext <<EOF
-#line 10171 "configure"
+#line 9914 "configure"
 #include "confdefs.h"
  #include <time.h> 
 int main() {
 struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
 ; return 0; }
 EOF
-if { (eval echo configure:10178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
       have_clock_gettime=yes
@@ -10203,13 +9946,13 @@ EOF
 
   if test "$have_clock_gettime" = "no"; then
     echo $ac_n "checking for clock_get_time""... $ac_c" 1>&6
-echo "configure:10207: checking for clock_get_time" >&5
+echo "configure:9950: checking for clock_get_time" >&5
 
     if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 10213 "configure"
+#line 9956 "configure"
 #include "confdefs.h"
  #include <mach/mach.h>
       #include <mach/clock.h>
@@ -10233,7 +9976,7 @@ else
       }
     
 EOF
-if { (eval echo configure:10237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:9980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       have_clock_get_time=yes
@@ -10264,10 +10007,10 @@ EOF
   have_broken_ptrace=no
 
   echo $ac_n "checking for ptrace""... $ac_c" 1>&6
-echo "configure:10268: checking for ptrace" >&5
+echo "configure:10011: checking for ptrace" >&5
 
   cat > conftest.$ac_ext <<EOF
-#line 10271 "configure"
+#line 10014 "configure"
 #include "confdefs.h"
 
     #include <sys/types.h>
@@ -10276,7 +10019,7 @@ int main() {
 ptrace(0, 0, (void *) 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:10280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10023: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     have_ptrace=yes
@@ -10294,13 +10037,13 @@ rm -f conftest*
 
   if test "$have_ptrace" = "yes"; then
     echo $ac_n "checking whether ptrace works""... $ac_c" 1>&6
-echo "configure:10298: checking whether ptrace works" >&5
+echo "configure:10041: checking whether ptrace works" >&5
 
     if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 10304 "configure"
+#line 10047 "configure"
 #include "confdefs.h"
 
       #include <unistd.h>
@@ -10371,7 +10114,7 @@ else
       }
     
 EOF
-if { (eval echo configure:10375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:10118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       echo "$ac_t""yes" 1>&6
@@ -10402,10 +10145,10 @@ EOF
 
   if test "$have_broken_ptrace" = "yes"; then
     echo $ac_n "checking for mach_vm_read""... $ac_c" 1>&6
-echo "configure:10406: checking for mach_vm_read" >&5
+echo "configure:10149: checking for mach_vm_read" >&5
 
     cat > conftest.$ac_ext <<EOF
-#line 10409 "configure"
+#line 10152 "configure"
 #include "confdefs.h"
  #include <mach/mach.h>
       #include <mach/mach_vm.h>
@@ -10416,7 +10159,7 @@ int main() {
     
 ; return 0; }
 EOF
-if { (eval echo configure:10420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:10163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
       have_mach_vm_read=yes
@@ -10452,13 +10195,13 @@ EOF
 
   if test -n "$proc_mem_file" ; then
     echo $ac_n "checking for proc mem file""... $ac_c" 1>&6
-echo "configure:10456: checking for proc mem file" >&5
+echo "configure:10199: checking for proc mem file" >&5
   
     if test "$cross_compiling" = yes; then
     { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 10462 "configure"
+#line 10205 "configure"
 #include "confdefs.h"
 
       #define _GNU_SOURCE
@@ -10488,7 +10231,7 @@ else
       }
     
 EOF
-if { (eval echo configure:10492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:10235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       echo "$ac_t""$proc_mem_file" 1>&6
@@ -10530,6 +10273,113 @@ EOF
   fi
   
 
+  
+  echo $ac_n "checking if gcc supports __sync_bool_compare_and_swap""... $ac_c" 1>&6
+echo "configure:10279: checking if gcc supports __sync_bool_compare_and_swap" >&5
+  cat > conftest.$ac_ext <<EOF
+#line 10281 "configure"
+#include "confdefs.h"
+
+int main() {
+
+    int variable = 1;
+    return (__sync_bool_compare_and_swap(&variable, 1, 2)
+           && __sync_add_and_fetch(&variable, 1)) ? 1 : 0;
+  
+; return 0; }
+EOF
+if { (eval echo configure:10292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  
+    echo "$ac_t""yes" 1>&6
+    cat >> confdefs.h <<\EOF
+#define HAVE_BUILTIN_ATOMIC 1
+EOF
+
+  
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+    echo "$ac_t""no" 1>&6
+  
+fi
+rm -f conftest*
+
+  
+  have_lq=no
+
+  echo $ac_n "checking for TCP_INFO""... $ac_c" 1>&6
+echo "configure:10315: checking for TCP_INFO" >&5
+
+  cat > conftest.$ac_ext <<EOF
+#line 10318 "configure"
+#include "confdefs.h"
+ #include <netinet/tcp.h> 
+int main() {
+struct tcp_info ti; int x = TCP_INFO;
+; return 0; }
+EOF
+if { (eval echo configure:10325: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+    have_lq=tcp_info
+    echo "$ac_t""yes" 1>&6
+  
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+    echo "$ac_t""no" 1>&6
+  
+fi
+rm -f conftest*
+
+  if test "$have_lq" = "tcp_info"; then
+    cat >> confdefs.h <<\EOF
+#define HAVE_LQ_TCP_INFO 1
+EOF
+
+  fi
+
+  if test "$have_lq" = "no" ; then
+    echo $ac_n "checking for SO_LISTENQLEN""... $ac_c" 1>&6
+echo "configure:10350: checking for SO_LISTENQLEN" >&5
+
+    cat > conftest.$ac_ext <<EOF
+#line 10353 "configure"
+#include "confdefs.h"
+ #include <sys/socket.h> 
+int main() {
+int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;
+; return 0; }
+EOF
+if { (eval echo configure:10360: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  
+      have_lq=so_listenq
+      echo "$ac_t""yes" 1>&6
+    
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  
+      echo "$ac_t""no" 1>&6
+    
+fi
+rm -f conftest*
+
+    if test "$have_lq" = "tcp_info"; then
+      cat >> confdefs.h <<\EOF
+#define HAVE_LQ_SO_LISTENQ 1
+EOF
+
+    fi
+  fi
+
 
   
 php_with_fpm_user=nobody
@@ -10542,10 +10392,7 @@ if test "${with_fpm_user+set}" = set; then
 else
   
   PHP_FPM_USER=nobody
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FPM_USER=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -10567,10 +10414,7 @@ if test "${with_fpm_group+set}" = set; then
 else
   
   PHP_FPM_GROUP=nobody
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FPM_GROUP=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -10595,12 +10439,6 @@ ext_output=$PHP_FPM_GROUP
 
   
   
-  PHP_VAR_SUBST="$PHP_VAR_SUBST fpm_version"
-
-  
-
-  
-  
   PHP_VAR_SUBST="$PHP_VAR_SUBST php_fpm_user"
 
   
@@ -10625,10 +10463,13 @@ ext_output=$PHP_FPM_GROUP
 
   
 
+  php_fpm_prefix=`eval echo $prefix`
+  
+  
+  PHP_VAR_SUBST="$PHP_VAR_SUBST php_fpm_prefix"
+
+  
 
-  cat >> confdefs.h <<EOF
-#define PHP_FPM_VERSION "$fpm_version"
-EOF
 
   cat >> confdefs.h <<EOF
 #define PHP_FPM_USER "$php_fpm_user"
@@ -10640,7 +10481,7 @@ EOF
 
 
   
-  PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.1"
+  PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.8"
 
   
   src=$abs_srcdir/sapi/fpm/Makefile.frag
@@ -10658,12 +10499,7 @@ EOF
     PHP_FPM_TRACE_FILES="fpm/fpm_trace.c fpm/fpm_trace_$fpm_trace_type.c"
   fi
   
-  PHP_FPM_CFLAGS="$LIBEVENT_CFLAGS -I$abs_srcdir/sapi/fpm"
-
-  SAPI_EXTRA_LIBS="$LIBEVENT_LIBS"
-  
-  PHP_VAR_SUBST="$PHP_VAR_SUBST SAPI_EXTRA_LIBS"
-
+  PHP_FPM_CFLAGS="-I$abs_srcdir/sapi/fpm"
  
   INSTALL_IT=":"
   PHP_FPM_FILES="fpm/fastcgi.c \
@@ -10691,6 +10527,17 @@ EOF
   "
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=fpm
   
   case "program" in
@@ -10885,7 +10732,7 @@ fi
 php_with_isapi=no
 
 echo $ac_n "checking for Zeus ISAPI support""... $ac_c" 1>&6
-echo "configure:10889: checking for Zeus ISAPI support" >&5
+echo "configure:10736: checking for Zeus ISAPI support" >&5
 # Check whether --with-isapi or --without-isapi was given.
 if test "${with_isapi+set}" = set; then
   withval="$with_isapi"
@@ -10893,10 +10740,7 @@ if test "${with_isapi+set}" = set; then
 else
   
   PHP_ISAPI=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ISAPI=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -10956,6 +10800,17 @@ EOF
   fi
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=isapi
   
   case "shared" in
@@ -11131,7 +10986,7 @@ fi
 
 
 echo $ac_n "checking for LiteSpeed support""... $ac_c" 1>&6
-echo "configure:11135: checking for LiteSpeed support" >&5
+echo "configure:10990: checking for LiteSpeed support" >&5
 
 
 php_with_litespeed=no
@@ -11144,10 +10999,7 @@ if test "${with_litespeed+set}" = set; then
 else
   
   PHP_LITESPEED=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_LITESPEED=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_LITESPEED=$PHP_ENABLE_ALL
 
 fi
 
@@ -11191,6 +11043,17 @@ if test "$PHP_LITESPEED" != "no"; then
   PHP_VAR_SUBST="$PHP_VAR_SUBST SAPI_LITESPEED_PATH"
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=litespeed
   
   case "program" in
@@ -11386,7 +11249,7 @@ echo "$ac_t""$PHP_LITESPEED" 1>&6
 php_with_milter=no
 
 echo $ac_n "checking for Milter support""... $ac_c" 1>&6
-echo "configure:11390: checking for Milter support" >&5
+echo "configure:11253: checking for Milter support" >&5
 # Check whether --with-milter or --without-milter was given.
 if test "${with_milter+set}" = set; then
   withval="$with_milter"
@@ -11394,10 +11257,7 @@ if test "${with_milter+set}" = set; then
 else
   
   PHP_MILTER=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MILTER=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -11437,6 +11297,17 @@ if test "$PHP_MILTER" != "no"; then
   test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src  >> Makefile.fragments
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=milter
   
   case "program" in
@@ -11670,7 +11541,7 @@ fi
 php_with_nsapi=no
 
 echo $ac_n "checking for NSAPI support""... $ac_c" 1>&6
-echo "configure:11674: checking for NSAPI support" >&5
+echo "configure:11545: checking for NSAPI support" >&5
 # Check whether --with-nsapi or --without-nsapi was given.
 if test "${with_nsapi+set}" = set; then
   withval="$with_nsapi"
@@ -11678,10 +11549,7 @@ if test "${with_nsapi+set}" = set; then
 else
   
   PHP_NSAPI=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_NSAPI=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -11697,7 +11565,7 @@ if test "$PHP_NSAPI" != "no"; then
     { echo "configure: error: Please specify the path to the root of your Netscape/iPlanet/Sun Webserver using --with-nsapi=DIR" 1>&2; exit 1; }
   fi
   echo $ac_n "checking for NSAPI include files""... $ac_c" 1>&6
-echo "configure:11701: checking for NSAPI include files" >&5
+echo "configure:11569: checking for NSAPI include files" >&5
   if test -d $PHP_NSAPI/include ; then
     NSAPI_INC_DIR="$PHP_NSAPI/include"
     echo "$ac_t""Netscape 3.x / Sun 7.x style" 1>&6
@@ -11705,17 +11573,17 @@ echo "configure:11701: checking for NSAPI include files" >&5
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11709: checking for $ac_hdr" >&5
+echo "configure:11577: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11714 "configure"
+#line 11582 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11587: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11750,17 +11618,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:11754: checking for $ac_hdr" >&5
+echo "configure:11622: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 11759 "configure"
+#line 11627 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:11764: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:11632: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -11843,6 +11711,17 @@ done
 EOF
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=nsapi
   
   case "shared" in
@@ -12022,7 +11901,7 @@ fi
 php_with_phttpd=no
 
 echo $ac_n "checking for PHTTPD support""... $ac_c" 1>&6
-echo "configure:12026: checking for PHTTPD support" >&5
+echo "configure:11905: checking for PHTTPD support" >&5
 # Check whether --with-phttpd or --without-phttpd was given.
 if test "${with_phttpd+set}" = set; then
   withval="$with_phttpd"
@@ -12030,10 +11909,7 @@ if test "${with_phttpd+set}" = set; then
 else
   
   PHP_PHTTPD=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PHTTPD=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -12090,6 +11966,17 @@ if test "$PHP_PHTTPD" != "no"; then
 EOF
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=phttpd
   
   case "shared" in
@@ -12268,7 +12155,7 @@ fi
 php_with_pi3web=no
 
 echo $ac_n "checking for Pi3Web support""... $ac_c" 1>&6
-echo "configure:12272: checking for Pi3Web support" >&5
+echo "configure:12159: checking for Pi3Web support" >&5
 # Check whether --with-pi3web or --without-pi3web was given.
 if test "${with_pi3web+set}" = set; then
   withval="$with_pi3web"
@@ -12276,10 +12163,7 @@ if test "${with_pi3web+set}" = set; then
 else
   
   PHP_PI3WEB=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PI3WEB=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -12432,6 +12316,17 @@ EOF
   fi
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=pi3web
   
   case "shared" in
@@ -12617,10 +12512,7 @@ if test "${with_roxen+set}" = set; then
 else
   
   PHP_ROXEN=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ROXEN=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -12635,7 +12527,7 @@ ext_output=$PHP_ROXEN
 php_enable_roxen_zts=no
 
 echo $ac_n "checking whether Roxen module is build using ZTS""... $ac_c" 1>&6
-echo "configure:12639: checking whether Roxen module is build using ZTS" >&5
+echo "configure:12531: checking whether Roxen module is build using ZTS" >&5
 # Check whether --enable-roxen-zts or --disable-roxen-zts was given.
 if test "${enable_roxen_zts+set}" = set; then
   enableval="$enable_roxen_zts"
@@ -12643,10 +12535,7 @@ if test "${enable_roxen_zts+set}" = set; then
 else
   
   PHP_ROXEN_ZTS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ROXEN_ZTS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -12659,7 +12548,7 @@ echo "$ac_t""$ext_output" 1>&6
 
 RESULT=
 echo $ac_n "checking for Roxen/Pike support""... $ac_c" 1>&6
-echo "configure:12663: checking for Roxen/Pike support" >&5
+echo "configure:12552: checking for Roxen/Pike support" >&5
 if test "$PHP_ROXEN" != "no"; then
   if test ! -d $PHP_ROXEN ; then
     { echo "configure: error: You did not specify a directory" 1>&2; exit 1; }
@@ -12718,6 +12607,17 @@ if test "$PHP_ROXEN" != "no"; then
 EOF
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=roxen
   
   case "shared" in
@@ -12922,10 +12822,7 @@ if test "${with_thttpd+set}" = set; then
 else
   
   PHP_THTTPD=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_THTTPD=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -12937,7 +12834,7 @@ ext_output=$PHP_THTTPD
 
 
 echo $ac_n "checking for thttpd""... $ac_c" 1>&6
-echo "configure:12941: checking for thttpd" >&5
+echo "configure:12838: checking for thttpd" >&5
 
 if test "$PHP_THTTPD" != "no"; then
   if test ! -d $PHP_THTTPD; then
@@ -12970,7 +12867,7 @@ if test "$PHP_THTTPD" != "no"; then
         
   gcc_arg_name=ac_cv_gcc_arg_rdynamic
   echo $ac_n "checking whether $CC supports -rdynamic""... $ac_c" 1>&6
-echo "configure:12974: checking whether $CC supports -rdynamic" >&5
+echo "configure:12871: checking whether $CC supports -rdynamic" >&5
 if eval "test \"`echo '$''{'ac_cv_gcc_arg_rdynamic'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -13041,6 +12938,17 @@ echo "$ac_t""$ac_cv_gcc_arg_rdynamic" 1>&6
   fi
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=thttpd
   
   case "static" in
@@ -13183,10 +13091,7 @@ if test "${with_tux+set}" = set; then
 else
   
   PHP_TUX=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_TUX=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -13198,24 +13103,24 @@ ext_output=$PHP_TUX
 
 
 echo $ac_n "checking for TUX""... $ac_c" 1>&6
-echo "configure:13202: checking for TUX" >&5
+echo "configure:13107: checking for TUX" >&5
 if test "$PHP_TUX" != "no"; then
   INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_TUX/php5.tux.so"
   for ac_hdr in tuxmodule.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:13209: checking for $ac_hdr" >&5
+echo "configure:13114: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 13214 "configure"
+#line 13119 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:13219: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:13124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -13243,6 +13148,17 @@ fi
 done
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=tux
   
   case "shared" in
@@ -13429,10 +13345,7 @@ if test "${with_webjames+set}" = set; then
 else
   
   PHP_WEBJAMES=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_WEBJAMES=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -13444,7 +13357,7 @@ ext_output=$PHP_WEBJAMES
 
 
 echo $ac_n "checking for webjames""... $ac_c" 1>&6
-echo "configure:13448: checking for webjames" >&5
+echo "configure:13361: checking for webjames" >&5
 
 if test "$PHP_WEBJAMES" != "no"; then
   
@@ -13494,6 +13407,17 @@ if test "$PHP_WEBJAMES" != "no"; then
   fi
 
   
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=webjames
   
   case "static" in
@@ -13680,10 +13604,7 @@ if test "${enable_cgi+set}" = set; then
 else
   
   PHP_CGI=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CGI=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -13696,14 +13617,14 @@ ext_output=$PHP_CGI
 
 if test "$PHP_SAPI" = "default"; then
   echo $ac_n "checking whether to build CGI binary""... $ac_c" 1>&6
-echo "configure:13700: checking whether to build CGI binary" >&5
+echo "configure:13621: checking whether to build CGI binary" >&5
   if test "$PHP_CGI" != "no"; then
     echo "$ac_t""yes" 1>&6
 
     echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6
-echo "configure:13705: checking for socklen_t in sys/socket.h" >&5
+echo "configure:13626: checking for socklen_t in sys/socket.h" >&5
     cat > conftest.$ac_ext <<EOF
-#line 13707 "configure"
+#line 13628 "configure"
 #include "confdefs.h"
 #include <sys/socket.h>
 EOF
@@ -13723,9 +13644,9 @@ rm -f conftest*
 
 
     echo $ac_n "checking for sun_len in sys/un.h""... $ac_c" 1>&6
-echo "configure:13727: checking for sun_len in sys/un.h" >&5
+echo "configure:13648: checking for sun_len in sys/un.h" >&5
     cat > conftest.$ac_ext <<EOF
-#line 13729 "configure"
+#line 13650 "configure"
 #include "confdefs.h"
 #include <sys/un.h>
 EOF
@@ -13745,7 +13666,7 @@ rm -f conftest*
 
 
     echo $ac_n "checking whether cross-process locking is required by accept()""... $ac_c" 1>&6
-echo "configure:13749: checking whether cross-process locking is required by accept()" >&5
+echo "configure:13670: checking whether cross-process locking is required by accept()" >&5
     case "`uname -sr`" in
       IRIX\ 5.* | SunOS\ 5.* | UNIX_System_V\ 4.0)	
         echo "$ac_t""yes" 1>&6
@@ -13780,6 +13701,17 @@ EOF
 
         INSTALL_IT="@echo \"Installing PHP CGI binary: \$(INSTALL_ROOT)\$(bindir)/\"; \$(INSTALL) -m 0755 \$(SAPI_CGI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php-cgi\$(program_suffix)\$(EXEEXT)"
     
+  if test "$PHP_SAPI" != "default"; then
+{ echo "configure: error: 
++--------------------------------------------------------------------+
+|                        *** ATTENTION ***                           |
+|                                                                    |
+| You've configured multiple SAPIs to be build. You can build only   |
+| one SAPI module and CLI binary at the same time.                   |
++--------------------------------------------------------------------+
+" 1>&2; exit 1; }
+  fi
+
   PHP_SAPI=cgi
   
   case "program" in
@@ -13978,7 +13910,7 @@ fi
 
 
 echo $ac_n "checking for chosen SAPI module""... $ac_c" 1>&6
-echo "configure:13982: checking for chosen SAPI module" >&5
+echo "configure:13914: checking for chosen SAPI module" >&5
 echo "$ac_t""$PHP_SAPI" 1>&6
 
 if test "$enable_maintainer_zts" = "yes"; then
@@ -14035,7 +13967,7 @@ fi
   # Extract the first word of "sendmail", so it can be a program name with args.
 set dummy sendmail; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:14039: checking for $ac_word" >&5
+echo "configure:13971: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PROG_SENDMAIL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -14074,7 +14006,7 @@ fi
 
 
   echo $ac_n "checking whether system uses EBCDIC""... $ac_c" 1>&6
-echo "configure:14078: checking whether system uses EBCDIC" >&5
+echo "configure:14010: checking whether system uses EBCDIC" >&5
 if eval "test \"`echo '$''{'ac_cv_ebcdic'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -14085,7 +14017,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 14089 "configure"
+#line 14021 "configure"
 #include "confdefs.h"
 
 int main(void) { 
@@ -14093,7 +14025,7 @@ int main(void) {
 } 
 
 EOF
-if { (eval echo configure:14097: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_ebcdic=yes
@@ -14121,7 +14053,7 @@ EOF
 
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:14125: checking whether byte ordering is bigendian" >&5
+echo "configure:14057: checking whether byte ordering is bigendian" >&5
 if eval "test \"`echo '$''{'ac_cv_c_bigendian_php'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -14131,7 +14063,7 @@ else
   ac_cv_c_bigendian_php=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 14135 "configure"
+#line 14067 "configure"
 #include "confdefs.h"
 
 int main(void)
@@ -14147,7 +14079,7 @@ int main(void)
 }
   
 EOF
-if { (eval echo configure:14151: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14083: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_bigendian_php=yes
 else
@@ -14173,7 +14105,7 @@ EOF
 
 
   echo $ac_n "checking whether writing to stdout works""... $ac_c" 1>&6
-echo "configure:14177: checking whether writing to stdout works" >&5
+echo "configure:14109: checking whether writing to stdout works" >&5
 if eval "test \"`echo '$''{'ac_cv_write_stdout'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -14184,7 +14116,7 @@ else
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 14188 "configure"
+#line 14120 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_UNISTD_H
@@ -14202,7 +14134,7 @@ main()
 }
     
 EOF
-if { (eval echo configure:14206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       ac_cv_write_stdout=yes
@@ -14277,12 +14209,12 @@ test -d /usr/ucblib &&
   unset found
   
   echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:14281: checking for socket" >&5
+echo "configure:14213: checking for socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14286 "configure"
+#line 14218 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -14305,7 +14237,7 @@ socket();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14309: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -14323,12 +14255,12 @@ if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __socket""... $ac_c" 1>&6
-echo "configure:14327: checking for __socket" >&5
+echo "configure:14259: checking for __socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func___socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14332 "configure"
+#line 14264 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __socket(); below.  */
@@ -14351,7 +14283,7 @@ __socket();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___socket=yes"
 else
@@ -14389,7 +14321,7 @@ EOF
   unset ac_cv_lib_socket___socket
   unset found
   echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:14393: checking for socket in -lsocket" >&5
+echo "configure:14325: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14397,7 +14329,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14401 "configure"
+#line 14333 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14408,7 +14340,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:14412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14428,7 +14360,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __socket in -lsocket""... $ac_c" 1>&6
-echo "configure:14432: checking for __socket in -lsocket" >&5
+echo "configure:14364: checking for __socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'__socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14436,7 +14368,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14440 "configure"
+#line 14372 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14447,7 +14379,7 @@ int main() {
 __socket()
 ; return 0; }
 EOF
-if { (eval echo configure:14451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14479,11 +14411,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14483 "configure"
+#line 14415 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:14487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -14534,12 +14466,12 @@ EOF
   unset found
   
   echo $ac_n "checking for socketpair""... $ac_c" 1>&6
-echo "configure:14538: checking for socketpair" >&5
+echo "configure:14470: checking for socketpair" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socketpair'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14543 "configure"
+#line 14475 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socketpair(); below.  */
@@ -14562,7 +14494,7 @@ socketpair();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socketpair=yes"
 else
@@ -14580,12 +14512,12 @@ if eval "test \"`echo '$ac_cv_func_'socketpair`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __socketpair""... $ac_c" 1>&6
-echo "configure:14584: checking for __socketpair" >&5
+echo "configure:14516: checking for __socketpair" >&5
 if eval "test \"`echo '$''{'ac_cv_func___socketpair'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14589 "configure"
+#line 14521 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __socketpair(); below.  */
@@ -14608,7 +14540,7 @@ __socketpair();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___socketpair=yes"
 else
@@ -14646,7 +14578,7 @@ EOF
   unset ac_cv_lib_socket___socketpair
   unset found
   echo $ac_n "checking for socketpair in -lsocket""... $ac_c" 1>&6
-echo "configure:14650: checking for socketpair in -lsocket" >&5
+echo "configure:14582: checking for socketpair in -lsocket" >&5
 ac_lib_var=`echo socket'_'socketpair | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14654,7 +14586,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14658 "configure"
+#line 14590 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14665,7 +14597,7 @@ int main() {
 socketpair()
 ; return 0; }
 EOF
-if { (eval echo configure:14669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14601: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14685,7 +14617,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __socketpair in -lsocket""... $ac_c" 1>&6
-echo "configure:14689: checking for __socketpair in -lsocket" >&5
+echo "configure:14621: checking for __socketpair in -lsocket" >&5
 ac_lib_var=`echo socket'_'__socketpair | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14693,7 +14625,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14697 "configure"
+#line 14629 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14704,7 +14636,7 @@ int main() {
 __socketpair()
 ; return 0; }
 EOF
-if { (eval echo configure:14708: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14736,11 +14668,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14740 "configure"
+#line 14672 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:14744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -14791,12 +14723,12 @@ EOF
   unset found
   
   echo $ac_n "checking for htonl""... $ac_c" 1>&6
-echo "configure:14795: checking for htonl" >&5
+echo "configure:14727: checking for htonl" >&5
 if eval "test \"`echo '$''{'ac_cv_func_htonl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14800 "configure"
+#line 14732 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char htonl(); below.  */
@@ -14819,7 +14751,7 @@ htonl();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14823: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_htonl=yes"
 else
@@ -14837,12 +14769,12 @@ if eval "test \"`echo '$ac_cv_func_'htonl`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __htonl""... $ac_c" 1>&6
-echo "configure:14841: checking for __htonl" >&5
+echo "configure:14773: checking for __htonl" >&5
 if eval "test \"`echo '$''{'ac_cv_func___htonl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14846 "configure"
+#line 14778 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __htonl(); below.  */
@@ -14865,7 +14797,7 @@ __htonl();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___htonl=yes"
 else
@@ -14903,7 +14835,7 @@ EOF
   unset ac_cv_lib_socket___htonl
   unset found
   echo $ac_n "checking for htonl in -lsocket""... $ac_c" 1>&6
-echo "configure:14907: checking for htonl in -lsocket" >&5
+echo "configure:14839: checking for htonl in -lsocket" >&5
 ac_lib_var=`echo socket'_'htonl | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14911,7 +14843,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14915 "configure"
+#line 14847 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14922,7 +14854,7 @@ int main() {
 htonl()
 ; return 0; }
 EOF
-if { (eval echo configure:14926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14942,7 +14874,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __htonl in -lsocket""... $ac_c" 1>&6
-echo "configure:14946: checking for __htonl in -lsocket" >&5
+echo "configure:14878: checking for __htonl in -lsocket" >&5
 ac_lib_var=`echo socket'_'__htonl | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14950,7 +14882,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14954 "configure"
+#line 14886 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14961,7 +14893,7 @@ int main() {
 __htonl()
 ; return 0; }
 EOF
-if { (eval echo configure:14965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14993,11 +14925,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 14997 "configure"
+#line 14929 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:14933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15048,12 +14980,12 @@ EOF
   unset found
   
   echo $ac_n "checking for gethostname""... $ac_c" 1>&6
-echo "configure:15052: checking for gethostname" >&5
+echo "configure:14984: checking for gethostname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15057 "configure"
+#line 14989 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostname(); below.  */
@@ -15076,7 +15008,7 @@ gethostname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostname=yes"
 else
@@ -15094,12 +15026,12 @@ if eval "test \"`echo '$ac_cv_func_'gethostname`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __gethostname""... $ac_c" 1>&6
-echo "configure:15098: checking for __gethostname" >&5
+echo "configure:15030: checking for __gethostname" >&5
 if eval "test \"`echo '$''{'ac_cv_func___gethostname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15103 "configure"
+#line 15035 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __gethostname(); below.  */
@@ -15122,7 +15054,7 @@ __gethostname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15126: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___gethostname=yes"
 else
@@ -15160,7 +15092,7 @@ EOF
   unset ac_cv_lib_nsl___gethostname
   unset found
   echo $ac_n "checking for gethostname in -lnsl""... $ac_c" 1>&6
-echo "configure:15164: checking for gethostname in -lnsl" >&5
+echo "configure:15096: checking for gethostname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15168,7 +15100,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15172 "configure"
+#line 15104 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15179,7 +15111,7 @@ int main() {
 gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:15183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15199,7 +15131,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __gethostname in -lnsl""... $ac_c" 1>&6
-echo "configure:15203: checking for __gethostname in -lnsl" >&5
+echo "configure:15135: checking for __gethostname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'__gethostname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15207,7 +15139,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15211 "configure"
+#line 15143 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15218,7 +15150,7 @@ int main() {
 __gethostname()
 ; return 0; }
 EOF
-if { (eval echo configure:15222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15250,11 +15182,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 15254 "configure"
+#line 15186 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15258: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15190: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15305,12 +15237,12 @@ EOF
   unset found
   
   echo $ac_n "checking for gethostbyaddr""... $ac_c" 1>&6
-echo "configure:15309: checking for gethostbyaddr" >&5
+echo "configure:15241: checking for gethostbyaddr" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyaddr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15314 "configure"
+#line 15246 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyaddr(); below.  */
@@ -15333,7 +15265,7 @@ gethostbyaddr();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyaddr=yes"
 else
@@ -15351,12 +15283,12 @@ if eval "test \"`echo '$ac_cv_func_'gethostbyaddr`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __gethostbyaddr""... $ac_c" 1>&6
-echo "configure:15355: checking for __gethostbyaddr" >&5
+echo "configure:15287: checking for __gethostbyaddr" >&5
 if eval "test \"`echo '$''{'ac_cv_func___gethostbyaddr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15360 "configure"
+#line 15292 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __gethostbyaddr(); below.  */
@@ -15379,7 +15311,7 @@ __gethostbyaddr();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___gethostbyaddr=yes"
 else
@@ -15417,7 +15349,7 @@ EOF
   unset ac_cv_lib_nsl___gethostbyaddr
   unset found
   echo $ac_n "checking for gethostbyaddr in -lnsl""... $ac_c" 1>&6
-echo "configure:15421: checking for gethostbyaddr in -lnsl" >&5
+echo "configure:15353: checking for gethostbyaddr in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyaddr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15425,7 +15357,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15429 "configure"
+#line 15361 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15436,7 +15368,7 @@ int main() {
 gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:15440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15456,7 +15388,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __gethostbyaddr in -lnsl""... $ac_c" 1>&6
-echo "configure:15460: checking for __gethostbyaddr in -lnsl" >&5
+echo "configure:15392: checking for __gethostbyaddr in -lnsl" >&5
 ac_lib_var=`echo nsl'_'__gethostbyaddr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15464,7 +15396,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15468 "configure"
+#line 15400 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15475,7 +15407,7 @@ int main() {
 __gethostbyaddr()
 ; return 0; }
 EOF
-if { (eval echo configure:15479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15507,11 +15439,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 15511 "configure"
+#line 15443 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15447: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15562,12 +15494,12 @@ EOF
   unset found
   
   echo $ac_n "checking for yp_get_default_domain""... $ac_c" 1>&6
-echo "configure:15566: checking for yp_get_default_domain" >&5
+echo "configure:15498: checking for yp_get_default_domain" >&5
 if eval "test \"`echo '$''{'ac_cv_func_yp_get_default_domain'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15571 "configure"
+#line 15503 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char yp_get_default_domain(); below.  */
@@ -15590,7 +15522,7 @@ yp_get_default_domain();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_yp_get_default_domain=yes"
 else
@@ -15608,12 +15540,12 @@ if eval "test \"`echo '$ac_cv_func_'yp_get_default_domain`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __yp_get_default_domain""... $ac_c" 1>&6
-echo "configure:15612: checking for __yp_get_default_domain" >&5
+echo "configure:15544: checking for __yp_get_default_domain" >&5
 if eval "test \"`echo '$''{'ac_cv_func___yp_get_default_domain'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15617 "configure"
+#line 15549 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __yp_get_default_domain(); below.  */
@@ -15636,7 +15568,7 @@ __yp_get_default_domain();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___yp_get_default_domain=yes"
 else
@@ -15674,7 +15606,7 @@ EOF
   unset ac_cv_lib_nsl___yp_get_default_domain
   unset found
   echo $ac_n "checking for yp_get_default_domain in -lnsl""... $ac_c" 1>&6
-echo "configure:15678: checking for yp_get_default_domain in -lnsl" >&5
+echo "configure:15610: checking for yp_get_default_domain in -lnsl" >&5
 ac_lib_var=`echo nsl'_'yp_get_default_domain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15682,7 +15614,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15686 "configure"
+#line 15618 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15693,7 +15625,7 @@ int main() {
 yp_get_default_domain()
 ; return 0; }
 EOF
-if { (eval echo configure:15697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15713,7 +15645,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __yp_get_default_domain in -lnsl""... $ac_c" 1>&6
-echo "configure:15717: checking for __yp_get_default_domain in -lnsl" >&5
+echo "configure:15649: checking for __yp_get_default_domain in -lnsl" >&5
 ac_lib_var=`echo nsl'_'__yp_get_default_domain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15721,7 +15653,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15725 "configure"
+#line 15657 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15732,7 +15664,7 @@ int main() {
 __yp_get_default_domain()
 ; return 0; }
 EOF
-if { (eval echo configure:15736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15764,11 +15696,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 15768 "configure"
+#line 15700 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:15772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -15820,12 +15752,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:15824: checking for dlopen" >&5
+echo "configure:15756: checking for dlopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15829 "configure"
+#line 15761 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); below.  */
@@ -15848,7 +15780,7 @@ dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dlopen=yes"
 else
@@ -15866,12 +15798,12 @@ if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __dlopen""... $ac_c" 1>&6
-echo "configure:15870: checking for __dlopen" >&5
+echo "configure:15802: checking for __dlopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func___dlopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15875 "configure"
+#line 15807 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dlopen(); below.  */
@@ -15894,7 +15826,7 @@ __dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___dlopen=yes"
 else
@@ -15932,7 +15864,7 @@ EOF
   unset ac_cv_lib_dl___dlopen
   unset found
   echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:15936: checking for dlopen in -ldl" >&5
+echo "configure:15868: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15940,7 +15872,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15944 "configure"
+#line 15876 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15951,7 +15883,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:15955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15887: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15971,7 +15903,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:15975: checking for __dlopen in -ldl" >&5
+echo "configure:15907: checking for __dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'__dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15979,7 +15911,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15983 "configure"
+#line 15915 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15990,7 +15922,7 @@ int main() {
 __dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:15994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16022,11 +15954,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 16026 "configure"
+#line 15958 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:16030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:15962: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -16078,7 +16010,7 @@ EOF
 
 fi
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
-echo "configure:16082: checking for sin in -lm" >&5
+echo "configure:16014: checking for sin in -lm" >&5
 ac_lib_var=`echo m'_'sin | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16086,7 +16018,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16090 "configure"
+#line 16022 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16097,7 +16029,7 @@ int main() {
 sin()
 ; return 0; }
 EOF
-if { (eval echo configure:16101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16033: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16131,12 +16063,12 @@ fi
   unset found
   
   echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
-echo "configure:16135: checking for inet_aton" >&5
+echo "configure:16067: checking for inet_aton" >&5
 if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16140 "configure"
+#line 16072 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char inet_aton(); below.  */
@@ -16159,7 +16091,7 @@ inet_aton();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_inet_aton=yes"
 else
@@ -16177,12 +16109,12 @@ if eval "test \"`echo '$ac_cv_func_'inet_aton`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __inet_aton""... $ac_c" 1>&6
-echo "configure:16181: checking for __inet_aton" >&5
+echo "configure:16113: checking for __inet_aton" >&5
 if eval "test \"`echo '$''{'ac_cv_func___inet_aton'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16186 "configure"
+#line 16118 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __inet_aton(); below.  */
@@ -16205,7 +16137,7 @@ __inet_aton();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___inet_aton=yes"
 else
@@ -16243,7 +16175,7 @@ EOF
   unset ac_cv_lib_resolv___inet_aton
   unset found
   echo $ac_n "checking for inet_aton in -lresolv""... $ac_c" 1>&6
-echo "configure:16247: checking for inet_aton in -lresolv" >&5
+echo "configure:16179: checking for inet_aton in -lresolv" >&5
 ac_lib_var=`echo resolv'_'inet_aton | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16251,7 +16183,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16255 "configure"
+#line 16187 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16262,7 +16194,7 @@ int main() {
 inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:16266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16282,7 +16214,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __inet_aton in -lresolv""... $ac_c" 1>&6
-echo "configure:16286: checking for __inet_aton in -lresolv" >&5
+echo "configure:16218: checking for __inet_aton in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__inet_aton | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16290,7 +16222,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16294 "configure"
+#line 16226 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16301,7 +16233,7 @@ int main() {
 __inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:16305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16333,11 +16265,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 16337 "configure"
+#line 16269 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:16341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -16379,7 +16311,7 @@ EOF
   unset ac_cv_lib_bind___inet_aton
   unset found
   echo $ac_n "checking for inet_aton in -lbind""... $ac_c" 1>&6
-echo "configure:16383: checking for inet_aton in -lbind" >&5
+echo "configure:16315: checking for inet_aton in -lbind" >&5
 ac_lib_var=`echo bind'_'inet_aton | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16387,7 +16319,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16391 "configure"
+#line 16323 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16398,7 +16330,7 @@ int main() {
 inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:16402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16418,7 +16350,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __inet_aton in -lbind""... $ac_c" 1>&6
-echo "configure:16422: checking for __inet_aton in -lbind" >&5
+echo "configure:16354: checking for __inet_aton in -lbind" >&5
 ac_lib_var=`echo bind'_'__inet_aton | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16426,7 +16358,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16430 "configure"
+#line 16362 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16437,7 +16369,7 @@ int main() {
 __inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:16441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16469,11 +16401,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 16473 "configure"
+#line 16405 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:16477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -16524,12 +16456,12 @@ EOF
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:16528: checking for ANSI C header files" >&5
+echo "configure:16460: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16533 "configure"
+#line 16465 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -16537,7 +16469,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:16541: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:16473: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -16554,7 +16486,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 16558 "configure"
+#line 16490 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -16572,7 +16504,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 16576 "configure"
+#line 16508 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -16593,7 +16525,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 16597 "configure"
+#line 16529 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -16604,7 +16536,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:16608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -16632,12 +16564,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:16636: checking for $ac_hdr that defines DIR" >&5
+echo "configure:16568: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16641 "configure"
+#line 16573 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -16645,7 +16577,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:16649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -16670,7 +16602,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:16674: checking for opendir in -ldir" >&5
+echo "configure:16606: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16678,7 +16610,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16682 "configure"
+#line 16614 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16689,7 +16621,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:16693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16711,7 +16643,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:16715: checking for opendir in -lx" >&5
+echo "configure:16647: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16719,7 +16651,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16723 "configure"
+#line 16655 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16730,7 +16662,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:16734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16812,17 +16744,17 @@ assert.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:16816: checking for $ac_hdr" >&5
+echo "configure:16748: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16821 "configure"
+#line 16753 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:16826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:16758: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -16851,12 +16783,12 @@ done
 
 
   echo $ac_n "checking for fopencookie""... $ac_c" 1>&6
-echo "configure:16855: checking for fopencookie" >&5
+echo "configure:16787: checking for fopencookie" >&5
 if eval "test \"`echo '$''{'ac_cv_func_fopencookie'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16860 "configure"
+#line 16792 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char fopencookie(); below.  */
@@ -16879,7 +16811,7 @@ fopencookie();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_fopencookie=yes"
 else
@@ -16901,7 +16833,7 @@ fi
 
   if test "$have_glibc_fopencookie" = "yes"; then
 cat > conftest.$ac_ext <<EOF
-#line 16905 "configure"
+#line 16837 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -16911,7 +16843,7 @@ int main() {
 cookie_io_functions_t cookie;
 ; return 0; }
 EOF
-if { (eval echo configure:16915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_cookie_io_functions_t=yes
 else
@@ -16930,7 +16862,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 16934 "configure"
+#line 16866 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -16962,7 +16894,7 @@ main() {
 
 
 EOF
-if { (eval echo configure:16966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:16898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cookie_io_functions_use_off64_t=yes
@@ -16982,7 +16914,7 @@ fi
     else
 
 cat > conftest.$ac_ext <<EOF
-#line 16986 "configure"
+#line 16918 "configure"
 #include "confdefs.h"
 
 #define _GNU_SOURCE
@@ -16992,7 +16924,7 @@ int main() {
  _IO_cookie_io_functions_t cookie; 
 ; return 0; }
 EOF
-if { (eval echo configure:16996: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   have_IO_cookie_io_functions_t=yes
 else
@@ -17026,7 +16958,7 @@ EOF
 
 
   echo $ac_n "checking for broken getcwd""... $ac_c" 1>&6
-echo "configure:17030: checking for broken getcwd" >&5
+echo "configure:16962: checking for broken getcwd" >&5
   os=`uname -sr 2>/dev/null`
   case $os in
     SunOS*)
@@ -17041,14 +16973,14 @@ EOF
 
 
   echo $ac_n "checking for broken libc stdio""... $ac_c" 1>&6
-echo "configure:17045: checking for broken libc stdio" >&5
+echo "configure:16977: checking for broken libc stdio" >&5
   if eval "test \"`echo '$''{'_cv_have_broken_glibc_fopen_append'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   if test "$cross_compiling" = yes; then
   cat > conftest.$ac_ext <<EOF
-#line 17052 "configure"
+#line 16984 "configure"
 #include "confdefs.h"
 
 #include <features.h>
@@ -17061,7 +16993,7 @@ choke me
 
 ; return 0; }
 EOF
-if { (eval echo configure:17065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16997: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   _cv_have_broken_glibc_fopen_append=yes
 else
@@ -17074,7 +17006,7 @@ rm -f conftest*
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 17078 "configure"
+#line 17010 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -17102,7 +17034,7 @@ int main(int argc, char *argv[])
 }
 
 EOF
-if { (eval echo configure:17106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   _cv_have_broken_glibc_fopen_append=no
 else
@@ -17130,12 +17062,12 @@ EOF
 
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:17134: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:17066: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17139 "configure"
+#line 17071 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -17143,7 +17075,7 @@ int main() {
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:17147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -17164,12 +17096,12 @@ EOF
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:17168: checking for tm_zone in struct tm" >&5
+echo "configure:17100: checking for tm_zone in struct tm" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17173 "configure"
+#line 17105 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -17177,7 +17109,7 @@ int main() {
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:17181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17113: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -17197,12 +17129,12 @@ EOF
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:17201: checking for tzname" >&5
+echo "configure:17133: checking for tzname" >&5
 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17206 "configure"
+#line 17138 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -17212,7 +17144,7 @@ int main() {
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:17216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -17236,16 +17168,16 @@ fi
 
 
   echo $ac_n "checking for missing declarations of reentrant functions""... $ac_c" 1>&6
-echo "configure:17240: checking for missing declarations of reentrant functions" >&5
+echo "configure:17172: checking for missing declarations of reentrant functions" >&5
   cat > conftest.$ac_ext <<EOF
-#line 17242 "configure"
+#line 17174 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 struct tm *(*func)() = localtime_r
 ; return 0; }
 EOF
-if { (eval echo configure:17249: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17181: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -17263,14 +17195,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17267 "configure"
+#line 17199 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 struct tm *(*func)() = gmtime_r
 ; return 0; }
 EOF
-if { (eval echo configure:17274: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -17288,14 +17220,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17292 "configure"
+#line 17224 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 char *(*func)() = asctime_r
 ; return 0; }
 EOF
-if { (eval echo configure:17299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -17313,14 +17245,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17317 "configure"
+#line 17249 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 char *(*func)() = ctime_r
 ; return 0; }
 EOF
-if { (eval echo configure:17324: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17256: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -17338,14 +17270,14 @@ EOF
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17342 "configure"
+#line 17274 "configure"
 #include "confdefs.h"
 #include <string.h>
 int main() {
 char *(*func)() = strtok_r
 ; return 0; }
 EOF
-if { (eval echo configure:17349: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     :
@@ -17366,16 +17298,16 @@ rm -f conftest*
 
 
   echo $ac_n "checking for fclose declaration""... $ac_c" 1>&6
-echo "configure:17370: checking for fclose declaration" >&5
+echo "configure:17302: checking for fclose declaration" >&5
   cat > conftest.$ac_ext <<EOF
-#line 17372 "configure"
+#line 17304 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 int (*func)() = fclose
 ; return 0; }
 EOF
-if { (eval echo configure:17379: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     cat >> confdefs.h <<\EOF
@@ -17401,12 +17333,12 @@ rm -f conftest*
 
 
 echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6
-echo "configure:17405: checking for tm_gmtoff in struct tm" >&5
+echo "configure:17337: checking for tm_gmtoff in struct tm" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm_gmtoff'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17410 "configure"
+#line 17342 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -17414,7 +17346,7 @@ int main() {
 struct tm tm; tm.tm_gmtoff;
 ; return 0; }
 EOF
-if { (eval echo configure:17418: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_gmtoff=yes
 else
@@ -17437,12 +17369,12 @@ fi
 
 
 echo $ac_n "checking for struct flock""... $ac_c" 1>&6
-echo "configure:17441: checking for struct flock" >&5
+echo "configure:17373: checking for struct flock" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_flock'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17446 "configure"
+#line 17378 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -17452,7 +17384,7 @@ int main() {
 struct flock x;
 ; return 0; }
 EOF
-if { (eval echo configure:17456: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17388: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
           ac_cv_struct_flock=yes
@@ -17479,12 +17411,12 @@ fi
 
 
 echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
-echo "configure:17483: checking for socklen_t" >&5
+echo "configure:17415: checking for socklen_t" >&5
 if eval "test \"`echo '$''{'ac_cv_socklen_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17488 "configure"
+#line 17420 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -17496,7 +17428,7 @@ socklen_t x;
 
 ; return 0; }
 EOF
-if { (eval echo configure:17500: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17432: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_socklen_t=yes
@@ -17522,7 +17454,7 @@ fi
 
 
 echo $ac_n "checking size of size_t""... $ac_c" 1>&6
-echo "configure:17526: checking size of size_t" >&5
+echo "configure:17458: checking size of size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17530,7 +17462,7 @@ else
   ac_cv_sizeof_size_t=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 17534 "configure"
+#line 17466 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -17541,7 +17473,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:17545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_size_t=`cat conftestval`
 else
@@ -17561,7 +17493,7 @@ EOF
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:17565: checking size of long long" >&5
+echo "configure:17497: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17569,7 +17501,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 17573 "configure"
+#line 17505 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -17580,7 +17512,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:17584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -17600,7 +17532,7 @@ EOF
 
 
 echo $ac_n "checking size of long long int""... $ac_c" 1>&6
-echo "configure:17604: checking size of long long int" >&5
+echo "configure:17536: checking size of long long int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17608,7 +17540,7 @@ else
   ac_cv_sizeof_long_long_int=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 17612 "configure"
+#line 17544 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -17619,7 +17551,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:17623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long_int=`cat conftestval`
 else
@@ -17639,7 +17571,7 @@ EOF
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:17643: checking size of long" >&5
+echo "configure:17575: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17647,7 +17579,7 @@ else
   ac_cv_sizeof_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 17651 "configure"
+#line 17583 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -17658,7 +17590,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:17662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -17678,7 +17610,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:17682: checking size of int" >&5
+echo "configure:17614: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17686,7 +17618,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 17690 "configure"
+#line 17622 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -17697,7 +17629,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:17701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -17719,7 +17651,7 @@ EOF
 
 
   echo $ac_n "checking size of intmax_t""... $ac_c" 1>&6
-echo "configure:17723: checking size of intmax_t" >&5
+echo "configure:17655: checking size of intmax_t" >&5
   
   php_cache_value=php_cv_sizeof_intmax_t
   if eval "test \"`echo '$''{'php_cv_sizeof_intmax_t'+set}'`\" = set"; then
@@ -17736,7 +17668,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 17740 "configure"
+#line 17672 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -17760,7 +17692,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:17764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     eval $php_cache_value=`cat conftestval`
@@ -17799,7 +17731,7 @@ EOF
 
 
   echo $ac_n "checking size of ssize_t""... $ac_c" 1>&6
-echo "configure:17803: checking size of ssize_t" >&5
+echo "configure:17735: checking size of ssize_t" >&5
   
   php_cache_value=php_cv_sizeof_ssize_t
   if eval "test \"`echo '$''{'php_cv_sizeof_ssize_t'+set}'`\" = set"; then
@@ -17816,7 +17748,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 17820 "configure"
+#line 17752 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -17840,7 +17772,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:17844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     eval $php_cache_value=`cat conftestval`
@@ -17879,7 +17811,7 @@ EOF
 
 
   echo $ac_n "checking size of ptrdiff_t""... $ac_c" 1>&6
-echo "configure:17883: checking size of ptrdiff_t" >&5
+echo "configure:17815: checking size of ptrdiff_t" >&5
   
   php_cache_value=php_cv_sizeof_ptrdiff_t
   if eval "test \"`echo '$''{'php_cv_sizeof_ptrdiff_t'+set}'`\" = set"; then
@@ -17896,7 +17828,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 17900 "configure"
+#line 17832 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -17920,7 +17852,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:17924: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:17856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     eval $php_cache_value=`cat conftestval`
@@ -17959,12 +17891,12 @@ EOF
 
 
 echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:17963: checking for st_blksize in struct stat" >&5
+echo "configure:17895: checking for st_blksize in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17968 "configure"
+#line 17900 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -17972,7 +17904,7 @@ int main() {
 struct stat s; s.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:17976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blksize=yes
 else
@@ -17994,12 +17926,12 @@ fi
 
 if test "`uname -s 2>/dev/null`" != "QNX"; then
   echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6
-echo "configure:17998: checking for st_blocks in struct stat" >&5
+echo "configure:17930: checking for st_blocks in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18003 "configure"
+#line 17935 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -18007,7 +17939,7 @@ int main() {
 struct stat s; s.st_blocks;
 ; return 0; }
 EOF
-if { (eval echo configure:18011: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17943: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_blocks=yes
 else
@@ -18034,12 +17966,12 @@ else
   WARNING_LEVEL=0
 fi
 echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:18038: checking for st_rdev in struct stat" >&5
+echo "configure:17970: checking for st_rdev in struct stat" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18043 "configure"
+#line 17975 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -18047,7 +17979,7 @@ int main() {
 struct stat s; s.st_rdev;
 ; return 0; }
 EOF
-if { (eval echo configure:18051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17983: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_st_rdev=yes
 else
@@ -18069,12 +18001,12 @@ fi
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:18073: checking for size_t" >&5
+echo "configure:18005: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18078 "configure"
+#line 18010 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -18102,12 +18034,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:18106: checking for uid_t in sys/types.h" >&5
+echo "configure:18038: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18111 "configure"
+#line 18043 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -18138,12 +18070,12 @@ fi
 
 
     echo $ac_n "checking for struct sockaddr_storage""... $ac_c" 1>&6
-echo "configure:18142: checking for struct sockaddr_storage" >&5
+echo "configure:18074: checking for struct sockaddr_storage" >&5
 if eval "test \"`echo '$''{'ac_cv_sockaddr_storage'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18147 "configure"
+#line 18079 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -18151,7 +18083,7 @@ int main() {
 struct sockaddr_storage s; s
 ; return 0; }
 EOF
-if { (eval echo configure:18155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:18087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sockaddr_storage=yes
 else
@@ -18172,13 +18104,13 @@ EOF
 
   fi
     echo $ac_n "checking for field sa_len in struct sockaddr""... $ac_c" 1>&6
-echo "configure:18176: checking for field sa_len in struct sockaddr" >&5
+echo "configure:18108: checking for field sa_len in struct sockaddr" >&5
 if eval "test \"`echo '$''{'ac_cv_sockaddr_sa_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 18182 "configure"
+#line 18114 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -18186,7 +18118,7 @@ int main() {
 static struct sockaddr sa; int n = (int) sa.sa_len; return n;
 ; return 0; }
 EOF
-if { (eval echo configure:18190: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:18122: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sockaddr_sa_len=yes
 else
@@ -18209,12 +18141,12 @@ EOF
 
 
 echo $ac_n "checking for IPv6 support""... $ac_c" 1>&6
-echo "configure:18213: checking for IPv6 support" >&5
+echo "configure:18145: checking for IPv6 support" >&5
 if eval "test \"`echo '$''{'ac_cv_ipv6_support'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18218 "configure"
+#line 18150 "configure"
 #include "confdefs.h"
  #include <sys/types.h>
 #include <sys/socket.h>
@@ -18223,7 +18155,7 @@ int main() {
 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:18227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_ipv6_support=yes
 else
@@ -18239,12 +18171,12 @@ echo "$ac_t""$ac_cv_ipv6_support" 1>&6
 
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:18243: checking for vprintf" >&5
+echo "configure:18175: checking for vprintf" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18248 "configure"
+#line 18180 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -18267,7 +18199,7 @@ vprintf();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vprintf=yes"
 else
@@ -18291,12 +18223,12 @@ fi
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:18295: checking for _doprnt" >&5
+echo "configure:18227: checking for _doprnt" >&5
 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18300 "configure"
+#line 18232 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -18319,7 +18251,7 @@ _doprnt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func__doprnt=yes"
 else
@@ -18427,12 +18359,12 @@ asprintf \
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:18431: checking for $ac_func" >&5
+echo "configure:18363: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18436 "configure"
+#line 18368 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -18455,7 +18387,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -18481,124 +18413,12 @@ done
 
 
 
-  unset ac_cv_func_nanosleep
-  unset ac_cv_func___nanosleep
-  unset found
-  
-  echo $ac_n "checking for nanosleep""... $ac_c" 1>&6
-echo "configure:18490: checking for nanosleep" >&5
-if eval "test \"`echo '$''{'ac_cv_func_nanosleep'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 18495 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char nanosleep(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char nanosleep();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_nanosleep) || defined (__stub___nanosleep)
-choke me
-#else
-nanosleep();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:18518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func_nanosleep=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_nanosleep=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'nanosleep`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  found=yes
-else
-  echo "$ac_t""no" 1>&6
- echo $ac_n "checking for __nanosleep""... $ac_c" 1>&6
-echo "configure:18536: checking for __nanosleep" >&5
-if eval "test \"`echo '$''{'ac_cv_func___nanosleep'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 18541 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char __nanosleep(); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-/* We use char because int might match the return type of a gcc2
-    builtin and then its argument prototype would still apply.  */
-char __nanosleep();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub___nanosleep) || defined (__stub_____nanosleep)
-choke me
-#else
-__nanosleep();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:18564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  eval "ac_cv_func___nanosleep=yes"
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func___nanosleep=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'__nanosleep`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  found=yes
-else
-  echo "$ac_t""no" 1>&6
-found=no
-fi
- 
-fi
-
-
-  case $found in
-  yes) 
-    cat >> confdefs.h <<\EOF
-#define HAVE_NANOSLEEP 1
-EOF
-
-    ac_cv_func_nanosleep=yes
-  ;;
-  
-    *) 
   
   unset ac_cv_lib_rt_nanosleep
   unset ac_cv_lib_rt___nanosleep
   unset found
   echo $ac_n "checking for nanosleep in -lrt""... $ac_c" 1>&6
-echo "configure:18602: checking for nanosleep in -lrt" >&5
+echo "configure:18422: checking for nanosleep in -lrt" >&5
 ac_lib_var=`echo rt'_'nanosleep | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -18606,7 +18426,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 18610 "configure"
+#line 18430 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -18617,7 +18437,7 @@ int main() {
 nanosleep()
 ; return 0; }
 EOF
-if { (eval echo configure:18621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -18637,7 +18457,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __nanosleep in -lrt""... $ac_c" 1>&6
-echo "configure:18641: checking for __nanosleep in -lrt" >&5
+echo "configure:18461: checking for __nanosleep in -lrt" >&5
 ac_lib_var=`echo rt'_'__nanosleep | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -18645,7 +18465,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 18649 "configure"
+#line 18469 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -18656,7 +18476,7 @@ int main() {
 __nanosleep()
 ; return 0; }
 EOF
-if { (eval echo configure:18660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -18688,11 +18508,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 18692 "configure"
+#line 18512 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:18696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -18733,31 +18553,28 @@ EOF
 
   fi
   
- ;;
-  
-  esac
 
 
 echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6
-echo "configure:18743: checking for getaddrinfo" >&5
+echo "configure:18560: checking for getaddrinfo" >&5
 if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18748 "configure"
+#line 18565 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);
 ; return 0; }
 EOF
-if { (eval echo configure:18755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   if test "$cross_compiling" = yes; then
   ac_cv_func_getaddrinfo=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 18761 "configure"
+#line 18578 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -18797,7 +18614,7 @@ int main(void) {
 }
   
 EOF
-if { (eval echo configure:18801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_getaddrinfo=yes
 else
@@ -18829,12 +18646,12 @@ fi
 for ac_func in strlcat strlcpy getopt
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:18833: checking for $ac_func" >&5
+echo "configure:18650: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18838 "configure"
+#line 18655 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -18857,7 +18674,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:18861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -18884,7 +18701,7 @@ done
 
 
 echo $ac_n "checking whether utime accepts a null argument""... $ac_c" 1>&6
-echo "configure:18888: checking whether utime accepts a null argument" >&5
+echo "configure:18705: checking whether utime accepts a null argument" >&5
 if eval "test \"`echo '$''{'ac_cv_func_utime_null'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -18894,7 +18711,7 @@ if test "$cross_compiling" = yes; then
   ac_cv_func_utime_null=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 18898 "configure"
+#line 18715 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -18905,7 +18722,7 @@ exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0
 && t.st_mtime - s.st_mtime < 120));
 }
 EOF
-if { (eval echo configure:18909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_utime_null=yes
 else
@@ -18931,19 +18748,19 @@ fi
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:18935: checking for working alloca.h" >&5
+echo "configure:18752: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18940 "configure"
+#line 18757 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:18947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -18964,12 +18781,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:18968: checking for alloca" >&5
+echo "configure:18785: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 18973 "configure"
+#line 18790 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -18997,7 +18814,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:19001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -19029,12 +18846,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:19033: checking whether alloca needs Cray hooks" >&5
+echo "configure:18850: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 19038 "configure"
+#line 18855 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -19059,12 +18876,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:19063: checking for $ac_func" >&5
+echo "configure:18880: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 19068 "configure"
+#line 18885 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -19087,7 +18904,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:19091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:18908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -19114,7 +18931,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:19118: checking stack direction for C alloca" >&5
+echo "configure:18935: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19122,7 +18939,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 19126 "configure"
+#line 18943 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -19141,7 +18958,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:19145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:18962: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -19164,13 +18981,13 @@ fi
 
 
   echo $ac_n "checking for declared timezone""... $ac_c" 1>&6
-echo "configure:19168: checking for declared timezone" >&5
+echo "configure:18985: checking for declared timezone" >&5
 if eval "test \"`echo '$''{'ac_cv_declared_timezone'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 19174 "configure"
+#line 18991 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -19185,7 +19002,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:19189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:19006: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_declared_timezone=yes
@@ -19211,7 +19028,7 @@ EOF
 
 
 echo $ac_n "checking for type of reentrant time-related functions""... $ac_c" 1>&6
-echo "configure:19215: checking for type of reentrant time-related functions" >&5
+echo "configure:19032: checking for type of reentrant time-related functions" >&5
 if eval "test \"`echo '$''{'ac_cv_time_r_type'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19222,7 +19039,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 19226 "configure"
+#line 19043 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -19240,7 +19057,7 @@ return (1);
 }
 
 EOF
-if { (eval echo configure:19244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:19061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_time_r_type=hpux
@@ -19256,7 +19073,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 19260 "configure"
+#line 19077 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -19272,7 +19089,7 @@ main() {
 }
   
 EOF
-if { (eval echo configure:19276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:19093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_time_r_type=irix
@@ -19310,12 +19127,12 @@ EOF
 
 
     echo $ac_n "checking for readdir_r""... $ac_c" 1>&6
-echo "configure:19314: checking for readdir_r" >&5
+echo "configure:19131: checking for readdir_r" >&5
 if eval "test \"`echo '$''{'ac_cv_func_readdir_r'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 19319 "configure"
+#line 19136 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char readdir_r(); below.  */
@@ -19338,7 +19155,7 @@ readdir_r();
 
 ; return 0; }
 EOF
-if { (eval echo configure:19342: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:19159: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_readdir_r=yes"
 else
@@ -19360,7 +19177,7 @@ fi
 
   if test "$ac_cv_func_readdir_r" = "yes"; then
   echo $ac_n "checking for type of readdir_r""... $ac_c" 1>&6
-echo "configure:19364: checking for type of readdir_r" >&5
+echo "configure:19181: checking for type of readdir_r" >&5
 if eval "test \"`echo '$''{'ac_cv_what_readdir_r'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19371,7 +19188,7 @@ else
    
 else
   cat > conftest.$ac_ext <<EOF
-#line 19375 "configure"
+#line 19192 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT
@@ -19396,7 +19213,7 @@ main() {
 }
     
 EOF
-if { (eval echo configure:19400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:19217: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       ac_cv_what_readdir_r=POSIX
@@ -19407,7 +19224,7 @@ else
   rm -fr conftest*
   
       cat > conftest.$ac_ext <<EOF
-#line 19411 "configure"
+#line 19228 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT
@@ -19417,7 +19234,7 @@ int readdir_r(DIR *, struct dirent *);
         
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:19421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:19238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -19459,12 +19276,12 @@ EOF
 
 
 echo $ac_n "checking for in_addr_t""... $ac_c" 1>&6
-echo "configure:19463: checking for in_addr_t" >&5
+echo "configure:19280: checking for in_addr_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_in_addr_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 19468 "configure"
+#line 19285 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -19498,12 +19315,12 @@ fi
 for ac_func in crypt_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:19502: checking for $ac_func" >&5
+echo "configure:19319: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 19507 "configure"
+#line 19324 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -19526,7 +19343,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:19530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:19347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -19554,14 +19371,14 @@ done
 if test "x$php_crypt_r" = "x1"; then
   
   echo $ac_n "checking which data struct is used by crypt_r""... $ac_c" 1>&6
-echo "configure:19558: checking which data struct is used by crypt_r" >&5
+echo "configure:19375: checking which data struct is used by crypt_r" >&5
 if eval "test \"`echo '$''{'php_cv_crypt_r_style'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     php_cv_crypt_r_style=none
     cat > conftest.$ac_ext <<EOF
-#line 19565 "configure"
+#line 19382 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -19574,7 +19391,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:19578: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:19395: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=cryptd
 else
@@ -19585,7 +19402,7 @@ rm -f conftest*
 
     if test "$php_cv_crypt_r_style" = "none"; then
       cat > conftest.$ac_ext <<EOF
-#line 19589 "configure"
+#line 19406 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -19598,7 +19415,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:19602: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:19419: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=struct_crypt_data
 else
@@ -19610,7 +19427,7 @@ rm -f conftest*
 
     if test "$php_cv_crypt_r_style" = "none"; then
       cat > conftest.$ac_ext <<EOF
-#line 19614 "configure"
+#line 19431 "configure"
 #include "confdefs.h"
 
 #define _REENTRANT 1
@@ -19624,7 +19441,7 @@ crypt_r("passwd", "hash", &buffer);
 
 ; return 0; }
 EOF
-if { (eval echo configure:19628: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:19445: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   php_cv_crypt_r_style=struct_crypt_data_gnu_source
 else
@@ -19683,7 +19500,7 @@ fi
 php_enable_gcov=no
 
 echo $ac_n "checking whether to include gcov symbols""... $ac_c" 1>&6
-echo "configure:19687: checking whether to include gcov symbols" >&5
+echo "configure:19504: checking whether to include gcov symbols" >&5
 # Check whether --enable-gcov or --disable-gcov was given.
 if test "${enable_gcov+set}" = set; then
   enableval="$enable_gcov"
@@ -19691,10 +19508,7 @@ if test "${enable_gcov+set}" = set; then
 else
   
   PHP_GCOV=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_GCOV=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -19725,7 +19539,7 @@ if test "$PHP_GCOV" = "yes"; then
   # Extract the first word of "lcov", so it can be a program name with args.
 set dummy lcov; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:19729: checking for $ac_word" >&5
+echo "configure:19543: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LTP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19754,7 +19568,7 @@ fi
   # Extract the first word of "genhtml", so it can be a program name with args.
 set dummy genhtml; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:19758: checking for $ac_word" >&5
+echo "configure:19572: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LTP_GENHTML'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19789,7 +19603,7 @@ fi
 
   if test "$LTP"; then
     echo $ac_n "checking for ltp version""... $ac_c" 1>&6
-echo "configure:19793: checking for ltp version" >&5
+echo "configure:19607: checking for ltp version" >&5
 if eval "test \"`echo '$''{'php_cv_ltp_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -19846,7 +19660,7 @@ fi
 php_enable_debug=no
 
 echo $ac_n "checking whether to include debugging symbols""... $ac_c" 1>&6
-echo "configure:19850: checking whether to include debugging symbols" >&5
+echo "configure:19664: checking whether to include debugging symbols" >&5
 # Check whether --enable-debug or --disable-debug was given.
 if test "${enable_debug+set}" = set; then
   enableval="$enable_debug"
@@ -19854,10 +19668,7 @@ if test "${enable_debug+set}" = set; then
 else
   
   PHP_DEBUG=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DEBUG=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -19876,7 +19687,7 @@ if test "$PHP_DEBUG" = "yes"; then
   CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
   
     if test "$GCC" = "yes" || test "$ICC" = "yes"; then
-    CFLAGS="$CFLAGS -g -O0"
+    CFLAGS="$CFLAGS -O0"
     CXXFLAGS="$CXXFLAGS -g -O0"
   fi
   if test "$SUNCC" = "yes"; then
@@ -19897,7 +19708,7 @@ fi
 php_with_layout=PHP
 
 echo $ac_n "checking layout of installed files""... $ac_c" 1>&6
-echo "configure:19901: checking layout of installed files" >&5
+echo "configure:19712: checking layout of installed files" >&5
 # Check whether --with-layout or --without-layout was given.
 if test "${with_layout+set}" = set; then
   withval="$with_layout"
@@ -19905,10 +19716,7 @@ if test "${with_layout+set}" = set; then
 else
   
   PHP_LAYOUT=PHP
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LAYOUT=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -19932,7 +19740,7 @@ esac
 php_with_config_file_path=DEFAULT
 
 echo $ac_n "checking path to configuration file""... $ac_c" 1>&6
-echo "configure:19936: checking path to configuration file" >&5
+echo "configure:19744: checking path to configuration file" >&5
 # Check whether --with-config-file-path or --without-config-file-path was given.
 if test "${with_config_file_path+set}" = set; then
   withval="$with_config_file_path"
@@ -19940,10 +19748,7 @@ if test "${with_config_file_path+set}" = set; then
 else
   
   PHP_CONFIG_FILE_PATH=DEFAULT
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CONFIG_FILE_PATH=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -19966,7 +19771,7 @@ if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
 fi
 
 echo $ac_n "checking where to scan for configuration files""... $ac_c" 1>&6
-echo "configure:19970: checking where to scan for configuration files" >&5
+echo "configure:19775: checking where to scan for configuration files" >&5
 
 php_with_config_file_scan_dir=DEFAULT
 
@@ -19978,10 +19783,7 @@ if test "${with_config_file_scan_dir+set}" = set; then
 else
   
   PHP_CONFIG_FILE_SCAN_DIR=DEFAULT
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CONFIG_FILE_SCAN_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20002,7 +19804,7 @@ test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
 php_enable_safe_mode=no
 
 echo $ac_n "checking whether to enable safe mode by default""... $ac_c" 1>&6
-echo "configure:20006: checking whether to enable safe mode by default" >&5
+echo "configure:19808: checking whether to enable safe mode by default" >&5
 # Check whether --enable-safe-mode or --disable-safe-mode was given.
 if test "${enable_safe_mode+set}" = set; then
   enableval="$enable_safe_mode"
@@ -20010,10 +19812,7 @@ if test "${enable_safe_mode+set}" = set; then
 else
   
   PHP_SAFE_MODE=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_SAFE_MODE=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20037,7 +19836,7 @@ EOF
 fi
 
 echo $ac_n "checking for safe mode exec dir""... $ac_c" 1>&6
-echo "configure:20041: checking for safe mode exec dir" >&5
+echo "configure:19840: checking for safe mode exec dir" >&5
 
 php_with_exec_dir=no
 
@@ -20049,10 +19848,7 @@ if test "${with_exec_dir+set}" = set; then
 else
   
   PHP_EXEC_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_EXEC_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20081,7 +19877,7 @@ fi
 php_enable_sigchild=no
 
 echo $ac_n "checking whether to enable PHP's own SIGCHLD handler""... $ac_c" 1>&6
-echo "configure:20085: checking whether to enable PHP's own SIGCHLD handler" >&5
+echo "configure:19881: checking whether to enable PHP's own SIGCHLD handler" >&5
 # Check whether --enable-sigchild or --disable-sigchild was given.
 if test "${enable_sigchild+set}" = set; then
   enableval="$enable_sigchild"
@@ -20089,10 +19885,7 @@ if test "${enable_sigchild+set}" = set; then
 else
   
   PHP_SIGCHILD=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_SIGCHILD=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20119,7 +19912,7 @@ fi
 php_enable_magic_quotes=no
 
 echo $ac_n "checking whether to enable magic quotes by default""... $ac_c" 1>&6
-echo "configure:20123: checking whether to enable magic quotes by default" >&5
+echo "configure:19916: checking whether to enable magic quotes by default" >&5
 # Check whether --enable-magic-quotes or --disable-magic-quotes was given.
 if test "${enable_magic_quotes+set}" = set; then
   enableval="$enable_magic_quotes"
@@ -20127,10 +19920,7 @@ if test "${enable_magic_quotes+set}" = set; then
 else
   
   PHP_MAGIC_QUOTES=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MAGIC_QUOTES=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20157,7 +19947,7 @@ fi
 php_enable_libgcc=no
 
 echo $ac_n "checking whether to explicitly link against libgcc""... $ac_c" 1>&6
-echo "configure:20161: checking whether to explicitly link against libgcc" >&5
+echo "configure:19951: checking whether to explicitly link against libgcc" >&5
 # Check whether --enable-libgcc or --disable-libgcc was given.
 if test "${enable_libgcc+set}" = set; then
   enableval="$enable_libgcc"
@@ -20165,10 +19955,7 @@ if test "${enable_libgcc+set}" = set; then
 else
   
   PHP_LIBGCC=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBGCC=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20237,7 +20024,7 @@ fi
 php_enable_short_tags=yes
 
 echo $ac_n "checking whether to enable short tags by default""... $ac_c" 1>&6
-echo "configure:20241: checking whether to enable short tags by default" >&5
+echo "configure:20028: checking whether to enable short tags by default" >&5
 # Check whether --enable-short-tags or --disable-short-tags was given.
 if test "${enable_short_tags+set}" = set; then
   enableval="$enable_short_tags"
@@ -20245,10 +20032,7 @@ if test "${enable_short_tags+set}" = set; then
 else
   
   PHP_SHORT_TAGS=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_SHORT_TAGS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20275,7 +20059,7 @@ fi
 php_enable_dmalloc=no
 
 echo $ac_n "checking whether to enable dmalloc""... $ac_c" 1>&6
-echo "configure:20279: checking whether to enable dmalloc" >&5
+echo "configure:20063: checking whether to enable dmalloc" >&5
 # Check whether --enable-dmalloc or --disable-dmalloc was given.
 if test "${enable_dmalloc+set}" = set; then
   enableval="$enable_dmalloc"
@@ -20283,10 +20067,7 @@ if test "${enable_dmalloc+set}" = set; then
 else
   
   PHP_DMALLOC=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DMALLOC=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20299,7 +20080,7 @@ echo "$ac_t""$ext_output" 1>&6
 
 if test "$PHP_DMALLOC" = "yes"; then
   echo $ac_n "checking for dmalloc_error in -ldmalloc""... $ac_c" 1>&6
-echo "configure:20303: checking for dmalloc_error in -ldmalloc" >&5
+echo "configure:20084: checking for dmalloc_error in -ldmalloc" >&5
 ac_lib_var=`echo dmalloc'_'dmalloc_error | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -20307,7 +20088,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldmalloc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 20311 "configure"
+#line 20092 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -20318,7 +20099,7 @@ int main() {
 dmalloc_error()
 ; return 0; }
 EOF
-if { (eval echo configure:20322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:20103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -20363,7 +20144,7 @@ fi
 php_enable_ipv6=yes
 
 echo $ac_n "checking whether to enable IPv6 support""... $ac_c" 1>&6
-echo "configure:20367: checking whether to enable IPv6 support" >&5
+echo "configure:20148: checking whether to enable IPv6 support" >&5
 # Check whether --enable-ipv6 or --disable-ipv6 was given.
 if test "${enable_ipv6+set}" = set; then
   enableval="$enable_ipv6"
@@ -20371,10 +20152,7 @@ if test "${enable_ipv6+set}" = set; then
 else
   
   PHP_IPV6=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_IPV6=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20393,7 +20171,7 @@ EOF
 fi
 
 echo $ac_n "checking how big to make fd sets""... $ac_c" 1>&6
-echo "configure:20397: checking how big to make fd sets" >&5
+echo "configure:20175: checking how big to make fd sets" >&5
 
 php_enable_fd_setsize=no
 
@@ -20405,10 +20183,7 @@ if test "${enable_fd_setsize+set}" = set; then
 else
   
   PHP_FD_SETSIZE=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FD_SETSIZE=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -20464,7 +20239,7 @@ fi
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:20468: checking size of long" >&5
+echo "configure:20243: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -20472,7 +20247,7 @@ else
   ac_cv_sizeof_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 20476 "configure"
+#line 20251 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -20483,7 +20258,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:20487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:20262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -20503,7 +20278,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:20507: checking size of int" >&5
+echo "configure:20282: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -20511,7 +20286,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 20515 "configure"
+#line 20290 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -20522,7 +20297,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:20526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:20301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -20543,13 +20318,13 @@ EOF
 
 
 echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:20547: checking for int32_t" >&5
+echo "configure:20322: checking for int32_t" >&5
 if eval "test \"`echo '$''{'ac_cv_int_type_int32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 20553 "configure"
+#line 20328 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H
@@ -20568,7 +20343,7 @@ if (sizeof (int32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:20572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:20347: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_int_type_int32_t=yes
 else
@@ -20591,13 +20366,13 @@ fi
 
 
 echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:20595: checking for uint32_t" >&5
+echo "configure:20370: checking for uint32_t" >&5
 if eval "test \"`echo '$''{'ac_cv_int_type_uint32_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 20601 "configure"
+#line 20376 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H
@@ -20616,7 +20391,7 @@ if (sizeof (uint32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:20620: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:20395: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_int_type_uint32_t=yes
 else
@@ -20648,17 +20423,17 @@ stdlib.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:20652: checking for $ac_hdr" >&5
+echo "configure:20427: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 20657 "configure"
+#line 20432 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:20662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:20437: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -20688,12 +20463,12 @@ done
 for ac_func in strtoll atoll strftime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:20692: checking for $ac_func" >&5
+echo "configure:20467: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 20697 "configure"
+#line 20472 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -20716,7 +20491,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:20720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:20495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -21149,10 +20924,7 @@ if test "${with_regex+set}" = set; then
 else
   
   PHP_REGEX=php
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_REGEX=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -21181,7 +20953,7 @@ case $PHP_REGEX in
 esac
 
 echo $ac_n "checking which regex library to use""... $ac_c" 1>&6
-echo "configure:21185: checking which regex library to use" >&5
+echo "configure:20957: checking which regex library to use" >&5
 echo "$ac_t""$REGEX_TYPE" 1>&6
 
 if test "$REGEX_TYPE" = "php"; then
@@ -21558,13 +21330,13 @@ elif test "$REGEX_TYPE" = "system"; then
 EOF
 
     echo $ac_n "checking whether field re_magic exists in struct regex_t""... $ac_c" 1>&6
-echo "configure:21562: checking whether field re_magic exists in struct regex_t" >&5
+echo "configure:21334: checking whether field re_magic exists in struct regex_t" >&5
 if eval "test \"`echo '$''{'ac_cv_regex_t_re_magic'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 21568 "configure"
+#line 21340 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <regex.h>
@@ -21572,7 +21344,7 @@ int main() {
 regex_t rt; rt.re_magic;
 ; return 0; }
 EOF
-if { (eval echo configure:21576: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:21348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_regex_t_re_magic=yes
 else
@@ -21598,7 +21370,7 @@ fi
 php_enable_libxml=yes
 
 echo $ac_n "checking whether to enable LIBXML support""... $ac_c" 1>&6
-echo "configure:21602: checking whether to enable LIBXML support" >&5
+echo "configure:21374: checking whether to enable LIBXML support" >&5
 # Check whether --enable-libxml or --disable-libxml was given.
 if test "${enable_libxml+set}" = set; then
   enableval="$enable_libxml"
@@ -21606,10 +21378,7 @@ if test "${enable_libxml+set}" = set; then
 else
   
   PHP_LIBXML=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_LIBXML=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_LIBXML=$PHP_ENABLE_ALL
 
 fi
 
@@ -21646,7 +21415,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:21650: checking libxml2 install dir" >&5
+echo "configure:21419: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -21654,10 +21423,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -21675,7 +21441,7 @@ if test "$PHP_LIBXML" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:21679: checking for xml2-config path" >&5
+echo "configure:21445: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -21833,7 +21599,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:21837: checking whether libxml build works" >&5
+echo "configure:21603: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -21849,7 +21615,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 21853 "configure"
+#line 21619 "configure"
 #include "confdefs.h"
 
     
@@ -21860,7 +21626,7 @@ else
     }
   
 EOF
-if { (eval echo configure:21864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:21630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -22225,7 +21991,7 @@ fi
 php_with_openssl=no
 
 echo $ac_n "checking for OpenSSL support""... $ac_c" 1>&6
-echo "configure:22229: checking for OpenSSL support" >&5
+echo "configure:21995: checking for OpenSSL support" >&5
 # Check whether --with-openssl or --without-openssl was given.
 if test "${with_openssl+set}" = set; then
   withval="$with_openssl"
@@ -22233,10 +21999,7 @@ if test "${with_openssl+set}" = set; then
 else
   
   PHP_OPENSSL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_OPENSSL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_OPENSSL=$PHP_ENABLE_ALL
 
 fi
 
@@ -22272,7 +22035,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_kerberos=no
 
 echo $ac_n "checking for Kerberos support""... $ac_c" 1>&6
-echo "configure:22276: checking for Kerberos support" >&5
+echo "configure:22039: checking for Kerberos support" >&5
 # Check whether --with-kerberos or --without-kerberos was given.
 if test "${with_kerberos+set}" = set; then
   withval="$with_kerberos"
@@ -22280,10 +22043,7 @@ if test "${with_kerberos+set}" = set; then
 else
   
   PHP_KERBEROS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_KERBEROS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -22601,7 +22361,7 @@ EOF
     # Extract the first word of "krb5-config", so it can be a program name with args.
 set dummy krb5-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:22605: checking for $ac_word" >&5
+echo "configure:22365: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_KRB5_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -22961,7 +22721,7 @@ fi
   fi
 
   echo $ac_n "checking for DSA_get_default_method in -lssl""... $ac_c" 1>&6
-echo "configure:22965: checking for DSA_get_default_method in -lssl" >&5
+echo "configure:22725: checking for DSA_get_default_method in -lssl" >&5
 ac_lib_var=`echo ssl'_'DSA_get_default_method | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -22969,7 +22729,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 22973 "configure"
+#line 22733 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -22980,7 +22740,7 @@ int main() {
 DSA_get_default_method()
 ; return 0; }
 EOF
-if { (eval echo configure:22984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:22744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -23022,7 +22782,7 @@ fi
     # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:23026: checking for $ac_word" >&5
+echo "configure:22786: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -23227,9 +22987,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:23231: checking for OpenSSL version" >&5
+echo "configure:22991: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 23233 "configure"
+#line 22993 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -23384,7 +23144,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:23388: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:23148: checking for CRYPTO_free in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'CRYPTO_free | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -23392,7 +23152,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 23396 "configure"
+#line 23156 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -23403,7 +23163,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:23407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -23560,7 +23320,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:23564: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:23324: checking for SSL_CTX_set_ssl_version in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_CTX_set_ssl_version | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -23568,7 +23328,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 23572 "configure"
+#line 23332 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -23579,7 +23339,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:23583: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:23343: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -23708,10 +23468,7 @@ if test "${with_pcre_regex+set}" = set; then
 else
   
   PHP_PCRE_REGEX=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PCRE_REGEX=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -23724,7 +23481,7 @@ ext_output=$PHP_PCRE_REGEX
 
   if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
     echo $ac_n "checking for PCRE headers location""... $ac_c" 1>&6
-echo "configure:23728: checking for PCRE headers location" >&5
+echo "configure:23485: checking for PCRE headers location" >&5
     for i in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/include $PHP_PCRE_REGEX/include/pcre $PHP_PCRE_REGEX/local/include; do
       test -f $i/pcre.h && PCRE_INCDIR=$i
     done
@@ -23735,7 +23492,7 @@ echo "configure:23728: checking for PCRE headers location" >&5
     echo "$ac_t""$PCRE_INCDIR" 1>&6
 
     echo $ac_n "checking for PCRE library location""... $ac_c" 1>&6
-echo "configure:23739: checking for PCRE library location" >&5
+echo "configure:23496: checking for PCRE library location" >&5
     for j in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/$PHP_LIBDIR; do
       test -f $j/libpcre.a || test -f $j/libpcre.$SHLIB_SUFFIX_NAME && PCRE_LIBDIR=$j
     done
@@ -24157,7 +23914,7 @@ EOF
 
   else
     echo $ac_n "checking for PCRE library to use""... $ac_c" 1>&6
-echo "configure:24161: checking for PCRE library to use" >&5
+echo "configure:23918: checking for PCRE library to use" >&5
     echo "$ac_t""bundled" 1>&6
     pcrelib_sources="pcrelib/pcre_chartables.c pcrelib/pcre_ucd.c \
     				 pcrelib/pcre_compile.c pcrelib/pcre_config.c pcrelib/pcre_exec.c \
@@ -24494,7 +24251,7 @@ EOF
 php_with_sqlite3=yes
 
 echo $ac_n "checking whether to enable the SQLite3 extension""... $ac_c" 1>&6
-echo "configure:24498: checking whether to enable the SQLite3 extension" >&5
+echo "configure:24255: checking whether to enable the SQLite3 extension" >&5
 # Check whether --with-sqlite3 or --without-sqlite3 was given.
 if test "${with_sqlite3+set}" = set; then
   withval="$with_sqlite3"
@@ -24502,10 +24259,7 @@ if test "${with_sqlite3+set}" = set; then
 else
   
   PHP_SQLITE3=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SQLITE3=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SQLITE3=$PHP_ENABLE_ALL
 
 fi
 
@@ -24552,7 +24306,7 @@ if test $PHP_SQLITE3 != "no"; then
 
   if test $PHP_SQLITE3 != "yes"; then
     echo $ac_n "checking for sqlite3 files in default path""... $ac_c" 1>&6
-echo "configure:24556: checking for sqlite3 files in default path" >&5
+echo "configure:24310: checking for sqlite3 files in default path" >&5
     for i in $PHP_SQLITE3 /usr/local /usr; do
       if test -r $i/include/sqlite3.h; then
         SQLITE3_DIR=$i
@@ -24567,7 +24321,7 @@ echo "configure:24556: checking for sqlite3 files in default path" >&5
     fi
 
     echo $ac_n "checking for SQLite 3.3.9+""... $ac_c" 1>&6
-echo "configure:24571: checking for SQLite 3.3.9+" >&5
+echo "configure:24325: checking for SQLite 3.3.9+" >&5
     
   save_old_LDFLAGS=$LDFLAGS
   ac_stuff="
@@ -24666,7 +24420,7 @@ echo "configure:24571: checking for SQLite 3.3.9+" >&5
   done
 
   echo $ac_n "checking for sqlite3_prepare_v2 in -lsqlite3""... $ac_c" 1>&6
-echo "configure:24670: checking for sqlite3_prepare_v2 in -lsqlite3" >&5
+echo "configure:24424: checking for sqlite3_prepare_v2 in -lsqlite3" >&5
 ac_lib_var=`echo sqlite3'_'sqlite3_prepare_v2 | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -24674,7 +24428,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 24678 "configure"
+#line 24432 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -24685,7 +24439,7 @@ int main() {
 sqlite3_prepare_v2()
 ; return 0; }
 EOF
-if { (eval echo configure:24689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:24443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -24945,7 +24699,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_key in -lsqlite3""... $ac_c" 1>&6
-echo "configure:24949: checking for sqlite3_key in -lsqlite3" >&5
+echo "configure:24703: checking for sqlite3_key in -lsqlite3" >&5
 ac_lib_var=`echo sqlite3'_'sqlite3_key | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -24953,7 +24707,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 24957 "configure"
+#line 24711 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -24964,7 +24718,7 @@ int main() {
 sqlite3_key()
 ; return 0; }
 EOF
-if { (eval echo configure:24968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:24722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -25096,7 +24850,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_load_extension in -lsqlite3""... $ac_c" 1>&6
-echo "configure:25100: checking for sqlite3_load_extension in -lsqlite3" >&5
+echo "configure:24854: checking for sqlite3_load_extension in -lsqlite3" >&5
 ac_lib_var=`echo sqlite3'_'sqlite3_load_extension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -25104,7 +24858,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 25108 "configure"
+#line 24862 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -25115,7 +24869,7 @@ int main() {
 sqlite3_load_extension()
 ; return 0; }
 EOF
-if { (eval echo configure:25119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:24873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -25152,7 +24906,7 @@ fi
 
   else
     echo $ac_n "checking bundled sqlite3 library""... $ac_c" 1>&6
-echo "configure:25156: checking bundled sqlite3 library" >&5
+echo "configure:24910: checking bundled sqlite3 library" >&5
     echo "$ac_t""yes" 1>&6
 
     sqlite3_extra_sources="libsqlite/sqlite3.c"
@@ -25508,7 +25262,7 @@ fi
 php_with_zlib=no
 
 echo $ac_n "checking for ZLIB support""... $ac_c" 1>&6
-echo "configure:25512: checking for ZLIB support" >&5
+echo "configure:25266: checking for ZLIB support" >&5
 # Check whether --with-zlib or --without-zlib was given.
 if test "${with_zlib+set}" = set; then
   withval="$with_zlib"
@@ -25516,10 +25270,7 @@ if test "${with_zlib+set}" = set; then
 else
   
   PHP_ZLIB=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ZLIB=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ZLIB=$PHP_ENABLE_ALL
 
 fi
 
@@ -25555,7 +25306,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_zlib_dir=no
 
 echo $ac_n "checking if the location of ZLIB install directory is defined""... $ac_c" 1>&6
-echo "configure:25559: checking if the location of ZLIB install directory is defined" >&5
+echo "configure:25310: checking if the location of ZLIB install directory is defined" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -25563,10 +25314,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -26001,7 +25749,7 @@ EOF
   done
 
   echo $ac_n "checking for gzgets in -lz""... $ac_c" 1>&6
-echo "configure:26005: checking for gzgets in -lz" >&5
+echo "configure:25753: checking for gzgets in -lz" >&5
 ac_lib_var=`echo z'_'gzgets | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -26009,7 +25757,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lz  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 26013 "configure"
+#line 25761 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -26020,7 +25768,7 @@ int main() {
 gzgets()
 ; return 0; }
 EOF
-if { (eval echo configure:26024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:25772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -26160,7 +25908,7 @@ fi
 php_enable_bcmath=no
 
 echo $ac_n "checking whether to enable bc style precision math functions""... $ac_c" 1>&6
-echo "configure:26164: checking whether to enable bc style precision math functions" >&5
+echo "configure:25912: checking whether to enable bc style precision math functions" >&5
 # Check whether --enable-bcmath or --disable-bcmath was given.
 if test "${enable_bcmath+set}" = set; then
   enableval="$enable_bcmath"
@@ -26168,10 +25916,7 @@ if test "${enable_bcmath+set}" = set; then
 else
   
   PHP_BCMATH=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_BCMATH=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_BCMATH=$PHP_ENABLE_ALL
 
 fi
 
@@ -26528,7 +26273,7 @@ fi
 php_with_bz2=no
 
 echo $ac_n "checking for BZip2 support""... $ac_c" 1>&6
-echo "configure:26532: checking for BZip2 support" >&5
+echo "configure:26277: checking for BZip2 support" >&5
 # Check whether --with-bz2 or --without-bz2 was given.
 if test "${with_bz2+set}" = set; then
   withval="$with_bz2"
@@ -26536,10 +26281,7 @@ if test "${with_bz2+set}" = set; then
 else
   
   PHP_BZ2=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_BZ2=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_BZ2=$PHP_ENABLE_ALL
 
 fi
 
@@ -26576,7 +26318,7 @@ if test "$PHP_BZ2" != "no"; then
     BZIP_DIR=$PHP_BZ2
   else
     echo $ac_n "checking for BZip2 in default path""... $ac_c" 1>&6
-echo "configure:26580: checking for BZip2 in default path" >&5
+echo "configure:26322: checking for BZip2 in default path" >&5
     for i in /usr/local /usr; do
       if test -r $i/include/bzlib.h; then
         BZIP_DIR=$i
@@ -26689,7 +26431,7 @@ echo "configure:26580: checking for BZip2 in default path" >&5
   done
 
   echo $ac_n "checking for BZ2_bzerror in -lbz2""... $ac_c" 1>&6
-echo "configure:26693: checking for BZ2_bzerror in -lbz2" >&5
+echo "configure:26435: checking for BZ2_bzerror in -lbz2" >&5
 ac_lib_var=`echo bz2'_'BZ2_bzerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -26697,7 +26439,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbz2  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 26701 "configure"
+#line 26443 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -26708,7 +26450,7 @@ int main() {
 BZ2_bzerror()
 ; return 0; }
 EOF
-if { (eval echo configure:26712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:26454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -27176,7 +26918,7 @@ fi
 php_enable_calendar=no
 
 echo $ac_n "checking whether to enable calendar conversion support""... $ac_c" 1>&6
-echo "configure:27180: checking whether to enable calendar conversion support" >&5
+echo "configure:26922: checking whether to enable calendar conversion support" >&5
 # Check whether --enable-calendar or --disable-calendar was given.
 if test "${enable_calendar+set}" = set; then
   enableval="$enable_calendar"
@@ -27184,10 +26926,7 @@ if test "${enable_calendar+set}" = set; then
 else
   
   PHP_CALENDAR=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_CALENDAR=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_CALENDAR=$PHP_ENABLE_ALL
 
 fi
 
@@ -27523,7 +27262,7 @@ fi
 php_enable_ctype=yes
 
 echo $ac_n "checking whether to enable ctype functions""... $ac_c" 1>&6
-echo "configure:27527: checking whether to enable ctype functions" >&5
+echo "configure:27266: checking whether to enable ctype functions" >&5
 # Check whether --enable-ctype or --disable-ctype was given.
 if test "${enable_ctype+set}" = set; then
   enableval="$enable_ctype"
@@ -27531,10 +27270,7 @@ if test "${enable_ctype+set}" = set; then
 else
   
   PHP_CTYPE=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_CTYPE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_CTYPE=$PHP_ENABLE_ALL
 
 fi
 
@@ -27870,7 +27606,7 @@ fi
 php_with_curl=no
 
 echo $ac_n "checking for cURL support""... $ac_c" 1>&6
-echo "configure:27874: checking for cURL support" >&5
+echo "configure:27610: checking for cURL support" >&5
 # Check whether --with-curl or --without-curl was given.
 if test "${with_curl+set}" = set; then
   withval="$with_curl"
@@ -27878,10 +27614,7 @@ if test "${with_curl+set}" = set; then
 else
   
   PHP_CURL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_CURL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_CURL=$PHP_ENABLE_ALL
 
 fi
 
@@ -27917,7 +27650,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_curlwrappers=no
 
 echo $ac_n "checking if we should use cURL for url streams""... $ac_c" 1>&6
-echo "configure:27921: checking if we should use cURL for url streams" >&5
+echo "configure:27654: checking if we should use cURL for url streams" >&5
 # Check whether --with-curlwrappers or --without-curlwrappers was given.
 if test "${with_curlwrappers+set}" = set; then
   withval="$with_curlwrappers"
@@ -27925,10 +27658,7 @@ if test "${with_curlwrappers+set}" = set; then
 else
   
   PHP_CURLWRAPPERS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CURLWRAPPERS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -27944,7 +27674,7 @@ if test "$PHP_CURL" != "no"; then
     CURL_DIR=$PHP_CURL
   else
     echo $ac_n "checking for cURL in default path""... $ac_c" 1>&6
-echo "configure:27948: checking for cURL in default path" >&5
+echo "configure:27678: checking for cURL in default path" >&5
     for i in /usr/local /usr; do
       if test -r $i/include/curl/easy.h; then
         CURL_DIR=$i
@@ -27962,7 +27692,7 @@ echo "configure:27948: checking for cURL in default path" >&5
 
   CURL_CONFIG="curl-config"
   echo $ac_n "checking for cURL 7.10.5 or greater""... $ac_c" 1>&6
-echo "configure:27966: checking for cURL 7.10.5 or greater" >&5
+echo "configure:27696: checking for cURL 7.10.5 or greater" >&5
 
   if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then
     CURL_CONFIG=${CURL_DIR}/bin/curl-config
@@ -28200,7 +27930,7 @@ echo "configure:27966: checking for cURL 7.10.5 or greater" >&5
 
   
   echo $ac_n "checking for SSL support in libcurl""... $ac_c" 1>&6
-echo "configure:28204: checking for SSL support in libcurl" >&5
+echo "configure:27934: checking for SSL support in libcurl" >&5
   CURL_SSL=`$CURL_CONFIG --feature | $EGREP SSL`
   if test "$CURL_SSL" = "SSL"; then
     echo "$ac_t""yes" 1>&6
@@ -28213,7 +27943,7 @@ EOF
     CFLAGS="`$CURL_CONFIG --cflags`"
    
     echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:28217: checking how to run the C preprocessor" >&5
+echo "configure:27947: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -28228,13 +27958,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 28232 "configure"
+#line 27962 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:28238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:27968: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -28245,13 +27975,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 28249 "configure"
+#line 27979 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:28255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:27985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -28262,13 +27992,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 28266 "configure"
+#line 27996 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:28272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:28002: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -28293,14 +28023,14 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
     echo $ac_n "checking for openssl support in libcurl""... $ac_c" 1>&6
-echo "configure:28297: checking for openssl support in libcurl" >&5
+echo "configure:28027: checking for openssl support in libcurl" >&5
     if test "$cross_compiling" = yes; then
   
       echo "$ac_t""no" 1>&6
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 28304 "configure"
+#line 28034 "configure"
 #include "confdefs.h"
 
 #include <curl/curl.h>
@@ -28319,7 +28049,7 @@ int main(int argc, char *argv[])
 }
     
 EOF
-if { (eval echo configure:28323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:28053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       echo "$ac_t""yes" 1>&6
@@ -28327,17 +28057,17 @@ then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:28331: checking for $ac_hdr" >&5
+echo "configure:28061: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 28336 "configure"
+#line 28066 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:28341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:28071: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -28382,14 +28112,14 @@ fi
 
    
     echo $ac_n "checking for gnutls support in libcurl""... $ac_c" 1>&6
-echo "configure:28386: checking for gnutls support in libcurl" >&5
+echo "configure:28116: checking for gnutls support in libcurl" >&5
     if test "$cross_compiling" = yes; then
   
       echo "$ac_t""no" 1>&6
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 28393 "configure"
+#line 28123 "configure"
 #include "confdefs.h"
 
 #include <curl/curl.h>
@@ -28408,23 +28138,23 @@ int main(int argc, char *argv[])
 }
 
 EOF
-if { (eval echo configure:28412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:28142: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       echo "$ac_t""yes" 1>&6
       ac_safe=`echo "gcrypt.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for gcrypt.h""... $ac_c" 1>&6
-echo "configure:28418: checking for gcrypt.h" >&5
+echo "configure:28148: checking for gcrypt.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 28423 "configure"
+#line 28153 "configure"
 #include "confdefs.h"
 #include <gcrypt.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:28428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:28158: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -28566,7 +28296,7 @@ fi
   done
 
   echo $ac_n "checking for curl_easy_perform in -lcurl""... $ac_c" 1>&6
-echo "configure:28570: checking for curl_easy_perform in -lcurl" >&5
+echo "configure:28300: checking for curl_easy_perform in -lcurl" >&5
 ac_lib_var=`echo curl'_'curl_easy_perform | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -28574,7 +28304,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 28578 "configure"
+#line 28308 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -28585,7 +28315,7 @@ int main() {
 curl_easy_perform()
 ; return 0; }
 EOF
-if { (eval echo configure:28589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -28721,7 +28451,7 @@ fi
   done
 
   echo $ac_n "checking for curl_version_info in -lcurl""... $ac_c" 1>&6
-echo "configure:28725: checking for curl_version_info in -lcurl" >&5
+echo "configure:28455: checking for curl_version_info in -lcurl" >&5
 ac_lib_var=`echo curl'_'curl_version_info | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -28729,7 +28459,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 28733 "configure"
+#line 28463 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -28740,7 +28470,7 @@ int main() {
 curl_version_info()
 ; return 0; }
 EOF
-if { (eval echo configure:28744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -28874,7 +28604,7 @@ fi
   done
 
   echo $ac_n "checking for curl_easy_strerror in -lcurl""... $ac_c" 1>&6
-echo "configure:28878: checking for curl_easy_strerror in -lcurl" >&5
+echo "configure:28608: checking for curl_easy_strerror in -lcurl" >&5
 ac_lib_var=`echo curl'_'curl_easy_strerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -28882,7 +28612,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 28886 "configure"
+#line 28616 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -28893,7 +28623,7 @@ int main() {
 curl_easy_strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:28897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -29027,7 +28757,7 @@ fi
   done
 
   echo $ac_n "checking for curl_multi_strerror in -lcurl""... $ac_c" 1>&6
-echo "configure:29031: checking for curl_multi_strerror in -lcurl" >&5
+echo "configure:28761: checking for curl_multi_strerror in -lcurl" >&5
 ac_lib_var=`echo curl'_'curl_multi_strerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -29035,7 +28765,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcurl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 29039 "configure"
+#line 28769 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -29046,7 +28776,7 @@ int main() {
 curl_multi_strerror()
 ; return 0; }
 EOF
-if { (eval echo configure:29050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:28780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -29412,10 +29142,7 @@ if test "${enable_dba+set}" = set; then
 else
   
   PHP_DBA=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_DBA=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_DBA=$PHP_ENABLE_ALL
 
 fi
 
@@ -29458,10 +29185,7 @@ if test "${with_qdbm+set}" = set; then
 else
   
   PHP_QDBM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_QDBM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29483,10 +29207,7 @@ if test "${with_gdbm+set}" = set; then
 else
   
   PHP_GDBM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_GDBM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29508,10 +29229,7 @@ if test "${with_ndbm+set}" = set; then
 else
   
   PHP_NDBM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_NDBM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29533,10 +29251,7 @@ if test "${with_db4+set}" = set; then
 else
   
   PHP_DB4=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DB4=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29558,10 +29273,7 @@ if test "${with_db3+set}" = set; then
 else
   
   PHP_DB3=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DB3=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29583,10 +29295,7 @@ if test "${with_db2+set}" = set; then
 else
   
   PHP_DB2=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DB2=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29608,10 +29317,7 @@ if test "${with_db1+set}" = set; then
 else
   
   PHP_DB1=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DB1=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29633,10 +29339,7 @@ if test "${with_dbm+set}" = set; then
 else
   
   PHP_DBM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_DBM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -29759,7 +29462,7 @@ if test "$PHP_QDBM" != "no"; then
   done
 
   echo $ac_n "checking for dpopen in -l$LIB""... $ac_c" 1>&6
-echo "configure:29763: checking for dpopen in -l$LIB" >&5
+echo "configure:29466: checking for dpopen in -l$LIB" >&5
 ac_lib_var=`echo $LIB'_'dpopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -29767,7 +29470,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 29771 "configure"
+#line 29474 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -29778,7 +29481,7 @@ int main() {
 dpopen()
 ; return 0; }
 EOF
-if { (eval echo configure:29782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:29485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -29947,7 +29650,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:29951: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29654: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -29975,7 +29678,7 @@ if test "$PHP_GDBM" != "no"; then
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:29979: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29682: checking for $THIS_FULL_NAME support" >&5
   if test -n "You cannot combine --with-gdbm with --with-qdbm"; then
     { echo "configure: error: You cannot combine --with-gdbm with --with-qdbm" 1>&2; exit 1; }
   fi
@@ -30094,7 +29797,7 @@ echo "configure:29979: checking for $THIS_FULL_NAME support" >&5
   done
 
   echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:30098: checking for gdbm_open in -lgdbm" >&5
+echo "configure:29801: checking for gdbm_open in -lgdbm" >&5
 ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -30102,7 +29805,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgdbm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 30106 "configure"
+#line 29809 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -30113,7 +29816,7 @@ int main() {
 gdbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:30117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:29820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -30278,7 +29981,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30282: checking for $THIS_FULL_NAME support" >&5
+echo "configure:29985: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -30407,7 +30110,7 @@ if test "$PHP_NDBM" != "no"; then
   done
 
   echo $ac_n "checking for dbm_open in -l$LIB""... $ac_c" 1>&6
-echo "configure:30411: checking for dbm_open in -l$LIB" >&5
+echo "configure:30114: checking for dbm_open in -l$LIB" >&5
 ac_lib_var=`echo $LIB'_'dbm_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -30415,7 +30118,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 30419 "configure"
+#line 30122 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -30426,7 +30129,7 @@ int main() {
 dbm_open()
 ; return 0; }
 EOF
-if { (eval echo configure:30430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:30133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -30595,7 +30298,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30599: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30302: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -30679,7 +30382,7 @@ if test "$PHP_DB4" != "no"; then
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 30683 "configure"
+#line 30386 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30690,11 +30393,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:30694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:30397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 30698 "configure"
+#line 30401 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30731,18 +30434,18 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for DB4 major version""... $ac_c" 1>&6
-echo "configure:30735: checking for DB4 major version" >&5
+echo "configure:30438: checking for DB4 major version" >&5
     { echo "configure: error: Header contains different version" 1>&2; exit 1; }
   fi
   if test "4" = "4"; then
     echo $ac_n "checking for DB4 minor version and patch level""... $ac_c" 1>&6
-echo "configure:30740: checking for DB4 minor version and patch level" >&5
+echo "configure:30443: checking for DB4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 30742 "configure"
+#line 30445 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
-#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR != 1) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
       yes
 #endif
     
@@ -30764,9 +30467,9 @@ rm -f conftest*
   fi
   if test "$ext_shared" = "yes"; then
     echo $ac_n "checking if dba can be used as shared extension""... $ac_c" 1>&6
-echo "configure:30768: checking if dba can be used as shared extension" >&5
+echo "configure:30471: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 30770 "configure"
+#line 30473 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -30923,7 +30626,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30927: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30630: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -30951,7 +30654,7 @@ if test "$PHP_DB3" != "no"; then
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:30955: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30658: checking for $THIS_FULL_NAME support" >&5
   if test -n "You cannot combine --with-db3 with --with-db4"; then
     { echo "configure: error: You cannot combine --with-db3 with --with-db4" 1>&2; exit 1; }
   fi
@@ -31002,7 +30705,7 @@ echo "configure:30955: checking for $THIS_FULL_NAME support" >&5
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 31006 "configure"
+#line 30709 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31013,11 +30716,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:31017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:30720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 31021 "configure"
+#line 30724 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31054,18 +30757,18 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for DB3 major version""... $ac_c" 1>&6
-echo "configure:31058: checking for DB3 major version" >&5
+echo "configure:30761: checking for DB3 major version" >&5
     { echo "configure: error: Header contains different version" 1>&2; exit 1; }
   fi
   if test "3" = "4"; then
     echo $ac_n "checking for DB4 minor version and patch level""... $ac_c" 1>&6
-echo "configure:31063: checking for DB4 minor version and patch level" >&5
+echo "configure:30766: checking for DB4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 31065 "configure"
+#line 30768 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
-#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR != 1) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
       yes
 #endif
     
@@ -31087,9 +30790,9 @@ rm -f conftest*
   fi
   if test "$ext_shared" = "yes"; then
     echo $ac_n "checking if dba can be used as shared extension""... $ac_c" 1>&6
-echo "configure:31091: checking if dba can be used as shared extension" >&5
+echo "configure:30794: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 31093 "configure"
+#line 30796 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31246,7 +30949,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31250: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30953: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31274,7 +30977,7 @@ if test "$PHP_DB2" != "no"; then
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31278: checking for $THIS_FULL_NAME support" >&5
+echo "configure:30981: checking for $THIS_FULL_NAME support" >&5
   if test -n "You cannot combine --with-db2 with --with-db3 or --with-db4"; then
     { echo "configure: error: You cannot combine --with-db2 with --with-db3 or --with-db4" 1>&2; exit 1; }
   fi
@@ -31325,7 +31028,7 @@ echo "configure:31278: checking for $THIS_FULL_NAME support" >&5
   LIBS="-l$LIB $LIBS"
   
         cat > conftest.$ac_ext <<EOF
-#line 31329 "configure"
+#line 31032 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31336,11 +31039,11 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:31340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:31043: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
           cat > conftest.$ac_ext <<EOF
-#line 31344 "configure"
+#line 31047 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31377,18 +31080,18 @@ rm -f conftest*
   done
   if test -z "$THIS_LIBS"; then
     echo $ac_n "checking for DB2 major version""... $ac_c" 1>&6
-echo "configure:31381: checking for DB2 major version" >&5
+echo "configure:31084: checking for DB2 major version" >&5
     { echo "configure: error: Header contains different version" 1>&2; exit 1; }
   fi
   if test "2" = "4"; then
     echo $ac_n "checking for DB4 minor version and patch level""... $ac_c" 1>&6
-echo "configure:31386: checking for DB4 minor version and patch level" >&5
+echo "configure:31089: checking for DB4 minor version and patch level" >&5
     cat > conftest.$ac_ext <<EOF
-#line 31388 "configure"
+#line 31091 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
-#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR != 1) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
       yes
 #endif
     
@@ -31410,9 +31113,9 @@ rm -f conftest*
   fi
   if test "$ext_shared" = "yes"; then
     echo $ac_n "checking if dba can be used as shared extension""... $ac_c" 1>&6
-echo "configure:31414: checking if dba can be used as shared extension" >&5
+echo "configure:31117: checking if dba can be used as shared extension" >&5
     cat > conftest.$ac_ext <<EOF
-#line 31416 "configure"
+#line 31119 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31569,7 +31272,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31573: checking for $THIS_FULL_NAME support" >&5
+echo "configure:31276: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31589,7 +31292,7 @@ if test "$PHP_DB1" != "no"; then
   unset THIS_INCLUDE THIS_LIBS THIS_LFLAGS THIS_PREFIX THIS_RESULT
 
   echo $ac_n "checking for DB1 in library""... $ac_c" 1>&6
-echo "configure:31593: checking for DB1 in library" >&5
+echo "configure:31296: checking for DB1 in library" >&5
   if test "$HAVE_DB4" = "1"; then
     THIS_VERSION=4
     THIS_LIBS=$DB4_LIBS
@@ -31637,7 +31340,7 @@ EOF
   fi
   echo "$ac_t""$THIS_LIBS" 1>&6
   echo $ac_n "checking for DB1 in header""... $ac_c" 1>&6
-echo "configure:31641: checking for DB1 in header" >&5
+echo "configure:31344: checking for DB1 in header" >&5
   echo "$ac_t""$THIS_INCLUDE" 1>&6
   if test -n "$THIS_INCLUDE"; then
     
@@ -31647,7 +31350,7 @@ echo "configure:31641: checking for DB1 in header" >&5
   LIBS="-l$THIS_LIBS $LIBS"
   
       cat > conftest.$ac_ext <<EOF
-#line 31651 "configure"
+#line 31354 "configure"
 #include "confdefs.h"
 
 #include "$THIS_INCLUDE"
@@ -31658,7 +31361,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:31662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:31365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         cat >> confdefs.h <<EOF
@@ -31808,7 +31511,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31812: checking for $THIS_FULL_NAME support" >&5
+echo "configure:31515: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -31836,7 +31539,7 @@ if test "$PHP_DBM" != "no"; then
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:31840: checking for $THIS_FULL_NAME support" >&5
+echo "configure:31543: checking for $THIS_FULL_NAME support" >&5
   if test -n "You cannot combine --with-dbm with --with-qdbm"; then
     { echo "configure: error: You cannot combine --with-dbm with --with-qdbm" 1>&2; exit 1; }
   fi
@@ -31960,7 +31663,7 @@ echo "configure:31840: checking for $THIS_FULL_NAME support" >&5
   done
 
   echo $ac_n "checking for dbminit in -l$LIB""... $ac_c" 1>&6
-echo "configure:31964: checking for dbminit in -l$LIB" >&5
+echo "configure:31667: checking for dbminit in -l$LIB" >&5
 ac_lib_var=`echo $LIB'_'dbminit | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -31968,7 +31671,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 31972 "configure"
+#line 31675 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -31979,7 +31682,7 @@ int main() {
 dbminit()
 ; return 0; }
 EOF
-if { (eval echo configure:31983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:31686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -31999,7 +31702,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
     ext_shared=$save_ext_shared
     
         echo $ac_n "checking for DBM using GDBM""... $ac_c" 1>&6
-echo "configure:32003: checking for DBM using GDBM" >&5
+echo "configure:31706: checking for DBM using GDBM" >&5
         cat >> confdefs.h <<EOF
 #define DBM_INCLUDE_FILE "$THIS_INCLUDE"
 EOF
@@ -32163,7 +31866,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:32167: checking for $THIS_FULL_NAME support" >&5
+echo "configure:31870: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -32194,10 +31897,7 @@ if test "${with_cdb+set}" = set; then
 else
   
   PHP_CDB=$php_dba_enable
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_CDB=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -32219,10 +31919,7 @@ if test "${enable_inifile+set}" = set; then
 else
   
   PHP_INIFILE=$php_dba_enable
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_INIFILE=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -32244,10 +31941,7 @@ if test "${enable_flatfile+set}" = set; then
 else
   
   PHP_FLATFILE=$php_dba_enable
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FLATFILE=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -32384,7 +32078,7 @@ elif test "$PHP_CDB" != "no"; then
   done
 
   echo $ac_n "checking for cdb_read in -l$LIB""... $ac_c" 1>&6
-echo "configure:32388: checking for cdb_read in -l$LIB" >&5
+echo "configure:32082: checking for cdb_read in -l$LIB" >&5
 ac_lib_var=`echo $LIB'_'cdb_read | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -32392,7 +32086,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 32396 "configure"
+#line 32090 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -32403,7 +32097,7 @@ int main() {
 cdb_read()
 ; return 0; }
 EOF
-if { (eval echo configure:32407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:32101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -32572,7 +32266,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:32576: checking for $THIS_FULL_NAME support" >&5
+echo "configure:32270: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -32603,7 +32297,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:32607: checking for $THIS_FULL_NAME support" >&5
+echo "configure:32301: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -32634,7 +32328,7 @@ fi
     THIS_FULL_NAME="$THIS_NAME"
   fi
   echo $ac_n "checking for $THIS_FULL_NAME support""... $ac_c" 1>&6
-echo "configure:32638: checking for $THIS_FULL_NAME support" >&5
+echo "configure:32332: checking for $THIS_FULL_NAME support" >&5
   if test -n ""; then
     { echo "configure: error: " 1>&2; exit 1; }
   fi
@@ -32649,7 +32343,7 @@ echo "configure:32638: checking for $THIS_FULL_NAME support" >&5
 
 
 echo $ac_n "checking whether to enable DBA interface""... $ac_c" 1>&6
-echo "configure:32653: checking whether to enable DBA interface" >&5
+echo "configure:32347: checking whether to enable DBA interface" >&5
 if test "$HAVE_DBA" = "1"; then
   if test "$ext_shared" = "yes"; then
     echo "$ac_t""yes, shared" 1>&6
@@ -32979,7 +32673,7 @@ fi
 php_enable_dom=yes
 
 echo $ac_n "checking whether to enable DOM support""... $ac_c" 1>&6
-echo "configure:32983: checking whether to enable DOM support" >&5
+echo "configure:32677: checking whether to enable DOM support" >&5
 # Check whether --enable-dom or --disable-dom was given.
 if test "${enable_dom+set}" = set; then
   enableval="$enable_dom"
@@ -32987,10 +32681,7 @@ if test "${enable_dom+set}" = set; then
 else
   
   PHP_DOM=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_DOM=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_DOM=$PHP_ENABLE_ALL
 
 fi
 
@@ -33027,7 +32718,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:33031: checking libxml2 install dir" >&5
+echo "configure:32722: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -33035,10 +32726,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -33058,7 +32746,7 @@ if test "$PHP_DOM" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:33062: checking for xml2-config path" >&5
+echo "configure:32750: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -33216,7 +32904,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:33220: checking whether libxml build works" >&5
+echo "configure:32908: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -33232,7 +32920,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 33236 "configure"
+#line 32924 "configure"
 #include "confdefs.h"
 
     
@@ -33243,7 +32931,7 @@ else
     }
   
 EOF
-if { (eval echo configure:33247: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:32935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -33666,7 +33354,7 @@ fi
 php_with_enchant=no
 
 echo $ac_n "checking for ENCHANT support""... $ac_c" 1>&6
-echo "configure:33670: checking for ENCHANT support" >&5
+echo "configure:33358: checking for ENCHANT support" >&5
 # Check whether --with-enchant or --without-enchant was given.
 if test "${with_enchant+set}" = set; then
   withval="$with_enchant"
@@ -33674,10 +33362,7 @@ if test "${with_enchant+set}" = set; then
 else
   
   PHP_ENCHANT=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ENCHANT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ENCHANT=$PHP_ENABLE_ALL
 
 fi
 
@@ -34254,7 +33939,7 @@ EOF
   done
 
   echo $ac_n "checking for enchant_broker_set_param in -lenchant""... $ac_c" 1>&6
-echo "configure:34258: checking for enchant_broker_set_param in -lenchant" >&5
+echo "configure:33943: checking for enchant_broker_set_param in -lenchant" >&5
 ac_lib_var=`echo enchant'_'enchant_broker_set_param | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -34262,7 +33947,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lenchant  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 34266 "configure"
+#line 33951 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -34273,7 +33958,7 @@ int main() {
 enchant_broker_set_param()
 ; return 0; }
 EOF
-if { (eval echo configure:34277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:33962: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -34320,7 +34005,7 @@ fi
 php_enable_exif=no
 
 echo $ac_n "checking whether to enable EXIF (metadata from images) support""... $ac_c" 1>&6
-echo "configure:34324: checking whether to enable EXIF (metadata from images) support" >&5
+echo "configure:34009: checking whether to enable EXIF (metadata from images) support" >&5
 # Check whether --enable-exif or --disable-exif was given.
 if test "${enable_exif+set}" = set; then
   enableval="$enable_exif"
@@ -34328,10 +34013,7 @@ if test "${enable_exif+set}" = set; then
 else
   
   PHP_EXIF=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_EXIF=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_EXIF=$PHP_ENABLE_ALL
 
 fi
 
@@ -34667,7 +34349,7 @@ fi
 php_enable_fileinfo=yes
 
 echo $ac_n "checking for fileinfo support""... $ac_c" 1>&6
-echo "configure:34671: checking for fileinfo support" >&5
+echo "configure:34353: checking for fileinfo support" >&5
 # Check whether --enable-fileinfo or --disable-fileinfo was given.
 if test "${enable_fileinfo+set}" = set; then
   enableval="$enable_fileinfo"
@@ -34675,10 +34357,7 @@ if test "${enable_fileinfo+set}" = set; then
 else
   
   PHP_FILEINFO=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_FILEINFO=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_FILEINFO=$PHP_ENABLE_ALL
 
 fi
 
@@ -35020,12 +34699,12 @@ EOF
   for ac_func in utimes strndup
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:35024: checking for $ac_func" >&5
+echo "configure:34703: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 35029 "configure"
+#line 34708 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -35048,7 +34727,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:35052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:34731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -35086,7 +34765,7 @@ fi
 php_enable_filter=yes
 
 echo $ac_n "checking whether to enable input filter support""... $ac_c" 1>&6
-echo "configure:35090: checking whether to enable input filter support" >&5
+echo "configure:34769: checking whether to enable input filter support" >&5
 # Check whether --enable-filter or --disable-filter was given.
 if test "${enable_filter+set}" = set; then
   enableval="$enable_filter"
@@ -35094,10 +34773,7 @@ if test "${enable_filter+set}" = set; then
 else
   
   PHP_FILTER=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_FILTER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_FILTER=$PHP_ENABLE_ALL
 
 fi
 
@@ -35133,7 +34809,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_pcre_dir=no
 
 echo $ac_n "checking pcre install prefix""... $ac_c" 1>&6
-echo "configure:35137: checking pcre install prefix" >&5
+echo "configure:34813: checking pcre install prefix" >&5
 # Check whether --with-pcre-dir or --without-pcre-dir was given.
 if test "${with_pcre_dir+set}" = set; then
   withval="$with_pcre_dir"
@@ -35141,10 +34817,7 @@ if test "${with_pcre_dir+set}" = set; then
 else
   
   PHP_PCRE_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PCRE_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -35163,7 +34836,7 @@ if test "$PHP_FILTER" != "no"; then
         old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=$INCLUDES
     cat > conftest.$ac_ext <<EOF
-#line 35167 "configure"
+#line 34840 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -35182,7 +34855,7 @@ else
   rm -rf conftest*
   
       cat > conftest.$ac_ext <<EOF
-#line 35186 "configure"
+#line 34859 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -35552,7 +35225,7 @@ fi
 php_enable_ftp=no
 
 echo $ac_n "checking whether to enable FTP support""... $ac_c" 1>&6
-echo "configure:35556: checking whether to enable FTP support" >&5
+echo "configure:35229: checking whether to enable FTP support" >&5
 # Check whether --enable-ftp or --disable-ftp was given.
 if test "${enable_ftp+set}" = set; then
   enableval="$enable_ftp"
@@ -35560,10 +35233,7 @@ if test "${enable_ftp+set}" = set; then
 else
   
   PHP_FTP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_FTP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_FTP=$PHP_ENABLE_ALL
 
 fi
 
@@ -35599,7 +35269,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_openssl_dir=no
 
 echo $ac_n "checking OpenSSL dir for FTP""... $ac_c" 1>&6
-echo "configure:35603: checking OpenSSL dir for FTP" >&5
+echo "configure:35273: checking OpenSSL dir for FTP" >&5
 # Check whether --with-openssl-dir or --without-openssl-dir was given.
 if test "${with_openssl_dir+set}" = set; then
   withval="$with_openssl_dir"
@@ -35607,10 +35277,7 @@ if test "${with_openssl_dir+set}" = set; then
 else
   
   PHP_OPENSSL_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_OPENSSL_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -35940,7 +35607,7 @@ EOF
     # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:35944: checking for $ac_word" >&5
+echo "configure:35611: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -36145,9 +35812,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:36149: checking for OpenSSL version" >&5
+echo "configure:35816: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 36151 "configure"
+#line 35818 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -36302,7 +35969,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:36306: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:35973: checking for CRYPTO_free in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'CRYPTO_free | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -36310,7 +35977,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 36314 "configure"
+#line 35981 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -36321,7 +35988,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:36325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:35992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -36478,7 +36145,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:36482: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:36149: checking for SSL_CTX_set_ssl_version in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_CTX_set_ssl_version | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -36486,7 +36153,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 36490 "configure"
+#line 36157 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -36497,7 +36164,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:36501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -36616,7 +36283,7 @@ fi
 php_with_gd=no
 
 echo $ac_n "checking for GD support""... $ac_c" 1>&6
-echo "configure:36620: checking for GD support" >&5
+echo "configure:36287: checking for GD support" >&5
 # Check whether --with-gd or --without-gd was given.
 if test "${with_gd+set}" = set; then
   withval="$with_gd"
@@ -36624,10 +36291,7 @@ if test "${with_gd+set}" = set; then
 else
   
   PHP_GD=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_GD=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_GD=$PHP_ENABLE_ALL
 
 fi
 
@@ -36664,7 +36328,7 @@ if test -z "$PHP_JPEG_DIR"; then
 php_with_jpeg_dir=no
 
 echo $ac_n "checking for the location of libjpeg""... $ac_c" 1>&6
-echo "configure:36668: checking for the location of libjpeg" >&5
+echo "configure:36332: checking for the location of libjpeg" >&5
 # Check whether --with-jpeg-dir or --without-jpeg-dir was given.
 if test "${with_jpeg_dir+set}" = set; then
   withval="$with_jpeg_dir"
@@ -36672,10 +36336,7 @@ if test "${with_jpeg_dir+set}" = set; then
 else
   
   PHP_JPEG_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_JPEG_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36692,7 +36353,7 @@ if test -z "$PHP_PNG_DIR"; then
 php_with_png_dir=no
 
 echo $ac_n "checking for the location of libpng""... $ac_c" 1>&6
-echo "configure:36696: checking for the location of libpng" >&5
+echo "configure:36357: checking for the location of libpng" >&5
 # Check whether --with-png-dir or --without-png-dir was given.
 if test "${with_png_dir+set}" = set; then
   withval="$with_png_dir"
@@ -36700,10 +36361,7 @@ if test "${with_png_dir+set}" = set; then
 else
   
   PHP_PNG_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PNG_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36720,7 +36378,7 @@ if test -z "$PHP_ZLIB_DIR"; then
 php_with_zlib_dir=no
 
 echo $ac_n "checking for the location of libz""... $ac_c" 1>&6
-echo "configure:36724: checking for the location of libz" >&5
+echo "configure:36382: checking for the location of libz" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -36728,10 +36386,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36747,7 +36402,7 @@ fi
 php_with_xpm_dir=no
 
 echo $ac_n "checking for the location of libXpm""... $ac_c" 1>&6
-echo "configure:36751: checking for the location of libXpm" >&5
+echo "configure:36406: checking for the location of libXpm" >&5
 # Check whether --with-xpm-dir or --without-xpm-dir was given.
 if test "${with_xpm_dir+set}" = set; then
   withval="$with_xpm_dir"
@@ -36755,10 +36410,7 @@ if test "${with_xpm_dir+set}" = set; then
 else
   
   PHP_XPM_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_XPM_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36773,7 +36425,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_freetype_dir=no
 
 echo $ac_n "checking for FreeType 2""... $ac_c" 1>&6
-echo "configure:36777: checking for FreeType 2" >&5
+echo "configure:36429: checking for FreeType 2" >&5
 # Check whether --with-freetype-dir or --without-freetype-dir was given.
 if test "${with_freetype_dir+set}" = set; then
   withval="$with_freetype_dir"
@@ -36781,10 +36433,7 @@ if test "${with_freetype_dir+set}" = set; then
 else
   
   PHP_FREETYPE_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_FREETYPE_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36799,7 +36448,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_t1lib=no
 
 echo $ac_n "checking for T1lib support""... $ac_c" 1>&6
-echo "configure:36803: checking for T1lib support" >&5
+echo "configure:36452: checking for T1lib support" >&5
 # Check whether --with-t1lib or --without-t1lib was given.
 if test "${with_t1lib+set}" = set; then
   withval="$with_t1lib"
@@ -36807,10 +36456,7 @@ if test "${with_t1lib+set}" = set; then
 else
   
   PHP_T1LIB=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_T1LIB=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36825,7 +36471,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_gd_native_ttf=no
 
 echo $ac_n "checking whether to enable truetype string function in GD""... $ac_c" 1>&6
-echo "configure:36829: checking whether to enable truetype string function in GD" >&5
+echo "configure:36475: checking whether to enable truetype string function in GD" >&5
 # Check whether --enable-gd-native-ttf or --disable-gd-native-ttf was given.
 if test "${enable_gd_native_ttf+set}" = set; then
   enableval="$enable_gd_native_ttf"
@@ -36833,10 +36479,7 @@ if test "${enable_gd_native_ttf+set}" = set; then
 else
   
   PHP_GD_NATIVE_TTF=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_GD_NATIVE_TTF=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36851,7 +36494,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_gd_jis_conv=no
 
 echo $ac_n "checking whether to enable JIS-mapped Japanese font support in GD""... $ac_c" 1>&6
-echo "configure:36855: checking whether to enable JIS-mapped Japanese font support in GD" >&5
+echo "configure:36498: checking whether to enable JIS-mapped Japanese font support in GD" >&5
 # Check whether --enable-gd-jis-conv or --disable-gd-jis-conv was given.
 if test "${enable_gd_jis_conv+set}" = set; then
   enableval="$enable_gd_jis_conv"
@@ -36859,10 +36502,7 @@ if test "${enable_gd_jis_conv+set}" = set; then
 else
   
   PHP_GD_JIS_CONV=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_GD_JIS_CONV=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -36906,12 +36546,12 @@ if test "$PHP_GD" = "yes"; then
   for ac_func in fabsf floorf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:36910: checking for $ac_func" >&5
+echo "configure:36550: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 36915 "configure"
+#line 36555 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -36934,7 +36574,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:36938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -37106,7 +36746,7 @@ EOF
   done
 
   echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:37110: checking for jpeg_read_header in -ljpeg" >&5
+echo "configure:36750: checking for jpeg_read_header in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'jpeg_read_header | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -37114,7 +36754,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37118 "configure"
+#line 36758 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -37125,7 +36765,7 @@ int main() {
 jpeg_read_header()
 ; return 0; }
 EOF
-if { (eval echo configure:37129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:36769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -37407,7 +37047,7 @@ fi
   done
 
   echo $ac_n "checking for png_write_image in -lpng""... $ac_c" 1>&6
-echo "configure:37411: checking for png_write_image in -lpng" >&5
+echo "configure:37051: checking for png_write_image in -lpng" >&5
 ac_lib_var=`echo png'_'png_write_image | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -37415,7 +37055,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpng  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37419 "configure"
+#line 37059 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -37426,7 +37066,7 @@ int main() {
 png_write_image()
 ; return 0; }
 EOF
-if { (eval echo configure:37430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -37806,7 +37446,7 @@ fi
   done
 
   echo $ac_n "checking for XpmFreeXpmImage in -lXpm""... $ac_c" 1>&6
-echo "configure:37810: checking for XpmFreeXpmImage in -lXpm" >&5
+echo "configure:37450: checking for XpmFreeXpmImage in -lXpm" >&5
 ac_lib_var=`echo Xpm'_'XpmFreeXpmImage | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -37814,7 +37454,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 37818 "configure"
+#line 37458 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -37825,7 +37465,7 @@ int main() {
 XpmFreeXpmImage()
 ; return 0; }
 EOF
-if { (eval echo configure:37829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -38200,7 +37840,7 @@ fi
   done
 
   echo $ac_n "checking for FT_New_Face in -lfreetype""... $ac_c" 1>&6
-echo "configure:38204: checking for FT_New_Face in -lfreetype" >&5
+echo "configure:37844: checking for FT_New_Face in -lfreetype" >&5
 ac_lib_var=`echo freetype'_'FT_New_Face | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -38208,7 +37848,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfreetype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 38212 "configure"
+#line 37852 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -38219,7 +37859,7 @@ int main() {
 FT_New_Face()
 ; return 0; }
 EOF
-if { (eval echo configure:38223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:37863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -38536,7 +38176,7 @@ fi
   done
 
   echo $ac_n "checking for T1_StrError in -lt1""... $ac_c" 1>&6
-echo "configure:38540: checking for T1_StrError in -lt1" >&5
+echo "configure:38180: checking for T1_StrError in -lt1" >&5
 ac_lib_var=`echo t1'_'T1_StrError | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -38544,7 +38184,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lt1  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 38548 "configure"
+#line 38188 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -38555,7 +38195,7 @@ int main() {
 T1_StrError()
 ; return 0; }
 EOF
-if { (eval echo configure:38559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:38199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -38998,7 +38638,7 @@ EOF
   done
 
   echo $ac_n "checking for jpeg_read_header in -ljpeg""... $ac_c" 1>&6
-echo "configure:39002: checking for jpeg_read_header in -ljpeg" >&5
+echo "configure:38642: checking for jpeg_read_header in -ljpeg" >&5
 ac_lib_var=`echo jpeg'_'jpeg_read_header | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -39006,7 +38646,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ljpeg  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39010 "configure"
+#line 38650 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -39017,7 +38657,7 @@ int main() {
 jpeg_read_header()
 ; return 0; }
 EOF
-if { (eval echo configure:39021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:38661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -39299,7 +38939,7 @@ fi
   done
 
   echo $ac_n "checking for png_write_image in -lpng""... $ac_c" 1>&6
-echo "configure:39303: checking for png_write_image in -lpng" >&5
+echo "configure:38943: checking for png_write_image in -lpng" >&5
 ac_lib_var=`echo png'_'png_write_image | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -39307,7 +38947,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpng  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39311 "configure"
+#line 38951 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -39318,7 +38958,7 @@ int main() {
 png_write_image()
 ; return 0; }
 EOF
-if { (eval echo configure:39322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:38962: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -39698,7 +39338,7 @@ fi
   done
 
   echo $ac_n "checking for XpmFreeXpmImage in -lXpm""... $ac_c" 1>&6
-echo "configure:39702: checking for XpmFreeXpmImage in -lXpm" >&5
+echo "configure:39342: checking for XpmFreeXpmImage in -lXpm" >&5
 ac_lib_var=`echo Xpm'_'XpmFreeXpmImage | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -39706,7 +39346,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 39710 "configure"
+#line 39350 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -39717,7 +39357,7 @@ int main() {
 XpmFreeXpmImage()
 ; return 0; }
 EOF
-if { (eval echo configure:39721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -40092,7 +39732,7 @@ fi
   done
 
   echo $ac_n "checking for FT_New_Face in -lfreetype""... $ac_c" 1>&6
-echo "configure:40096: checking for FT_New_Face in -lfreetype" >&5
+echo "configure:39736: checking for FT_New_Face in -lfreetype" >&5
 ac_lib_var=`echo freetype'_'FT_New_Face | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -40100,7 +39740,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfreetype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40104 "configure"
+#line 39744 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -40111,7 +39751,7 @@ int main() {
 FT_New_Face()
 ; return 0; }
 EOF
-if { (eval echo configure:40115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:39755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -40428,7 +40068,7 @@ fi
   done
 
   echo $ac_n "checking for T1_StrError in -lt1""... $ac_c" 1>&6
-echo "configure:40432: checking for T1_StrError in -lt1" >&5
+echo "configure:40072: checking for T1_StrError in -lt1" >&5
 ac_lib_var=`echo t1'_'T1_StrError | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -40436,7 +40076,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lt1  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40440 "configure"
+#line 40080 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -40447,7 +40087,7 @@ int main() {
 T1_StrError()
 ; return 0; }
 EOF
-if { (eval echo configure:40451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -40822,7 +40462,7 @@ EOF
   done
 
   echo $ac_n "checking for gdImageString16 in -lgd""... $ac_c" 1>&6
-echo "configure:40826: checking for gdImageString16 in -lgd" >&5
+echo "configure:40466: checking for gdImageString16 in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageString16 | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -40830,7 +40470,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40834 "configure"
+#line 40474 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -40841,7 +40481,7 @@ int main() {
 gdImageString16()
 ; return 0; }
 EOF
-if { (eval echo configure:40845: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -40970,7 +40610,7 @@ fi
   done
 
   echo $ac_n "checking for gdImagePaletteCopy in -lgd""... $ac_c" 1>&6
-echo "configure:40974: checking for gdImagePaletteCopy in -lgd" >&5
+echo "configure:40614: checking for gdImagePaletteCopy in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImagePaletteCopy | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -40978,7 +40618,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 40982 "configure"
+#line 40622 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -40989,7 +40629,7 @@ int main() {
 gdImagePaletteCopy()
 ; return 0; }
 EOF
-if { (eval echo configure:40993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41118,7 +40758,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromPng in -lgd""... $ac_c" 1>&6
-echo "configure:41122: checking for gdImageCreateFromPng in -lgd" >&5
+echo "configure:40762: checking for gdImageCreateFromPng in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateFromPng | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41126,7 +40766,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41130 "configure"
+#line 40770 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41137,7 +40777,7 @@ int main() {
 gdImageCreateFromPng()
 ; return 0; }
 EOF
-if { (eval echo configure:41141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41266,7 +40906,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromGif in -lgd""... $ac_c" 1>&6
-echo "configure:41270: checking for gdImageCreateFromGif in -lgd" >&5
+echo "configure:40910: checking for gdImageCreateFromGif in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateFromGif | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41274,7 +40914,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41278 "configure"
+#line 40918 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41285,7 +40925,7 @@ int main() {
 gdImageCreateFromGif()
 ; return 0; }
 EOF
-if { (eval echo configure:41289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:40929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41414,7 +41054,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageGif in -lgd""... $ac_c" 1>&6
-echo "configure:41418: checking for gdImageGif in -lgd" >&5
+echo "configure:41058: checking for gdImageGif in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageGif | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41422,7 +41062,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41426 "configure"
+#line 41066 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41433,7 +41073,7 @@ int main() {
 gdImageGif()
 ; return 0; }
 EOF
-if { (eval echo configure:41437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41562,7 +41202,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageWBMP in -lgd""... $ac_c" 1>&6
-echo "configure:41566: checking for gdImageWBMP in -lgd" >&5
+echo "configure:41206: checking for gdImageWBMP in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageWBMP | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41570,7 +41210,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41574 "configure"
+#line 41214 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41581,7 +41221,7 @@ int main() {
 gdImageWBMP()
 ; return 0; }
 EOF
-if { (eval echo configure:41585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41710,7 +41350,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromJpeg in -lgd""... $ac_c" 1>&6
-echo "configure:41714: checking for gdImageCreateFromJpeg in -lgd" >&5
+echo "configure:41354: checking for gdImageCreateFromJpeg in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateFromJpeg | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41718,7 +41358,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41722 "configure"
+#line 41362 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41729,7 +41369,7 @@ int main() {
 gdImageCreateFromJpeg()
 ; return 0; }
 EOF
-if { (eval echo configure:41733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -41858,7 +41498,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromXpm in -lgd""... $ac_c" 1>&6
-echo "configure:41862: checking for gdImageCreateFromXpm in -lgd" >&5
+echo "configure:41502: checking for gdImageCreateFromXpm in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateFromXpm | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -41866,7 +41506,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 41870 "configure"
+#line 41510 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -41877,7 +41517,7 @@ int main() {
 gdImageCreateFromXpm()
 ; return 0; }
 EOF
-if { (eval echo configure:41881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42006,7 +41646,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateFromGd2 in -lgd""... $ac_c" 1>&6
-echo "configure:42010: checking for gdImageCreateFromGd2 in -lgd" >&5
+echo "configure:41650: checking for gdImageCreateFromGd2 in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateFromGd2 | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42014,7 +41654,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42018 "configure"
+#line 41658 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42025,7 +41665,7 @@ int main() {
 gdImageCreateFromGd2()
 ; return 0; }
 EOF
-if { (eval echo configure:42029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42154,7 +41794,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreateTrueColor in -lgd""... $ac_c" 1>&6
-echo "configure:42158: checking for gdImageCreateTrueColor in -lgd" >&5
+echo "configure:41798: checking for gdImageCreateTrueColor in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreateTrueColor | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42162,7 +41802,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42166 "configure"
+#line 41806 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42173,7 +41813,7 @@ int main() {
 gdImageCreateTrueColor()
 ; return 0; }
 EOF
-if { (eval echo configure:42177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42302,7 +41942,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageSetTile in -lgd""... $ac_c" 1>&6
-echo "configure:42306: checking for gdImageSetTile in -lgd" >&5
+echo "configure:41946: checking for gdImageSetTile in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageSetTile | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42310,7 +41950,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42314 "configure"
+#line 41954 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42321,7 +41961,7 @@ int main() {
 gdImageSetTile()
 ; return 0; }
 EOF
-if { (eval echo configure:42325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:41965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42450,7 +42090,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageEllipse in -lgd""... $ac_c" 1>&6
-echo "configure:42454: checking for gdImageEllipse in -lgd" >&5
+echo "configure:42094: checking for gdImageEllipse in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageEllipse | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42458,7 +42098,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42462 "configure"
+#line 42102 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42469,7 +42109,7 @@ int main() {
 gdImageEllipse()
 ; return 0; }
 EOF
-if { (eval echo configure:42473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42598,7 +42238,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageSetBrush in -lgd""... $ac_c" 1>&6
-echo "configure:42602: checking for gdImageSetBrush in -lgd" >&5
+echo "configure:42242: checking for gdImageSetBrush in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageSetBrush | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42606,7 +42246,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42610 "configure"
+#line 42250 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42617,7 +42257,7 @@ int main() {
 gdImageSetBrush()
 ; return 0; }
 EOF
-if { (eval echo configure:42621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42746,7 +42386,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringTTF in -lgd""... $ac_c" 1>&6
-echo "configure:42750: checking for gdImageStringTTF in -lgd" >&5
+echo "configure:42390: checking for gdImageStringTTF in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageStringTTF | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42754,7 +42394,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42758 "configure"
+#line 42398 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42765,7 +42405,7 @@ int main() {
 gdImageStringTTF()
 ; return 0; }
 EOF
-if { (eval echo configure:42769: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -42894,7 +42534,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringFT in -lgd""... $ac_c" 1>&6
-echo "configure:42898: checking for gdImageStringFT in -lgd" >&5
+echo "configure:42538: checking for gdImageStringFT in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageStringFT | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -42902,7 +42542,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 42906 "configure"
+#line 42546 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -42913,7 +42553,7 @@ int main() {
 gdImageStringFT()
 ; return 0; }
 EOF
-if { (eval echo configure:42917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43042,7 +42682,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageStringFTEx in -lgd""... $ac_c" 1>&6
-echo "configure:43046: checking for gdImageStringFTEx in -lgd" >&5
+echo "configure:42686: checking for gdImageStringFTEx in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageStringFTEx | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43050,7 +42690,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43054 "configure"
+#line 42694 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43061,7 +42701,7 @@ int main() {
 gdImageStringFTEx()
 ; return 0; }
 EOF
-if { (eval echo configure:43065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43190,7 +42830,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageColorClosestHWB in -lgd""... $ac_c" 1>&6
-echo "configure:43194: checking for gdImageColorClosestHWB in -lgd" >&5
+echo "configure:42834: checking for gdImageColorClosestHWB in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageColorClosestHWB | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43198,7 +42838,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43202 "configure"
+#line 42842 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43209,7 +42849,7 @@ int main() {
 gdImageColorClosestHWB()
 ; return 0; }
 EOF
-if { (eval echo configure:43213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:42853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43338,7 +42978,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageColorResolve in -lgd""... $ac_c" 1>&6
-echo "configure:43342: checking for gdImageColorResolve in -lgd" >&5
+echo "configure:42982: checking for gdImageColorResolve in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageColorResolve | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43346,7 +42986,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43350 "configure"
+#line 42990 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43357,7 +42997,7 @@ int main() {
 gdImageColorResolve()
 ; return 0; }
 EOF
-if { (eval echo configure:43361: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43486,7 +43126,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageGifCtx in -lgd""... $ac_c" 1>&6
-echo "configure:43490: checking for gdImageGifCtx in -lgd" >&5
+echo "configure:43130: checking for gdImageGifCtx in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageGifCtx | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43494,7 +43134,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43498 "configure"
+#line 43138 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43505,7 +43145,7 @@ int main() {
 gdImageGifCtx()
 ; return 0; }
 EOF
-if { (eval echo configure:43509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43634,7 +43274,7 @@ fi
   done
 
   echo $ac_n "checking for gdCacheCreate in -lgd""... $ac_c" 1>&6
-echo "configure:43638: checking for gdCacheCreate in -lgd" >&5
+echo "configure:43278: checking for gdCacheCreate in -lgd" >&5
 ac_lib_var=`echo gd'_'gdCacheCreate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43642,7 +43282,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43646 "configure"
+#line 43286 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43653,7 +43293,7 @@ int main() {
 gdCacheCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:43657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43782,7 +43422,7 @@ fi
   done
 
   echo $ac_n "checking for gdFontCacheShutdown in -lgd""... $ac_c" 1>&6
-echo "configure:43786: checking for gdFontCacheShutdown in -lgd" >&5
+echo "configure:43426: checking for gdFontCacheShutdown in -lgd" >&5
 ac_lib_var=`echo gd'_'gdFontCacheShutdown | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43790,7 +43430,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43794 "configure"
+#line 43434 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43801,7 +43441,7 @@ int main() {
 gdFontCacheShutdown()
 ; return 0; }
 EOF
-if { (eval echo configure:43805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -43930,7 +43570,7 @@ fi
   done
 
   echo $ac_n "checking for gdFreeFontCache in -lgd""... $ac_c" 1>&6
-echo "configure:43934: checking for gdFreeFontCache in -lgd" >&5
+echo "configure:43574: checking for gdFreeFontCache in -lgd" >&5
 ac_lib_var=`echo gd'_'gdFreeFontCache | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -43938,7 +43578,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 43942 "configure"
+#line 43582 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -43949,7 +43589,7 @@ int main() {
 gdFreeFontCache()
 ; return 0; }
 EOF
-if { (eval echo configure:43953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -44078,7 +43718,7 @@ fi
   done
 
   echo $ac_n "checking for gdFontCacheMutexSetup in -lgd""... $ac_c" 1>&6
-echo "configure:44082: checking for gdFontCacheMutexSetup in -lgd" >&5
+echo "configure:43722: checking for gdFontCacheMutexSetup in -lgd" >&5
 ac_lib_var=`echo gd'_'gdFontCacheMutexSetup | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -44086,7 +43726,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44090 "configure"
+#line 43730 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -44097,7 +43737,7 @@ int main() {
 gdFontCacheMutexSetup()
 ; return 0; }
 EOF
-if { (eval echo configure:44101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -44226,7 +43866,7 @@ fi
   done
 
   echo $ac_n "checking for gdNewDynamicCtxEx in -lgd""... $ac_c" 1>&6
-echo "configure:44230: checking for gdNewDynamicCtxEx in -lgd" >&5
+echo "configure:43870: checking for gdNewDynamicCtxEx in -lgd" >&5
 ac_lib_var=`echo gd'_'gdNewDynamicCtxEx | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -44234,7 +43874,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44238 "configure"
+#line 43878 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -44245,7 +43885,7 @@ int main() {
 gdNewDynamicCtxEx()
 ; return 0; }
 EOF
-if { (eval echo configure:44249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:43889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -44300,7 +43940,7 @@ fi
         old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS=-I$GD_INCLUDE
   cat > conftest.$ac_ext <<EOF
-#line 44304 "configure"
+#line 43944 "configure"
 #include "confdefs.h"
 
 #include <gd.h>
@@ -44314,7 +43954,7 @@ ctx->gd_free = 1;
   
 ; return 0; }
 EOF
-if { (eval echo configure:44318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:43958: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     cat >> confdefs.h <<\EOF
@@ -44645,7 +44285,7 @@ EOF
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 44649 "configure"
+#line 44289 "configure"
 #include "confdefs.h"
 
     char foobar () {}
@@ -44656,7 +44296,7 @@ else
     }
   
 EOF
-if { (eval echo configure:44660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:44300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -44807,7 +44447,7 @@ fi
   done
 
   echo $ac_n "checking for gdImageCreate in -lgd""... $ac_c" 1>&6
-echo "configure:44811: checking for gdImageCreate in -lgd" >&5
+echo "configure:44451: checking for gdImageCreate in -lgd" >&5
 ac_lib_var=`echo gd'_'gdImageCreate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -44815,7 +44455,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgd  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44819 "configure"
+#line 44459 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -44826,7 +44466,7 @@ int main() {
 gdImageCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:44830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:44470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -44891,7 +44531,7 @@ fi
 php_with_gettext=no
 
 echo $ac_n "checking for GNU gettext support""... $ac_c" 1>&6
-echo "configure:44895: checking for GNU gettext support" >&5
+echo "configure:44535: checking for GNU gettext support" >&5
 # Check whether --with-gettext or --without-gettext was given.
 if test "${with_gettext+set}" = set; then
   withval="$with_gettext"
@@ -44899,10 +44539,7 @@ if test "${with_gettext+set}" = set; then
 else
   
   PHP_GETTEXT=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_GETTEXT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_GETTEXT=$PHP_ENABLE_ALL
 
 fi
 
@@ -44949,7 +44586,7 @@ if test "$PHP_GETTEXT" != "no"; then
   O_LDFLAGS=$LDFLAGS
   LDFLAGS="$LDFLAGS -L$GETTEXT_LIBDIR"
   echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
-echo "configure:44953: checking for bindtextdomain in -lintl" >&5
+echo "configure:44590: checking for bindtextdomain in -lintl" >&5
 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -44957,7 +44594,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lintl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 44961 "configure"
+#line 44598 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -44968,7 +44605,7 @@ int main() {
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:44972: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:44609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -44990,7 +44627,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for bindtextdomain in -lc""... $ac_c" 1>&6
-echo "configure:44994: checking for bindtextdomain in -lc" >&5
+echo "configure:44631: checking for bindtextdomain in -lc" >&5
 ac_lib_var=`echo c'_'bindtextdomain | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -44998,7 +44635,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45002 "configure"
+#line 44639 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45009,7 +44646,7 @@ int main() {
 bindtextdomain()
 ; return 0; }
 EOF
-if { (eval echo configure:45013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:44650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45473,7 +45110,7 @@ EOF
 
 
   echo $ac_n "checking for ngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:45477: checking for ngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:45114: checking for ngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
 ac_lib_var=`echo $GETTEXT_CHECK_IN_LIB'_'ngettext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45481,7 +45118,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45485 "configure"
+#line 45122 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45492,7 +45129,7 @@ int main() {
 ngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:45496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45516,7 +45153,7 @@ else
 fi
 
   echo $ac_n "checking for dngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:45520: checking for dngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:45157: checking for dngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
 ac_lib_var=`echo $GETTEXT_CHECK_IN_LIB'_'dngettext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45524,7 +45161,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45528 "configure"
+#line 45165 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45535,7 +45172,7 @@ int main() {
 dngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:45539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45176: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45559,7 +45196,7 @@ else
 fi
 
   echo $ac_n "checking for dcngettext in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:45563: checking for dcngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:45200: checking for dcngettext in -l$GETTEXT_CHECK_IN_LIB" >&5
 ac_lib_var=`echo $GETTEXT_CHECK_IN_LIB'_'dcngettext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45567,7 +45204,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45571 "configure"
+#line 45208 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45578,7 +45215,7 @@ int main() {
 dcngettext()
 ; return 0; }
 EOF
-if { (eval echo configure:45582: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45602,7 +45239,7 @@ else
 fi
 
   echo $ac_n "checking for bind_textdomain_codeset in -l$GETTEXT_CHECK_IN_LIB""... $ac_c" 1>&6
-echo "configure:45606: checking for bind_textdomain_codeset in -l$GETTEXT_CHECK_IN_LIB" >&5
+echo "configure:45243: checking for bind_textdomain_codeset in -l$GETTEXT_CHECK_IN_LIB" >&5
 ac_lib_var=`echo $GETTEXT_CHECK_IN_LIB'_'bind_textdomain_codeset | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45610,7 +45247,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$GETTEXT_CHECK_IN_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45614 "configure"
+#line 45251 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45621,7 +45258,7 @@ int main() {
 bind_textdomain_codeset()
 ; return 0; }
 EOF
-if { (eval echo configure:45625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45652,7 +45289,7 @@ fi
 php_with_gmp=no
 
 echo $ac_n "checking for GNU MP support""... $ac_c" 1>&6
-echo "configure:45656: checking for GNU MP support" >&5
+echo "configure:45293: checking for GNU MP support" >&5
 # Check whether --with-gmp or --without-gmp was given.
 if test "${with_gmp+set}" = set; then
   withval="$with_gmp"
@@ -45660,10 +45297,7 @@ if test "${with_gmp+set}" = set; then
 else
   
   PHP_GMP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_GMP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_GMP=$PHP_ENABLE_ALL
 
 fi
 
@@ -45803,7 +45437,7 @@ if test "$PHP_GMP" != "no"; then
   done
 
   echo $ac_n "checking for __gmp_randinit_lc_2exp_size in -lgmp""... $ac_c" 1>&6
-echo "configure:45807: checking for __gmp_randinit_lc_2exp_size in -lgmp" >&5
+echo "configure:45441: checking for __gmp_randinit_lc_2exp_size in -lgmp" >&5
 ac_lib_var=`echo gmp'_'__gmp_randinit_lc_2exp_size | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45811,7 +45445,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgmp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45815 "configure"
+#line 45449 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45822,7 +45456,7 @@ int main() {
 __gmp_randinit_lc_2exp_size()
 ; return 0; }
 EOF
-if { (eval echo configure:45826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -45947,7 +45581,7 @@ else
   done
 
   echo $ac_n "checking for gmp_randinit_lc_2exp_size in -lgmp""... $ac_c" 1>&6
-echo "configure:45951: checking for gmp_randinit_lc_2exp_size in -lgmp" >&5
+echo "configure:45585: checking for gmp_randinit_lc_2exp_size in -lgmp" >&5
 ac_lib_var=`echo gmp'_'gmp_randinit_lc_2exp_size | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -45955,7 +45589,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgmp  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 45959 "configure"
+#line 45593 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -45966,7 +45600,7 @@ int main() {
 gmp_randinit_lc_2exp_size()
 ; return 0; }
 EOF
-if { (eval echo configure:45970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:45604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -46438,7 +46072,7 @@ fi
 php_with_mhash=no
 
 echo $ac_n "checking for mhash support""... $ac_c" 1>&6
-echo "configure:46442: checking for mhash support" >&5
+echo "configure:46076: checking for mhash support" >&5
 # Check whether --with-mhash or --without-mhash was given.
 if test "${with_mhash+set}" = set; then
   withval="$with_mhash"
@@ -46446,10 +46080,7 @@ if test "${with_mhash+set}" = set; then
 else
   
   PHP_MHASH=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MHASH=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MHASH=$PHP_ENABLE_ALL
 
 fi
 
@@ -46485,7 +46116,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_hash=yes
 
 echo $ac_n "checking whether to enable hash support""... $ac_c" 1>&6
-echo "configure:46489: checking whether to enable hash support" >&5
+echo "configure:46120: checking whether to enable hash support" >&5
 # Check whether --enable-hash or --disable-hash was given.
 if test "${enable_hash+set}" = set; then
   enableval="$enable_hash"
@@ -46493,10 +46124,7 @@ if test "${enable_hash+set}" = set; then
 else
   
   PHP_HASH=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_HASH=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_HASH=$PHP_ENABLE_ALL
 
 fi
 
@@ -46546,7 +46174,7 @@ EOF
 
 
   echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:46550: checking whether byte ordering is bigendian" >&5
+echo "configure:46178: checking whether byte ordering is bigendian" >&5
 if eval "test \"`echo '$''{'ac_cv_c_bigendian_php'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -46556,7 +46184,7 @@ else
   ac_cv_c_bigendian_php=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 46560 "configure"
+#line 46188 "configure"
 #include "confdefs.h"
 
 int main(void)
@@ -46572,7 +46200,7 @@ int main(void)
 }
   
 EOF
-if { (eval echo configure:46576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46204: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_bigendian_php=yes
 else
@@ -46597,7 +46225,7 @@ EOF
 
 
   echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:46601: checking size of short" >&5
+echo "configure:46229: checking size of short" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -46605,7 +46233,7 @@ else
   ac_cv_sizeof_short=2
 else
   cat > conftest.$ac_ext <<EOF
-#line 46609 "configure"
+#line 46237 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -46616,7 +46244,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:46620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -46636,7 +46264,7 @@ EOF
 
 
   echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:46640: checking size of int" >&5
+echo "configure:46268: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -46644,7 +46272,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 46648 "configure"
+#line 46276 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -46655,7 +46283,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:46659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -46675,7 +46303,7 @@ EOF
 
 
   echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:46679: checking size of long" >&5
+echo "configure:46307: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -46683,7 +46311,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 46687 "configure"
+#line 46315 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -46694,7 +46322,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:46698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -46714,7 +46342,7 @@ EOF
 
 
   echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:46718: checking size of long long" >&5
+echo "configure:46346: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -46722,7 +46350,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 46726 "configure"
+#line 46354 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -46733,7 +46361,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:46737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:46365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -47082,7 +46710,7 @@ fi
 php_with_iconv=yes
 
 echo $ac_n "checking for iconv support""... $ac_c" 1>&6
-echo "configure:47086: checking for iconv support" >&5
+echo "configure:46714: checking for iconv support" >&5
 # Check whether --with-iconv or --without-iconv was given.
 if test "${with_iconv+set}" = set; then
   withval="$with_iconv"
@@ -47090,10 +46718,7 @@ if test "${with_iconv+set}" = set; then
 else
   
   PHP_ICONV=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ICONV=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ICONV=$PHP_ENABLE_ALL
 
 fi
 
@@ -47146,12 +46771,12 @@ if test "$PHP_ICONV" != "no"; then
 
         if test "$PHP_ICONV" = "yes"; then
     echo $ac_n "checking for iconv""... $ac_c" 1>&6
-echo "configure:47150: checking for iconv" >&5
+echo "configure:46775: checking for iconv" >&5
 if eval "test \"`echo '$''{'ac_cv_func_iconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 47155 "configure"
+#line 46780 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char iconv(); below.  */
@@ -47174,7 +46799,7 @@ iconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:47178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:46803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_iconv=yes"
 else
@@ -47195,12 +46820,12 @@ else
   echo "$ac_t""no" 1>&6
 
       echo $ac_n "checking for libiconv""... $ac_c" 1>&6
-echo "configure:47199: checking for libiconv" >&5
+echo "configure:46824: checking for libiconv" >&5
 if eval "test \"`echo '$''{'ac_cv_func_libiconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 47204 "configure"
+#line 46829 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char libiconv(); below.  */
@@ -47223,7 +46848,7 @@ libiconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:47227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:46852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_libiconv=yes"
 else
@@ -47379,7 +47004,7 @@ EOF
   done
 
   echo $ac_n "checking for libiconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:47383: checking for libiconv in -l$iconv_lib_name" >&5
+echo "configure:47008: checking for libiconv in -l$iconv_lib_name" >&5
 ac_lib_var=`echo $iconv_lib_name'_'libiconv | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -47387,7 +47012,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 47391 "configure"
+#line 47016 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -47398,7 +47023,7 @@ int main() {
 libiconv()
 ; return 0; }
 EOF
-if { (eval echo configure:47402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -47539,7 +47164,7 @@ else
   done
 
   echo $ac_n "checking for iconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:47543: checking for iconv in -l$iconv_lib_name" >&5
+echo "configure:47168: checking for iconv in -l$iconv_lib_name" >&5
 ac_lib_var=`echo $iconv_lib_name'_'iconv | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -47547,7 +47172,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 47551 "configure"
+#line 47176 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -47558,7 +47183,7 @@ int main() {
 iconv()
 ; return 0; }
 EOF
-if { (eval echo configure:47562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -47769,16 +47394,16 @@ else
     fi 
 
     echo $ac_n "checking if iconv is glibc's""... $ac_c" 1>&6
-echo "configure:47773: checking if iconv is glibc's" >&5
+echo "configure:47398: checking if iconv is glibc's" >&5
     cat > conftest.$ac_ext <<EOF
-#line 47775 "configure"
+#line 47400 "configure"
 #include "confdefs.h"
 #include <gnu/libc-version.h>
 int main() {
 gnu_get_libc_version();
 ; return 0; }
 EOF
-if { (eval echo configure:47782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
       echo "$ac_t""yes" 1>&6
@@ -47796,7 +47421,7 @@ rm -f conftest*
 
     if test -z "$iconv_impl_name"; then
       echo $ac_n "checking if using GNU libiconv""... $ac_c" 1>&6
-echo "configure:47800: checking if using GNU libiconv" >&5
+echo "configure:47425: checking if using GNU libiconv" >&5
       php_iconv_old_ld="$LDFLAGS"
       LDFLAGS="-liconv $LDFLAGS"
       if test "$cross_compiling" = yes; then
@@ -47806,7 +47431,7 @@ echo "configure:47800: checking if using GNU libiconv" >&5
       
 else
   cat > conftest.$ac_ext <<EOF
-#line 47810 "configure"
+#line 47435 "configure"
 #include "confdefs.h"
 
 #include <$PHP_ICONV_H_PATH>
@@ -47816,7 +47441,7 @@ int main() {
 }
       
 EOF
-if { (eval echo configure:47820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:47445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
         echo "$ac_t""yes" 1>&6
@@ -47838,16 +47463,16 @@ fi
 
     if test -z "$iconv_impl_name"; then
       echo $ac_n "checking if iconv is Konstantin Chuguev's""... $ac_c" 1>&6
-echo "configure:47842: checking if iconv is Konstantin Chuguev's" >&5
+echo "configure:47467: checking if iconv is Konstantin Chuguev's" >&5
       cat > conftest.$ac_ext <<EOF
-#line 47844 "configure"
+#line 47469 "configure"
 #include "confdefs.h"
 #include <iconv.h>
 int main() {
 iconv_ccs_init(NULL, NULL);
 ; return 0; }
 EOF
-if { (eval echo configure:47851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""yes" 1>&6
@@ -47866,18 +47491,18 @@ rm -f conftest*
 
     if test -z "$iconv_impl_name"; then
       echo $ac_n "checking if using IBM iconv""... $ac_c" 1>&6
-echo "configure:47870: checking if using IBM iconv" >&5
+echo "configure:47495: checking if using IBM iconv" >&5
       php_iconv_old_ld="$LDFLAGS"
       LDFLAGS="-liconv $LDFLAGS"
       cat > conftest.$ac_ext <<EOF
-#line 47874 "configure"
+#line 47499 "configure"
 #include "confdefs.h"
 #include <iconv.h>
 int main() {
 cstoccsid("");
 ; return 0; }
 EOF
-if { (eval echo configure:47881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:47506: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""yes" 1>&6
@@ -48063,7 +47688,7 @@ EOF
     esac
 
     echo $ac_n "checking if iconv supports errno""... $ac_c" 1>&6
-echo "configure:48067: checking if iconv supports errno" >&5
+echo "configure:47692: checking if iconv supports errno" >&5
     if test "$cross_compiling" = yes; then
   
       echo "$ac_t""no" 1>&6
@@ -48077,7 +47702,7 @@ EOF
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 48081 "configure"
+#line 47706 "configure"
 #include "confdefs.h"
 
 #include <$PHP_ICONV_H_PATH>
@@ -48098,7 +47723,7 @@ int main() {
 }
     
 EOF
-if { (eval echo configure:48102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:47727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       echo "$ac_t""yes" 1>&6
@@ -48130,9 +47755,9 @@ fi
 
 
     echo $ac_n "checking if your cpp allows macro usage in include lines""... $ac_c" 1>&6
-echo "configure:48134: checking if your cpp allows macro usage in include lines" >&5
+echo "configure:47759: checking if your cpp allows macro usage in include lines" >&5
     cat > conftest.$ac_ext <<EOF
-#line 48136 "configure"
+#line 47761 "configure"
 #include "confdefs.h"
 
 #define FOO <$PHP_ICONV_H_PATH>
@@ -48142,7 +47767,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:48146: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:47771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
       echo "$ac_t""yes" 1>&6
@@ -48498,7 +48123,7 @@ fi
 php_with_imap=no
 
 echo $ac_n "checking for IMAP support""... $ac_c" 1>&6
-echo "configure:48502: checking for IMAP support" >&5
+echo "configure:48127: checking for IMAP support" >&5
 # Check whether --with-imap or --without-imap was given.
 if test "${with_imap+set}" = set; then
   withval="$with_imap"
@@ -48506,10 +48131,7 @@ if test "${with_imap+set}" = set; then
 else
   
   PHP_IMAP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_IMAP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_IMAP=$PHP_ENABLE_ALL
 
 fi
 
@@ -48545,7 +48167,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_kerberos=no
 
 echo $ac_n "checking for IMAP Kerberos support""... $ac_c" 1>&6
-echo "configure:48549: checking for IMAP Kerberos support" >&5
+echo "configure:48171: checking for IMAP Kerberos support" >&5
 # Check whether --with-kerberos or --without-kerberos was given.
 if test "${with_kerberos+set}" = set; then
   withval="$with_kerberos"
@@ -48553,10 +48175,7 @@ if test "${with_kerberos+set}" = set; then
 else
   
   PHP_KERBEROS=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_KERBEROS=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -48571,7 +48190,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_imap_ssl=no
 
 echo $ac_n "checking for IMAP SSL support""... $ac_c" 1>&6
-echo "configure:48575: checking for IMAP SSL support" >&5
+echo "configure:48194: checking for IMAP SSL support" >&5
 # Check whether --with-imap-ssl or --without-imap-ssl was given.
 if test "${with_imap_ssl+set}" = set; then
   withval="$with_imap_ssl"
@@ -48579,10 +48198,7 @@ if test "${with_imap_ssl+set}" = set; then
 else
   
   PHP_IMAP_SSL=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_IMAP_SSL=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -48978,7 +48594,7 @@ EOF
     done
 
         cat > conftest.$ac_ext <<EOF
-#line 48982 "configure"
+#line 48598 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/mail.h>
 EOF
@@ -48998,12 +48614,12 @@ rm -f conftest*
         old_CFLAGS=$CFLAGS
     CFLAGS="-I$IMAP_INC_DIR"
     echo $ac_n "checking for utf8_mime2text signature""... $ac_c" 1>&6
-echo "configure:49002: checking for utf8_mime2text signature" >&5
+echo "configure:48618: checking for utf8_mime2text signature" >&5
 if eval "test \"`echo '$''{'ac_cv_utf8_mime2text'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 49007 "configure"
+#line 48623 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -49016,7 +48632,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:49020: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:48636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
         ac_cv_utf8_mime2text=old
@@ -49045,12 +48661,12 @@ EOF
     old_CFLAGS=$CFLAGS
     CFLAGS="-I$IMAP_INC_DIR"
     echo $ac_n "checking for U8T_DECOMPOSE""... $ac_c" 1>&6
-echo "configure:49049: checking for U8T_DECOMPOSE" >&5
+echo "configure:48665: checking for U8T_DECOMPOSE" >&5
 if eval "test \"`echo '$''{'ac_cv_u8t_canonical'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 49054 "configure"
+#line 48670 "configure"
 #include "confdefs.h"
 
 #include <c-client.h>
@@ -49061,7 +48677,7 @@ int main() {
       
 ; return 0; }
 EOF
-if { (eval echo configure:49065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:48681: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
          ac_cv_u8t_decompose=yes
@@ -49091,7 +48707,7 @@ echo "$ac_t""$ac_cv_u8t_canonical" 1>&6
         old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$IMAP_INC_DIR
     cat > conftest.$ac_ext <<EOF
-#line 49095 "configure"
+#line 48711 "configure"
 #include "confdefs.h"
 
 #include "imap4r1.h"
@@ -49210,7 +48826,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for pam_start in -lpam""... $ac_c" 1>&6
-echo "configure:49214: checking for pam_start in -lpam" >&5
+echo "configure:48830: checking for pam_start in -lpam" >&5
 ac_lib_var=`echo pam'_'pam_start | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -49218,7 +48834,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpam  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49222 "configure"
+#line 48838 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -49229,7 +48845,7 @@ int main() {
 pam_start()
 ; return 0; }
 EOF
-if { (eval echo configure:49233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:48849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -49384,7 +49000,7 @@ fi
   done
 
   echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:49388: checking for crypt in -lcrypt" >&5
+echo "configure:49004: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -49392,7 +49008,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 49396 "configure"
+#line 49012 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -49403,7 +49019,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:49407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:49023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -49607,7 +49223,7 @@ fi
     # Extract the first word of "krb5-config", so it can be a program name with args.
 set dummy krb5-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:49611: checking for $ac_word" >&5
+echo "configure:49227: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_KRB5_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -49976,7 +49592,7 @@ else
 
   else
     cat > conftest.$ac_ext <<EOF
-#line 49980 "configure"
+#line 49596 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/linkage.h>
 EOF
@@ -50017,7 +49633,7 @@ rm -f conftest*
     # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:50021: checking for $ac_word" >&5
+echo "configure:49637: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -50222,9 +49838,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:50226: checking for OpenSSL version" >&5
+echo "configure:49842: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 50228 "configure"
+#line 49844 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -50379,7 +49995,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:50383: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:49999: checking for CRYPTO_free in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'CRYPTO_free | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -50387,7 +50003,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 50391 "configure"
+#line 50007 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -50398,7 +50014,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:50402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:50018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -50555,7 +50171,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:50559: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:50175: checking for SSL_CTX_set_ssl_version in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_CTX_set_ssl_version | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -50563,7 +50179,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 50567 "configure"
+#line 50183 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -50574,7 +50190,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:50578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:50194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -50693,7 +50309,7 @@ else
 
   elif test -f "$IMAP_INC_DIR/linkage.c"; then
     cat > conftest.$ac_ext <<EOF
-#line 50697 "configure"
+#line 50313 "configure"
 #include "confdefs.h"
 #include <$IMAP_INC_DIR/linkage.c>
 EOF
@@ -50724,7 +50340,7 @@ rm -f conftest*
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 50728 "configure"
+#line 50344 "configure"
 #include "confdefs.h"
 
     
@@ -50757,7 +50373,7 @@ else
     }
   
 EOF
-if { (eval echo configure:50761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:50377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -50793,7 +50409,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 50797 "configure"
+#line 50413 "configure"
 #include "confdefs.h"
 
     
@@ -50826,7 +50442,7 @@ else
     }
   
 EOF
-if { (eval echo configure:50830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:50446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -50853,7 +50469,7 @@ fi
 
 
     echo $ac_n "checking whether rfc822_output_address_list function present""... $ac_c" 1>&6
-echo "configure:50857: checking whether rfc822_output_address_list function present" >&5
+echo "configure:50473: checking whether rfc822_output_address_list function present" >&5
     
   old_LIBS=$LIBS
   LIBS="
@@ -50865,7 +50481,7 @@ echo "configure:50857: checking whether rfc822_output_address_list function pres
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 50869 "configure"
+#line 50485 "configure"
 #include "confdefs.h"
 
     
@@ -50901,7 +50517,7 @@ else
     }
   
 EOF
-if { (eval echo configure:50905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:50521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -50930,7 +50546,7 @@ fi
 
 
     echo $ac_n "checking whether build with IMAP works""... $ac_c" 1>&6
-echo "configure:50934: checking whether build with IMAP works" >&5
+echo "configure:50550: checking whether build with IMAP works" >&5
     
   
   old_LIBS=$LIBS
@@ -50941,7 +50557,7 @@ echo "configure:50934: checking whether build with IMAP works" >&5
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 50945 "configure"
+#line 50561 "configure"
 #include "confdefs.h"
 
     
@@ -50974,7 +50590,7 @@ else
     }
   
 EOF
-if { (eval echo configure:50978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:50594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -51006,7 +50622,7 @@ fi
 php_with_interbase=no
 
 echo $ac_n "checking for InterBase support""... $ac_c" 1>&6
-echo "configure:51010: checking for InterBase support" >&5
+echo "configure:50626: checking for InterBase support" >&5
 # Check whether --with-interbase or --without-interbase was given.
 if test "${with_interbase+set}" = set; then
   withval="$with_interbase"
@@ -51014,10 +50630,7 @@ if test "${with_interbase+set}" = set; then
 else
   
   PHP_INTERBASE=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_INTERBASE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_INTERBASE=$PHP_ENABLE_ALL
 
 fi
 
@@ -51156,7 +50769,7 @@ if test "$PHP_INTERBASE" != "no"; then
   done
 
   echo $ac_n "checking for isc_detach_database in -lfbclient""... $ac_c" 1>&6
-echo "configure:51160: checking for isc_detach_database in -lfbclient" >&5
+echo "configure:50773: checking for isc_detach_database in -lfbclient" >&5
 ac_lib_var=`echo fbclient'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -51164,7 +50777,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfbclient  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 51168 "configure"
+#line 50781 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -51175,7 +50788,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:51179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:50792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -51302,7 +50915,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lgds""... $ac_c" 1>&6
-echo "configure:51306: checking for isc_detach_database in -lgds" >&5
+echo "configure:50919: checking for isc_detach_database in -lgds" >&5
 ac_lib_var=`echo gds'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -51310,7 +50923,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgds  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 51314 "configure"
+#line 50927 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -51321,7 +50934,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:51325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:50938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -51448,7 +51061,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lib_util""... $ac_c" 1>&6
-echo "configure:51452: checking for isc_detach_database in -lib_util" >&5
+echo "configure:51065: checking for isc_detach_database in -lib_util" >&5
 ac_lib_var=`echo ib_util'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -51456,7 +51069,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lib_util  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 51460 "configure"
+#line 51073 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -51467,7 +51080,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:51471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:51084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -51944,7 +51557,7 @@ fi
 php_enable_intl=no
 
 echo $ac_n "checking whether to enable internationalization support""... $ac_c" 1>&6
-echo "configure:51948: checking whether to enable internationalization support" >&5
+echo "configure:51561: checking whether to enable internationalization support" >&5
 # Check whether --enable-intl or --disable-intl was given.
 if test "${enable_intl+set}" = set; then
   enableval="$enable_intl"
@@ -51952,10 +51565,7 @@ if test "${enable_intl+set}" = set; then
 else
   
   PHP_INTL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_INTL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_INTL=$PHP_ENABLE_ALL
 
 fi
 
@@ -52000,10 +51610,7 @@ if test "${with_icu_dir+set}" = set; then
 else
   
   PHP_ICU_DIR=DEFAULT
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ICU_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -52022,7 +51629,7 @@ ext_output=$PHP_ICU_DIR
         # Extract the first word of "icu-config", so it can be a program name with args.
 set dummy icu-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:52026: checking for $ac_word" >&5
+echo "configure:51633: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_ICU_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -52060,7 +51667,7 @@ fi
   fi
 
   echo $ac_n "checking for location of ICU headers and libraries""... $ac_c" 1>&6
-echo "configure:52064: checking for location of ICU headers and libraries" >&5
+echo "configure:51671: checking for location of ICU headers and libraries" >&5
 
     icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
   if test "$?" != "0" || test -z "$icu_install_prefix"; then
@@ -52070,7 +51677,7 @@ echo "configure:52064: checking for location of ICU headers and libraries" >&5
     echo "$ac_t""$icu_install_prefix" 1>&6
 
         echo $ac_n "checking for ICU 3.4 or greater""... $ac_c" 1>&6
-echo "configure:52074: checking for ICU 3.4 or greater" >&5
+echo "configure:51681: checking for ICU 3.4 or greater" >&5
     icu_version_full=`$ICU_CONFIG --version`
     ac_IFS=$IFS
     IFS="."
@@ -52226,7 +51833,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:52230: checking for $ac_word" >&5
+echo "configure:51837: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -52258,7 +51865,7 @@ test -n "$CXX" || CXX="gcc"
 
 
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:52262: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+echo "configure:51869: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
 
 ac_ext=C
 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -52269,12 +51876,12 @@ cross_compiling=$ac_cv_prog_cxx_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 52273 "configure"
+#line 51880 "configure"
 #include "confdefs.h"
 
 int main(){return(0);}
 EOF
-if { (eval echo configure:52278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:51885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cxx_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -52300,12 +51907,12 @@ if test $ac_cv_prog_cxx_works = no; then
   { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:52304: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:51911: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
 cross_compiling=$ac_cv_prog_cxx_cross
 
 echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:52309: checking whether we are using GNU C++" >&5
+echo "configure:51916: checking whether we are using GNU C++" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -52314,7 +51921,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:52318: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:51925: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gxx=yes
 else
   ac_cv_prog_gxx=no
@@ -52333,7 +51940,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}"
 ac_save_CXXFLAGS="$CXXFLAGS"
 CXXFLAGS=
 echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:52337: checking whether ${CXX-g++} accepts -g" >&5
+echo "configure:51944: checking whether ${CXX-g++} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -52374,7 +51981,7 @@ for ac_declaration in \
    'void exit (int);'
 do
   cat > conftest.$ac_ext <<EOF
-#line 52378 "configure"
+#line 51985 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -52382,7 +51989,7 @@ int main() {
 exit (42);
 ; return 0; }
 EOF
-if { (eval echo configure:52386: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:51993: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -52392,14 +51999,14 @@ else
 fi
 rm -f conftest*
   cat > conftest.$ac_ext <<EOF
-#line 52396 "configure"
+#line 52003 "configure"
 #include "confdefs.h"
 $ac_declaration
 int main() {
 exit (42);
 ; return 0; }
 EOF
-if { (eval echo configure:52403: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:52010: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   break
 else
@@ -52416,7 +52023,7 @@ fi
 
 
     echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
-echo "configure:52420: checking how to run the C++ preprocessor" >&5
+echo "configure:52027: checking how to run the C++ preprocessor" >&5
 if test -z "$CXXCPP"; then
 if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -52429,12 +52036,12 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
 cross_compiling=$ac_cv_prog_cxx_cross
   CXXCPP="${CXX-g++} -E"
   cat > conftest.$ac_ext <<EOF
-#line 52433 "configure"
+#line 52040 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:52438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:52045: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -52992,7 +52599,7 @@ fi
 php_enable_json=yes
 
 echo $ac_n "checking whether to enable JavaScript Object Serialization support""... $ac_c" 1>&6
-echo "configure:52996: checking whether to enable JavaScript Object Serialization support" >&5
+echo "configure:52603: checking whether to enable JavaScript Object Serialization support" >&5
 # Check whether --enable-json or --disable-json was given.
 if test "${enable_json+set}" = set; then
   enableval="$enable_json"
@@ -53000,10 +52607,7 @@ if test "${enable_json+set}" = set; then
 else
   
   PHP_JSON=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_JSON=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_JSON=$PHP_ENABLE_ALL
 
 fi
 
@@ -53041,12 +52645,12 @@ if test "$PHP_JSON" != "no"; then
 EOF
 
   echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:53045: checking for ANSI C header files" >&5
+echo "configure:52649: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 53050 "configure"
+#line 52654 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -53054,7 +52658,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:53058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:52662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -53071,7 +52675,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 53075 "configure"
+#line 52679 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -53089,7 +52693,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 53093 "configure"
+#line 52697 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -53110,7 +52714,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 53114 "configure"
+#line 52718 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -53121,7 +52725,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:53125: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:52729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -53471,7 +53075,7 @@ fi
 php_with_ldap=no
 
 echo $ac_n "checking for LDAP support""... $ac_c" 1>&6
-echo "configure:53475: checking for LDAP support" >&5
+echo "configure:53079: checking for LDAP support" >&5
 # Check whether --with-ldap or --without-ldap was given.
 if test "${with_ldap+set}" = set; then
   withval="$with_ldap"
@@ -53479,10 +53083,7 @@ if test "${with_ldap+set}" = set; then
 else
   
   PHP_LDAP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_LDAP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_LDAP=$PHP_ENABLE_ALL
 
 fi
 
@@ -53518,7 +53119,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_ldap_sasl=no
 
 echo $ac_n "checking for LDAP Cyrus SASL support""... $ac_c" 1>&6
-echo "configure:53522: checking for LDAP Cyrus SASL support" >&5
+echo "configure:53123: checking for LDAP Cyrus SASL support" >&5
 # Check whether --with-ldap-sasl or --without-ldap-sasl was given.
 if test "${with_ldap_sasl+set}" = set; then
   withval="$with_ldap_sasl"
@@ -53526,10 +53127,7 @@ if test "${with_ldap_sasl+set}" = set; then
 else
   
   PHP_LDAP_SASL=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LDAP_SASL=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -55863,19 +55461,19 @@ EOF
   LIBS="$LIBS $LDAP_SHARED_LIBADD"
 
     echo $ac_n "checking for 3 arg ldap_set_rebind_proc""... $ac_c" 1>&6
-echo "configure:55867: checking for 3 arg ldap_set_rebind_proc" >&5
+echo "configure:55465: checking for 3 arg ldap_set_rebind_proc" >&5
 if eval "test \"`echo '$''{'ac_cv_3arg_setrebindproc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 55872 "configure"
+#line 55470 "configure"
 #include "confdefs.h"
 #include <ldap.h>
 int main() {
 ldap_set_rebind_proc(0,0,0)
 ; return 0; }
 EOF
-if { (eval echo configure:55879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:55477: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_3arg_setrebindproc=yes
 else
@@ -55898,12 +55496,12 @@ EOF
       for ac_func in ldap_parse_result ldap_parse_reference ldap_start_tls_s
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:55902: checking for $ac_func" >&5
+echo "configure:55500: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 55907 "configure"
+#line 55505 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -55926,7 +55524,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:55930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -56088,7 +55686,7 @@ EOF
   done
 
   echo $ac_n "checking for sasl_version in -lldap""... $ac_c" 1>&6
-echo "configure:56092: checking for sasl_version in -lldap" >&5
+echo "configure:55690: checking for sasl_version in -lldap" >&5
 ac_lib_var=`echo ldap'_'sasl_version | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -56096,7 +55694,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lldap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 56100 "configure"
+#line 55698 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -56107,7 +55705,7 @@ int main() {
 sasl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:56111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -56276,12 +55874,12 @@ fi
   fi
 
         echo $ac_n "checking for ldap_bind_s""... $ac_c" 1>&6
-echo "configure:56280: checking for ldap_bind_s" >&5
+echo "configure:55878: checking for ldap_bind_s" >&5
 if eval "test \"`echo '$''{'ac_cv_func_ldap_bind_s'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56285 "configure"
+#line 55883 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char ldap_bind_s(); below.  */
@@ -56304,7 +55902,7 @@ ldap_bind_s();
 
 ; return 0; }
 EOF
-if { (eval echo configure:56308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:55906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_ldap_bind_s=yes"
 else
@@ -56357,7 +55955,7 @@ fi
 php_enable_mbstring=no
 
 echo $ac_n "checking whether to enable multibyte string support""... $ac_c" 1>&6
-echo "configure:56361: checking whether to enable multibyte string support" >&5
+echo "configure:55959: checking whether to enable multibyte string support" >&5
 # Check whether --enable-mbstring or --disable-mbstring was given.
 if test "${enable_mbstring+set}" = set; then
   enableval="$enable_mbstring"
@@ -56365,10 +55963,7 @@ if test "${enable_mbstring+set}" = set; then
 else
   
   PHP_MBSTRING=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MBSTRING=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MBSTRING=$PHP_ENABLE_ALL
 
 fi
 
@@ -56404,7 +55999,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_mbregex=yes
 
 echo $ac_n "checking whether to enable multibyte regex support""... $ac_c" 1>&6
-echo "configure:56408: checking whether to enable multibyte regex support" >&5
+echo "configure:56003: checking whether to enable multibyte regex support" >&5
 # Check whether --enable-mbregex or --disable-mbregex was given.
 if test "${enable_mbregex+set}" = set; then
   enableval="$enable_mbregex"
@@ -56412,10 +56007,7 @@ if test "${enable_mbregex+set}" = set; then
 else
   
   PHP_MBREGEX=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MBREGEX=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -56430,7 +56022,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_mbregex_backtrack=yes
 
 echo $ac_n "checking whether to check multibyte regex backtrack""... $ac_c" 1>&6
-echo "configure:56434: checking whether to check multibyte regex backtrack" >&5
+echo "configure:56026: checking whether to check multibyte regex backtrack" >&5
 # Check whether --enable-mbregex_backtrack or --disable-mbregex_backtrack was given.
 if test "${enable_mbregex_backtrack+set}" = set; then
   enableval="$enable_mbregex_backtrack"
@@ -56438,10 +56030,7 @@ if test "${enable_mbregex_backtrack+set}" = set; then
 else
   
   PHP_MBREGEX_BACKTRACK=yes
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MBREGEX_BACKTRACK=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -56456,7 +56045,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_libmbfl=no
 
 echo $ac_n "checking for external libmbfl""... $ac_c" 1>&6
-echo "configure:56460: checking for external libmbfl" >&5
+echo "configure:56049: checking for external libmbfl" >&5
 # Check whether --with-libmbfl or --without-libmbfl was given.
 if test "${with_libmbfl+set}" = set; then
   withval="$with_libmbfl"
@@ -56464,10 +56053,7 @@ if test "${with_libmbfl+set}" = set; then
 else
   
   PHP_LIBMBFL=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBMBFL=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -56482,7 +56068,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_onig=no
 
 echo $ac_n "checking for external oniguruma""... $ac_c" 1>&6
-echo "configure:56486: checking for external oniguruma" >&5
+echo "configure:56072: checking for external oniguruma" >&5
 # Check whether --with-onig or --without-onig was given.
 if test "${with_onig+set}" = set; then
   withval="$with_onig"
@@ -56490,10 +56076,7 @@ if test "${with_onig+set}" = set; then
 else
   
   PHP_ONIG=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ONIG=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -56526,7 +56109,7 @@ EOF
       fi
 
       echo $ac_n "checking for variable length prototypes and stdarg.h""... $ac_c" 1>&6
-echo "configure:56530: checking for variable length prototypes and stdarg.h" >&5
+echo "configure:56113: checking for variable length prototypes and stdarg.h" >&5
 if eval "test \"`echo '$''{'php_cv_mbstring_stdarg'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -56544,7 +56127,7 @@ else
         
 else
   cat > conftest.$ac_ext <<EOF
-#line 56548 "configure"
+#line 56131 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -56559,7 +56142,7 @@ int foo(int x, ...) {
 int main() { return foo(10, "", 3.14); }
         
 EOF
-if { (eval echo configure:56563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   php_cv_mbstring_stdarg=yes
 else
@@ -56580,17 +56163,17 @@ echo "$ac_t""$php_cv_mbstring_stdarg" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:56584: checking for $ac_hdr" >&5
+echo "configure:56167: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56589 "configure"
+#line 56172 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:56594: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:56177: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -56617,7 +56200,7 @@ fi
 done
 
       echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:56621: checking size of int" >&5
+echo "configure:56204: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -56625,7 +56208,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 56629 "configure"
+#line 56212 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -56636,7 +56219,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:56640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56223: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -56656,7 +56239,7 @@ EOF
 
 
       echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:56660: checking size of short" >&5
+echo "configure:56243: checking size of short" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -56664,7 +56247,7 @@ else
   ac_cv_sizeof_short=2
 else
   cat > conftest.$ac_ext <<EOF
-#line 56668 "configure"
+#line 56251 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -56675,7 +56258,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:56679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -56695,7 +56278,7 @@ EOF
 
 
       echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:56699: checking size of long" >&5
+echo "configure:56282: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -56703,7 +56286,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 56707 "configure"
+#line 56290 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -56714,7 +56297,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:56718: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -56734,12 +56317,12 @@ EOF
 
 
       echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:56738: checking for working const" >&5
+echo "configure:56321: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56743 "configure"
+#line 56326 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -56788,7 +56371,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:56792: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:56375: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -56809,12 +56392,12 @@ EOF
 fi
 
       echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:56813: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:56396: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56818 "configure"
+#line 56401 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -56823,7 +56406,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:56827: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:56410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -56846,19 +56429,19 @@ fi
       # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:56850: checking for working alloca.h" >&5
+echo "configure:56433: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56855 "configure"
+#line 56438 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:56862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:56445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -56879,12 +56462,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:56883: checking for alloca" >&5
+echo "configure:56466: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56888 "configure"
+#line 56471 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -56912,7 +56495,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:56916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:56499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -56944,12 +56527,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:56948: checking whether alloca needs Cray hooks" >&5
+echo "configure:56531: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56953 "configure"
+#line 56536 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -56974,12 +56557,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:56978: checking for $ac_func" >&5
+echo "configure:56561: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 56983 "configure"
+#line 56566 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -57002,7 +56585,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:57006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:56589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -57029,7 +56612,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:57033: checking stack direction for C alloca" >&5
+echo "configure:56616: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -57037,7 +56620,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 57041 "configure"
+#line 56624 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -57056,7 +56639,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:57060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -57078,7 +56661,7 @@ EOF
 fi
 
       echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:57082: checking for 8-bit clean memcmp" >&5
+echo "configure:56665: checking for 8-bit clean memcmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -57086,7 +56669,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 57090 "configure"
+#line 56673 "configure"
 #include "confdefs.h"
 
 main()
@@ -57096,7 +56679,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:57100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:56683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -57115,17 +56698,17 @@ test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
 
       ac_safe=`echo "stdarg.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for stdarg.h""... $ac_c" 1>&6
-echo "configure:57119: checking for stdarg.h" >&5
+echo "configure:56702: checking for stdarg.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 57124 "configure"
+#line 56707 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:57129: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:56712: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -57355,7 +56938,7 @@ EOF
   done
 
   echo $ac_n "checking for onig_init in -lonig""... $ac_c" 1>&6
-echo "configure:57359: checking for onig_init in -lonig" >&5
+echo "configure:56942: checking for onig_init in -lonig" >&5
 ac_lib_var=`echo onig'_'onig_init | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -57363,7 +56946,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lonig  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 57367 "configure"
+#line 56950 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -57374,7 +56957,7 @@ int main() {
 onig_init()
 ; return 0; }
 EOF
-if { (eval echo configure:57378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:56961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -57600,9 +57183,9 @@ fi
   done
 
       echo $ac_n "checking if oniguruma has an invalid entry for KOI8 encoding""... $ac_c" 1>&6
-echo "configure:57604: checking if oniguruma has an invalid entry for KOI8 encoding" >&5
+echo "configure:57187: checking if oniguruma has an invalid entry for KOI8 encoding" >&5
       cat > conftest.$ac_ext <<EOF
-#line 57606 "configure"
+#line 57189 "configure"
 #include "confdefs.h"
 
 #include <oniguruma.h>
@@ -57613,7 +57196,7 @@ return (int)(ONIG_ENCODING_KOI8 + 1);
       
 ; return 0; }
 EOF
-if { (eval echo configure:57617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:57200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
         echo "$ac_t""no" 1>&6
@@ -57911,7 +57494,7 @@ EOF
   done
 
   echo $ac_n "checking for mbfl_buffer_converter_new in -lmbfl""... $ac_c" 1>&6
-echo "configure:57915: checking for mbfl_buffer_converter_new in -lmbfl" >&5
+echo "configure:57498: checking for mbfl_buffer_converter_new in -lmbfl" >&5
 ac_lib_var=`echo mbfl'_'mbfl_buffer_converter_new | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -57919,7 +57502,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmbfl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 57923 "configure"
+#line 57506 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -57930,7 +57513,7 @@ int main() {
 mbfl_buffer_converter_new()
 ; return 0; }
 EOF
-if { (eval echo configure:57934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:57517: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -58567,7 +58150,7 @@ fi
 php_with_mcrypt=no
 
 echo $ac_n "checking for mcrypt support""... $ac_c" 1>&6
-echo "configure:58571: checking for mcrypt support" >&5
+echo "configure:58154: checking for mcrypt support" >&5
 # Check whether --with-mcrypt or --without-mcrypt was given.
 if test "${with_mcrypt+set}" = set; then
   withval="$with_mcrypt"
@@ -58575,10 +58158,7 @@ if test "${with_mcrypt+set}" = set; then
 else
   
   PHP_MCRYPT=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MCRYPT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MCRYPT=$PHP_ENABLE_ALL
 
 fi
 
@@ -58623,9 +58203,9 @@ if test "$PHP_MCRYPT" != "no"; then
   old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS=-I$MCRYPT_DIR/include
   echo $ac_n "checking for libmcrypt version""... $ac_c" 1>&6
-echo "configure:58627: checking for libmcrypt version" >&5
+echo "configure:58207: checking for libmcrypt version" >&5
   cat > conftest.$ac_ext <<EOF
-#line 58629 "configure"
+#line 58209 "configure"
 #include "confdefs.h"
 
 #include <mcrypt.h>
@@ -58749,7 +58329,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for mcrypt_module_open in -lmcrypt""... $ac_c" 1>&6
-echo "configure:58753: checking for mcrypt_module_open in -lmcrypt" >&5
+echo "configure:58333: checking for mcrypt_module_open in -lmcrypt" >&5
 ac_lib_var=`echo mcrypt'_'mcrypt_module_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -58757,7 +58337,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 58761 "configure"
+#line 58341 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -58768,7 +58348,7 @@ int main() {
 mcrypt_module_open()
 ; return 0; }
 EOF
-if { (eval echo configure:58772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:58352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -58921,7 +58501,7 @@ else
   done
 
   echo $ac_n "checking for mcrypt_module_open in -lmcrypt""... $ac_c" 1>&6
-echo "configure:58925: checking for mcrypt_module_open in -lmcrypt" >&5
+echo "configure:58505: checking for mcrypt_module_open in -lmcrypt" >&5
 ac_lib_var=`echo mcrypt'_'mcrypt_module_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -58929,7 +58509,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 58933 "configure"
+#line 58513 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -58940,7 +58520,7 @@ int main() {
 mcrypt_module_open()
 ; return 0; }
 EOF
-if { (eval echo configure:58944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:58524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -59413,7 +58993,7 @@ fi
 php_with_mssql=no
 
 echo $ac_n "checking for MSSQL support via FreeTDS""... $ac_c" 1>&6
-echo "configure:59417: checking for MSSQL support via FreeTDS" >&5
+echo "configure:58997: checking for MSSQL support via FreeTDS" >&5
 # Check whether --with-mssql or --without-mssql was given.
 if test "${with_mssql+set}" = set; then
   withval="$with_mssql"
@@ -59421,10 +59001,7 @@ if test "${with_mssql+set}" = set; then
 else
   
   PHP_MSSQL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MSSQL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MSSQL=$PHP_ENABLE_ALL
 
 fi
 
@@ -59914,7 +59491,7 @@ EOF
   fi
 
   echo $ac_n "checking for dnet_addr in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:59918: checking for dnet_addr in -ldnet_stub" >&5
+echo "configure:59495: checking for dnet_addr in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_addr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -59922,7 +59499,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 59926 "configure"
+#line 59503 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -59933,7 +59510,7 @@ int main() {
 dnet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:59937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:59514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -60077,7 +59654,7 @@ fi
 php_with_mysql=no
 
 echo $ac_n "checking for MySQL support""... $ac_c" 1>&6
-echo "configure:60081: checking for MySQL support" >&5
+echo "configure:59658: checking for MySQL support" >&5
 # Check whether --with-mysql or --without-mysql was given.
 if test "${with_mysql+set}" = set; then
   withval="$with_mysql"
@@ -60085,10 +59662,7 @@ if test "${with_mysql+set}" = set; then
 else
   
   PHP_MYSQL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MYSQL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MYSQL=$PHP_ENABLE_ALL
 
 fi
 
@@ -60124,7 +59698,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_mysql_sock=no
 
 echo $ac_n "checking for specified location of the MySQL UNIX socket""... $ac_c" 1>&6
-echo "configure:60128: checking for specified location of the MySQL UNIX socket" >&5
+echo "configure:59702: checking for specified location of the MySQL UNIX socket" >&5
 # Check whether --with-mysql-sock or --without-mysql-sock was given.
 if test "${with_mysql_sock+set}" = set; then
   withval="$with_mysql_sock"
@@ -60132,10 +59706,7 @@ if test "${with_mysql_sock+set}" = set; then
 else
   
   PHP_MYSQL_SOCK=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MYSQL_SOCK=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -60151,7 +59722,7 @@ if test -z "$PHP_ZLIB_DIR"; then
 php_with_zlib_dir=no
 
 echo $ac_n "checking for the location of libz""... $ac_c" 1>&6
-echo "configure:60155: checking for the location of libz" >&5
+echo "configure:59726: checking for the location of libz" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -60159,10 +59730,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -60328,7 +59896,7 @@ Note that the MySQL client library is not bundled anymore!" 1>&2; exit 1; }
   done
 
   echo $ac_n "checking for mysql_close in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:60332: checking for mysql_close in -l$MYSQL_LIBNAME" >&5
+echo "configure:59900: checking for mysql_close in -l$MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $MYSQL_LIBNAME'_'mysql_close | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -60336,7 +59904,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60340 "configure"
+#line 59908 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -60347,7 +59915,7 @@ int main() {
 mysql_close()
 ; return 0; }
 EOF
-if { (eval echo configure:60351: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:59919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -60570,7 +60138,7 @@ else
   done
 
   echo $ac_n "checking for mysql_error in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:60574: checking for mysql_error in -l$MYSQL_LIBNAME" >&5
+echo "configure:60142: checking for mysql_error in -l$MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $MYSQL_LIBNAME'_'mysql_error | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -60578,7 +60146,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60582 "configure"
+#line 60150 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -60589,7 +60157,7 @@ int main() {
 mysql_error()
 ; return 0; }
 EOF
-if { (eval echo configure:60593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:60161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -60744,7 +60312,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_errno in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:60748: checking for mysql_errno in -l$MYSQL_LIBNAME" >&5
+echo "configure:60316: checking for mysql_errno in -l$MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $MYSQL_LIBNAME'_'mysql_errno | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -60752,7 +60320,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 60756 "configure"
+#line 60324 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -60763,7 +60331,7 @@ int main() {
 mysql_errno()
 ; return 0; }
 EOF
-if { (eval echo configure:60767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:60335: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -60957,7 +60525,7 @@ fi
 
 if test "$PHP_MYSQL" != "no"; then
   echo $ac_n "checking for MySQL UNIX socket location""... $ac_c" 1>&6
-echo "configure:60961: checking for MySQL UNIX socket location" >&5
+echo "configure:60529: checking for MySQL UNIX socket location" >&5
   if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
     MYSQL_SOCK=$PHP_MYSQL_SOCK
     cat >> confdefs.h <<EOF
@@ -61330,7 +60898,7 @@ fi
 php_with_mysqli=no
 
 echo $ac_n "checking for MySQLi support""... $ac_c" 1>&6
-echo "configure:61334: checking for MySQLi support" >&5
+echo "configure:60902: checking for MySQLi support" >&5
 # Check whether --with-mysqli or --without-mysqli was given.
 if test "${with_mysqli+set}" = set; then
   withval="$with_mysqli"
@@ -61338,10 +60906,7 @@ if test "${with_mysqli+set}" = set; then
 else
   
   PHP_MYSQLI=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_MYSQLI=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_MYSQLI=$PHP_ENABLE_ALL
 
 fi
 
@@ -61377,7 +60942,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_embedded_mysqli=no
 
 echo $ac_n "checking whether to enable embedded MySQLi support""... $ac_c" 1>&6
-echo "configure:61381: checking whether to enable embedded MySQLi support" >&5
+echo "configure:60946: checking whether to enable embedded MySQLi support" >&5
 # Check whether --enable-embedded_mysqli or --disable-embedded_mysqli was given.
 if test "${enable_embedded_mysqli+set}" = set; then
   enableval="$enable_embedded_mysqli"
@@ -61385,10 +60950,7 @@ if test "${enable_embedded_mysqli+set}" = set; then
 else
   
   PHP_EMBEDDED_MYSQLI=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_EMBEDDED_MYSQLI=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -61531,7 +61093,7 @@ EOF
   done
 
   echo $ac_n "checking for mysql_set_server_option in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:61535: checking for mysql_set_server_option in -l$MYSQL_LIB_NAME" >&5
+echo "configure:61097: checking for mysql_set_server_option in -l$MYSQL_LIB_NAME" >&5
 ac_lib_var=`echo $MYSQL_LIB_NAME'_'mysql_set_server_option | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -61539,7 +61101,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 61543 "configure"
+#line 61105 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -61550,7 +61112,7 @@ int main() {
 mysql_set_server_option()
 ; return 0; }
 EOF
-if { (eval echo configure:61554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:61116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -61798,7 +61360,7 @@ EOF
   done
 
   echo $ac_n "checking for mysql_set_character_set in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:61802: checking for mysql_set_character_set in -l$MYSQL_LIB_NAME" >&5
+echo "configure:61364: checking for mysql_set_character_set in -l$MYSQL_LIB_NAME" >&5
 ac_lib_var=`echo $MYSQL_LIB_NAME'_'mysql_set_character_set | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -61806,7 +61368,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 61810 "configure"
+#line 61372 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -61817,7 +61379,7 @@ int main() {
 mysql_set_character_set()
 ; return 0; }
 EOF
-if { (eval echo configure:61821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:61383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -61961,7 +61523,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_stmt_next_result in -l$MYSQL_LIB_NAME""... $ac_c" 1>&6
-echo "configure:61965: checking for mysql_stmt_next_result in -l$MYSQL_LIB_NAME" >&5
+echo "configure:61527: checking for mysql_stmt_next_result in -l$MYSQL_LIB_NAME" >&5
 ac_lib_var=`echo $MYSQL_LIB_NAME'_'mysql_stmt_next_result | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -61969,7 +61531,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIB_NAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 61973 "configure"
+#line 61535 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -61980,7 +61542,7 @@ int main() {
 mysql_stmt_next_result()
 ; return 0; }
 EOF
-if { (eval echo configure:61984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:61546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -62317,6 +61879,24 @@ EOF
   
   PHP_VAR_SUBST="$PHP_VAR_SUBST MYSQLI_SHARED_LIBADD"
 
+  
+  
+    for header_file in ext/mysqli/php_mysqli_structs.h; do
+      
+  
+  unique=`echo $header_file|$SED 's/[^a-zA-Z0-9]/_/g'`
+  
+  cmd="echo $ac_n \"\$INSTALLHEADERS$unique$ac_c\""
+  if test -n "$unique" && test "`eval $cmd`" = "" ; then
+    eval "INSTALLHEADERS$unique=set"
+    
+        INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
+      
+  fi
+
+    done 
+  
+
 
   if test "$PHP_MYSQLI" = "mysqlnd"; then
     
@@ -62366,7 +61946,7 @@ fi
 php_with_oci8=no
 
 echo $ac_n "checking for Oracle (OCI8) support""... $ac_c" 1>&6
-echo "configure:62370: checking for Oracle (OCI8) support" >&5
+echo "configure:61950: checking for Oracle (OCI8) support" >&5
 # Check whether --with-oci8 or --without-oci8 was given.
 if test "${with_oci8+set}" = set; then
   withval="$with_oci8"
@@ -62374,10 +61954,7 @@ if test "${with_oci8+set}" = set; then
 else
   
   PHP_OCI8=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_OCI8=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_OCI8=$PHP_ENABLE_ALL
 
 fi
 
@@ -62417,7 +61994,7 @@ if test "$PHP_OCI8" != "no"; then
 
   
   echo $ac_n "checking PHP version""... $ac_c" 1>&6
-echo "configure:62421: checking PHP version" >&5
+echo "configure:61998: checking PHP version" >&5
 
   tmp_version=$PHP_VERSION
   if test -z "$tmp_version"; then
@@ -62449,7 +62026,7 @@ echo "configure:62421: checking PHP version" >&5
 
   
   echo $ac_n "checking size of long int""... $ac_c" 1>&6
-echo "configure:62453: checking size of long int" >&5
+echo "configure:62030: checking size of long int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -62457,7 +62034,7 @@ else
   ac_cv_sizeof_long_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 62461 "configure"
+#line 62038 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -62468,7 +62045,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:62472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:62049: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_int=`cat conftestval`
 else
@@ -62488,7 +62065,7 @@ EOF
 
 
   echo $ac_n "checking checking if we're on a 64-bit platform""... $ac_c" 1>&6
-echo "configure:62492: checking checking if we're on a 64-bit platform" >&5
+echo "configure:62069: checking checking if we're on a 64-bit platform" >&5
   if test "$ac_cv_sizeof_long_int" = "4"; then
     echo "$ac_t""no" 1>&6
     PHP_OCI8_OH_LIBDIR=lib32 
@@ -62532,7 +62109,7 @@ echo "configure:62492: checking checking if we're on a 64-bit platform" >&5
   if test "$PHP_OCI8_INSTANT_CLIENT" = "no"; then
             
     echo $ac_n "checking Oracle ORACLE_HOME install directory""... $ac_c" 1>&6
-echo "configure:62536: checking Oracle ORACLE_HOME install directory" >&5
+echo "configure:62113: checking Oracle ORACLE_HOME install directory" >&5
 
     if test "$PHP_OCI8" = "yes"; then
       OCI8_DIR=$ORACLE_HOME
@@ -62543,7 +62120,7 @@ echo "configure:62536: checking Oracle ORACLE_HOME install directory" >&5
 
     
   echo $ac_n "checking ORACLE_HOME library validity""... $ac_c" 1>&6
-echo "configure:62547: checking ORACLE_HOME library validity" >&5
+echo "configure:62124: checking ORACLE_HOME library validity" >&5
   if test ! -d "$OCI8_DIR"; then
     { echo "configure: error: ${OCI8_DIR} is not a directory" 1>&2; exit 1; }
   fi
@@ -62884,7 +62461,7 @@ echo "configure:62547: checking ORACLE_HOME library validity" >&5
 
     
   echo $ac_n "checking Oracle version""... $ac_c" 1>&6
-echo "configure:62888: checking Oracle version" >&5
+echo "configure:62465: checking Oracle version" >&5
   if test -s "$OCI8_DIR/orainst/unix.rgs"; then
     OCI8_ORACLE_VERSION=`grep '"ocommon"' $OCI8_DIR/orainst/unix.rgs | $PHP_OCI8_SED 's/  */:/g' | cut -d: -f 6 | cut -c 2-4`
     test -z "$OCI8_ORACLE_VERSION" && OCI8_ORACLE_VERSION=7.3
@@ -63014,7 +62591,7 @@ echo "configure:62888: checking Oracle version" >&5
   done
 
   echo $ac_n "checking for OCIEnvNlsCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:63018: checking for OCIEnvNlsCreate in -lclntsh" >&5
+echo "configure:62595: checking for OCIEnvNlsCreate in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCIEnvNlsCreate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -63022,7 +62599,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 63026 "configure"
+#line 62603 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -63033,7 +62610,7 @@ int main() {
 OCIEnvNlsCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:63037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:62614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -63470,7 +63047,7 @@ EOF
   else
             
     echo $ac_n "checking Oracle Instant Client directory""... $ac_c" 1>&6
-echo "configure:63474: checking Oracle Instant Client directory" >&5
+echo "configure:63051: checking Oracle Instant Client directory" >&5
 
     if test "$PHP_OCI8_INSTANT_CLIENT" = "yes"; then
                                     PHP_OCI8_INSTANT_CLIENT=`ls -d /usr/lib/oracle/*/client${PHP_OCI8_IC_LIBDIR_SUFFIX}/lib/libclntsh.* 2> /dev/null | tail -1 | $PHP_OCI8_SED -e 's#/libclntsh[^/]*##'`
@@ -63483,7 +63060,7 @@ echo "configure:63474: checking Oracle Instant Client directory" >&5
     OCI8_DIR=$PHP_OCI8_INSTANT_CLIENT
 
     echo $ac_n "checking Oracle Instant Client SDK header directory""... $ac_c" 1>&6
-echo "configure:63487: checking Oracle Instant Client SDK header directory" >&5
+echo "configure:63064: checking Oracle Instant Client SDK header directory" >&5
 
         OCISDKRPMINC=`echo "$PHP_OCI8_INSTANT_CLIENT" | $PHP_OCI8_SED -e 's!^/usr/lib/oracle/\(.*\)/client\('${PHP_OCI8_IC_LIBDIR_SUFFIX}'\)*/lib/*$!/usr/include/oracle/\1/client\2!'`
 
@@ -63692,7 +63269,7 @@ echo "configure:63487: checking Oracle Instant Client SDK header directory" >&5
 
     
   echo $ac_n "checking Oracle Instant Client version""... $ac_c" 1>&6
-echo "configure:63696: checking Oracle Instant Client version" >&5
+echo "configure:63273: checking Oracle Instant Client version" >&5
   if test -f $PHP_OCI8_INSTANT_CLIENT/libnnz11.$SHLIB_SUFFIX_NAME; then
     if test -f $PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then
       if test ! -f $PHP_OCI8_INSTANT_CLIENT/libclntsh.$SHLIB_SUFFIX_NAME; then
@@ -64137,10 +63714,7 @@ if test "${with_adabas+set}" = set; then
 else
   
   PHP_ADABAS=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ADABAS=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ADABAS=$PHP_ENABLE_ALL
 
 fi
 
@@ -64174,7 +63748,7 @@ esac
 
   if test "$PHP_ADABAS" != "no"; then
     echo $ac_n "checking for Adabas support""... $ac_c" 1>&6
-echo "configure:64178: checking for Adabas support" >&5
+echo "configure:63752: checking for Adabas support" >&5
     if test "$PHP_ADABAS" = "yes"; then
       PHP_ADABAS=/usr/local
     fi
@@ -64343,10 +63917,7 @@ if test "${with_sapdb+set}" = set; then
 else
   
   PHP_SAPDB=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SAPDB=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SAPDB=$PHP_ENABLE_ALL
 
 fi
 
@@ -64380,7 +63951,7 @@ esac
 
   if test "$PHP_SAPDB" != "no"; then
     echo $ac_n "checking for SAP DB support""... $ac_c" 1>&6
-echo "configure:64384: checking for SAP DB support" >&5
+echo "configure:63955: checking for SAP DB support" >&5
     if test "$PHP_SAPDB" = "yes"; then
       PHP_SAPDB=/usr/local
     fi
@@ -64479,10 +64050,7 @@ if test "${with_solid+set}" = set; then
 else
   
   PHP_SOLID=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SOLID=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SOLID=$PHP_ENABLE_ALL
 
 fi
 
@@ -64516,7 +64084,7 @@ esac
 
   if test "$PHP_SOLID" != "no"; then
     echo $ac_n "checking for Solid support""... $ac_c" 1>&6
-echo "configure:64520: checking for Solid support" >&5
+echo "configure:64088: checking for Solid support" >&5
     if test "$PHP_SOLID" = "yes"; then
       PHP_SOLID=/usr/local/solid
     fi
@@ -64543,7 +64111,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Solid library file""... $ac_c" 1>&6
-echo "configure:64547: checking Solid library file" >&5  
+echo "configure:64115: checking Solid library file" >&5  
   ac_solid_uname_r=`uname -r 2>/dev/null`
   ac_solid_uname_s=`uname -s 2>/dev/null`
   case $ac_solid_uname_s in
@@ -64630,10 +64198,7 @@ if test "${with_ibm_db2+set}" = set; then
 else
   
   PHP_IBM_DB2=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_IBM_DB2=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_IBM_DB2=$PHP_ENABLE_ALL
 
 fi
 
@@ -64667,7 +64232,7 @@ esac
 
   if test "$PHP_IBM_DB2" != "no"; then
     echo $ac_n "checking for IBM DB2 support""... $ac_c" 1>&6
-echo "configure:64671: checking for IBM DB2 support" >&5
+echo "configure:64236: checking for IBM DB2 support" >&5
     if test "$PHP_IBM_DB2" = "yes"; then
       ODBC_INCDIR=/home/db2inst1/sqllib/include
       ODBC_LIBDIR=/home/db2inst1/sqllib/lib
@@ -64698,7 +64263,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 64702 "configure"
+#line 64267 "configure"
 #include "confdefs.h"
 
     
@@ -64709,7 +64274,7 @@ else
     }
   
 EOF
-if { (eval echo configure:64713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:64278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -64756,10 +64321,7 @@ if test "${with_ODBCRouter+set}" = set; then
 else
   
   PHP_ODBCROUTER=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ODBCROUTER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ODBCROUTER=$PHP_ENABLE_ALL
 
 fi
 
@@ -64793,7 +64355,7 @@ esac
 
   if test "$PHP_ODBCROUTER" != "no"; then
     echo $ac_n "checking for ODBCRouter.com support""... $ac_c" 1>&6
-echo "configure:64797: checking for ODBCRouter.com support" >&5
+echo "configure:64359: checking for ODBCRouter.com support" >&5
     if test "$PHP_ODBCROUTER" = "yes"; then
       PHP_ODBCROUTER=/usr
     fi
@@ -64823,10 +64385,7 @@ if test "${with_empress+set}" = set; then
 else
   
   PHP_EMPRESS=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_EMPRESS=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_EMPRESS=$PHP_ENABLE_ALL
 
 fi
 
@@ -64860,7 +64419,7 @@ esac
 
   if test "$PHP_EMPRESS" != "no"; then
     echo $ac_n "checking for Empress support""... $ac_c" 1>&6
-echo "configure:64864: checking for Empress support" >&5
+echo "configure:64423: checking for Empress support" >&5
     if test "$PHP_EMPRESS" = "yes"; then
       ODBC_INCDIR=$EMPRESSPATH/include/odbc
       ODBC_LIBDIR=$EMPRESSPATH/shlib
@@ -64878,7 +64437,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Empress library file""... $ac_c" 1>&6
-echo "configure:64882: checking Empress library file" >&5
+echo "configure:64441: checking Empress library file" >&5
   ODBC_LIBS=`echo $ODBC_LIBDIR/libempodbccl.so | cut -d' ' -f1`
   if test ! -f $ODBC_LIBS; then
     ODBC_LIBS=`echo $ODBC_LIBDIR/libempodbccl.so | cut -d' ' -f1`
@@ -64900,10 +64459,7 @@ if test "${with_empress_bcs+set}" = set; then
 else
   
   PHP_EMPRESS_BCS=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_EMPRESS_BCS=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_EMPRESS_BCS=$PHP_ENABLE_ALL
 
 fi
 
@@ -64937,7 +64493,7 @@ esac
 
   if test "$PHP_EMPRESS_BCS" != "no"; then
     echo $ac_n "checking for Empress local access support""... $ac_c" 1>&6
-echo "configure:64941: checking for Empress local access support" >&5
+echo "configure:64497: checking for Empress local access support" >&5
     if test "$PHP_EMPRESS_BCS" = "yes"; then
       ODBC_INCDIR=$EMPRESSPATH/include/odbc
       ODBC_LIBDIR=$EMPRESSPATH/shlib
@@ -64971,7 +64527,7 @@ EOF
     echo "$ac_t""$ext_output" 1>&6
     
   echo $ac_n "checking Empress local access library file""... $ac_c" 1>&6
-echo "configure:64975: checking Empress local access library file" >&5
+echo "configure:64531: checking Empress local access library file" >&5
   ODBCBCS_LIBS=`echo $ODBC_LIBDIR/libempodbcbcs.a | cut -d' ' -f1`
   if test ! -f $ODBCBCS_LIBS; then
     ODBCBCS_LIBS=`echo $ODBC_LIBDIR/libempodbcbcs.a | cut -d' ' -f1`
@@ -64993,10 +64549,7 @@ if test "${with_birdstep+set}" = set; then
 else
   
   PHP_BIRDSTEP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_BIRDSTEP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_BIRDSTEP=$PHP_ENABLE_ALL
 
 fi
 
@@ -65030,7 +64583,7 @@ esac
   
   if test "$PHP_BIRDSTEP" != "no"; then
     echo $ac_n "checking for Birdstep support""... $ac_c" 1>&6
-echo "configure:65034: checking for Birdstep support" >&5
+echo "configure:64587: checking for Birdstep support" >&5
     if test "$PHP_BIRDSTEP" = "yes"; then
         ODBC_INCDIR=/usr/local/birdstep/include
         ODBC_LIBDIR=/usr/local/birdstep/lib
@@ -65108,10 +64661,7 @@ if test "${with_custom_odbc+set}" = set; then
 else
   
   PHP_CUSTOM_ODBC=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_CUSTOM_ODBC=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_CUSTOM_ODBC=$PHP_ENABLE_ALL
 
 fi
 
@@ -65145,7 +64695,7 @@ esac
 
   if test "$PHP_CUSTOM_ODBC" != "no"; then
     echo $ac_n "checking for a custom ODBC support""... $ac_c" 1>&6
-echo "configure:65149: checking for a custom ODBC support" >&5
+echo "configure:64699: checking for a custom ODBC support" >&5
     if test "$PHP_CUSTOM_ODBC" = "yes"; then
       PHP_CUSTOM_ODBC=/usr/local
     fi
@@ -65175,10 +64725,7 @@ if test "${with_iodbc+set}" = set; then
 else
   
   PHP_IODBC=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_IODBC=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_IODBC=$PHP_ENABLE_ALL
 
 fi
 
@@ -65212,7 +64759,7 @@ esac
 
   if test "$PHP_IODBC" != "no"; then
     echo $ac_n "checking for iODBC support""... $ac_c" 1>&6
-echo "configure:65216: checking for iODBC support" >&5
+echo "configure:64763: checking for iODBC support" >&5
     if test "$PHP_IODBC" = "yes"; then
       PHP_IODBC=/usr/local
     fi
@@ -65324,10 +64871,7 @@ if test "${with_esoob+set}" = set; then
 else
   
   PHP_ESOOB=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ESOOB=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ESOOB=$PHP_ENABLE_ALL
 
 fi
 
@@ -65361,7 +64905,7 @@ esac
 
   if test "$PHP_ESOOB" != "no"; then
     echo $ac_n "checking for Easysoft ODBC-ODBC Bridge support""... $ac_c" 1>&6
-echo "configure:65365: checking for Easysoft ODBC-ODBC Bridge support" >&5
+echo "configure:64909: checking for Easysoft ODBC-ODBC Bridge support" >&5
     if test "$PHP_ESOOB" = "yes"; then
       PHP_ESOOB=/usr/local/easysoft/oob/client
     fi
@@ -65391,10 +64935,7 @@ if test "${with_unixODBC+set}" = set; then
 else
   
   PHP_UNIXODBC=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_UNIXODBC=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_UNIXODBC=$PHP_ENABLE_ALL
 
 fi
 
@@ -65428,7 +64969,7 @@ esac
 
   if test "$PHP_UNIXODBC" != "no"; then
     echo $ac_n "checking for unixODBC support""... $ac_c" 1>&6
-echo "configure:65432: checking for unixODBC support" >&5
+echo "configure:64973: checking for unixODBC support" >&5
     if test "$PHP_UNIXODBC" = "yes"; then
       PHP_UNIXODBC=/usr/local
     fi
@@ -65463,10 +65004,7 @@ if test "${with_dbmaker+set}" = set; then
 else
   
   PHP_DBMAKER=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_DBMAKER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_DBMAKER=$PHP_ENABLE_ALL
 
 fi
 
@@ -65500,7 +65038,7 @@ esac
 
   if test "$PHP_DBMAKER" != "no"; then
     echo $ac_n "checking for DBMaker support""... $ac_c" 1>&6
-echo "configure:65504: checking for DBMaker support" >&5
+echo "configure:65042: checking for DBMaker support" >&5
     if test "$PHP_DBMAKER" = "yes"; then
       # find dbmaker's home directory
       DBMAKER_HOME=`grep "^dbmaker:" /etc/passwd | $AWK -F: '{print $6}'`
@@ -66062,7 +65600,7 @@ fi
 php_enable_pcntl=no
 
 echo $ac_n "checking whether to enable pcntl support""... $ac_c" 1>&6
-echo "configure:66066: checking whether to enable pcntl support" >&5
+echo "configure:65604: checking whether to enable pcntl support" >&5
 # Check whether --enable-pcntl or --disable-pcntl was given.
 if test "${enable_pcntl+set}" = set; then
   enableval="$enable_pcntl"
@@ -66070,10 +65608,7 @@ if test "${enable_pcntl+set}" = set; then
 else
   
   PHP_PCNTL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PCNTL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PCNTL=$PHP_ENABLE_ALL
 
 fi
 
@@ -66109,12 +65644,12 @@ if test "$PHP_PCNTL" != "no"; then
   for ac_func in fork
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:66113: checking for $ac_func" >&5
+echo "configure:65648: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 66118 "configure"
+#line 65653 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -66137,7 +65672,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:66141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:65676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -66168,12 +65703,12 @@ done
   for ac_func in waitpid
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:66172: checking for $ac_func" >&5
+echo "configure:65707: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 66177 "configure"
+#line 65712 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -66196,7 +65731,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:66200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:65735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -66227,12 +65762,12 @@ done
   for ac_func in sigaction
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:66231: checking for $ac_func" >&5
+echo "configure:65766: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 66236 "configure"
+#line 65771 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -66255,7 +65790,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:66259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:65794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -66286,12 +65821,12 @@ done
   for ac_func in getpriority setpriority wait3 sigprocmask sigwaitinfo sigtimedwait
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:66290: checking for $ac_func" >&5
+echo "configure:65825: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 66295 "configure"
+#line 65830 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -66314,7 +65849,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:66318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:65853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -66639,7 +66174,7 @@ fi
 php_enable_pdo=yes
 
 echo $ac_n "checking whether to enable PDO support""... $ac_c" 1>&6
-echo "configure:66643: checking whether to enable PDO support" >&5
+echo "configure:66178: checking whether to enable PDO support" >&5
 # Check whether --enable-pdo or --disable-pdo was given.
 if test "${enable_pdo+set}" = set; then
   enableval="$enable_pdo"
@@ -66647,10 +66182,7 @@ if test "${enable_pdo+set}" = set; then
 else
   
   PHP_PDO=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO=$PHP_ENABLE_ALL
 
 fi
 
@@ -67076,7 +66608,7 @@ fi
 php_with_pdo_dblib=no
 
 echo $ac_n "checking for PDO_DBLIB support via FreeTDS""... $ac_c" 1>&6
-echo "configure:67080: checking for PDO_DBLIB support via FreeTDS" >&5
+echo "configure:66612: checking for PDO_DBLIB support via FreeTDS" >&5
 # Check whether --with-pdo-dblib or --without-pdo-dblib was given.
 if test "${with_pdo_dblib+set}" = set; then
   withval="$with_pdo_dblib"
@@ -67084,10 +66616,7 @@ if test "${with_pdo_dblib+set}" = set; then
 else
   
   PHP_PDO_DBLIB=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_DBLIB=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_DBLIB=$PHP_ENABLE_ALL
 
 fi
 
@@ -67296,13 +66825,13 @@ if test "$PHP_PDO_DBLIB" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:67300: checking for PDO includes" >&5
+echo "configure:66829: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:67306: checking for PDO includes" >&5
+echo "configure:66835: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -67616,7 +67145,7 @@ EOF
   fi
 
   echo $ac_n "checking for dnet_addr in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:67620: checking for dnet_addr in -ldnet_stub" >&5
+echo "configure:67149: checking for dnet_addr in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_addr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -67624,7 +67153,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 67628 "configure"
+#line 67157 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -67635,7 +67164,7 @@ int main() {
 dnet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:67639: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -67796,7 +67325,7 @@ fi
 php_with_pdo_firebird=no
 
 echo $ac_n "checking for Firebird support for PDO""... $ac_c" 1>&6
-echo "configure:67800: checking for Firebird support for PDO" >&5
+echo "configure:67329: checking for Firebird support for PDO" >&5
 # Check whether --with-pdo-firebird or --without-pdo-firebird was given.
 if test "${with_pdo_firebird+set}" = set; then
   withval="$with_pdo_firebird"
@@ -67804,10 +67333,7 @@ if test "${with_pdo_firebird+set}" = set; then
 else
   
   PHP_PDO_FIREBIRD=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_FIREBIRD=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_FIREBIRD=$PHP_ENABLE_ALL
 
 fi
 
@@ -67953,7 +67479,7 @@ if test "$PHP_PDO_FIREBIRD" != "no"; then
   done
 
   echo $ac_n "checking for isc_detach_database in -lfbclient""... $ac_c" 1>&6
-echo "configure:67957: checking for isc_detach_database in -lfbclient" >&5
+echo "configure:67483: checking for isc_detach_database in -lfbclient" >&5
 ac_lib_var=`echo fbclient'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -67961,7 +67487,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lfbclient  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 67965 "configure"
+#line 67491 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -67972,7 +67498,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:67976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -68099,7 +67625,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lgds""... $ac_c" 1>&6
-echo "configure:68103: checking for isc_detach_database in -lgds" >&5
+echo "configure:67629: checking for isc_detach_database in -lgds" >&5
 ac_lib_var=`echo gds'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -68107,7 +67633,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgds  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 68111 "configure"
+#line 67637 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -68118,7 +67644,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:68122: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -68245,7 +67771,7 @@ else
   done
 
   echo $ac_n "checking for isc_detach_database in -lib_util""... $ac_c" 1>&6
-echo "configure:68249: checking for isc_detach_database in -lib_util" >&5
+echo "configure:67775: checking for isc_detach_database in -lib_util" >&5
 ac_lib_var=`echo ib_util'_'isc_detach_database | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -68253,7 +67779,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lib_util  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 68257 "configure"
+#line 67783 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -68264,7 +67790,7 @@ int main() {
 isc_detach_database()
 ; return 0; }
 EOF
-if { (eval echo configure:68268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:67794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -68309,13 +67835,13 @@ fi
  
   
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:68313: checking for PDO includes" >&5
+echo "configure:67839: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:68319: checking for PDO includes" >&5
+echo "configure:67845: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -68787,7 +68313,7 @@ fi
 php_with_pdo_mysql=no
 
 echo $ac_n "checking for MySQL support for PDO""... $ac_c" 1>&6
-echo "configure:68791: checking for MySQL support for PDO" >&5
+echo "configure:68317: checking for MySQL support for PDO" >&5
 # Check whether --with-pdo-mysql or --without-pdo-mysql was given.
 if test "${with_pdo_mysql+set}" = set; then
   withval="$with_pdo_mysql"
@@ -68795,10 +68321,7 @@ if test "${with_pdo_mysql+set}" = set; then
 else
   
   PHP_PDO_MYSQL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_MYSQL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_MYSQL=$PHP_ENABLE_ALL
 
 fi
 
@@ -68835,7 +68358,7 @@ if test -z "$PHP_ZLIB_DIR"; then
 php_with_zlib_dir=no
 
 echo $ac_n "checking for the location of libz""... $ac_c" 1>&6
-echo "configure:68839: checking for the location of libz" >&5
+echo "configure:68362: checking for the location of libz" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -68843,10 +68366,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -68902,14 +68422,14 @@ EOF
 
 
     echo $ac_n "checking for mysql_config""... $ac_c" 1>&6
-echo "configure:68906: checking for mysql_config" >&5
+echo "configure:68426: checking for mysql_config" >&5
     if test -n "$PDO_MYSQL_CONFIG"; then
       echo "$ac_t""$PDO_MYSQL_CONFIG" 1>&6
       if test "x$SED" = "x"; then
         # Extract the first word of "sed", so it can be a program name with args.
 set dummy sed; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:68913: checking for $ac_word" >&5
+echo "configure:68433: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_SED'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -68953,7 +68473,7 @@ fi
     elif test -n "$PDO_MYSQL_DIR"; then
       echo "$ac_t""not found" 1>&6
       echo $ac_n "checking for mysql install under $PDO_MYSQL_DIR""... $ac_c" 1>&6
-echo "configure:68957: checking for mysql install under $PDO_MYSQL_DIR" >&5
+echo "configure:68477: checking for mysql install under $PDO_MYSQL_DIR" >&5
       if test -r $PDO_MYSQL_DIR/include/mysql; then
         PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include/mysql
       else
@@ -69107,7 +68627,7 @@ echo "configure:68957: checking for mysql install under $PDO_MYSQL_DIR" >&5
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:69111: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:68631: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $PDO_MYSQL_LIBNAME'_'mysql_query | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -69115,7 +68635,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 69119 "configure"
+#line 68639 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -69126,7 +68646,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:69130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:68650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -69479,7 +68999,7 @@ else
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:69483: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:69003: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $PDO_MYSQL_LIBNAME'_'mysql_query | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -69487,7 +69007,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 69491 "configure"
+#line 69011 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -69498,7 +69018,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:69502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -69653,7 +69173,7 @@ fi
   done
 
   echo $ac_n "checking for mysql_query in -l$PDO_MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:69657: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
+echo "configure:69177: checking for mysql_query in -l$PDO_MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $PDO_MYSQL_LIBNAME'_'mysql_query | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -69661,7 +69181,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$PDO_MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 69665 "configure"
+#line 69185 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -69672,7 +69192,7 @@ int main() {
 mysql_query()
 ; return 0; }
 EOF
-if { (eval echo configure:69676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -69846,12 +69366,12 @@ fi
     for ac_func in mysql_commit mysql_stmt_prepare mysql_next_result mysql_sqlstate
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:69850: checking for $ac_func" >&5
+echo "configure:69370: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 69855 "configure"
+#line 69375 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -69874,7 +69394,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:69878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:69398: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -69904,13 +69424,13 @@ done
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:69908: checking for PDO includes" >&5
+echo "configure:69428: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:69914: checking for PDO includes" >&5
+echo "configure:69434: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -70295,7 +69815,7 @@ SUPPORTED_LIB_VERS="9.0 10.1 11.1"  # This caters for all Oracle 9.x, 10.x and 1
 php_with_pdo_oci=no
 
 echo $ac_n "checking Oracle OCI support for PDO""... $ac_c" 1>&6
-echo "configure:70299: checking Oracle OCI support for PDO" >&5
+echo "configure:69819: checking Oracle OCI support for PDO" >&5
 # Check whether --with-pdo-oci or --without-pdo-oci was given.
 if test "${with_pdo_oci+set}" = set; then
   withval="$with_pdo_oci"
@@ -70303,10 +69823,7 @@ if test "${with_pdo_oci+set}" = set; then
 else
   
   PHP_PDO_OCI=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_OCI=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_OCI=$PHP_ENABLE_ALL
 
 fi
 
@@ -70345,7 +69862,7 @@ if test "$PHP_PDO_OCI" != "no"; then
   fi
 
   echo $ac_n "checking Oracle Install-Dir""... $ac_c" 1>&6
-echo "configure:70349: checking Oracle Install-Dir" >&5
+echo "configure:69866: checking Oracle Install-Dir" >&5
   if test "$PHP_PDO_OCI" = "yes" || test -z "$PHP_PDO_OCI"; then
     PDO_OCI_DIR=$ORACLE_HOME
   else
@@ -70354,7 +69871,7 @@ echo "configure:70349: checking Oracle Install-Dir" >&5
   echo "$ac_t""$PHP_PDO_OCI" 1>&6
 
   echo $ac_n "checking if that is sane""... $ac_c" 1>&6
-echo "configure:70358: checking if that is sane" >&5
+echo "configure:69875: checking if that is sane" >&5
   if test -z "$PDO_OCI_DIR"; then
     { echo "configure: error: 
 You need to tell me where to find your Oracle Instant Client SDK, or set ORACLE_HOME.
@@ -70367,7 +69884,7 @@ You need to tell me where to find your Oracle Instant Client SDK, or set ORACLE_
     PDO_OCI_IC_PREFIX="`echo $PDO_OCI_DIR | cut -d, -f2`"
     PDO_OCI_IC_VERS="`echo $PDO_OCI_DIR | cut -d, -f3`"
     echo $ac_n "checking for oci.h""... $ac_c" 1>&6
-echo "configure:70371: checking for oci.h" >&5
+echo "configure:69888: checking for oci.h" >&5
     if test -f $PDO_OCI_IC_PREFIX/include/oracle/$PDO_OCI_IC_VERS/client/oci.h ; then
       
   if test "$PDO_OCI_IC_PREFIX/include/oracle/$PDO_OCI_IC_VERS/client" != "/usr/include"; then
@@ -70516,7 +70033,7 @@ echo "configure:70371: checking for oci.h" >&5
   else
     
   echo $ac_n "checking size of long int""... $ac_c" 1>&6
-echo "configure:70520: checking size of long int" >&5
+echo "configure:70037: checking size of long int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -70524,7 +70041,7 @@ else
   ac_cv_sizeof_long_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 70528 "configure"
+#line 70045 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -70535,7 +70052,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:70539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:70056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_int=`cat conftestval`
 else
@@ -70555,7 +70072,7 @@ EOF
 
 
   echo $ac_n "checking if we're on a 64-bit platform""... $ac_c" 1>&6
-echo "configure:70559: checking if we're on a 64-bit platform" >&5
+echo "configure:70076: checking if we're on a 64-bit platform" >&5
   if test "$ac_cv_sizeof_long_int" = "4" ; then
     echo "$ac_t""no" 1>&6
     TMP_PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib32"
@@ -70565,7 +70082,7 @@ echo "configure:70559: checking if we're on a 64-bit platform" >&5
   fi
 
   echo $ac_n "checking OCI8 libraries dir""... $ac_c" 1>&6
-echo "configure:70569: checking OCI8 libraries dir" >&5
+echo "configure:70086: checking OCI8 libraries dir" >&5
   if test -d "$PDO_OCI_DIR/lib" && test ! -d "$PDO_OCI_DIR/lib32"; then
     PDO_OCI_LIB_DIR="$PDO_OCI_DIR/lib"
   elif test ! -d "$PDO_OCI_DIR/lib" && test -d "$PDO_OCI_DIR/lib32"; then
@@ -70932,7 +70449,7 @@ echo "configure:70569: checking OCI8 libraries dir" >&5
     fi
     
   echo $ac_n "checking Oracle version""... $ac_c" 1>&6
-echo "configure:70936: checking Oracle version" >&5
+echo "configure:70453: checking Oracle version" >&5
   for OCI_VER in $SUPPORTED_LIB_VERS; do
     if test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.$OCI_VER; then
       PDO_OCI_VERSION="$OCI_VER"
@@ -71114,7 +70631,7 @@ echo "configure:70936: checking Oracle version" >&5
   done
 
   echo $ac_n "checking for OCIEnvCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:71118: checking for OCIEnvCreate in -lclntsh" >&5
+echo "configure:70635: checking for OCIEnvCreate in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCIEnvCreate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71122,7 +70639,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71126 "configure"
+#line 70643 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71133,7 +70650,7 @@ int main() {
 OCIEnvCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:71137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:70654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71267,7 +70784,7 @@ fi
   done
 
   echo $ac_n "checking for OCIEnvNlsCreate in -lclntsh""... $ac_c" 1>&6
-echo "configure:71271: checking for OCIEnvNlsCreate in -lclntsh" >&5
+echo "configure:70788: checking for OCIEnvNlsCreate in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCIEnvNlsCreate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71275,7 +70792,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71279 "configure"
+#line 70796 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71286,7 +70803,7 @@ int main() {
 OCIEnvNlsCreate()
 ; return 0; }
 EOF
-if { (eval echo configure:71290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:70807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71420,7 +70937,7 @@ fi
   done
 
   echo $ac_n "checking for OCILobIsTemporary in -lclntsh""... $ac_c" 1>&6
-echo "configure:71424: checking for OCILobIsTemporary in -lclntsh" >&5
+echo "configure:70941: checking for OCILobIsTemporary in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCILobIsTemporary | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71428,7 +70945,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71432 "configure"
+#line 70949 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71439,7 +70956,7 @@ int main() {
 OCILobIsTemporary()
 ; return 0; }
 EOF
-if { (eval echo configure:71443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:70960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71569,7 +71086,7 @@ else
   done
 
   echo $ac_n "checking for OCILobIsTemporary in -locijdbc8""... $ac_c" 1>&6
-echo "configure:71573: checking for OCILobIsTemporary in -locijdbc8" >&5
+echo "configure:71090: checking for OCILobIsTemporary in -locijdbc8" >&5
 ac_lib_var=`echo ocijdbc8'_'OCILobIsTemporary | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71577,7 +71094,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-locijdbc8  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71581 "configure"
+#line 71098 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71588,7 +71105,7 @@ int main() {
 OCILobIsTemporary()
 ; return 0; }
 EOF
-if { (eval echo configure:71592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71109: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71749,7 +71266,7 @@ fi
   done
 
   echo $ac_n "checking for OCICollAssign in -lclntsh""... $ac_c" 1>&6
-echo "configure:71753: checking for OCICollAssign in -lclntsh" >&5
+echo "configure:71270: checking for OCICollAssign in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCICollAssign | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71757,7 +71274,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71761 "configure"
+#line 71278 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71768,7 +71285,7 @@ int main() {
 OCICollAssign()
 ; return 0; }
 EOF
-if { (eval echo configure:71772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71902,7 +71419,7 @@ fi
   done
 
   echo $ac_n "checking for OCIStmtFetch2 in -lclntsh""... $ac_c" 1>&6
-echo "configure:71906: checking for OCIStmtFetch2 in -lclntsh" >&5
+echo "configure:71423: checking for OCIStmtFetch2 in -lclntsh" >&5
 ac_lib_var=`echo clntsh'_'OCIStmtFetch2 | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -71910,7 +71427,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lclntsh  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 71914 "configure"
+#line 71431 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -71921,7 +71438,7 @@ int main() {
 OCIStmtFetch2()
 ; return 0; }
 EOF
-if { (eval echo configure:71925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:71442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -71960,13 +71477,13 @@ fi
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:71964: checking for PDO includes" >&5
+echo "configure:71481: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:71970: checking for PDO includes" >&5
+echo "configure:71487: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -72334,7 +71851,7 @@ fi
 php_with_pdo_odbc=no
 
 echo $ac_n "checking for ODBC v3 support for PDO""... $ac_c" 1>&6
-echo "configure:72338: checking for ODBC v3 support for PDO" >&5
+echo "configure:71855: checking for ODBC v3 support for PDO" >&5
 # Check whether --with-pdo-odbc or --without-pdo-odbc was given.
 if test "${with_pdo_odbc+set}" = set; then
   withval="$with_pdo_odbc"
@@ -72342,10 +71859,7 @@ if test "${with_pdo_odbc+set}" = set; then
 else
   
   PHP_PDO_ODBC=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_ODBC=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_ODBC=$PHP_ENABLE_ALL
 
 fi
 
@@ -72389,13 +71903,13 @@ if test "$PHP_PDO_ODBC" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:72393: checking for PDO includes" >&5
+echo "configure:71907: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:72399: checking for PDO includes" >&5
+echo "configure:71913: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -72416,7 +71930,7 @@ echo "$ac_t""$pdo_inc_path" 1>&6
   
 
   echo $ac_n "checking for selected PDO ODBC flavour""... $ac_c" 1>&6
-echo "configure:72420: checking for selected PDO ODBC flavour" >&5
+echo "configure:71934: checking for selected PDO ODBC flavour" >&5
 
   pdo_odbc_flavour="`echo $PHP_PDO_ODBC | cut -d, -f1`"
   pdo_odbc_dir="`echo $PHP_PDO_ODBC | cut -d, -f2`"
@@ -72495,7 +72009,7 @@ echo "configure:72420: checking for selected PDO ODBC flavour" >&5
 
   
   echo $ac_n "checking for odbc.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72499: checking for odbc.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72013: checking for odbc.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/odbc.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72509,7 +72023,7 @@ EOF
 
   
   echo $ac_n "checking for odbcsdk.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72513: checking for odbcsdk.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72027: checking for odbcsdk.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/odbcsdk.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72523,7 +72037,7 @@ EOF
 
   
   echo $ac_n "checking for iodbc.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72527: checking for iodbc.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72041: checking for iodbc.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/iodbc.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72537,7 +72051,7 @@ EOF
 
   
   echo $ac_n "checking for sqlunix.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72541: checking for sqlunix.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72055: checking for sqlunix.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sqlunix.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72551,7 +72065,7 @@ EOF
 
   
   echo $ac_n "checking for sqltypes.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72555: checking for sqltypes.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72069: checking for sqltypes.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sqltypes.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72565,7 +72079,7 @@ EOF
 
   
   echo $ac_n "checking for sqlucode.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72569: checking for sqlucode.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72083: checking for sqlucode.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sqlucode.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72579,7 +72093,7 @@ EOF
 
   
   echo $ac_n "checking for sql.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72583: checking for sql.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72097: checking for sql.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sql.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72593,7 +72107,7 @@ EOF
 
   
   echo $ac_n "checking for isql.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72597: checking for isql.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72111: checking for isql.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/isql.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72607,7 +72121,7 @@ EOF
 
   
   echo $ac_n "checking for sqlext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72611: checking for sqlext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72125: checking for sqlext.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sqlext.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72621,7 +72135,7 @@ EOF
 
   
   echo $ac_n "checking for isqlext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72625: checking for isqlext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72139: checking for isqlext.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/isqlext.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72635,7 +72149,7 @@ EOF
 
   
   echo $ac_n "checking for udbcext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72639: checking for udbcext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72153: checking for udbcext.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/udbcext.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72649,7 +72163,7 @@ EOF
 
   
   echo $ac_n "checking for sqlcli1.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72653: checking for sqlcli1.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72167: checking for sqlcli1.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/sqlcli1.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72663,7 +72177,7 @@ EOF
 
   
   echo $ac_n "checking for LibraryManager.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72667: checking for LibraryManager.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72181: checking for LibraryManager.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/LibraryManager.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72677,7 +72191,7 @@ EOF
 
   
   echo $ac_n "checking for cli0core.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72681: checking for cli0core.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72195: checking for cli0core.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/cli0core.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72691,7 +72205,7 @@ EOF
 
   
   echo $ac_n "checking for cli0ext.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72695: checking for cli0ext.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72209: checking for cli0ext.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/cli0ext.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72705,7 +72219,7 @@ EOF
 
   
   echo $ac_n "checking for cli0cli.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72709: checking for cli0cli.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72223: checking for cli0cli.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/cli0cli.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72719,7 +72233,7 @@ EOF
 
   
   echo $ac_n "checking for cli0defs.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72723: checking for cli0defs.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72237: checking for cli0defs.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/cli0defs.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72733,7 +72247,7 @@ EOF
 
   
   echo $ac_n "checking for cli0env.h in $PDO_ODBC_INCDIR""... $ac_c" 1>&6
-echo "configure:72737: checking for cli0env.h in $PDO_ODBC_INCDIR" >&5
+echo "configure:72251: checking for cli0env.h in $PDO_ODBC_INCDIR" >&5
   if test -f "$PDO_ODBC_INCDIR/cli0env.h"; then
     php_pdo_have_header=yes
     cat >> confdefs.h <<\EOF
@@ -72939,7 +72453,7 @@ EOF
   done
 
   echo $ac_n "checking for SQLBindCol in -l$pdo_odbc_def_lib""... $ac_c" 1>&6
-echo "configure:72943: checking for SQLBindCol in -l$pdo_odbc_def_lib" >&5
+echo "configure:72457: checking for SQLBindCol in -l$pdo_odbc_def_lib" >&5
 ac_lib_var=`echo $pdo_odbc_def_lib'_'SQLBindCol | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -72947,7 +72461,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$pdo_odbc_def_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 72951 "configure"
+#line 72465 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -72958,7 +72472,7 @@ int main() {
 SQLBindCol()
 ; return 0; }
 EOF
-if { (eval echo configure:72962: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73073,7 +72587,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   done
 
   echo $ac_n "checking for SQLAllocHandle in -l$pdo_odbc_def_lib""... $ac_c" 1>&6
-echo "configure:73077: checking for SQLAllocHandle in -l$pdo_odbc_def_lib" >&5
+echo "configure:72591: checking for SQLAllocHandle in -l$pdo_odbc_def_lib" >&5
 ac_lib_var=`echo $pdo_odbc_def_lib'_'SQLAllocHandle | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73081,7 +72595,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$pdo_odbc_def_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73085 "configure"
+#line 72599 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73092,7 +72606,7 @@ int main() {
 SQLAllocHandle()
 ; return 0; }
 EOF
-if { (eval echo configure:73096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:72610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73466,7 +72980,7 @@ fi
 php_with_pdo_pgsql=no
 
 echo $ac_n "checking for PostgreSQL support for PDO""... $ac_c" 1>&6
-echo "configure:73470: checking for PostgreSQL support for PDO" >&5
+echo "configure:72984: checking for PostgreSQL support for PDO" >&5
 # Check whether --with-pdo-pgsql or --without-pdo-pgsql was given.
 if test "${with_pdo_pgsql+set}" = set; then
   withval="$with_pdo_pgsql"
@@ -73474,10 +72988,7 @@ if test "${with_pdo_pgsql+set}" = set; then
 else
   
   PHP_PDO_PGSQL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_PGSQL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_PGSQL=$PHP_ENABLE_ALL
 
 fi
 
@@ -73528,7 +73039,7 @@ if test "$PHP_PDO_PGSQL" != "no"; then
 
 
   echo $ac_n "checking for pg_config""... $ac_c" 1>&6
-echo "configure:73532: checking for pg_config" >&5
+echo "configure:73043: checking for pg_config" >&5
   for i in $PHP_PDO_PGSQL $PHP_PDO_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
     if test -x $i/pg_config; then
       PG_CONFIG="$i/pg_config"
@@ -73592,13 +73103,13 @@ EOF
 
 
   echo $ac_n "checking for openssl dependencies""... $ac_c" 1>&6
-echo "configure:73596: checking for openssl dependencies" >&5
+echo "configure:73107: checking for openssl dependencies" >&5
   if grep -q openssl $PGSQL_INCLUDE/libpq-fe.h ; then
     echo "$ac_t""yes" 1>&6
         # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:73602: checking for $ac_word" >&5
+echo "configure:73113: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -73642,7 +73153,7 @@ fi
   old_LDFLAGS=$LDFLAGS
   LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
   echo $ac_n "checking for PQparameterStatus in -lpq""... $ac_c" 1>&6
-echo "configure:73646: checking for PQparameterStatus in -lpq" >&5
+echo "configure:73157: checking for PQparameterStatus in -lpq" >&5
 ac_lib_var=`echo pq'_'PQparameterStatus | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73650,7 +73161,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73654 "configure"
+#line 73165 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73661,7 +73172,7 @@ int main() {
 PQparameterStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:73665: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73176: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73690,7 +73201,7 @@ fi
 
 
   echo $ac_n "checking for PQprepare in -lpq""... $ac_c" 1>&6
-echo "configure:73694: checking for PQprepare in -lpq" >&5
+echo "configure:73205: checking for PQprepare in -lpq" >&5
 ac_lib_var=`echo pq'_'PQprepare | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73698,7 +73209,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73702 "configure"
+#line 73213 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73709,7 +73220,7 @@ int main() {
 PQprepare()
 ; return 0; }
 EOF
-if { (eval echo configure:73713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73733,7 +73244,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeStringConn in -lpq""... $ac_c" 1>&6
-echo "configure:73737: checking for PQescapeStringConn in -lpq" >&5
+echo "configure:73248: checking for PQescapeStringConn in -lpq" >&5
 ac_lib_var=`echo pq'_'PQescapeStringConn | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73741,7 +73252,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73745 "configure"
+#line 73256 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73752,7 +73263,7 @@ int main() {
 PQescapeStringConn()
 ; return 0; }
 EOF
-if { (eval echo configure:73756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73776,7 +73287,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeByteaConn in -lpq""... $ac_c" 1>&6
-echo "configure:73780: checking for PQescapeByteaConn in -lpq" >&5
+echo "configure:73291: checking for PQescapeByteaConn in -lpq" >&5
 ac_lib_var=`echo pq'_'PQescapeByteaConn | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73784,7 +73295,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73788 "configure"
+#line 73299 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73795,7 +73306,7 @@ int main() {
 PQescapeByteaConn()
 ; return 0; }
 EOF
-if { (eval echo configure:73799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -73820,7 +73331,7 @@ fi
 
 
   echo $ac_n "checking for pg_encoding_to_char in -lpq""... $ac_c" 1>&6
-echo "configure:73824: checking for pg_encoding_to_char in -lpq" >&5
+echo "configure:73335: checking for pg_encoding_to_char in -lpq" >&5
 ac_lib_var=`echo pq'_'pg_encoding_to_char | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -73828,7 +73339,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 73832 "configure"
+#line 73343 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -73839,7 +73350,7 @@ int main() {
 pg_encoding_to_char()
 ; return 0; }
 EOF
-if { (eval echo configure:73843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:73354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -74003,13 +73514,13 @@ fi
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:74007: checking for PDO includes" >&5
+echo "configure:73518: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:74013: checking for PDO includes" >&5
+echo "configure:73524: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -74349,7 +73860,7 @@ fi
 php_with_pdo_sqlite=$PHP_PDO
 
 echo $ac_n "checking for sqlite 3 support for PDO""... $ac_c" 1>&6
-echo "configure:74353: checking for sqlite 3 support for PDO" >&5
+echo "configure:73864: checking for sqlite 3 support for PDO" >&5
 # Check whether --with-pdo-sqlite or --without-pdo-sqlite was given.
 if test "${with_pdo_sqlite+set}" = set; then
   withval="$with_pdo_sqlite"
@@ -74357,10 +73868,7 @@ if test "${with_pdo_sqlite+set}" = set; then
 else
   
   PHP_PDO_SQLITE=$PHP_PDO
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PDO_SQLITE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PDO_SQLITE=$PHP_ENABLE_ALL
 
 fi
 
@@ -74401,13 +73909,13 @@ if test "$PHP_PDO_SQLITE" != "no"; then
   
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:74405: checking for PDO includes" >&5
+echo "configure:73913: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:74411: checking for PDO includes" >&5
+echo "configure:73919: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -74436,7 +73944,7 @@ echo "$ac_t""$pdo_inc_path" 1>&6
       PDO_SQLITE_DIR=$PHP_PDO_SQLITE
     else # search default path list
       echo $ac_n "checking for sqlite3 files in default path""... $ac_c" 1>&6
-echo "configure:74440: checking for sqlite3 files in default path" >&5
+echo "configure:73948: checking for sqlite3 files in default path" >&5
       for i in $SEARCH_PATH ; do
         if test -r $i/$SEARCH_FOR; then
           PDO_SQLITE_DIR=$i
@@ -74582,7 +74090,7 @@ echo "configure:74440: checking for sqlite3 files in default path" >&5
   done
 
   echo $ac_n "checking for $LIBSYMBOL in -l$LIBNAME""... $ac_c" 1>&6
-echo "configure:74586: checking for $LIBSYMBOL in -l$LIBNAME" >&5
+echo "configure:74094: checking for $LIBSYMBOL in -l$LIBNAME" >&5
 ac_lib_var=`echo $LIBNAME'_'$LIBSYMBOL | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -74590,7 +74098,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74594 "configure"
+#line 74102 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -74601,7 +74109,7 @@ int main() {
 $LIBSYMBOL()
 ; return 0; }
 EOF
-if { (eval echo configure:74605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -74831,7 +74339,7 @@ fi
   done
 
   echo $ac_n "checking for sqlite3_key in -lsqlite3""... $ac_c" 1>&6
-echo "configure:74835: checking for sqlite3_key in -lsqlite3" >&5
+echo "configure:74343: checking for sqlite3_key in -lsqlite3" >&5
 ac_lib_var=`echo sqlite3'_'sqlite3_key | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -74839,7 +74347,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite3  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 74843 "configure"
+#line 74351 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -74850,7 +74358,7 @@ int main() {
 sqlite3_key()
 ; return 0; }
 EOF
-if { (eval echo configure:74854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:74362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -75591,12 +75099,12 @@ but you've either not enabled sqlite3, or have disabled it.
       for ac_func in usleep nanosleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:75595: checking for $ac_func" >&5
+echo "configure:75103: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 75600 "configure"
+#line 75108 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -75619,7 +75127,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:75623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -75647,17 +75155,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:75651: checking for $ac_hdr" >&5
+echo "configure:75159: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 75656 "configure"
+#line 75164 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:75661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:75169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -75781,7 +75289,7 @@ done
   done
 
   echo $ac_n "checking for fdatasync in -lrt""... $ac_c" 1>&6
-echo "configure:75785: checking for fdatasync in -lrt" >&5
+echo "configure:75293: checking for fdatasync in -lrt" >&5
 ac_lib_var=`echo rt'_'fdatasync | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -75789,7 +75297,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 75793 "configure"
+#line 75301 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -75800,7 +75308,7 @@ int main() {
 fdatasync()
 ; return 0; }
 EOF
-if { (eval echo configure:75804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75312: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -75881,7 +75389,7 @@ fi
 php_with_pgsql=no
 
 echo $ac_n "checking for PostgreSQL support""... $ac_c" 1>&6
-echo "configure:75885: checking for PostgreSQL support" >&5
+echo "configure:75393: checking for PostgreSQL support" >&5
 # Check whether --with-pgsql or --without-pgsql was given.
 if test "${with_pgsql+set}" = set; then
   withval="$with_pgsql"
@@ -75889,10 +75397,7 @@ if test "${with_pgsql+set}" = set; then
 else
   
   PHP_PGSQL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PGSQL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PGSQL=$PHP_ENABLE_ALL
 
 fi
 
@@ -75938,7 +75443,7 @@ if test "$PHP_PGSQL" != "no"; then
 
 
   echo $ac_n "checking for pg_config""... $ac_c" 1>&6
-echo "configure:75942: checking for pg_config" >&5
+echo "configure:75447: checking for pg_config" >&5
   for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
 	if test -x $i/pg_config; then
       PG_CONFIG="$i/pg_config"
@@ -76006,7 +75511,7 @@ EOF
   old_LDFLAGS=$LDFLAGS
   LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
   echo $ac_n "checking for PQescapeString in -lpq""... $ac_c" 1>&6
-echo "configure:76010: checking for PQescapeString in -lpq" >&5
+echo "configure:75515: checking for PQescapeString in -lpq" >&5
 ac_lib_var=`echo pq'_'PQescapeString | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76014,7 +75519,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76018 "configure"
+#line 75523 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76025,7 +75530,7 @@ int main() {
 PQescapeString()
 ; return 0; }
 EOF
-if { (eval echo configure:76029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76049,7 +75554,7 @@ else
 fi
 
   echo $ac_n "checking for PQunescapeBytea in -lpq""... $ac_c" 1>&6
-echo "configure:76053: checking for PQunescapeBytea in -lpq" >&5
+echo "configure:75558: checking for PQunescapeBytea in -lpq" >&5
 ac_lib_var=`echo pq'_'PQunescapeBytea | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76057,7 +75562,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76061 "configure"
+#line 75566 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76068,7 +75573,7 @@ int main() {
 PQunescapeBytea()
 ; return 0; }
 EOF
-if { (eval echo configure:76072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75577: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76092,7 +75597,7 @@ else
 fi
 
   echo $ac_n "checking for PQsetnonblocking in -lpq""... $ac_c" 1>&6
-echo "configure:76096: checking for PQsetnonblocking in -lpq" >&5
+echo "configure:75601: checking for PQsetnonblocking in -lpq" >&5
 ac_lib_var=`echo pq'_'PQsetnonblocking | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76100,7 +75605,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76104 "configure"
+#line 75609 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76111,7 +75616,7 @@ int main() {
 PQsetnonblocking()
 ; return 0; }
 EOF
-if { (eval echo configure:76115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76135,7 +75640,7 @@ else
 fi
 
   echo $ac_n "checking for PQcmdTuples in -lpq""... $ac_c" 1>&6
-echo "configure:76139: checking for PQcmdTuples in -lpq" >&5
+echo "configure:75644: checking for PQcmdTuples in -lpq" >&5
 ac_lib_var=`echo pq'_'PQcmdTuples | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76143,7 +75648,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76147 "configure"
+#line 75652 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76154,7 +75659,7 @@ int main() {
 PQcmdTuples()
 ; return 0; }
 EOF
-if { (eval echo configure:76158: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76178,7 +75683,7 @@ else
 fi
 
   echo $ac_n "checking for PQoidValue in -lpq""... $ac_c" 1>&6
-echo "configure:76182: checking for PQoidValue in -lpq" >&5
+echo "configure:75687: checking for PQoidValue in -lpq" >&5
 ac_lib_var=`echo pq'_'PQoidValue | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76186,7 +75691,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76190 "configure"
+#line 75695 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76197,7 +75702,7 @@ int main() {
 PQoidValue()
 ; return 0; }
 EOF
-if { (eval echo configure:76201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75706: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76221,7 +75726,7 @@ else
 fi
 
   echo $ac_n "checking for PQclientEncoding in -lpq""... $ac_c" 1>&6
-echo "configure:76225: checking for PQclientEncoding in -lpq" >&5
+echo "configure:75730: checking for PQclientEncoding in -lpq" >&5
 ac_lib_var=`echo pq'_'PQclientEncoding | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76229,7 +75734,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76233 "configure"
+#line 75738 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76240,7 +75745,7 @@ int main() {
 PQclientEncoding()
 ; return 0; }
 EOF
-if { (eval echo configure:76244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76264,7 +75769,7 @@ else
 fi
 
   echo $ac_n "checking for PQparameterStatus in -lpq""... $ac_c" 1>&6
-echo "configure:76268: checking for PQparameterStatus in -lpq" >&5
+echo "configure:75773: checking for PQparameterStatus in -lpq" >&5
 ac_lib_var=`echo pq'_'PQparameterStatus | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76272,7 +75777,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76276 "configure"
+#line 75781 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76283,7 +75788,7 @@ int main() {
 PQparameterStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:76287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76307,7 +75812,7 @@ else
 fi
 
   echo $ac_n "checking for PQprotocolVersion in -lpq""... $ac_c" 1>&6
-echo "configure:76311: checking for PQprotocolVersion in -lpq" >&5
+echo "configure:75816: checking for PQprotocolVersion in -lpq" >&5
 ac_lib_var=`echo pq'_'PQprotocolVersion | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76315,7 +75820,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76319 "configure"
+#line 75824 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76326,7 +75831,7 @@ int main() {
 PQprotocolVersion()
 ; return 0; }
 EOF
-if { (eval echo configure:76330: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76350,7 +75855,7 @@ else
 fi
 
   echo $ac_n "checking for PQtransactionStatus in -lpq""... $ac_c" 1>&6
-echo "configure:76354: checking for PQtransactionStatus in -lpq" >&5
+echo "configure:75859: checking for PQtransactionStatus in -lpq" >&5
 ac_lib_var=`echo pq'_'PQtransactionStatus | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76358,7 +75863,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76362 "configure"
+#line 75867 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76369,7 +75874,7 @@ int main() {
 PQtransactionStatus()
 ; return 0; }
 EOF
-if { (eval echo configure:76373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76393,7 +75898,7 @@ else
 fi
 
   echo $ac_n "checking for PQexecParams in -lpq""... $ac_c" 1>&6
-echo "configure:76397: checking for PQexecParams in -lpq" >&5
+echo "configure:75902: checking for PQexecParams in -lpq" >&5
 ac_lib_var=`echo pq'_'PQexecParams | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76401,7 +75906,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76405 "configure"
+#line 75910 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76412,7 +75917,7 @@ int main() {
 PQexecParams()
 ; return 0; }
 EOF
-if { (eval echo configure:76416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76436,7 +75941,7 @@ else
 fi
 
   echo $ac_n "checking for PQprepare in -lpq""... $ac_c" 1>&6
-echo "configure:76440: checking for PQprepare in -lpq" >&5
+echo "configure:75945: checking for PQprepare in -lpq" >&5
 ac_lib_var=`echo pq'_'PQprepare | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76444,7 +75949,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76448 "configure"
+#line 75953 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76455,7 +75960,7 @@ int main() {
 PQprepare()
 ; return 0; }
 EOF
-if { (eval echo configure:76459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:75964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76479,7 +75984,7 @@ else
 fi
 
   echo $ac_n "checking for PQexecPrepared in -lpq""... $ac_c" 1>&6
-echo "configure:76483: checking for PQexecPrepared in -lpq" >&5
+echo "configure:75988: checking for PQexecPrepared in -lpq" >&5
 ac_lib_var=`echo pq'_'PQexecPrepared | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76487,7 +75992,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76491 "configure"
+#line 75996 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76498,7 +76003,7 @@ int main() {
 PQexecPrepared()
 ; return 0; }
 EOF
-if { (eval echo configure:76502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76522,7 +76027,7 @@ else
 fi
 
   echo $ac_n "checking for PQresultErrorField in -lpq""... $ac_c" 1>&6
-echo "configure:76526: checking for PQresultErrorField in -lpq" >&5
+echo "configure:76031: checking for PQresultErrorField in -lpq" >&5
 ac_lib_var=`echo pq'_'PQresultErrorField | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76530,7 +76035,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76534 "configure"
+#line 76039 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76541,7 +76046,7 @@ int main() {
 PQresultErrorField()
 ; return 0; }
 EOF
-if { (eval echo configure:76545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76565,7 +76070,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendQueryParams in -lpq""... $ac_c" 1>&6
-echo "configure:76569: checking for PQsendQueryParams in -lpq" >&5
+echo "configure:76074: checking for PQsendQueryParams in -lpq" >&5
 ac_lib_var=`echo pq'_'PQsendQueryParams | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76573,7 +76078,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76577 "configure"
+#line 76082 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76584,7 +76089,7 @@ int main() {
 PQsendQueryParams()
 ; return 0; }
 EOF
-if { (eval echo configure:76588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76608,7 +76113,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendPrepare in -lpq""... $ac_c" 1>&6
-echo "configure:76612: checking for PQsendPrepare in -lpq" >&5
+echo "configure:76117: checking for PQsendPrepare in -lpq" >&5
 ac_lib_var=`echo pq'_'PQsendPrepare | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76616,7 +76121,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76620 "configure"
+#line 76125 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76627,7 +76132,7 @@ int main() {
 PQsendPrepare()
 ; return 0; }
 EOF
-if { (eval echo configure:76631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76651,7 +76156,7 @@ else
 fi
 
   echo $ac_n "checking for PQsendQueryPrepared in -lpq""... $ac_c" 1>&6
-echo "configure:76655: checking for PQsendQueryPrepared in -lpq" >&5
+echo "configure:76160: checking for PQsendQueryPrepared in -lpq" >&5
 ac_lib_var=`echo pq'_'PQsendQueryPrepared | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76659,7 +76164,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76663 "configure"
+#line 76168 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76670,7 +76175,7 @@ int main() {
 PQsendQueryPrepared()
 ; return 0; }
 EOF
-if { (eval echo configure:76674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76694,7 +76199,7 @@ else
 fi
 
   echo $ac_n "checking for PQputCopyData in -lpq""... $ac_c" 1>&6
-echo "configure:76698: checking for PQputCopyData in -lpq" >&5
+echo "configure:76203: checking for PQputCopyData in -lpq" >&5
 ac_lib_var=`echo pq'_'PQputCopyData | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76702,7 +76207,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76706 "configure"
+#line 76211 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76713,7 +76218,7 @@ int main() {
 PQputCopyData()
 ; return 0; }
 EOF
-if { (eval echo configure:76717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76222: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76737,7 +76242,7 @@ else
 fi
 
   echo $ac_n "checking for PQputCopyEnd in -lpq""... $ac_c" 1>&6
-echo "configure:76741: checking for PQputCopyEnd in -lpq" >&5
+echo "configure:76246: checking for PQputCopyEnd in -lpq" >&5
 ac_lib_var=`echo pq'_'PQputCopyEnd | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76745,7 +76250,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76749 "configure"
+#line 76254 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76756,7 +76261,7 @@ int main() {
 PQputCopyEnd()
 ; return 0; }
 EOF
-if { (eval echo configure:76760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76780,7 +76285,7 @@ else
 fi
 
   echo $ac_n "checking for PQgetCopyData in -lpq""... $ac_c" 1>&6
-echo "configure:76784: checking for PQgetCopyData in -lpq" >&5
+echo "configure:76289: checking for PQgetCopyData in -lpq" >&5
 ac_lib_var=`echo pq'_'PQgetCopyData | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76788,7 +76293,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76792 "configure"
+#line 76297 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76799,7 +76304,7 @@ int main() {
 PQgetCopyData()
 ; return 0; }
 EOF
-if { (eval echo configure:76803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76823,7 +76328,7 @@ else
 fi
 
   echo $ac_n "checking for PQfreemem in -lpq""... $ac_c" 1>&6
-echo "configure:76827: checking for PQfreemem in -lpq" >&5
+echo "configure:76332: checking for PQfreemem in -lpq" >&5
 ac_lib_var=`echo pq'_'PQfreemem | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76831,7 +76336,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76835 "configure"
+#line 76340 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76842,7 +76347,7 @@ int main() {
 PQfreemem()
 ; return 0; }
 EOF
-if { (eval echo configure:76846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76351: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76866,7 +76371,7 @@ else
 fi
 
   echo $ac_n "checking for PQsetErrorVerbosity in -lpq""... $ac_c" 1>&6
-echo "configure:76870: checking for PQsetErrorVerbosity in -lpq" >&5
+echo "configure:76375: checking for PQsetErrorVerbosity in -lpq" >&5
 ac_lib_var=`echo pq'_'PQsetErrorVerbosity | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76874,7 +76379,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76878 "configure"
+#line 76383 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76885,7 +76390,7 @@ int main() {
 PQsetErrorVerbosity()
 ; return 0; }
 EOF
-if { (eval echo configure:76889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76909,7 +76414,7 @@ else
 fi
 
   echo $ac_n "checking for PQftable in -lpq""... $ac_c" 1>&6
-echo "configure:76913: checking for PQftable in -lpq" >&5
+echo "configure:76418: checking for PQftable in -lpq" >&5
 ac_lib_var=`echo pq'_'PQftable | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76917,7 +76422,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76921 "configure"
+#line 76426 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76928,7 +76433,7 @@ int main() {
 PQftable()
 ; return 0; }
 EOF
-if { (eval echo configure:76932: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76952,7 +76457,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeStringConn in -lpq""... $ac_c" 1>&6
-echo "configure:76956: checking for PQescapeStringConn in -lpq" >&5
+echo "configure:76461: checking for PQescapeStringConn in -lpq" >&5
 ac_lib_var=`echo pq'_'PQescapeStringConn | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -76960,7 +76465,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 76964 "configure"
+#line 76469 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -76971,7 +76476,7 @@ int main() {
 PQescapeStringConn()
 ; return 0; }
 EOF
-if { (eval echo configure:76975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -76995,7 +76500,7 @@ else
 fi
 
   echo $ac_n "checking for PQescapeByteaConn in -lpq""... $ac_c" 1>&6
-echo "configure:76999: checking for PQescapeByteaConn in -lpq" >&5
+echo "configure:76504: checking for PQescapeByteaConn in -lpq" >&5
 ac_lib_var=`echo pq'_'PQescapeByteaConn | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -77003,7 +76508,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 77007 "configure"
+#line 76512 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -77014,7 +76519,7 @@ int main() {
 PQescapeByteaConn()
 ; return 0; }
 EOF
-if { (eval echo configure:77018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -77038,7 +76543,7 @@ else
 fi
 
   echo $ac_n "checking for pg_encoding_to_char in -lpq""... $ac_c" 1>&6
-echo "configure:77042: checking for pg_encoding_to_char in -lpq" >&5
+echo "configure:76547: checking for pg_encoding_to_char in -lpq" >&5
 ac_lib_var=`echo pq'_'pg_encoding_to_char | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -77046,7 +76551,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 77050 "configure"
+#line 76555 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -77057,7 +76562,7 @@ int main() {
 pg_encoding_to_char()
 ; return 0; }
 EOF
-if { (eval echo configure:77061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -77081,7 +76586,7 @@ else
 fi
 
   echo $ac_n "checking for lo_create in -lpq""... $ac_c" 1>&6
-echo "configure:77085: checking for lo_create in -lpq" >&5
+echo "configure:76590: checking for lo_create in -lpq" >&5
 ac_lib_var=`echo pq'_'lo_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -77089,7 +76594,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 77093 "configure"
+#line 76598 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -77100,7 +76605,7 @@ int main() {
 lo_create()
 ; return 0; }
 EOF
-if { (eval echo configure:77104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76609: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -77124,7 +76629,7 @@ else
 fi
 
   echo $ac_n "checking for lo_import_with_oid in -lpq""... $ac_c" 1>&6
-echo "configure:77128: checking for lo_import_with_oid in -lpq" >&5
+echo "configure:76633: checking for lo_import_with_oid in -lpq" >&5
 ac_lib_var=`echo pq'_'lo_import_with_oid | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -77132,7 +76637,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpq  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 77136 "configure"
+#line 76641 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -77143,7 +76648,7 @@ int main() {
 lo_import_with_oid()
 ; return 0; }
 EOF
-if { (eval echo configure:77147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:76652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -77603,7 +77108,7 @@ fi
 php_enable_phar=yes
 
 echo $ac_n "checking for phar archive support""... $ac_c" 1>&6
-echo "configure:77607: checking for phar archive support" >&5
+echo "configure:77112: checking for phar archive support" >&5
 # Check whether --enable-phar or --disable-phar was given.
 if test "${enable_phar+set}" = set; then
   enableval="$enable_phar"
@@ -77611,10 +77116,7 @@ if test "${enable_phar+set}" = set; then
 else
   
   PHP_PHAR=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PHAR=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PHAR=$PHP_ENABLE_ALL
 
 fi
 
@@ -77940,7 +77442,7 @@ EOF
   fi
 
   echo $ac_n "checking for phar openssl support""... $ac_c" 1>&6
-echo "configure:77944: checking for phar openssl support" >&5
+echo "configure:77446: checking for phar openssl support" >&5
   if test "$PHP_HASH_SHARED" != "yes"; then
     if test "$PHP_HASH" != "no"; then
       cat >> confdefs.h <<\EOF
@@ -78015,7 +77517,7 @@ fi
 php_enable_posix=yes
 
 echo $ac_n "checking whether to enable POSIX-like functions""... $ac_c" 1>&6
-echo "configure:78019: checking whether to enable POSIX-like functions" >&5
+echo "configure:77521: checking whether to enable POSIX-like functions" >&5
 # Check whether --enable-posix or --disable-posix was given.
 if test "${enable_posix+set}" = set; then
   enableval="$enable_posix"
@@ -78023,10 +77525,7 @@ if test "${enable_posix+set}" = set; then
 else
   
   PHP_POSIX=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_POSIX=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_POSIX=$PHP_ENABLE_ALL
 
 fi
 
@@ -78360,17 +77859,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:78364: checking for $ac_hdr" >&5
+echo "configure:77863: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 78369 "configure"
+#line 77868 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:78374: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:77873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -78400,12 +77899,12 @@ done
   for ac_func in seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo mknod getrlimit getlogin getgroups makedev initgroups getpwuid_r getgrgid_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:78404: checking for $ac_func" >&5
+echo "configure:77903: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 78409 "configure"
+#line 77908 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -78428,7 +77927,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:78432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:77931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -78454,14 +77953,14 @@ done
 
 
   echo $ac_n "checking for working ttyname_r() implementation""... $ac_c" 1>&6
-echo "configure:78458: checking for working ttyname_r() implementation" >&5
+echo "configure:77957: checking for working ttyname_r() implementation" >&5
   if test "$cross_compiling" = yes; then
   
     echo "$ac_t""no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe" 1>&6
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 78465 "configure"
+#line 77964 "configure"
 #include "confdefs.h"
 
 #include <unistd.h>
@@ -78474,7 +77973,7 @@ int main(int argc, char *argv[])
 }
   
 EOF
-if { (eval echo configure:78478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:77977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     echo "$ac_t""yes" 1>&6
@@ -78496,13 +77995,13 @@ fi
 
 
   echo $ac_n "checking for utsname.domainname""... $ac_c" 1>&6
-echo "configure:78500: checking for utsname.domainname" >&5
+echo "configure:77999: checking for utsname.domainname" >&5
 if eval "test \"`echo '$''{'ac_cv_have_utsname_domainname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 78506 "configure"
+#line 78005 "configure"
 #include "confdefs.h"
 
       #define _GNU_SOURCE
@@ -78514,7 +78013,7 @@ int main() {
     
 ; return 0; }
 EOF
-if { (eval echo configure:78518: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:78017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
       ac_cv_have_utsname_domainname=yes
@@ -78545,7 +78044,7 @@ fi
 php_with_pspell=no
 
 echo $ac_n "checking for PSPELL support""... $ac_c" 1>&6
-echo "configure:78549: checking for PSPELL support" >&5
+echo "configure:78048: checking for PSPELL support" >&5
 # Check whether --with-pspell or --without-pspell was given.
 if test "${with_pspell+set}" = set; then
   withval="$with_pspell"
@@ -78553,10 +78052,7 @@ if test "${with_pspell+set}" = set; then
 else
   
   PHP_PSPELL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PSPELL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PSPELL=$PHP_ENABLE_ALL
 
 fi
 
@@ -79098,7 +78594,7 @@ EOF
   done
 
   echo $ac_n "checking for new_aspell_config in -laspell""... $ac_c" 1>&6
-echo "configure:79102: checking for new_aspell_config in -laspell" >&5
+echo "configure:78598: checking for new_aspell_config in -laspell" >&5
 ac_lib_var=`echo aspell'_'new_aspell_config | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -79106,7 +78602,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-laspell  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79110 "configure"
+#line 78606 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -79117,7 +78613,7 @@ int main() {
 new_aspell_config()
 ; return 0; }
 EOF
-if { (eval echo configure:79121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -79291,7 +78787,7 @@ fi
 php_with_libedit=no
 
 echo $ac_n "checking for libedit readline replacement""... $ac_c" 1>&6
-echo "configure:79295: checking for libedit readline replacement" >&5
+echo "configure:78791: checking for libedit readline replacement" >&5
 # Check whether --with-libedit or --without-libedit was given.
 if test "${with_libedit+set}" = set; then
   withval="$with_libedit"
@@ -79299,10 +78795,7 @@ if test "${with_libedit+set}" = set; then
 else
   
   PHP_LIBEDIT=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_LIBEDIT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_LIBEDIT=$PHP_ENABLE_ALL
 
 fi
 
@@ -79339,7 +78832,7 @@ if test "$PHP_LIBEDIT" = "no"; then
 php_with_readline=no
 
 echo $ac_n "checking for readline support""... $ac_c" 1>&6
-echo "configure:79343: checking for readline support" >&5
+echo "configure:78836: checking for readline support" >&5
 # Check whether --with-readline or --without-readline was given.
 if test "${with_readline+set}" = set; then
   withval="$with_readline"
@@ -79347,10 +78840,7 @@ if test "${with_readline+set}" = set; then
 else
   
   PHP_READLINE=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_READLINE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_READLINE=$PHP_ENABLE_ALL
 
 fi
 
@@ -79428,7 +78918,7 @@ if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then
 
   PHP_READLINE_LIBS=""
   echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:79432: checking for tgetent in -lncurses" >&5
+echo "configure:78922: checking for tgetent in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -79436,7 +78926,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79440 "configure"
+#line 78930 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -79447,7 +78937,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:79451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:78941: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -79492,7 +78982,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:79496: checking for tgetent in -ltermcap" >&5
+echo "configure:78986: checking for tgetent in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -79500,7 +78990,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79504 "configure"
+#line 78994 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -79511,7 +79001,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:79515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -79658,7 +79148,7 @@ fi
   done
 
   echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
-echo "configure:79662: checking for readline in -lreadline" >&5
+echo "configure:79152: checking for readline in -lreadline" >&5
 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -79666,7 +79156,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79670 "configure"
+#line 79160 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -79677,7 +79167,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:79681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79171: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -79906,7 +79396,7 @@ fi
   done
 
   echo $ac_n "checking for rl_pending_input in -lreadline""... $ac_c" 1>&6
-echo "configure:79910: checking for rl_pending_input in -lreadline" >&5
+echo "configure:79400: checking for rl_pending_input in -lreadline" >&5
 ac_lib_var=`echo readline'_'rl_pending_input | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -79914,7 +79404,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 79918 "configure"
+#line 79408 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -79925,7 +79415,7 @@ int main() {
 rl_pending_input()
 ; return 0; }
 EOF
-if { (eval echo configure:79929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -80056,7 +79546,7 @@ fi
   done
 
   echo $ac_n "checking for rl_callback_read_char in -lreadline""... $ac_c" 1>&6
-echo "configure:80060: checking for rl_callback_read_char in -lreadline" >&5
+echo "configure:79550: checking for rl_callback_read_char in -lreadline" >&5
 ac_lib_var=`echo readline'_'rl_callback_read_char | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -80064,7 +79554,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lreadline  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 80068 "configure"
+#line 79558 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -80075,7 +79565,7 @@ int main() {
 rl_callback_read_char()
 ; return 0; }
 EOF
-if { (eval echo configure:80079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -80159,7 +79649,7 @@ elif test "$PHP_LIBEDIT" != "no"; then
 
 
   echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:80163: checking for tgetent in -lncurses" >&5
+echo "configure:79653: checking for tgetent in -lncurses" >&5
 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -80167,7 +79657,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lncurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 80171 "configure"
+#line 79661 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -80178,7 +79668,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:80182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -80222,7 +79712,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:80226: checking for tgetent in -ltermcap" >&5
+echo "configure:79716: checking for tgetent in -ltermcap" >&5
 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -80230,7 +79720,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltermcap  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 80234 "configure"
+#line 79724 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -80241,7 +79731,7 @@ int main() {
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:80245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -80387,7 +79877,7 @@ fi
   done
 
   echo $ac_n "checking for readline in -ledit""... $ac_c" 1>&6
-echo "configure:80391: checking for readline in -ledit" >&5
+echo "configure:79881: checking for readline in -ledit" >&5
 ac_lib_var=`echo edit'_'readline | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -80395,7 +79885,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ledit  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 80399 "configure"
+#line 79889 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -80406,7 +79896,7 @@ int main() {
 readline()
 ; return 0; }
 EOF
-if { (eval echo configure:80410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:79900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -80547,12 +80037,12 @@ if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then
   for ac_func in rl_completion_matches
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:80551: checking for $ac_func" >&5
+echo "configure:80041: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 80556 "configure"
+#line 80046 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -80575,7 +80065,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:80579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:80069: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -80901,7 +80391,7 @@ fi
 php_with_recode=no
 
 echo $ac_n "checking for recode support""... $ac_c" 1>&6
-echo "configure:80905: checking for recode support" >&5
+echo "configure:80395: checking for recode support" >&5
 # Check whether --with-recode or --without-recode was given.
 if test "${with_recode+set}" = set; then
   withval="$with_recode"
@@ -80909,10 +80399,7 @@ if test "${with_recode+set}" = set; then
 else
   
   PHP_RECODE=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_RECODE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_RECODE=$PHP_ENABLE_ALL
 
 fi
 
@@ -81068,7 +80555,7 @@ if test "$PHP_RECODE" != "no"; then
   done
 
   echo $ac_n "checking for recode_format_table in -lrecode""... $ac_c" 1>&6
-echo "configure:81072: checking for recode_format_table in -lrecode" >&5
+echo "configure:80559: checking for recode_format_table in -lrecode" >&5
 ac_lib_var=`echo recode'_'recode_format_table | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -81076,7 +80563,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lrecode  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 81080 "configure"
+#line 80567 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -81087,7 +80574,7 @@ int main() {
 recode_format_table()
 ; return 0; }
 EOF
-if { (eval echo configure:81091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:80578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -81217,7 +80704,7 @@ else
     LDFLAGS="$LDFLAGS -L$RECODE_DIR/$RECODE_LIB"
     LIBS="$LIBS -lrecode"
     cat > conftest.$ac_ext <<EOF
-#line 81221 "configure"
+#line 80708 "configure"
 #include "confdefs.h"
 
 char *program_name;
@@ -81228,7 +80715,7 @@ recode_format_table();
     
 ; return 0; }
 EOF
-if { (eval echo configure:81232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:80719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   
       
@@ -81391,17 +80878,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:81395: checking for $ac_hdr" >&5
+echo "configure:80882: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 81400 "configure"
+#line 80887 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:81405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:80892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -82024,7 +81511,7 @@ EOF
 php_enable_session=yes
 
 echo $ac_n "checking whether to enable PHP sessions""... $ac_c" 1>&6
-echo "configure:82028: checking whether to enable PHP sessions" >&5
+echo "configure:81515: checking whether to enable PHP sessions" >&5
 # Check whether --enable-session or --disable-session was given.
 if test "${enable_session+set}" = set; then
   enableval="$enable_session"
@@ -82032,10 +81519,7 @@ if test "${enable_session+set}" = set; then
 else
   
   PHP_SESSION=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SESSION=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SESSION=$PHP_ENABLE_ALL
 
 fi
 
@@ -82071,7 +81555,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_mm=no
 
 echo $ac_n "checking for mm support""... $ac_c" 1>&6
-echo "configure:82075: checking for mm support" >&5
+echo "configure:81559: checking for mm support" >&5
 # Check whether --with-mm or --without-mm was given.
 if test "${with_mm+set}" = set; then
   withval="$with_mm"
@@ -82079,10 +81563,7 @@ if test "${with_mm+set}" = set; then
 else
   
   PHP_MM=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_MM=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -82096,7 +81577,7 @@ echo "$ac_t""$ext_output" 1>&6
 if test "$PHP_SESSION" != "no"; then
   
   echo $ac_n "checking whether pwrite works""... $ac_c" 1>&6
-echo "configure:82100: checking whether pwrite works" >&5
+echo "configure:81581: checking whether pwrite works" >&5
 if eval "test \"`echo '$''{'ac_cv_pwrite'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -82108,7 +81589,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 82112 "configure"
+#line 81593 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -82129,7 +81610,7 @@ else
 
   
 EOF
-if { (eval echo configure:82133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:81614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pwrite=yes
@@ -82154,7 +81635,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 82158 "configure"
+#line 81639 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -82175,7 +81656,7 @@ ssize_t pwrite(int, void *, size_t, off64_t);
 
   
 EOF
-if { (eval echo configure:82179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:81660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pwrite=yes
@@ -82216,7 +81697,7 @@ EOF
 
   
   echo $ac_n "checking whether pread works""... $ac_c" 1>&6
-echo "configure:82220: checking whether pread works" >&5
+echo "configure:81701: checking whether pread works" >&5
 if eval "test \"`echo '$''{'ac_cv_pread'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -82229,7 +81710,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 82233 "configure"
+#line 81714 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -82249,7 +81730,7 @@ else
     }
   
 EOF
-if { (eval echo configure:82253: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:81734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pread=yes
@@ -82276,7 +81757,7 @@ fi
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 82280 "configure"
+#line 81761 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -82296,7 +81777,7 @@ ssize_t pread(int, void *, size_t, off64_t);
     }
   
 EOF
-if { (eval echo configure:82300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:81781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_cv_pread=yes
@@ -82648,6 +82129,25 @@ but you've either not enabled hash, or have disabled it.
   fi
   
   
+  am_i_shared=$PHP_SESSION_SHARED
+  is_it_shared=$PHP_SPL_SHARED
+  is_it_enabled=$PHP_SPL
+  if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
+    { echo "configure: error: 
+You've configured extension session to build statically, but it
+depends on extension spl, which you've configured to build shared.
+You either need to build session shared or build spl statically for the
+build to be successful.
+" 1>&2; exit 1; }
+  fi
+  if test "x$is_it_enabled" = "xno" && test "x" != "xtrue"; then
+    { echo "configure: error: 
+You've configured extension session, which depends on extension spl,
+but you've either not enabled spl, or have disabled it.
+" 1>&2; exit 1; }
+  fi
+  
+  
   PHP_VAR_SUBST="$PHP_VAR_SUBST SESSION_SHARED_LIBADD"
 
   
@@ -82841,7 +82341,7 @@ fi
 php_enable_shmop=no
 
 echo $ac_n "checking whether to enable shmop support""... $ac_c" 1>&6
-echo "configure:82845: checking whether to enable shmop support" >&5
+echo "configure:82345: checking whether to enable shmop support" >&5
 # Check whether --enable-shmop or --disable-shmop was given.
 if test "${enable_shmop+set}" = set; then
   enableval="$enable_shmop"
@@ -82849,10 +82349,7 @@ if test "${enable_shmop+set}" = set; then
 else
   
   PHP_SHMOP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SHMOP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SHMOP=$PHP_ENABLE_ALL
 
 fi
 
@@ -83188,7 +82685,7 @@ fi
 php_enable_simplexml=yes
 
 echo $ac_n "checking whether to enable SimpleXML support""... $ac_c" 1>&6
-echo "configure:83192: checking whether to enable SimpleXML support" >&5
+echo "configure:82689: checking whether to enable SimpleXML support" >&5
 # Check whether --enable-simplexml or --disable-simplexml was given.
 if test "${enable_simplexml+set}" = set; then
   enableval="$enable_simplexml"
@@ -83196,10 +82693,7 @@ if test "${enable_simplexml+set}" = set; then
 else
   
   PHP_SIMPLEXML=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SIMPLEXML=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SIMPLEXML=$PHP_ENABLE_ALL
 
 fi
 
@@ -83236,7 +82730,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:83240: checking libxml2 install dir" >&5
+echo "configure:82734: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -83244,10 +82738,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -83267,7 +82758,7 @@ if test "$PHP_SIMPLEXML" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:83271: checking for xml2-config path" >&5
+echo "configure:82762: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -83425,7 +82916,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:83429: checking whether libxml build works" >&5
+echo "configure:82920: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -83441,7 +82932,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 83445 "configure"
+#line 82936 "configure"
 #include "confdefs.h"
 
     
@@ -83452,7 +82943,7 @@ else
     }
   
 EOF
-if { (eval echo configure:83456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:82947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -83840,7 +83331,7 @@ fi
 php_with_snmp=no
 
 echo $ac_n "checking for SNMP support""... $ac_c" 1>&6
-echo "configure:83844: checking for SNMP support" >&5
+echo "configure:83335: checking for SNMP support" >&5
 # Check whether --with-snmp or --without-snmp was given.
 if test "${with_snmp+set}" = set; then
   withval="$with_snmp"
@@ -83848,10 +83339,7 @@ if test "${with_snmp+set}" = set; then
 else
   
   PHP_SNMP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SNMP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SNMP=$PHP_ENABLE_ALL
 
 fi
 
@@ -83887,7 +83375,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_openssl_dir=no
 
 echo $ac_n "checking OpenSSL dir for SNMP""... $ac_c" 1>&6
-echo "configure:83891: checking OpenSSL dir for SNMP" >&5
+echo "configure:83379: checking OpenSSL dir for SNMP" >&5
 # Check whether --with-openssl-dir or --without-openssl-dir was given.
 if test "${with_openssl_dir+set}" = set; then
   withval="$with_openssl_dir"
@@ -83895,10 +83383,7 @@ if test "${with_openssl_dir+set}" = set; then
 else
   
   PHP_OPENSSL_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_OPENSSL_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -83913,7 +83398,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_ucd_snmp_hack=no
 
 echo $ac_n "checking whether to enable UCD SNMP hack""... $ac_c" 1>&6
-echo "configure:83917: checking whether to enable UCD SNMP hack" >&5
+echo "configure:83402: checking whether to enable UCD SNMP hack" >&5
 # Check whether --enable-ucd-snmp-hack or --disable-ucd-snmp-hack was given.
 if test "${enable_ucd_snmp_hack+set}" = set; then
   enableval="$enable_ucd_snmp_hack"
@@ -83921,10 +83406,7 @@ if test "${enable_ucd_snmp_hack+set}" = set; then
 else
   
   PHP_UCD_SNMP_HACK=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_UCD_SNMP_HACK=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -83941,7 +83423,7 @@ if test "$PHP_SNMP" != "no"; then
     # Extract the first word of "net-snmp-config", so it can be a program name with args.
 set dummy net-snmp-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:83945: checking for $ac_word" >&5
+echo "configure:83427: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_SNMP_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -84142,17 +83624,17 @@ EOF
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:84146: checking for $ac_hdr" >&5
+echo "configure:83628: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 84151 "configure"
+#line 83633 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:84156: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:83638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -84180,9 +83662,9 @@ done
 
     if test "$ac_cv_header_default_store_h" = "yes"; then
       echo $ac_n "checking for OpenSSL support in SNMP libraries""... $ac_c" 1>&6
-echo "configure:84184: checking for OpenSSL support in SNMP libraries" >&5
+echo "configure:83666: checking for OpenSSL support in SNMP libraries" >&5
       cat > conftest.$ac_ext <<EOF
-#line 84186 "configure"
+#line 83668 "configure"
 #include "confdefs.h"
 
 #include <ucd-snmp-config.h>
@@ -84237,7 +83719,7 @@ rm -f conftest*
     # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:84241: checking for $ac_word" >&5
+echo "configure:83723: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -84442,9 +83924,9 @@ fi
     old_CPPFLAGS=$CPPFLAGS
     CPPFLAGS=-I$OPENSSL_INCDIR
     echo $ac_n "checking for OpenSSL version""... $ac_c" 1>&6
-echo "configure:84446: checking for OpenSSL version" >&5
+echo "configure:83928: checking for OpenSSL version" >&5
     cat > conftest.$ac_ext <<EOF
-#line 84448 "configure"
+#line 83930 "configure"
 #include "confdefs.h"
 
 #include <openssl/opensslv.h>
@@ -84599,7 +84081,7 @@ rm -f conftest*
   done
 
   echo $ac_n "checking for CRYPTO_free in -lcrypto""... $ac_c" 1>&6
-echo "configure:84603: checking for CRYPTO_free in -lcrypto" >&5
+echo "configure:84085: checking for CRYPTO_free in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'CRYPTO_free | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -84607,7 +84089,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 84611 "configure"
+#line 84093 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -84618,7 +84100,7 @@ int main() {
 CRYPTO_free()
 ; return 0; }
 EOF
-if { (eval echo configure:84622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -84775,7 +84257,7 @@ fi
   done
 
   echo $ac_n "checking for SSL_CTX_set_ssl_version in -lssl""... $ac_c" 1>&6
-echo "configure:84779: checking for SSL_CTX_set_ssl_version in -lssl" >&5
+echo "configure:84261: checking for SSL_CTX_set_ssl_version in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_CTX_set_ssl_version | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -84783,7 +84265,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 84787 "configure"
+#line 84269 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -84794,7 +84276,7 @@ int main() {
 SSL_CTX_set_ssl_version()
 ; return 0; }
 EOF
-if { (eval echo configure:84798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -84907,7 +84389,7 @@ else
     fi
 
     echo $ac_n "checking for kstat_read in -lkstat""... $ac_c" 1>&6
-echo "configure:84911: checking for kstat_read in -lkstat" >&5
+echo "configure:84393: checking for kstat_read in -lkstat" >&5
 ac_lib_var=`echo kstat'_'kstat_read | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -84915,7 +84397,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lkstat  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 84919 "configure"
+#line 84401 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -84926,7 +84408,7 @@ int main() {
 kstat_read()
 ; return 0; }
 EOF
-if { (eval echo configure:84930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -85197,7 +84679,7 @@ fi
   done
 
   echo $ac_n "checking for snmp_parse_oid in -l$SNMP_LIBNAME""... $ac_c" 1>&6
-echo "configure:85201: checking for snmp_parse_oid in -l$SNMP_LIBNAME" >&5
+echo "configure:84683: checking for snmp_parse_oid in -l$SNMP_LIBNAME" >&5
 ac_lib_var=`echo $SNMP_LIBNAME'_'snmp_parse_oid | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -85205,7 +84687,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$SNMP_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 85209 "configure"
+#line 84691 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -85216,7 +84698,7 @@ int main() {
 snmp_parse_oid()
 ; return 0; }
 EOF
-if { (eval echo configure:85220: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -85350,7 +84832,7 @@ fi
   done
 
   echo $ac_n "checking for init_snmp in -l$SNMP_LIBNAME""... $ac_c" 1>&6
-echo "configure:85354: checking for init_snmp in -l$SNMP_LIBNAME" >&5
+echo "configure:84836: checking for init_snmp in -l$SNMP_LIBNAME" >&5
 ac_lib_var=`echo $SNMP_LIBNAME'_'init_snmp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -85358,7 +84840,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$SNMP_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 85362 "configure"
+#line 84844 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -85369,7 +84851,7 @@ int main() {
 init_snmp()
 ; return 0; }
 EOF
-if { (eval echo configure:85373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:84855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -85716,7 +85198,7 @@ fi
 php_enable_soap=no
 
 echo $ac_n "checking whether to enable SOAP support""... $ac_c" 1>&6
-echo "configure:85720: checking whether to enable SOAP support" >&5
+echo "configure:85202: checking whether to enable SOAP support" >&5
 # Check whether --enable-soap or --disable-soap was given.
 if test "${enable_soap+set}" = set; then
   enableval="$enable_soap"
@@ -85724,10 +85206,7 @@ if test "${enable_soap+set}" = set; then
 else
   
   PHP_SOAP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SOAP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SOAP=$PHP_ENABLE_ALL
 
 fi
 
@@ -85764,7 +85243,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:85768: checking libxml2 install dir" >&5
+echo "configure:85247: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -85772,10 +85251,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -85795,7 +85271,7 @@ if test "$PHP_SOAP" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:85799: checking for xml2-config path" >&5
+echo "configure:85275: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -85953,7 +85429,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:85957: checking whether libxml build works" >&5
+echo "configure:85433: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -85969,7 +85445,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 85973 "configure"
+#line 85449 "configure"
 #include "confdefs.h"
 
     
@@ -85980,7 +85456,7 @@ else
     }
   
 EOF
-if { (eval echo configure:85984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:85460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -86330,7 +85806,7 @@ fi
 php_enable_sockets=no
 
 echo $ac_n "checking whether to enable sockets support""... $ac_c" 1>&6
-echo "configure:86334: checking whether to enable sockets support" >&5
+echo "configure:85810: checking whether to enable sockets support" >&5
 # Check whether --enable-sockets or --disable-sockets was given.
 if test "${enable_sockets+set}" = set; then
   enableval="$enable_sockets"
@@ -86338,10 +85814,7 @@ if test "${enable_sockets+set}" = set; then
 else
   
   PHP_SOCKETS=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SOCKETS=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SOCKETS=$PHP_ENABLE_ALL
 
 fi
 
@@ -86375,13 +85848,13 @@ echo "$ac_t""$ext_output" 1>&6
 
 if test "$PHP_SOCKETS" != "no"; then
     echo $ac_n "checking for struct cmsghdr""... $ac_c" 1>&6
-echo "configure:86379: checking for struct cmsghdr" >&5
+echo "configure:85852: checking for struct cmsghdr" >&5
 if eval "test \"`echo '$''{'ac_cv_cmsghdr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 86385 "configure"
+#line 85858 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -86390,7 +85863,7 @@ int main() {
 struct cmsghdr s; s
 ; return 0; }
 EOF
-if { (eval echo configure:86394: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:85867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cmsghdr=yes
 else
@@ -86415,12 +85888,12 @@ EOF
   for ac_func in hstrerror socketpair
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:86419: checking for $ac_func" >&5
+echo "configure:85892: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 86424 "configure"
+#line 85897 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -86443,7 +85916,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:86447: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:85920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -86471,17 +85944,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:86475: checking for $ac_hdr" >&5
+echo "configure:85948: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 86480 "configure"
+#line 85953 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:86485: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:85958: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -86508,7 +85981,7 @@ fi
 done
 
   cat > conftest.$ac_ext <<EOF
-#line 86512 "configure"
+#line 85985 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -86518,7 +85991,7 @@ int main() {
 static struct msghdr tp; int n = (int) tp.msg_flags; return n
 ; return 0; }
 EOF
-if { (eval echo configure:86522: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:85995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -86852,7 +86325,7 @@ fi
 
 
   echo $ac_n "checking whether zend_object_value is packed""... $ac_c" 1>&6
-echo "configure:86856: checking whether zend_object_value is packed" >&5
+echo "configure:86329: checking whether zend_object_value is packed" >&5
   old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS="$INCLUDES -I$abs_srcdir $CPPFLAGS"
   if test "$cross_compiling" = yes; then
@@ -86862,7 +86335,7 @@ echo "configure:86856: checking whether zend_object_value is packed" >&5
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 86866 "configure"
+#line 86339 "configure"
 #include "confdefs.h"
 
 #include "Zend/zend_types.h"
@@ -86871,7 +86344,7 @@ int main(int argc, char **argv) {
 }
   
 EOF
-if { (eval echo configure:86875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:86348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     ac_result=1
@@ -87235,7 +86708,7 @@ but you've either not enabled pcre, or have disabled it.
 php_with_sqlite=yes
 
 echo $ac_n "checking for sqlite support""... $ac_c" 1>&6
-echo "configure:87239: checking for sqlite support" >&5
+echo "configure:86712: checking for sqlite support" >&5
 # Check whether --with-sqlite or --without-sqlite was given.
 if test "${with_sqlite+set}" = set; then
   withval="$with_sqlite"
@@ -87243,10 +86716,7 @@ if test "${with_sqlite+set}" = set; then
 else
   
   PHP_SQLITE=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SQLITE=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SQLITE=$PHP_ENABLE_ALL
 
 fi
 
@@ -87282,7 +86752,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_enable_sqlite_utf8=no
 
 echo $ac_n "checking whether to enable UTF-8 support in sqlite (default: ISO-8859-1)""... $ac_c" 1>&6
-echo "configure:87286: checking whether to enable UTF-8 support in sqlite (default: ISO-8859-1)" >&5
+echo "configure:86756: checking whether to enable UTF-8 support in sqlite (default: ISO-8859-1)" >&5
 # Check whether --enable-sqlite-utf8 or --disable-sqlite-utf8 was given.
 if test "${enable_sqlite_utf8+set}" = set; then
   enableval="$enable_sqlite_utf8"
@@ -87290,10 +86760,7 @@ if test "${enable_sqlite_utf8+set}" = set; then
 else
   
   PHP_SQLITE_UTF8=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_SQLITE_UTF8=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -87313,13 +86780,13 @@ if test "$PHP_SQLITE" != "no"; then
   if test "$PHP_PDO" != "no"; then
     
   echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:87317: checking for PDO includes" >&5
+echo "configure:86784: checking for PDO includes" >&5
 if eval "test \"`echo '$''{'pdo_inc_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     echo $ac_n "checking for PDO includes""... $ac_c" 1>&6
-echo "configure:87323: checking for PDO includes" >&5
+echo "configure:86790: checking for PDO includes" >&5
     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
       pdo_inc_path=$abs_srcdir/ext
     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
@@ -87353,7 +86820,7 @@ EOF
       SQLITE_DIR=$PHP_SQLITE
     else # search default path list
       echo $ac_n "checking for sqlite files in default path""... $ac_c" 1>&6
-echo "configure:87357: checking for sqlite files in default path" >&5
+echo "configure:86824: checking for sqlite files in default path" >&5
       for i in $SEARCH_PATH ; do
         if test -r $i/$SEARCH_FOR; then
           SQLITE_DIR=$i
@@ -87465,7 +86932,7 @@ echo "configure:87357: checking for sqlite files in default path" >&5
   done
 
   echo $ac_n "checking for sqlite_open in -lsqlite""... $ac_c" 1>&6
-echo "configure:87469: checking for sqlite_open in -lsqlite" >&5
+echo "configure:86936: checking for sqlite_open in -lsqlite" >&5
 ac_lib_var=`echo sqlite'_'sqlite_open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -87473,7 +86940,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsqlite  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 87477 "configure"
+#line 86944 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -87484,7 +86951,7 @@ int main() {
 sqlite_open()
 ; return 0; }
 EOF
-if { (eval echo configure:87488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:86955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -87657,7 +87124,7 @@ fi
   # Extract the first word of "lemon", so it can be a program name with args.
 set dummy lemon; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:87661: checking for $ac_word" >&5
+echo "configure:87128: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LEMON'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -87685,7 +87152,7 @@ fi
 
   if test "$LEMON"; then
     echo $ac_n "checking for lemon version""... $ac_c" 1>&6
-echo "configure:87689: checking for lemon version" >&5
+echo "configure:87156: checking for lemon version" >&5
 if eval "test \"`echo '$''{'php_cv_lemon_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88098,7 +87565,7 @@ but you've either not enabled pdo, or have disabled it.
   
 
     echo $ac_n "checking size of char *""... $ac_c" 1>&6
-echo "configure:88102: checking size of char *" >&5
+echo "configure:87569: checking size of char *" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_char_p'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88106,7 +87573,7 @@ else
   ac_cv_sizeof_char_p=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 88110 "configure"
+#line 87577 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -88117,7 +87584,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:88121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_char_p=`cat conftestval`
 else
@@ -88179,12 +87646,12 @@ EOF
   for ac_func in usleep nanosleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:88183: checking for $ac_func" >&5
+echo "configure:87650: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 88188 "configure"
+#line 87655 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -88207,7 +87674,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:88211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -88235,17 +87702,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:88239: checking for $ac_hdr" >&5
+echo "configure:87706: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 88244 "configure"
+#line 87711 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:88249: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:87716: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -88276,7 +87743,7 @@ fi
 
 
 echo $ac_n "checking whether flush should be called explicitly after a buffered io""... $ac_c" 1>&6
-echo "configure:88280: checking whether flush should be called explicitly after a buffered io" >&5
+echo "configure:87747: checking whether flush should be called explicitly after a buffered io" >&5
 if eval "test \"`echo '$''{'ac_cv_flush_io'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88287,7 +87754,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88291 "configure"
+#line 87758 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -88325,7 +87792,7 @@ int main(int argc, char **argv)
 }
 
 EOF
-if { (eval echo configure:88329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_flush_io=no
@@ -88353,7 +87820,7 @@ fi
 
 if test "$ac_cv_func_crypt" = "no"; then
   echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:88357: checking for crypt in -lcrypt" >&5
+echo "configure:87824: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -88361,7 +87828,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 88365 "configure"
+#line 87832 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -88372,7 +87839,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:88376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:87843: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -88401,7 +87868,7 @@ fi
 fi
   
 echo $ac_n "checking for standard DES crypt""... $ac_c" 1>&6
-echo "configure:88405: checking for standard DES crypt" >&5
+echo "configure:87872: checking for standard DES crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_des'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88412,7 +87879,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88416 "configure"
+#line 87883 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88431,7 +87898,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87902: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_des=yes
@@ -88452,7 +87919,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_des" 1>&6
 
 echo $ac_n "checking for extended DES crypt""... $ac_c" 1>&6
-echo "configure:88456: checking for extended DES crypt" >&5
+echo "configure:87923: checking for extended DES crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_ext_des'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88463,7 +87930,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88467 "configure"
+#line 87934 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88482,7 +87949,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:87953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_ext_des=yes
@@ -88503,7 +87970,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_ext_des" 1>&6
 
 echo $ac_n "checking for MD5 crypt""... $ac_c" 1>&6
-echo "configure:88507: checking for MD5 crypt" >&5
+echo "configure:87974: checking for MD5 crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_md5'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88514,7 +87981,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88518 "configure"
+#line 87985 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88542,7 +88009,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_md5=yes
@@ -88563,7 +88030,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_md5" 1>&6
 
 echo $ac_n "checking for Blowfish crypt""... $ac_c" 1>&6
-echo "configure:88567: checking for Blowfish crypt" >&5
+echo "configure:88034: checking for Blowfish crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_blowfish'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88574,7 +88041,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88578 "configure"
+#line 88045 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88599,7 +88066,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_blowfish=yes
@@ -88620,7 +88087,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_blowfish" 1>&6
 
 echo $ac_n "checking for SHA512 crypt""... $ac_c" 1>&6
-echo "configure:88624: checking for SHA512 crypt" >&5
+echo "configure:88091: checking for SHA512 crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_SHA512'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88631,7 +88098,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88635 "configure"
+#line 88102 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88655,7 +88122,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88126: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_SHA512=yes
@@ -88676,7 +88143,7 @@ fi
 echo "$ac_t""$ac_cv_crypt_SHA512" 1>&6
 
 echo $ac_n "checking for SHA256 crypt""... $ac_c" 1>&6
-echo "configure:88680: checking for SHA256 crypt" >&5
+echo "configure:88147: checking for SHA256 crypt" >&5
 if eval "test \"`echo '$''{'ac_cv_crypt_SHA256'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -88687,7 +88154,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 88691 "configure"
+#line 88158 "configure"
 #include "confdefs.h"
 
 #if HAVE_UNISTD_H
@@ -88711,7 +88178,7 @@ main() {
 #endif
 }
 EOF
-if { (eval echo configure:88715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_crypt_SHA256=yes
@@ -88735,13 +88202,13 @@ echo "$ac_t""$ac_cv_crypt_SHA256" 1>&6
 if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "x$php_crypt_r" = "x0"; then
 
         echo $ac_n "checking whether the compiler supports __alignof__""... $ac_c" 1>&6
-echo "configure:88739: checking whether the compiler supports __alignof__" >&5
+echo "configure:88206: checking whether the compiler supports __alignof__" >&5
 if eval "test \"`echo '$''{'ac_cv_alignof_exists'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 88745 "configure"
+#line 88212 "configure"
 #include "confdefs.h"
 
   
@@ -88751,7 +88218,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:88755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:88222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_alignof_exists=yes
@@ -88776,13 +88243,13 @@ EOF
   fi
 
         echo $ac_n "checking whether the compiler supports aligned attribute""... $ac_c" 1>&6
-echo "configure:88780: checking whether the compiler supports aligned attribute" >&5
+echo "configure:88247: checking whether the compiler supports aligned attribute" >&5
 if eval "test \"`echo '$''{'ac_cv_attribute_aligned'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 88786 "configure"
+#line 88253 "configure"
 #include "confdefs.h"
 
   
@@ -88792,7 +88259,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:88796: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:88263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
     ac_cv_attribute_aligned=yes
@@ -88971,12 +88438,12 @@ fi
 for ac_func in getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:88975: checking for $ac_func" >&5
+echo "configure:88442: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 88980 "configure"
+#line 88447 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -88999,7 +88466,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -89024,7 +88491,7 @@ fi
 done
 
 echo $ac_n "checking for working fnmatch""... $ac_c" 1>&6
-echo "configure:89028: checking for working fnmatch" >&5
+echo "configure:88495: checking for working fnmatch" >&5
 if eval "test \"`echo '$''{'ac_cv_func_fnmatch_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -89035,11 +88502,11 @@ if test "$cross_compiling" = yes; then
   ac_cv_func_fnmatch_works=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89039 "configure"
+#line 88506 "configure"
 #include "confdefs.h"
 main() { exit (fnmatch ("a*", "abc", 0) != 0); }
 EOF
-if { (eval echo configure:89043: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_fnmatch_works=yes
 else
@@ -89066,12 +88533,12 @@ fi
 for ac_func in fork CreateProcess
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:89070: checking for $ac_func" >&5
+echo "configure:88537: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 89075 "configure"
+#line 88542 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -89094,7 +88561,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -89124,7 +88591,7 @@ fi
 done
 
 echo $ac_n "checking if your OS can spawn processes with inherited handles""... $ac_c" 1>&6
-echo "configure:89128: checking if your OS can spawn processes with inherited handles" >&5
+echo "configure:88595: checking if your OS can spawn processes with inherited handles" >&5
 if test "$php_can_support_proc_open" = "yes"; then
   echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
@@ -89148,12 +88615,12 @@ fi
   unset found
   
   echo $ac_n "checking for res_nsearch""... $ac_c" 1>&6
-echo "configure:89152: checking for res_nsearch" >&5
+echo "configure:88619: checking for res_nsearch" >&5
 if eval "test \"`echo '$''{'ac_cv_func_res_nsearch'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 89157 "configure"
+#line 88624 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_nsearch(); below.  */
@@ -89176,7 +88643,7 @@ res_nsearch();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89180: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_res_nsearch=yes"
 else
@@ -89194,12 +88661,12 @@ if eval "test \"`echo '$ac_cv_func_'res_nsearch`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __res_nsearch""... $ac_c" 1>&6
-echo "configure:89198: checking for __res_nsearch" >&5
+echo "configure:88665: checking for __res_nsearch" >&5
 if eval "test \"`echo '$''{'ac_cv_func___res_nsearch'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 89203 "configure"
+#line 88670 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __res_nsearch(); below.  */
@@ -89222,7 +88689,7 @@ __res_nsearch();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88693: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___res_nsearch=yes"
 else
@@ -89260,7 +88727,7 @@ EOF
   unset ac_cv_lib_resolv___res_nsearch
   unset found
   echo $ac_n "checking for res_nsearch in -lresolv""... $ac_c" 1>&6
-echo "configure:89264: checking for res_nsearch in -lresolv" >&5
+echo "configure:88731: checking for res_nsearch in -lresolv" >&5
 ac_lib_var=`echo resolv'_'res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89268,7 +88735,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89272 "configure"
+#line 88739 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89279,7 +88746,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89299,7 +88766,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lresolv""... $ac_c" 1>&6
-echo "configure:89303: checking for __res_nsearch in -lresolv" >&5
+echo "configure:88770: checking for __res_nsearch in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89307,7 +88774,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89311 "configure"
+#line 88778 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89318,7 +88785,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89350,11 +88817,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89354 "configure"
+#line 88821 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89396,7 +88863,7 @@ EOF
   unset ac_cv_lib_bind___res_nsearch
   unset found
   echo $ac_n "checking for res_nsearch in -lbind""... $ac_c" 1>&6
-echo "configure:89400: checking for res_nsearch in -lbind" >&5
+echo "configure:88867: checking for res_nsearch in -lbind" >&5
 ac_lib_var=`echo bind'_'res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89404,7 +88871,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89408 "configure"
+#line 88875 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89415,7 +88882,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89419: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88886: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89435,7 +88902,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lbind""... $ac_c" 1>&6
-echo "configure:89439: checking for __res_nsearch in -lbind" >&5
+echo "configure:88906: checking for __res_nsearch in -lbind" >&5
 ac_lib_var=`echo bind'_'__res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89443,7 +88910,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89447 "configure"
+#line 88914 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89454,7 +88921,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:88925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89486,11 +88953,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89490 "configure"
+#line 88957 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89494: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:88961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89532,7 +88999,7 @@ EOF
   unset ac_cv_lib_socket___res_nsearch
   unset found
   echo $ac_n "checking for res_nsearch in -lsocket""... $ac_c" 1>&6
-echo "configure:89536: checking for res_nsearch in -lsocket" >&5
+echo "configure:89003: checking for res_nsearch in -lsocket" >&5
 ac_lib_var=`echo socket'_'res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89540,7 +89007,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89544 "configure"
+#line 89011 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89551,7 +89018,7 @@ int main() {
 res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89571,7 +89038,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_nsearch in -lsocket""... $ac_c" 1>&6
-echo "configure:89575: checking for __res_nsearch in -lsocket" >&5
+echo "configure:89042: checking for __res_nsearch in -lsocket" >&5
 ac_lib_var=`echo socket'_'__res_nsearch | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89579,7 +89046,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89583 "configure"
+#line 89050 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89590,7 +89057,7 @@ int main() {
 __res_nsearch()
 ; return 0; }
 EOF
-if { (eval echo configure:89594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89622,11 +89089,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89626 "configure"
+#line 89093 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89097: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89683,12 +89150,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dns_search""... $ac_c" 1>&6
-echo "configure:89687: checking for dns_search" >&5
+echo "configure:89154: checking for dns_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dns_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 89692 "configure"
+#line 89159 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dns_search(); below.  */
@@ -89711,7 +89178,7 @@ dns_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dns_search=yes"
 else
@@ -89729,12 +89196,12 @@ if eval "test \"`echo '$ac_cv_func_'dns_search`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __dns_search""... $ac_c" 1>&6
-echo "configure:89733: checking for __dns_search" >&5
+echo "configure:89200: checking for __dns_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func___dns_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 89738 "configure"
+#line 89205 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dns_search(); below.  */
@@ -89757,7 +89224,7 @@ __dns_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:89761: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___dns_search=yes"
 else
@@ -89795,7 +89262,7 @@ EOF
   unset ac_cv_lib_resolv___dns_search
   unset found
   echo $ac_n "checking for dns_search in -lresolv""... $ac_c" 1>&6
-echo "configure:89799: checking for dns_search in -lresolv" >&5
+echo "configure:89266: checking for dns_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89803,7 +89270,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89807 "configure"
+#line 89274 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89814,7 +89281,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89834,7 +89301,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lresolv""... $ac_c" 1>&6
-echo "configure:89838: checking for __dns_search in -lresolv" >&5
+echo "configure:89305: checking for __dns_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89842,7 +89309,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89846 "configure"
+#line 89313 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89853,7 +89320,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89885,11 +89352,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 89889 "configure"
+#line 89356 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:89893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -89931,7 +89398,7 @@ EOF
   unset ac_cv_lib_bind___dns_search
   unset found
   echo $ac_n "checking for dns_search in -lbind""... $ac_c" 1>&6
-echo "configure:89935: checking for dns_search in -lbind" >&5
+echo "configure:89402: checking for dns_search in -lbind" >&5
 ac_lib_var=`echo bind'_'dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89939,7 +89406,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89943 "configure"
+#line 89410 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89950,7 +89417,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -89970,7 +89437,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lbind""... $ac_c" 1>&6
-echo "configure:89974: checking for __dns_search in -lbind" >&5
+echo "configure:89441: checking for __dns_search in -lbind" >&5
 ac_lib_var=`echo bind'_'__dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -89978,7 +89445,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 89982 "configure"
+#line 89449 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -89989,7 +89456,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:89993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90021,11 +89488,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90025 "configure"
+#line 89492 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90067,7 +89534,7 @@ EOF
   unset ac_cv_lib_socket___dns_search
   unset found
   echo $ac_n "checking for dns_search in -lsocket""... $ac_c" 1>&6
-echo "configure:90071: checking for dns_search in -lsocket" >&5
+echo "configure:89538: checking for dns_search in -lsocket" >&5
 ac_lib_var=`echo socket'_'dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90075,7 +89542,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90079 "configure"
+#line 89546 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90086,7 +89553,7 @@ int main() {
 dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:90090: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90106,7 +89573,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dns_search in -lsocket""... $ac_c" 1>&6
-echo "configure:90110: checking for __dns_search in -lsocket" >&5
+echo "configure:89577: checking for __dns_search in -lsocket" >&5
 ac_lib_var=`echo socket'_'__dns_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90114,7 +89581,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90118 "configure"
+#line 89585 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90125,7 +89592,7 @@ int main() {
 __dns_search()
 ; return 0; }
 EOF
-if { (eval echo configure:90129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90157,11 +89624,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90161 "configure"
+#line 89628 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90218,12 +89685,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dn_expand""... $ac_c" 1>&6
-echo "configure:90222: checking for dn_expand" >&5
+echo "configure:89689: checking for dn_expand" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dn_expand'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 90227 "configure"
+#line 89694 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dn_expand(); below.  */
@@ -90246,7 +89713,7 @@ dn_expand();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dn_expand=yes"
 else
@@ -90264,12 +89731,12 @@ if eval "test \"`echo '$ac_cv_func_'dn_expand`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __dn_expand""... $ac_c" 1>&6
-echo "configure:90268: checking for __dn_expand" >&5
+echo "configure:89735: checking for __dn_expand" >&5
 if eval "test \"`echo '$''{'ac_cv_func___dn_expand'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 90273 "configure"
+#line 89740 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dn_expand(); below.  */
@@ -90292,7 +89759,7 @@ __dn_expand();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___dn_expand=yes"
 else
@@ -90330,7 +89797,7 @@ EOF
   unset ac_cv_lib_resolv___dn_expand
   unset found
   echo $ac_n "checking for dn_expand in -lresolv""... $ac_c" 1>&6
-echo "configure:90334: checking for dn_expand in -lresolv" >&5
+echo "configure:89801: checking for dn_expand in -lresolv" >&5
 ac_lib_var=`echo resolv'_'dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90338,7 +89805,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90342 "configure"
+#line 89809 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90349,7 +89816,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90369,7 +89836,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lresolv""... $ac_c" 1>&6
-echo "configure:90373: checking for __dn_expand in -lresolv" >&5
+echo "configure:89840: checking for __dn_expand in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90377,7 +89844,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90381 "configure"
+#line 89848 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90388,7 +89855,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90420,11 +89887,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90424 "configure"
+#line 89891 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:89895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90466,7 +89933,7 @@ EOF
   unset ac_cv_lib_bind___dn_expand
   unset found
   echo $ac_n "checking for dn_expand in -lbind""... $ac_c" 1>&6
-echo "configure:90470: checking for dn_expand in -lbind" >&5
+echo "configure:89937: checking for dn_expand in -lbind" >&5
 ac_lib_var=`echo bind'_'dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90474,7 +89941,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90478 "configure"
+#line 89945 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90485,7 +89952,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90505,7 +89972,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lbind""... $ac_c" 1>&6
-echo "configure:90509: checking for __dn_expand in -lbind" >&5
+echo "configure:89976: checking for __dn_expand in -lbind" >&5
 ac_lib_var=`echo bind'_'__dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90513,7 +89980,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90517 "configure"
+#line 89984 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90524,7 +89991,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90528: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:89995: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90556,11 +90023,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90560 "configure"
+#line 90027 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90602,7 +90069,7 @@ EOF
   unset ac_cv_lib_socket___dn_expand
   unset found
   echo $ac_n "checking for dn_expand in -lsocket""... $ac_c" 1>&6
-echo "configure:90606: checking for dn_expand in -lsocket" >&5
+echo "configure:90073: checking for dn_expand in -lsocket" >&5
 ac_lib_var=`echo socket'_'dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90610,7 +90077,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90614 "configure"
+#line 90081 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90621,7 +90088,7 @@ int main() {
 dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90641,7 +90108,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_expand in -lsocket""... $ac_c" 1>&6
-echo "configure:90645: checking for __dn_expand in -lsocket" >&5
+echo "configure:90112: checking for __dn_expand in -lsocket" >&5
 ac_lib_var=`echo socket'_'__dn_expand | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90649,7 +90116,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90653 "configure"
+#line 90120 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90660,7 +90127,7 @@ int main() {
 __dn_expand()
 ; return 0; }
 EOF
-if { (eval echo configure:90664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90131: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90692,11 +90159,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90696 "configure"
+#line 90163 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -90753,12 +90220,12 @@ EOF
   unset found
   
   echo $ac_n "checking for dn_skipname""... $ac_c" 1>&6
-echo "configure:90757: checking for dn_skipname" >&5
+echo "configure:90224: checking for dn_skipname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dn_skipname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 90762 "configure"
+#line 90229 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dn_skipname(); below.  */
@@ -90781,7 +90248,7 @@ dn_skipname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dn_skipname=yes"
 else
@@ -90799,12 +90266,12 @@ if eval "test \"`echo '$ac_cv_func_'dn_skipname`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __dn_skipname""... $ac_c" 1>&6
-echo "configure:90803: checking for __dn_skipname" >&5
+echo "configure:90270: checking for __dn_skipname" >&5
 if eval "test \"`echo '$''{'ac_cv_func___dn_skipname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 90808 "configure"
+#line 90275 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __dn_skipname(); below.  */
@@ -90827,7 +90294,7 @@ __dn_skipname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:90831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___dn_skipname=yes"
 else
@@ -90865,7 +90332,7 @@ EOF
   unset ac_cv_lib_resolv___dn_skipname
   unset found
   echo $ac_n "checking for dn_skipname in -lresolv""... $ac_c" 1>&6
-echo "configure:90869: checking for dn_skipname in -lresolv" >&5
+echo "configure:90336: checking for dn_skipname in -lresolv" >&5
 ac_lib_var=`echo resolv'_'dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90873,7 +90340,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90877 "configure"
+#line 90344 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90884,7 +90351,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:90888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90904,7 +90371,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lresolv""... $ac_c" 1>&6
-echo "configure:90908: checking for __dn_skipname in -lresolv" >&5
+echo "configure:90375: checking for __dn_skipname in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -90912,7 +90379,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 90916 "configure"
+#line 90383 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -90923,7 +90390,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:90927: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -90955,11 +90422,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 90959 "configure"
+#line 90426 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:90963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91001,7 +90468,7 @@ EOF
   unset ac_cv_lib_bind___dn_skipname
   unset found
   echo $ac_n "checking for dn_skipname in -lbind""... $ac_c" 1>&6
-echo "configure:91005: checking for dn_skipname in -lbind" >&5
+echo "configure:90472: checking for dn_skipname in -lbind" >&5
 ac_lib_var=`echo bind'_'dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91009,7 +90476,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91013 "configure"
+#line 90480 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91020,7 +90487,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:91024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91040,7 +90507,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lbind""... $ac_c" 1>&6
-echo "configure:91044: checking for __dn_skipname in -lbind" >&5
+echo "configure:90511: checking for __dn_skipname in -lbind" >&5
 ac_lib_var=`echo bind'_'__dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91048,7 +90515,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91052 "configure"
+#line 90519 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91059,7 +90526,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:91063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91091,11 +90558,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 91095 "configure"
+#line 90562 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:91099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91137,7 +90604,7 @@ EOF
   unset ac_cv_lib_socket___dn_skipname
   unset found
   echo $ac_n "checking for dn_skipname in -lsocket""... $ac_c" 1>&6
-echo "configure:91141: checking for dn_skipname in -lsocket" >&5
+echo "configure:90608: checking for dn_skipname in -lsocket" >&5
 ac_lib_var=`echo socket'_'dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91145,7 +90612,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91149 "configure"
+#line 90616 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91156,7 +90623,7 @@ int main() {
 dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:91160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91176,7 +90643,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __dn_skipname in -lsocket""... $ac_c" 1>&6
-echo "configure:91180: checking for __dn_skipname in -lsocket" >&5
+echo "configure:90647: checking for __dn_skipname in -lsocket" >&5
 ac_lib_var=`echo socket'_'__dn_skipname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91184,7 +90651,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91188 "configure"
+#line 90655 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91195,7 +90662,7 @@ int main() {
 __dn_skipname()
 ; return 0; }
 EOF
-if { (eval echo configure:91199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91227,11 +90694,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 91231 "configure"
+#line 90698 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:91235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91290,12 +90757,12 @@ EOF
   unset found
   
   echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:91294: checking for res_search" >&5
+echo "configure:90761: checking for res_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func_res_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 91299 "configure"
+#line 90766 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_search(); below.  */
@@ -91318,7 +90785,7 @@ res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:91322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_res_search=yes"
 else
@@ -91336,12 +90803,12 @@ if eval "test \"`echo '$ac_cv_func_'res_search`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
  echo $ac_n "checking for __res_search""... $ac_c" 1>&6
-echo "configure:91340: checking for __res_search" >&5
+echo "configure:90807: checking for __res_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func___res_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 91345 "configure"
+#line 90812 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char __res_search(); below.  */
@@ -91364,7 +90831,7 @@ __res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:91368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func___res_search=yes"
 else
@@ -91402,7 +90869,7 @@ EOF
   unset ac_cv_lib_resolv___res_search
   unset found
   echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:91406: checking for res_search in -lresolv" >&5
+echo "configure:90873: checking for res_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91410,7 +90877,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91414 "configure"
+#line 90881 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91421,7 +90888,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91425: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91441,7 +90908,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:91445: checking for __res_search in -lresolv" >&5
+echo "configure:90912: checking for __res_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'__res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91449,7 +90916,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91453 "configure"
+#line 90920 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91460,7 +90927,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91464: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:90931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91492,11 +90959,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 91496 "configure"
+#line 90963 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:91500: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:90967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91538,7 +91005,7 @@ EOF
   unset ac_cv_lib_bind___res_search
   unset found
   echo $ac_n "checking for res_search in -lbind""... $ac_c" 1>&6
-echo "configure:91542: checking for res_search in -lbind" >&5
+echo "configure:91009: checking for res_search in -lbind" >&5
 ac_lib_var=`echo bind'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91546,7 +91013,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91550 "configure"
+#line 91017 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91557,7 +91024,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91028: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91577,7 +91044,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lbind""... $ac_c" 1>&6
-echo "configure:91581: checking for __res_search in -lbind" >&5
+echo "configure:91048: checking for __res_search in -lbind" >&5
 ac_lib_var=`echo bind'_'__res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91585,7 +91052,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lbind  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91589 "configure"
+#line 91056 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91596,7 +91063,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91628,11 +91095,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 91632 "configure"
+#line 91099 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:91636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91103: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91674,7 +91141,7 @@ EOF
   unset ac_cv_lib_socket___res_search
   unset found
   echo $ac_n "checking for res_search in -lsocket""... $ac_c" 1>&6
-echo "configure:91678: checking for res_search in -lsocket" >&5
+echo "configure:91145: checking for res_search in -lsocket" >&5
 ac_lib_var=`echo socket'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91682,7 +91149,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91686 "configure"
+#line 91153 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91693,7 +91160,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91713,7 +91180,7 @@ else
   echo "$ac_t""no" 1>&6
 
     echo $ac_n "checking for __res_search in -lsocket""... $ac_c" 1>&6
-echo "configure:91717: checking for __res_search in -lsocket" >&5
+echo "configure:91184: checking for __res_search in -lsocket" >&5
 ac_lib_var=`echo socket'_'__res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -91721,7 +91188,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 91725 "configure"
+#line 91192 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -91732,7 +91199,7 @@ int main() {
 __res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:91736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -91764,11 +91231,11 @@ fi
   found=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 91768 "configure"
+#line 91235 "configure"
 #include "confdefs.h"
 main() { return (0); }
 EOF
-if { (eval echo configure:91772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   found=yes
 else
@@ -91821,7 +91288,7 @@ EOF
 
 
 echo $ac_n "checking whether atof() accepts NAN""... $ac_c" 1>&6
-echo "configure:91825: checking whether atof() accepts NAN" >&5
+echo "configure:91292: checking whether atof() accepts NAN" >&5
 if eval "test \"`echo '$''{'ac_cv_atof_accept_nan'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -91832,7 +91299,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 91836 "configure"
+#line 91303 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -91852,7 +91319,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:91856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_atof_accept_nan=yes
@@ -91879,7 +91346,7 @@ EOF
 fi
 
 echo $ac_n "checking whether atof() accepts INF""... $ac_c" 1>&6
-echo "configure:91883: checking whether atof() accepts INF" >&5
+echo "configure:91350: checking whether atof() accepts INF" >&5
 if eval "test \"`echo '$''{'ac_cv_atof_accept_inf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -91890,7 +91357,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 91894 "configure"
+#line 91361 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -91913,7 +91380,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:91917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_atof_accept_inf=yes
@@ -91940,7 +91407,7 @@ EOF
 fi
 
 echo $ac_n "checking whether HUGE_VAL == INF""... $ac_c" 1>&6
-echo "configure:91944: checking whether HUGE_VAL == INF" >&5
+echo "configure:91411: checking whether HUGE_VAL == INF" >&5
 if eval "test \"`echo '$''{'ac_cv_huge_val_inf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -91951,7 +91418,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 91955 "configure"
+#line 91422 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -91974,7 +91441,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:91978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_huge_val_inf=yes
@@ -92001,7 +91468,7 @@ EOF
 fi
 
 echo $ac_n "checking whether HUGE_VAL + -HUGEVAL == NAN""... $ac_c" 1>&6
-echo "configure:92005: checking whether HUGE_VAL + -HUGEVAL == NAN" >&5
+echo "configure:91472: checking whether HUGE_VAL + -HUGEVAL == NAN" >&5
 if eval "test \"`echo '$''{'ac_cv_huge_val_nan'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -92012,7 +91479,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 92016 "configure"
+#line 91483 "configure"
 #include "confdefs.h"
 
 #include <math.h>
@@ -92037,7 +91504,7 @@ int main(int argc, char** argv)
 }
 
 EOF
-if { (eval echo configure:92041: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:91508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   ac_cv_huge_val_nan=yes
@@ -92064,13 +91531,13 @@ EOF
 fi
 
 echo $ac_n "checking whether strptime() declaration fails""... $ac_c" 1>&6
-echo "configure:92068: checking whether strptime() declaration fails" >&5
+echo "configure:91535: checking whether strptime() declaration fails" >&5
 if eval "test \"`echo '$''{'ac_cv_strptime_decl_fails'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 92074 "configure"
+#line 91541 "configure"
 #include "confdefs.h"
 
 #include <time.h>
@@ -92086,7 +91553,7 @@ int strptime(const char *s, const char *format, struct tm *tm);
 
 ; return 0; }
 EOF
-if { (eval echo configure:92090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:91557: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_strptime_decl_fails=no
@@ -92114,17 +91581,17 @@ for ac_hdr in wchar.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:92118: checking for $ac_hdr" >&5
+echo "configure:91585: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 92123 "configure"
+#line 91590 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:92128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:91595: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -92153,12 +91620,12 @@ done
 for ac_func in mblen
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:92157: checking for $ac_func" >&5
+echo "configure:91624: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 92162 "configure"
+#line 91629 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -92181,7 +91648,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:92185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -92208,12 +91675,12 @@ done
 for ac_func in mbrlen mbsinit
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:92212: checking for $ac_func" >&5
+echo "configure:91679: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 92217 "configure"
+#line 91684 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -92236,7 +91703,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:92240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:91707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -92261,13 +91728,13 @@ fi
 done
 
 echo $ac_n "checking for mbstate_t""... $ac_c" 1>&6
-echo "configure:92265: checking for mbstate_t" >&5
+echo "configure:91732: checking for mbstate_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mbstate_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 92271 "configure"
+#line 91738 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_WCHAR_H
@@ -92280,7 +91747,7 @@ int __tmp__() { mbstate_t a; }
 
 ; return 0; }
 EOF
-if { (eval echo configure:92284: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:91751: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   ac_cv_type_mbstate_t=yes
@@ -92308,17 +91775,17 @@ for ac_hdr in atomic.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:92312: checking for $ac_hdr" >&5
+echo "configure:91779: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 92317 "configure"
+#line 91784 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:92322: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:91789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -92708,7 +92175,7 @@ EOF
 php_with_sybase_ct=no
 
 echo $ac_n "checking for Sybase-CT support""... $ac_c" 1>&6
-echo "configure:92712: checking for Sybase-CT support" >&5
+echo "configure:92179: checking for Sybase-CT support" >&5
 # Check whether --with-sybase-ct or --without-sybase-ct was given.
 if test "${with_sybase_ct+set}" = set; then
   withval="$with_sybase_ct"
@@ -92716,10 +92183,7 @@ if test "${with_sybase_ct+set}" = set; then
 else
   
   PHP_SYBASE_CT=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SYBASE_CT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SYBASE_CT=$PHP_ENABLE_ALL
 
 fi
 
@@ -93164,7 +92628,7 @@ EOF
 
 
     SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lct"
-  elif test -f $SYBASE_CT_INCDIR/libsybct64; then
+  elif test -f $SYBASE_CT_INCDIR/libsybct64.so; then
     
   
   case sybcs64 in
@@ -93363,7 +92827,7 @@ EOF
   done
 
   echo $ac_n "checking for netg_errstr in -lsybtcl64""... $ac_c" 1>&6
-echo "configure:93367: checking for netg_errstr in -lsybtcl64" >&5
+echo "configure:92831: checking for netg_errstr in -lsybtcl64" >&5
 ac_lib_var=`echo sybtcl64'_'netg_errstr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -93371,7 +92835,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsybtcl64  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 93375 "configure"
+#line 92839 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -93382,7 +92846,7 @@ int main() {
 netg_errstr()
 ; return 0; }
 EOF
-if { (eval echo configure:93386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:92850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -93557,7 +93021,7 @@ fi
   done
 
   echo $ac_n "checking for insck__getVdate in -linsck64""... $ac_c" 1>&6
-echo "configure:93561: checking for insck__getVdate in -linsck64" >&5
+echo "configure:93025: checking for insck__getVdate in -linsck64" >&5
 ac_lib_var=`echo insck64'_'insck__getVdate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -93565,7 +93029,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck64  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 93569 "configure"
+#line 93033 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -93576,7 +93040,7 @@ int main() {
 insck__getVdate()
 ; return 0; }
 EOF
-if { (eval echo configure:93580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -93724,7 +93188,7 @@ fi
   done
 
   echo $ac_n "checking for bsd_tcp in -linsck64""... $ac_c" 1>&6
-echo "configure:93728: checking for bsd_tcp in -linsck64" >&5
+echo "configure:93192: checking for bsd_tcp in -linsck64" >&5
 ac_lib_var=`echo insck64'_'bsd_tcp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -93732,7 +93196,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck64  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 93736 "configure"
+#line 93200 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -93743,7 +93207,7 @@ int main() {
 bsd_tcp()
 ; return 0; }
 EOF
-if { (eval echo configure:93747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -93795,7 +93259,7 @@ else
   
 fi
 
-  elif test -f $SYBASE_CT_INCDIR/libsybct; then
+  elif test -f $SYBASE_CT_INCDIR/libsybct.so; then
     
   
   case sybcs in
@@ -93989,7 +93453,7 @@ fi
   done
 
   echo $ac_n "checking for netg_errstr in -lsybtcl""... $ac_c" 1>&6
-echo "configure:93993: checking for netg_errstr in -lsybtcl" >&5
+echo "configure:93457: checking for netg_errstr in -lsybtcl" >&5
 ac_lib_var=`echo sybtcl'_'netg_errstr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -93997,7 +93461,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsybtcl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94001 "configure"
+#line 93465 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94008,7 +93472,7 @@ int main() {
 netg_errstr()
 ; return 0; }
 EOF
-if { (eval echo configure:94012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -94183,7 +93647,7 @@ fi
   done
 
   echo $ac_n "checking for insck__getVdate in -linsck""... $ac_c" 1>&6
-echo "configure:94187: checking for insck__getVdate in -linsck" >&5
+echo "configure:93651: checking for insck__getVdate in -linsck" >&5
 ac_lib_var=`echo insck'_'insck__getVdate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -94191,7 +93655,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94195 "configure"
+#line 93659 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94202,7 +93666,7 @@ int main() {
 insck__getVdate()
 ; return 0; }
 EOF
-if { (eval echo configure:94206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -94350,7 +93814,7 @@ fi
   done
 
   echo $ac_n "checking for bsd_tcp in -linsck""... $ac_c" 1>&6
-echo "configure:94354: checking for bsd_tcp in -linsck" >&5
+echo "configure:93818: checking for bsd_tcp in -linsck" >&5
 ac_lib_var=`echo insck'_'bsd_tcp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -94358,7 +93822,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94362 "configure"
+#line 93826 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94369,7 +93833,7 @@ int main() {
 bsd_tcp()
 ; return 0; }
 EOF
-if { (eval echo configure:94373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:93837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -94615,7 +94079,7 @@ fi
   done
 
   echo $ac_n "checking for netg_errstr in -ltcl""... $ac_c" 1>&6
-echo "configure:94619: checking for netg_errstr in -ltcl" >&5
+echo "configure:94083: checking for netg_errstr in -ltcl" >&5
 ac_lib_var=`echo tcl'_'netg_errstr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -94623,7 +94087,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltcl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94627 "configure"
+#line 94091 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94634,7 +94098,7 @@ int main() {
 netg_errstr()
 ; return 0; }
 EOF
-if { (eval echo configure:94638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:94102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -94809,7 +94273,7 @@ fi
   done
 
   echo $ac_n "checking for insck__getVdate in -linsck""... $ac_c" 1>&6
-echo "configure:94813: checking for insck__getVdate in -linsck" >&5
+echo "configure:94277: checking for insck__getVdate in -linsck" >&5
 ac_lib_var=`echo insck'_'insck__getVdate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -94817,7 +94281,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94821 "configure"
+#line 94285 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94828,7 +94292,7 @@ int main() {
 insck__getVdate()
 ; return 0; }
 EOF
-if { (eval echo configure:94832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:94296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -94976,7 +94440,7 @@ fi
   done
 
   echo $ac_n "checking for bsd_tcp in -linsck""... $ac_c" 1>&6
-echo "configure:94980: checking for bsd_tcp in -linsck" >&5
+echo "configure:94444: checking for bsd_tcp in -linsck" >&5
 ac_lib_var=`echo insck'_'bsd_tcp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -94984,7 +94448,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-linsck  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 94988 "configure"
+#line 94452 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -94995,7 +94459,7 @@ int main() {
 bsd_tcp()
 ; return 0; }
 EOF
-if { (eval echo configure:94999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:94463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -95055,7 +94519,7 @@ fi
 php_enable_sysvmsg=no
 
 echo $ac_n "checking whether to enable System V IPC support""... $ac_c" 1>&6
-echo "configure:95059: checking whether to enable System V IPC support" >&5
+echo "configure:94523: checking whether to enable System V IPC support" >&5
 # Check whether --enable-sysvmsg or --disable-sysvmsg was given.
 if test "${enable_sysvmsg+set}" = set; then
   enableval="$enable_sysvmsg"
@@ -95063,10 +94527,7 @@ if test "${enable_sysvmsg+set}" = set; then
 else
   
   PHP_SYSVMSG=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SYSVMSG=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SYSVMSG=$PHP_ENABLE_ALL
 
 fi
 
@@ -95101,17 +94562,17 @@ echo "$ac_t""$ext_output" 1>&6
 if test "$PHP_SYSVMSG" != "no"; then
   ac_safe=`echo "sys/msg.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/msg.h""... $ac_c" 1>&6
-echo "configure:95105: checking for sys/msg.h" >&5
+echo "configure:94566: checking for sys/msg.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 95110 "configure"
+#line 94571 "configure"
 #include "confdefs.h"
 #include <sys/msg.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:95115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:94576: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -95438,7 +94899,7 @@ fi
 php_enable_sysvsem=no
 
 echo $ac_n "checking whether to enable System V semaphore support""... $ac_c" 1>&6
-echo "configure:95442: checking whether to enable System V semaphore support" >&5
+echo "configure:94903: checking whether to enable System V semaphore support" >&5
 # Check whether --enable-sysvsem or --disable-sysvsem was given.
 if test "${enable_sysvsem+set}" = set; then
   enableval="$enable_sysvsem"
@@ -95446,10 +94907,7 @@ if test "${enable_sysvsem+set}" = set; then
 else
   
   PHP_SYSVSEM=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SYSVSEM=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SYSVSEM=$PHP_ENABLE_ALL
 
 fi
 
@@ -95779,12 +95237,12 @@ EOF
 EOF
 
  echo $ac_n "checking for union semun""... $ac_c" 1>&6
-echo "configure:95783: checking for union semun" >&5
+echo "configure:95241: checking for union semun" >&5
 if eval "test \"`echo '$''{'php_cv_semun'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 95788 "configure"
+#line 95246 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -95795,7 +95253,7 @@ int main() {
 union semun x;
 ; return 0; }
 EOF
-if { (eval echo configure:95799: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:95257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
      php_cv_semun=yes
@@ -95831,7 +95289,7 @@ fi
 php_enable_sysvshm=no
 
 echo $ac_n "checking whether to enable System V shared memory support""... $ac_c" 1>&6
-echo "configure:95835: checking whether to enable System V shared memory support" >&5
+echo "configure:95293: checking whether to enable System V shared memory support" >&5
 # Check whether --enable-sysvshm or --disable-sysvshm was given.
 if test "${enable_sysvshm+set}" = set; then
   enableval="$enable_sysvshm"
@@ -95839,10 +95297,7 @@ if test "${enable_sysvshm+set}" = set; then
 else
   
   PHP_SYSVSHM=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_SYSVSHM=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_SYSVSHM=$PHP_ENABLE_ALL
 
 fi
 
@@ -96178,7 +95633,7 @@ fi
 php_with_tidy=no
 
 echo $ac_n "checking for TIDY support""... $ac_c" 1>&6
-echo "configure:96182: checking for TIDY support" >&5
+echo "configure:95637: checking for TIDY support" >&5
 # Check whether --with-tidy or --without-tidy was given.
 if test "${with_tidy+set}" = set; then
   withval="$with_tidy"
@@ -96186,10 +95641,7 @@ if test "${with_tidy+set}" = set; then
 else
   
   PHP_TIDY=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_TIDY=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_TIDY=$PHP_ENABLE_ALL
 
 fi
 
@@ -96470,7 +95922,7 @@ if test "$PHP_TIDY" != "no"; then
   done
 
   echo $ac_n "checking for tidyOptGetDoc in -ltidy""... $ac_c" 1>&6
-echo "configure:96474: checking for tidyOptGetDoc in -ltidy" >&5
+echo "configure:95926: checking for tidyOptGetDoc in -ltidy" >&5
 ac_lib_var=`echo tidy'_'tidyOptGetDoc | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -96478,7 +95930,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ltidy  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 96482 "configure"
+#line 95934 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -96489,7 +95941,7 @@ int main() {
 tidyOptGetDoc()
 ; return 0; }
 EOF
-if { (eval echo configure:96493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:95945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -96833,7 +96285,7 @@ fi
 php_enable_tokenizer=yes
 
 echo $ac_n "checking whether to enable tokenizer support""... $ac_c" 1>&6
-echo "configure:96837: checking whether to enable tokenizer support" >&5
+echo "configure:96289: checking whether to enable tokenizer support" >&5
 # Check whether --enable-tokenizer or --disable-tokenizer was given.
 if test "${enable_tokenizer+set}" = set; then
   enableval="$enable_tokenizer"
@@ -96841,10 +96293,7 @@ if test "${enable_tokenizer+set}" = set; then
 else
   
   PHP_TOKENIZER=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_TOKENIZER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_TOKENIZER=$PHP_ENABLE_ALL
 
 fi
 
@@ -97182,7 +96631,7 @@ fi
 php_enable_wddx=no
 
 echo $ac_n "checking whether to enable WDDX support""... $ac_c" 1>&6
-echo "configure:97186: checking whether to enable WDDX support" >&5
+echo "configure:96635: checking whether to enable WDDX support" >&5
 # Check whether --enable-wddx or --disable-wddx was given.
 if test "${enable_wddx+set}" = set; then
   enableval="$enable_wddx"
@@ -97190,10 +96639,7 @@ if test "${enable_wddx+set}" = set; then
 else
   
   PHP_WDDX=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_WDDX=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_WDDX=$PHP_ENABLE_ALL
 
 fi
 
@@ -97230,7 +96676,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:97234: checking libxml2 install dir" >&5
+echo "configure:96680: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -97238,10 +96684,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -97257,7 +96700,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat dir for WDDX""... $ac_c" 1>&6
-echo "configure:97261: checking libexpat dir for WDDX" >&5
+echo "configure:96704: checking libexpat dir for WDDX" >&5
 # Check whether --with-libexpat-dir or --without-libexpat-dir was given.
 if test "${with_libexpat_dir+set}" = set; then
   withval="$with_libexpat_dir"
@@ -97265,10 +96708,7 @@ if test "${with_libexpat_dir+set}" = set; then
 else
   
   PHP_LIBEXPAT_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBEXPAT_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -97288,7 +96728,7 @@ if test "$PHP_WDDX" != "no"; then
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:97292: checking for xml2-config path" >&5
+echo "configure:96732: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -97446,7 +96886,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:97450: checking whether libxml build works" >&5
+echo "configure:96890: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -97462,7 +96902,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 97466 "configure"
+#line 96906 "configure"
 #include "confdefs.h"
 
     
@@ -97473,7 +96913,7 @@ else
     }
   
 EOF
-if { (eval echo configure:97477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:96917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -98040,7 +97480,7 @@ fi
 php_enable_xml=yes
 
 echo $ac_n "checking whether to enable XML support""... $ac_c" 1>&6
-echo "configure:98044: checking whether to enable XML support" >&5
+echo "configure:97484: checking whether to enable XML support" >&5
 # Check whether --enable-xml or --disable-xml was given.
 if test "${enable_xml+set}" = set; then
   enableval="$enable_xml"
@@ -98048,10 +97488,7 @@ if test "${enable_xml+set}" = set; then
 else
   
   PHP_XML=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_XML=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_XML=$PHP_ENABLE_ALL
 
 fi
 
@@ -98088,7 +97525,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:98092: checking libxml2 install dir" >&5
+echo "configure:97529: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -98096,10 +97533,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -98115,7 +97549,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat install dir""... $ac_c" 1>&6
-echo "configure:98119: checking libexpat install dir" >&5
+echo "configure:97553: checking libexpat install dir" >&5
 # Check whether --with-libexpat-dir or --without-libexpat-dir was given.
 if test "${with_libexpat_dir+set}" = set; then
   withval="$with_libexpat_dir"
@@ -98123,10 +97557,7 @@ if test "${with_libexpat_dir+set}" = set; then
 else
   
   PHP_LIBEXPAT_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBEXPAT_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -98147,7 +97578,7 @@ if test "$PHP_XML" != "no"; then
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:98151: checking for xml2-config path" >&5
+echo "configure:97582: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -98305,7 +97736,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:98309: checking whether libxml build works" >&5
+echo "configure:97740: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -98321,7 +97752,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 98325 "configure"
+#line 97756 "configure"
 #include "confdefs.h"
 
     
@@ -98332,7 +97763,7 @@ else
     }
   
 EOF
-if { (eval echo configure:98336: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:97767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -98868,7 +98299,7 @@ fi
 php_enable_xmlreader=yes
 
 echo $ac_n "checking whether to enable XMLReader support""... $ac_c" 1>&6
-echo "configure:98872: checking whether to enable XMLReader support" >&5
+echo "configure:98303: checking whether to enable XMLReader support" >&5
 # Check whether --enable-xmlreader or --disable-xmlreader was given.
 if test "${enable_xmlreader+set}" = set; then
   enableval="$enable_xmlreader"
@@ -98876,10 +98307,7 @@ if test "${enable_xmlreader+set}" = set; then
 else
   
   PHP_XMLREADER=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_XMLREADER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_XMLREADER=$PHP_ENABLE_ALL
 
 fi
 
@@ -98916,7 +98344,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:98920: checking libxml2 install dir" >&5
+echo "configure:98348: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -98924,10 +98352,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -98947,7 +98372,7 @@ if test "$PHP_XMLREADER" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:98951: checking for xml2-config path" >&5
+echo "configure:98376: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -99105,7 +98530,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:99109: checking whether libxml build works" >&5
+echo "configure:98534: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -99121,7 +98546,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 99125 "configure"
+#line 98550 "configure"
 #include "confdefs.h"
 
     
@@ -99132,7 +98557,7 @@ else
     }
   
 EOF
-if { (eval echo configure:99136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:98561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -99514,7 +98939,7 @@ fi
 php_with_xmlrpc=no
 
 echo $ac_n "checking for XMLRPC-EPI support""... $ac_c" 1>&6
-echo "configure:99518: checking for XMLRPC-EPI support" >&5
+echo "configure:98943: checking for XMLRPC-EPI support" >&5
 # Check whether --with-xmlrpc or --without-xmlrpc was given.
 if test "${with_xmlrpc+set}" = set; then
   withval="$with_xmlrpc"
@@ -99522,10 +98947,7 @@ if test "${with_xmlrpc+set}" = set; then
 else
   
   PHP_XMLRPC=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_XMLRPC=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_XMLRPC=$PHP_ENABLE_ALL
 
 fi
 
@@ -99562,7 +98984,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:99566: checking libxml2 install dir" >&5
+echo "configure:98988: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -99570,10 +98992,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -99589,7 +99008,7 @@ fi
 php_with_libexpat_dir=no
 
 echo $ac_n "checking libexpat dir for XMLRPC-EPI""... $ac_c" 1>&6
-echo "configure:99593: checking libexpat dir for XMLRPC-EPI" >&5
+echo "configure:99012: checking libexpat dir for XMLRPC-EPI" >&5
 # Check whether --with-libexpat-dir or --without-libexpat-dir was given.
 if test "${with_libexpat_dir+set}" = set; then
   withval="$with_libexpat_dir"
@@ -99597,10 +99016,7 @@ if test "${with_libexpat_dir+set}" = set; then
 else
   
   PHP_LIBEXPAT_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBEXPAT_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -99615,7 +99031,7 @@ echo "$ac_t""$ext_output" 1>&6
 php_with_iconv_dir=no
 
 echo $ac_n "checking iconv dir for XMLRPC-EPI""... $ac_c" 1>&6
-echo "configure:99619: checking iconv dir for XMLRPC-EPI" >&5
+echo "configure:99035: checking iconv dir for XMLRPC-EPI" >&5
 # Check whether --with-iconv-dir or --without-iconv-dir was given.
 if test "${with_iconv_dir+set}" = set; then
   withval="$with_iconv_dir"
@@ -99623,10 +99039,7 @@ if test "${with_iconv_dir+set}" = set; then
 else
   
   PHP_ICONV_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ICONV_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -99674,7 +99087,7 @@ EOF
 
     
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:99678: checking for xml2-config path" >&5
+echo "configure:99091: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -99832,7 +99245,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:99836: checking whether libxml build works" >&5
+echo "configure:99249: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -99848,7 +99261,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 99852 "configure"
+#line 99265 "configure"
 #include "confdefs.h"
 
     
@@ -99859,7 +99272,7 @@ else
     }
   
 EOF
-if { (eval echo configure:99863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:99276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -100128,12 +99541,12 @@ EOF
 
         if test "$PHP_ICONV" = "yes"; then
     echo $ac_n "checking for iconv""... $ac_c" 1>&6
-echo "configure:100132: checking for iconv" >&5
+echo "configure:99545: checking for iconv" >&5
 if eval "test \"`echo '$''{'ac_cv_func_iconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 100137 "configure"
+#line 99550 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char iconv(); below.  */
@@ -100156,7 +99569,7 @@ iconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:100160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:99573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_iconv=yes"
 else
@@ -100177,12 +99590,12 @@ else
   echo "$ac_t""no" 1>&6
 
       echo $ac_n "checking for libiconv""... $ac_c" 1>&6
-echo "configure:100181: checking for libiconv" >&5
+echo "configure:99594: checking for libiconv" >&5
 if eval "test \"`echo '$''{'ac_cv_func_libiconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 100186 "configure"
+#line 99599 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char libiconv(); below.  */
@@ -100205,7 +99618,7 @@ libiconv();
 
 ; return 0; }
 EOF
-if { (eval echo configure:100209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:99622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_libiconv=yes"
 else
@@ -100361,7 +99774,7 @@ EOF
   done
 
   echo $ac_n "checking for libiconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:100365: checking for libiconv in -l$iconv_lib_name" >&5
+echo "configure:99778: checking for libiconv in -l$iconv_lib_name" >&5
 ac_lib_var=`echo $iconv_lib_name'_'libiconv | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -100369,7 +99782,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 100373 "configure"
+#line 99786 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -100380,7 +99793,7 @@ int main() {
 libiconv()
 ; return 0; }
 EOF
-if { (eval echo configure:100384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:99797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -100521,7 +99934,7 @@ else
   done
 
   echo $ac_n "checking for iconv in -l$iconv_lib_name""... $ac_c" 1>&6
-echo "configure:100525: checking for iconv in -l$iconv_lib_name" >&5
+echo "configure:99938: checking for iconv in -l$iconv_lib_name" >&5
 ac_lib_var=`echo $iconv_lib_name'_'iconv | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -100529,7 +99942,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$iconv_lib_name  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 100533 "configure"
+#line 99946 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -100540,7 +99953,7 @@ int main() {
 iconv()
 ; return 0; }
 EOF
-if { (eval echo configure:100544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:99957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -100730,7 +100143,7 @@ if test "$PHP_XMLRPC" = "yes"; then
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:100734: checking for $ac_word" >&5
+echo "configure:100147: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -100758,21 +100171,21 @@ else
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:100762: checking for inline" >&5
+echo "configure:100175: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 100769 "configure"
+#line 100182 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:100776: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:100189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -100810,12 +100223,12 @@ EOF
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:100814: checking for ANSI C header files" >&5
+echo "configure:100227: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 100819 "configure"
+#line 100232 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -100823,7 +100236,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:100827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:100240: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -100840,7 +100253,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 100844 "configure"
+#line 100257 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -100858,7 +100271,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 100862 "configure"
+#line 100275 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -100879,7 +100292,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 100883 "configure"
+#line 100296 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -100890,7 +100303,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:100894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:100307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -100917,17 +100330,17 @@ for ac_hdr in xmlparse.h xmltok.h stdlib.h strings.h string.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:100921: checking for $ac_hdr" >&5
+echo "configure:100334: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 100926 "configure"
+#line 100339 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:100931: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:100344: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -100959,7 +100372,7 @@ done
 
 
 echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:100963: checking size of char" >&5
+echo "configure:100376: checking size of char" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -100967,7 +100380,7 @@ else
   ac_cv_sizeof_char=1
 else
   cat > conftest.$ac_ext <<EOF
-#line 100971 "configure"
+#line 100384 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -100978,7 +100391,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:100982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:100395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_char=`cat conftestval`
 else
@@ -100999,7 +100412,7 @@ EOF
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:101003: checking size of int" >&5
+echo "configure:100416: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -101007,7 +100420,7 @@ else
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 101011 "configure"
+#line 100424 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -101018,7 +100431,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:101022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:100435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -101038,7 +100451,7 @@ EOF
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:101042: checking size of long" >&5
+echo "configure:100455: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -101046,7 +100459,7 @@ else
   ac_cv_sizeof_long=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 101050 "configure"
+#line 100463 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -101057,7 +100470,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:101061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:100474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -101077,7 +100490,7 @@ EOF
 
 
 echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:101081: checking size of long long" >&5
+echo "configure:100494: checking size of long long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -101085,7 +100498,7 @@ else
   ac_cv_sizeof_long_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 101089 "configure"
+#line 100502 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main()
@@ -101096,7 +100509,7 @@ int main()
   return(0);
 }
 EOF
-if { (eval echo configure:101100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:100513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long_long=`cat conftestval`
 else
@@ -101116,12 +100529,12 @@ EOF
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:101120: checking for size_t" >&5
+echo "configure:100533: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 101125 "configure"
+#line 100538 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -101149,12 +100562,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:101153: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:100566: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 101158 "configure"
+#line 100571 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -101163,7 +100576,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:101167: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:100580: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -101184,12 +100597,12 @@ EOF
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:101188: checking for uid_t in sys/types.h" >&5
+echo "configure:100601: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 101193 "configure"
+#line 100606 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -101229,12 +100642,12 @@ for ac_func in \
  memcpy memmove
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:101233: checking for $ac_func" >&5
+echo "configure:100646: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 101238 "configure"
+#line 100651 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -101257,7 +100670,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:101261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:100674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -101611,7 +101024,7 @@ elif test "$PHP_XMLRPC" != "no"; then
     XMLRPC_DIR=$PHP_XMLRPC/include/xmlrpc-epi
   else
     echo $ac_n "checking for XMLRPC-EPI in default path""... $ac_c" 1>&6
-echo "configure:101615: checking for XMLRPC-EPI in default path" >&5
+echo "configure:101028: checking for XMLRPC-EPI in default path" >&5
     for i in /usr/local /usr; do
       if test -r $i/include/xmlrpc.h; then
         XMLRPC_DIR=$i/include
@@ -102054,7 +101467,7 @@ fi
 php_enable_xmlwriter=yes
 
 echo $ac_n "checking whether to enable XMLWriter support""... $ac_c" 1>&6
-echo "configure:102058: checking whether to enable XMLWriter support" >&5
+echo "configure:101471: checking whether to enable XMLWriter support" >&5
 # Check whether --enable-xmlwriter or --disable-xmlwriter was given.
 if test "${enable_xmlwriter+set}" = set; then
   enableval="$enable_xmlwriter"
@@ -102062,10 +101475,7 @@ if test "${enable_xmlwriter+set}" = set; then
 else
   
   PHP_XMLWRITER=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_XMLWRITER=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_XMLWRITER=$PHP_ENABLE_ALL
 
 fi
 
@@ -102102,7 +101512,7 @@ if test -z "$PHP_LIBXML_DIR"; then
 php_with_libxml_dir=no
 
 echo $ac_n "checking libxml2 install dir""... $ac_c" 1>&6
-echo "configure:102106: checking libxml2 install dir" >&5
+echo "configure:101516: checking libxml2 install dir" >&5
 # Check whether --with-libxml-dir or --without-libxml-dir was given.
 if test "${with_libxml_dir+set}" = set; then
   withval="$with_libxml_dir"
@@ -102110,10 +101520,7 @@ if test "${with_libxml_dir+set}" = set; then
 else
   
   PHP_LIBXML_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_LIBXML_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -102133,7 +101540,7 @@ if test "$PHP_XMLWRITER" != "no"; then
 
   
 echo $ac_n "checking for xml2-config path""... $ac_c" 1>&6
-echo "configure:102137: checking for xml2-config path" >&5
+echo "configure:101544: checking for xml2-config path" >&5
 if eval "test \"`echo '$''{'ac_cv_php_xml2_config_path'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -102291,7 +101698,7 @@ echo "$ac_t""$ac_cv_php_xml2_config_path" 1>&6
 
 
             echo $ac_n "checking whether libxml build works""... $ac_c" 1>&6
-echo "configure:102295: checking whether libxml build works" >&5
+echo "configure:101702: checking whether libxml build works" >&5
 if eval "test \"`echo '$''{'php_cv_libxml_build_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -102307,7 +101714,7 @@ else
   
 else
   cat > conftest.$ac_ext <<EOF
-#line 102311 "configure"
+#line 101718 "configure"
 #include "confdefs.h"
 
     
@@ -102318,7 +101725,7 @@ else
     }
   
 EOF
-if { (eval echo configure:102322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:101729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     LIBS=$old_LIBS
@@ -102668,7 +102075,7 @@ fi
 php_with_xsl=no
 
 echo $ac_n "checking for XSL support""... $ac_c" 1>&6
-echo "configure:102672: checking for XSL support" >&5
+echo "configure:102079: checking for XSL support" >&5
 # Check whether --with-xsl or --without-xsl was given.
 if test "${with_xsl+set}" = set; then
   withval="$with_xsl"
@@ -102676,10 +102083,7 @@ if test "${with_xsl+set}" = set; then
 else
   
   PHP_XSL=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_XSL=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_XSL=$PHP_ENABLE_ALL
 
 fi
 
@@ -102871,7 +102275,7 @@ if test "$PHP_XSL" != "no"; then
 
       
       echo $ac_n "checking for EXSLT support""... $ac_c" 1>&6
-echo "configure:102875: checking for EXSLT support" >&5
+echo "configure:102279: checking for EXSLT support" >&5
       for i in $PHP_XSL /usr/local /usr; do
         if test -r "$i/include/libexslt/exslt.h"; then
           PHP_XSL_EXSL_DIR=$i
@@ -103347,7 +102751,7 @@ fi
 php_enable_zip=no
 
 echo $ac_n "checking for zip archive read/writesupport""... $ac_c" 1>&6
-echo "configure:103351: checking for zip archive read/writesupport" >&5
+echo "configure:102755: checking for zip archive read/writesupport" >&5
 # Check whether --enable-zip or --disable-zip was given.
 if test "${enable_zip+set}" = set; then
   enableval="$enable_zip"
@@ -103355,10 +102759,7 @@ if test "${enable_zip+set}" = set; then
 else
   
   PHP_ZIP=no
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_ZIP=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_ZIP=$PHP_ENABLE_ALL
 
 fi
 
@@ -103395,7 +102796,7 @@ if test -z "$PHP_ZLIB_DIR"; then
 php_with_zlib_dir=no
 
 echo $ac_n "checking for the location of libz""... $ac_c" 1>&6
-echo "configure:103399: checking for the location of libz" >&5
+echo "configure:102800: checking for the location of libz" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -103403,10 +102804,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -103422,7 +102820,7 @@ fi
 php_with_pcre_dir=no
 
 echo $ac_n "checking pcre install prefix""... $ac_c" 1>&6
-echo "configure:103426: checking pcre install prefix" >&5
+echo "configure:102824: checking pcre install prefix" >&5
 # Check whether --with-pcre-dir or --without-pcre-dir was given.
 if test "${with_pcre_dir+set}" = set; then
   withval="$with_pcre_dir"
@@ -103430,10 +102828,7 @@ if test "${with_pcre_dir+set}" = set; then
 else
   
   PHP_PCRE_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_PCRE_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -103469,7 +102864,7 @@ if test "$PHP_ZIP" != "no"; then
   fi
 
     echo $ac_n "checking for the location of zlib""... $ac_c" 1>&6
-echo "configure:103473: checking for the location of zlib" >&5
+echo "configure:102868: checking for the location of zlib" >&5
   if test "$PHP_ZLIB_DIR" = "no"; then
     { echo "configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located" 1>&2; exit 1; }
   else
@@ -103607,7 +103002,7 @@ echo "configure:103473: checking for the location of zlib" >&5
     old_CPPFLAGS=$CPPFLAGS
   CPPFLAGS=$INCLUDES
   cat > conftest.$ac_ext <<EOF
-#line 103611 "configure"
+#line 103006 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -103626,7 +103021,7 @@ else
   rm -rf conftest*
   
     cat > conftest.$ac_ext <<EOF
-#line 103630 "configure"
+#line 103025 "configure"
 #include "confdefs.h"
 
 #include <main/php_config.h>
@@ -103994,7 +103389,7 @@ fi
 php_enable_disable_mysqlnd_compression_support=yes
 
 echo $ac_n "checking whether to disable compressed protocol support in mysqlnd""... $ac_c" 1>&6
-echo "configure:103998: checking whether to disable compressed protocol support in mysqlnd" >&5
+echo "configure:103393: checking whether to disable compressed protocol support in mysqlnd" >&5
 # Check whether --enable-disable_mysqlnd_compression_support or --disable-disable_mysqlnd_compression_support was given.
 if test "${enable_disable_mysqlnd_compression_support+set}" = set; then
   enableval="$enable_disable_mysqlnd_compression_support"
@@ -104002,10 +103397,7 @@ if test "${enable_disable_mysqlnd_compression_support+set}" = set; then
 else
   
   PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=yes
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_DISABLE_MYSQLND_COMPRESSION_SUPPORT=$PHP_ENABLE_ALL
 
 fi
 
@@ -104042,7 +103434,7 @@ if test -z "$PHP_ZLIB_DIR"; then
 php_with_zlib_dir=no
 
 echo $ac_n "checking for the location of libz""... $ac_c" 1>&6
-echo "configure:104046: checking for the location of libz" >&5
+echo "configure:103438: checking for the location of libz" >&5
 # Check whether --with-zlib-dir or --without-zlib-dir was given.
 if test "${with_zlib_dir+set}" = set; then
   withval="$with_zlib_dir"
@@ -104050,10 +103442,7 @@ if test "${with_zlib_dir+set}" = set; then
 else
   
   PHP_ZLIB_DIR=no
-
-  if test "$PHP_ENABLE_ALL" && test "no" = "yes"; then
-    PHP_ZLIB_DIR=$PHP_ENABLE_ALL
-  fi
+  
 
 fi
 
@@ -104390,11 +103779,11 @@ EOF
 
   
   if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then
-    cat >> confdefs.h <<\EOF
+    if test -z "$PHP_ZLIB_DIR"; then
+      cat >> confdefs.h <<\EOF
 #define MYSQLND_COMPRESSION_ENABLED 1
 EOF
 
-    if test "$PHP_ZLIB_DIR" != "no"; then
       
 
   if test "$ext_shared" = "yes"; then
@@ -104493,31 +103882,6 @@ EOF
 
 
       MYSQLND_LIBS="$MYSQLND_LIBS -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz"
-    else
-      
-  
-  case z in
-  c|c_r|pthread*) ;;
-  *) 
-    if test "$ext_shared" = "yes"; then
-        MYSQLND_SHARED_LIBADD="-lz $MYSQLND_SHARED_LIBADD" 
-    else
-      
-  
-  case z in
-  c|c_r|pthread*) ;;
-  *) 
-      LIBS="-lz $LIBS" 
-   ;;
-  esac
-
-
-    fi
-   ;;
-  esac
-
-
-      MYSQLND_LIBS="$MYSQLND_LIBS -lz"
     fi
   fi
   cat >> confdefs.h <<\EOF
@@ -104536,7 +103900,7 @@ if test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
     
   for php_typename in int8 uint8 int16 uint16 int32 uint32 uchar ulong int8_t uint8_t int16_t uint16_t int32_t uint32_t int64_t uint64_t; do
     echo $ac_n "checking whether $php_typename exists""... $ac_c" 1>&6
-echo "configure:104540: checking whether $php_typename exists" >&5
+echo "configure:103904: checking whether $php_typename exists" >&5
     
   php_cache_value=php_cv_sizeof_$php_typename
   if eval "test \"`echo '$''{'php_cv_sizeof_$php_typename'+set}'`\" = set"; then
@@ -104553,7 +103917,7 @@ else
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 104557 "configure"
+#line 103921 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 #if STDC_HEADERS
@@ -104583,7 +103947,7 @@ int main()
 }
   
 EOF
-if { (eval echo configure:104587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:103951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     eval $php_cache_value=`cat conftestval`
@@ -104723,7 +104087,7 @@ if test "$PHP_RECODE" != "no"; then
   done
 
   echo $ac_n "checking for hash_insert in -l$MYSQL_LIBNAME""... $ac_c" 1>&6
-echo "configure:104727: checking for hash_insert in -l$MYSQL_LIBNAME" >&5
+echo "configure:104091: checking for hash_insert in -l$MYSQL_LIBNAME" >&5
 ac_lib_var=`echo $MYSQL_LIBNAME'_'hash_insert | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -104731,7 +104095,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$MYSQL_LIBNAME  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 104735 "configure"
+#line 104099 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -104742,7 +104106,7 @@ int main() {
 hash_insert()
 ; return 0; }
 EOF
-if { (eval echo configure:104746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -104844,7 +104208,7 @@ fi
 php_with_pear=DEFAULT
 
 echo $ac_n "checking whether to install PEAR""... $ac_c" 1>&6
-echo "configure:104848: checking whether to install PEAR" >&5
+echo "configure:104212: checking whether to install PEAR" >&5
 # Check whether --with-pear or --without-pear was given.
 if test "${with_pear+set}" = set; then
   withval="$with_pear"
@@ -104852,10 +104216,7 @@ if test "${with_pear+set}" = set; then
 else
   
   PHP_PEAR=DEFAULT
-
-  if test "$PHP_ENABLE_ALL" && test "yes" = "yes"; then
-    PHP_PEAR=$PHP_ENABLE_ALL
-  fi
+  test "$PHP_ENABLE_ALL" && PHP_PEAR=$PHP_ENABLE_ALL
 
 fi
 
@@ -104941,7 +104302,7 @@ fi
 
 
   # we only support certain bison versions
-  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2"
+  bison_version_list="1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3"
 
   # for standalone build of Zend Engine
   test -z "$SED" && SED=sed
@@ -104949,7 +104310,7 @@ fi
   bison_version=none
   if test "$YACC"; then
     echo $ac_n "checking for bison version""... $ac_c" 1>&6
-echo "configure:104953: checking for bison version" >&5
+echo "configure:104314: checking for bison version" >&5
 if eval "test \"`echo '$''{'php_cv_bison_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105005,17 +104366,17 @@ dlfcn.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:105009: checking for $ac_hdr" >&5
+echo "configure:104370: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105014 "configure"
+#line 104375 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:105019: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:104380: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -105043,12 +104404,12 @@ done
 
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:105047: checking for size_t" >&5
+echo "configure:104408: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105052 "configure"
+#line 104413 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -105076,12 +104437,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:105080: checking return type of signal handlers" >&5
+echo "configure:104441: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105085 "configure"
+#line 104446 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -105098,7 +104459,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:105102: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:104463: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -105122,12 +104483,12 @@ EOF
 
 
 echo $ac_n "checking for uint""... $ac_c" 1>&6
-echo "configure:105126: checking for uint" >&5
+echo "configure:104487: checking for uint" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uint'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105131 "configure"
+#line 104492 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -105155,12 +104516,12 @@ EOF
 fi
 
 echo $ac_n "checking for ulong""... $ac_c" 1>&6
-echo "configure:105159: checking for ulong" >&5
+echo "configure:104520: checking for ulong" >&5
 if eval "test \"`echo '$''{'ac_cv_type_ulong'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105164 "configure"
+#line 104525 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -105190,9 +104551,9 @@ fi
 
 
 echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:105194: checking for int32_t" >&5
+echo "configure:104555: checking for int32_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 105196 "configure"
+#line 104557 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H  
@@ -105211,7 +104572,7 @@ if (sizeof (int32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:105215: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:104576: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   cat >> confdefs.h <<EOF
@@ -105230,9 +104591,9 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:105234: checking for uint32_t" >&5
+echo "configure:104595: checking for uint32_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 105236 "configure"
+#line 104597 "configure"
 #include "confdefs.h"
 
 #if HAVE_SYS_TYPES_H  
@@ -105251,7 +104612,7 @@ if (sizeof (uint32_t))
 
 ; return 0; }
 EOF
-if { (eval echo configure:105255: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:104616: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
   cat >> confdefs.h <<EOF
@@ -105270,12 +104631,12 @@ fi
 rm -f conftest*
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:105274: checking for vprintf" >&5
+echo "configure:104635: checking for vprintf" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105279 "configure"
+#line 104640 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char vprintf(); below.  */
@@ -105298,7 +104659,7 @@ vprintf();
 
 ; return 0; }
 EOF
-if { (eval echo configure:105302: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_vprintf=yes"
 else
@@ -105322,12 +104683,12 @@ fi
 
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:105326: checking for _doprnt" >&5
+echo "configure:104687: checking for _doprnt" >&5
 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105331 "configure"
+#line 104692 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char _doprnt(); below.  */
@@ -105350,7 +104711,7 @@ _doprnt();
 
 ; return 0; }
 EOF
-if { (eval echo configure:105354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func__doprnt=yes"
 else
@@ -105375,7 +104736,7 @@ fi
 fi
 
 echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:105379: checking for 8-bit clean memcmp" >&5
+echo "configure:104740: checking for 8-bit clean memcmp" >&5
 if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105383,7 +104744,7 @@ else
   ac_cv_func_memcmp_clean=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 105387 "configure"
+#line 104748 "configure"
 #include "confdefs.h"
 
 main()
@@ -105393,7 +104754,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:105397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:104758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_memcmp_clean=yes
 else
@@ -105413,19 +104774,19 @@ test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:105417: checking for working alloca.h" >&5
+echo "configure:104778: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105422 "configure"
+#line 104783 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:105429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -105446,12 +104807,12 @@ EOF
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:105450: checking for alloca" >&5
+echo "configure:104811: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105455 "configure"
+#line 104816 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -105479,7 +104840,7 @@ int main() {
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:105483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -105511,12 +104872,12 @@ EOF
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:105515: checking whether alloca needs Cray hooks" >&5
+echo "configure:104876: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105520 "configure"
+#line 104881 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -105541,12 +104902,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:105545: checking for $ac_func" >&5
+echo "configure:104906: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105550 "configure"
+#line 104911 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -105569,7 +104930,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:105573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:104934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -105596,7 +104957,7 @@ done
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:105600: checking stack direction for C alloca" >&5
+echo "configure:104961: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105604,7 +104965,7 @@ else
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 105608 "configure"
+#line 104969 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -105623,7 +104984,7 @@ main ()
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:105627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:104988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -105647,12 +105008,12 @@ fi
 for ac_func in memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:105651: checking for $ac_func" >&5
+echo "configure:105012: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105656 "configure"
+#line 105017 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -105675,7 +105036,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:105679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105040: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -105701,7 +105062,7 @@ done
 
 
   echo $ac_n "checking whether sprintf is broken""... $ac_c" 1>&6
-echo "configure:105705: checking whether sprintf is broken" >&5
+echo "configure:105066: checking whether sprintf is broken" >&5
 if eval "test \"`echo '$''{'ac_cv_broken_sprintf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -105712,11 +105073,11 @@ else
     
 else
   cat > conftest.$ac_ext <<EOF
-#line 105716 "configure"
+#line 105077 "configure"
 #include "confdefs.h"
 main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }
 EOF
-if { (eval echo configure:105720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:105081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
       ac_cv_broken_sprintf=no
@@ -105750,12 +105111,12 @@ EOF
 for ac_func in finite isfinite isinf isnan
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:105754: checking for $ac_func" >&5
+echo "configure:105115: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 105759 "configure"
+#line 105120 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -105778,7 +105139,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:105782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -105805,13 +105166,13 @@ done
 
 
   echo $ac_n "checking whether fp_except is defined""... $ac_c" 1>&6
-echo "configure:105809: checking whether fp_except is defined" >&5
+echo "configure:105170: checking whether fp_except is defined" >&5
 if eval "test \"`echo '$''{'ac_cv_type_fp_except'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
     cat > conftest.$ac_ext <<EOF
-#line 105815 "configure"
+#line 105176 "configure"
 #include "confdefs.h"
 
 #include <floatingpoint.h>
@@ -105822,7 +105183,7 @@ fp_except x = (fp_except) 0;
 
 ; return 0; }
 EOF
-if { (eval echo configure:105826: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:105187: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
      ac_cv_type_fp_except=yes
@@ -105849,9 +105210,9 @@ EOF
 
 
   echo $ac_n "checking for usable _FPU_SETCW""... $ac_c" 1>&6
-echo "configure:105853: checking for usable _FPU_SETCW" >&5
+echo "configure:105214: checking for usable _FPU_SETCW" >&5
   cat > conftest.$ac_ext <<EOF
-#line 105855 "configure"
+#line 105216 "configure"
 #include "confdefs.h"
 
     #include <fpu_control.h>
@@ -105871,7 +105232,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:105875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have__fpu_setcw=yes
 else
@@ -105892,9 +105253,9 @@ EOF
   fi
   
   echo $ac_n "checking for usable fpsetprec""... $ac_c" 1>&6
-echo "configure:105896: checking for usable fpsetprec" >&5
+echo "configure:105257: checking for usable fpsetprec" >&5
   cat > conftest.$ac_ext <<EOF
-#line 105898 "configure"
+#line 105259 "configure"
 #include "confdefs.h"
 
     #include <machine/ieeefp.h>
@@ -105913,7 +105274,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:105917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have_fpsetprec=yes
 else
@@ -105934,9 +105295,9 @@ EOF
   fi
 
   echo $ac_n "checking for usable _controlfp""... $ac_c" 1>&6
-echo "configure:105938: checking for usable _controlfp" >&5
+echo "configure:105299: checking for usable _controlfp" >&5
   cat > conftest.$ac_ext <<EOF
-#line 105940 "configure"
+#line 105301 "configure"
 #include "confdefs.h"
 
     #include <float.h>
@@ -105955,7 +105316,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:105959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have__controlfp=yes
 else
@@ -105976,9 +105337,9 @@ EOF
   fi
 
   echo $ac_n "checking for usable _controlfp_s""... $ac_c" 1>&6
-echo "configure:105980: checking for usable _controlfp_s" >&5
+echo "configure:105341: checking for usable _controlfp_s" >&5
   cat > conftest.$ac_ext <<EOF
-#line 105982 "configure"
+#line 105343 "configure"
 #include "confdefs.h"
 
    #include <float.h>
@@ -105998,7 +105359,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:106002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have__controlfp_s=yes
 else
@@ -106019,9 +105380,9 @@ EOF
   fi
 
   echo $ac_n "checking whether FPU control word can be manipulated by inline assembler""... $ac_c" 1>&6
-echo "configure:106023: checking whether FPU control word can be manipulated by inline assembler" >&5
+echo "configure:105384: checking whether FPU control word can be manipulated by inline assembler" >&5
   cat > conftest.$ac_ext <<EOF
-#line 106025 "configure"
+#line 105386 "configure"
 #include "confdefs.h"
 
     /* nothing */
@@ -106043,7 +105404,7 @@ int main() {
   
 ; return 0; }
 EOF
-if { (eval echo configure:106047: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:105408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cfp_have_fpu_inline_asm_x86=yes
 else
@@ -106065,7 +105426,7 @@ EOF
 
 
 echo $ac_n "checking whether double cast to long preserves least significant bits""... $ac_c" 1>&6
-echo "configure:106069: checking whether double cast to long preserves least significant bits" >&5
+echo "configure:105430: checking whether double cast to long preserves least significant bits" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -106073,7 +105434,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 106077 "configure"
+#line 105438 "configure"
 #include "confdefs.h"
 
 #include <limits.h>
@@ -106097,7 +105458,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:106101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:105462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -106123,17 +105484,17 @@ for ac_hdr in dlfcn.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:106127: checking for $ac_hdr" >&5
+echo "configure:105488: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 106132 "configure"
+#line 105493 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:106137: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:105498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -106161,14 +105522,14 @@ done
 
 
 echo $ac_n "checking whether dlsym() requires a leading underscore in symbol names""... $ac_c" 1>&6
-echo "configure:106165: checking whether dlsym() requires a leading underscore in symbol names" >&5
+echo "configure:105526: checking whether dlsym() requires a leading underscore in symbol names" >&5
 if test "$cross_compiling" = yes; then :
   
 else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 106172 "configure"
+#line 105533 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -106231,7 +105592,7 @@ int main ()
     exit (status);
 }
 EOF
-  if { (eval echo configure:106235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:105596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -106314,23 +105675,23 @@ fi
 
 
 echo $ac_n "checking virtual machine dispatch method""... $ac_c" 1>&6
-echo "configure:106318: checking virtual machine dispatch method" >&5
+echo "configure:105679: checking virtual machine dispatch method" >&5
 echo "$ac_t""$PHP_ZEND_VM" 1>&6
 
 echo $ac_n "checking whether to enable thread-safety""... $ac_c" 1>&6
-echo "configure:106322: checking whether to enable thread-safety" >&5
+echo "configure:105683: checking whether to enable thread-safety" >&5
 echo "$ac_t""$ZEND_MAINTAINER_ZTS" 1>&6
 
 echo $ac_n "checking whether to enable inline optimization for GCC""... $ac_c" 1>&6
-echo "configure:106326: checking whether to enable inline optimization for GCC" >&5
+echo "configure:105687: checking whether to enable inline optimization for GCC" >&5
 echo "$ac_t""$ZEND_INLINE_OPTIMIZATION" 1>&6
 
 echo $ac_n "checking whether to enable Zend debugging""... $ac_c" 1>&6
-echo "configure:106330: checking whether to enable Zend debugging" >&5
+echo "configure:105691: checking whether to enable Zend debugging" >&5
 echo "$ac_t""$ZEND_DEBUG" 1>&6
 
 echo $ac_n "checking whether to enable Zend multibyte""... $ac_c" 1>&6
-echo "configure:106334: checking whether to enable Zend multibyte" >&5
+echo "configure:105695: checking whether to enable Zend multibyte" >&5
 echo "$ac_t""$ZEND_MULTIBYTE" 1>&6
 
 case $PHP_ZEND_VM in
@@ -106403,21 +105764,21 @@ fi
 
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:106407: checking for inline" >&5
+echo "configure:105768: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 106414 "configure"
+#line 105775 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:106421: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:105782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -106446,7 +105807,7 @@ esac
 
 
 echo $ac_n "checking target system is Darwin""... $ac_c" 1>&6
-echo "configure:106450: checking target system is Darwin" >&5
+echo "configure:105811: checking target system is Darwin" >&5
 if echo "$target" | grep "darwin" > /dev/null; then
   cat >> confdefs.h <<\EOF
 #define DARWIN 1
@@ -106458,7 +105819,7 @@ else
 fi
 
 echo $ac_n "checking for MM alignment and log values""... $ac_c" 1>&6
-echo "configure:106462: checking for MM alignment and log values" >&5
+echo "configure:105823: checking for MM alignment and log values" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -106466,7 +105827,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 106470 "configure"
+#line 105831 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -106502,7 +105863,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:106506: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:105867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   LIBZEND_MM_ALIGN=`cat conftest.zend | cut -d ' ' -f 1`
@@ -106527,7 +105888,7 @@ fi
 echo "$ac_t""done" 1>&6
 
 echo $ac_n "checking for memory allocation using mmap(MAP_ANON)""... $ac_c" 1>&6
-echo "configure:106531: checking for memory allocation using mmap(MAP_ANON)" >&5
+echo "configure:105892: checking for memory allocation using mmap(MAP_ANON)" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -106535,7 +105896,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 106539 "configure"
+#line 105900 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -106571,7 +105932,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:106575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:105936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -106593,7 +105954,7 @@ fi
 
 
 echo $ac_n "checking for memory allocation using mmap("/dev/zero")""... $ac_c" 1>&6
-echo "configure:106597: checking for memory allocation using mmap("/dev/zero")" >&5
+echo "configure:105958: checking for memory allocation using mmap("/dev/zero")" >&5
 
 if test "$cross_compiling" = yes; then
   
@@ -106601,7 +105962,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 106605 "configure"
+#line 105966 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -106647,7 +106008,7 @@ int main()
 }
 
 EOF
-if { (eval echo configure:106651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:106012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   cat >> confdefs.h <<\EOF
@@ -106671,12 +106032,12 @@ fi
 for ac_func in mremap
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:106675: checking for $ac_func" >&5
+echo "configure:106036: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 106680 "configure"
+#line 106041 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -106699,7 +106060,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:106703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:106064: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -106766,17 +106127,17 @@ for ac_hdr in stdarg.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:106770: checking for $ac_hdr" >&5
+echo "configure:106131: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 106775 "configure"
+#line 106136 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:106780: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:106141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -106853,7 +106214,7 @@ if test "$TSRM_PTH" != "no"; then
   
 
 echo $ac_n "checking for GNU Pth""... $ac_c" 1>&6
-echo "configure:106857: checking for GNU Pth" >&5
+echo "configure:106218: checking for GNU Pth" >&5
 PTH_PREFIX="`$TSRM_PTH --prefix`"
 if test -z "$PTH_PREFIX"; then
   echo "$ac_t""Please check your Pth installation" 1>&6
@@ -106883,17 +106244,17 @@ elif test "$TSRM_ST" != "no"; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:106887: checking for $ac_hdr" >&5
+echo "configure:106248: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 106892 "configure"
+#line 106253 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:106897: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:106258: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -106923,7 +106284,7 @@ done
 
   LIBS="$LIBS -lst"
   echo $ac_n "checking for SGI's State Threads""... $ac_c" 1>&6
-echo "configure:106927: checking for SGI's State Threads" >&5
+echo "configure:106288: checking for SGI's State Threads" >&5
   echo "$ac_t""yes" 1>&6
   cat >> confdefs.h <<\EOF
 #define TSRM_ST 1
@@ -106962,7 +106323,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 106966 "configure"
+#line 106327 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -106980,7 +106341,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:106984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:106345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -107000,7 +106361,7 @@ fi
   CFLAGS=$save_CFLAGS
 
   echo $ac_n "checking for pthreads_cflags""... $ac_c" 1>&6
-echo "configure:107004: checking for pthreads_cflags" >&5
+echo "configure:106365: checking for pthreads_cflags" >&5
 if eval "test \"`echo '$''{'ac_cv_pthreads_cflags'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -107022,7 +106383,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 107026 "configure"
+#line 106387 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -107040,7 +106401,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:107044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:106405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -107070,7 +106431,7 @@ fi
 echo "$ac_t""$ac_cv_pthreads_cflags" 1>&6
 
 echo $ac_n "checking for pthreads_lib""... $ac_c" 1>&6
-echo "configure:107074: checking for pthreads_lib" >&5
+echo "configure:106435: checking for pthreads_lib" >&5
 if eval "test \"`echo '$''{'ac_cv_pthreads_lib'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -107092,7 +106453,7 @@ if test "$cross_compiling" = yes; then
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 107096 "configure"
+#line 106457 "configure"
 #include "confdefs.h"
 
 #include <pthread.h>
@@ -107110,7 +106471,7 @@ int main() {
     return pthread_create(&thd, NULL, thread_routine, &data);
 } 
 EOF
-if { (eval echo configure:107114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:106475: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
   pthreads_working=yes
@@ -107161,7 +106522,7 @@ EOF
 
 
   echo $ac_n "checking for POSIX threads""... $ac_c" 1>&6
-echo "configure:107165: checking for POSIX threads" >&5
+echo "configure:106526: checking for POSIX threads" >&5
   echo "$ac_t""yes" 1>&6
 fi
 
@@ -107714,8 +107075,8 @@ LDFLAGS="$LDFLAGS $PHP_AIX_LDFLAGS"
 
 case $host_alias in
 *darwin9*|*darwin10*)
-	ac_cv_exeext=
-	;;
+  ac_cv_exeext=
+  ;;
 esac
 
 
@@ -107795,7 +107156,7 @@ fi
 
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:107799: checking build system type" >&5
+echo "configure:107160: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -107824,7 +107185,7 @@ ac_prog=ld
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by $CC""... $ac_c" 1>&6
-echo "configure:107828: checking for ld used by $CC" >&5
+echo "configure:107189: checking for ld used by $CC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -107854,10 +107215,10 @@ echo "configure:107828: checking for ld used by $CC" >&5
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:107858: checking for GNU ld" >&5
+echo "configure:107219: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:107861: checking for non-GNU ld" >&5
+echo "configure:107222: checking for non-GNU ld" >&5
 fi
 if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -107896,7 +107257,7 @@ else
 fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:107900: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:107261: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -107916,7 +107277,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
 echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6
-echo "configure:107920: checking for $LD option to reload object files" >&5
+echo "configure:107281: checking for $LD option to reload object files" >&5
 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -107941,7 +107302,7 @@ case $host_os in
 esac
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:107945: checking for BSD-compatible nm" >&5
+echo "configure:107306: checking for BSD-compatible nm" >&5
 if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -107994,7 +107355,7 @@ echo "$ac_t""$lt_cv_path_NM" 1>&6
 NM="$lt_cv_path_NM"
 
 echo $ac_n "checking how to recognize dependent libraries""... $ac_c" 1>&6
-echo "configure:107998: checking how to recognize dependent libraries" >&5
+echo "configure:107359: checking how to recognize dependent libraries" >&5
 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108186,13 +107547,13 @@ deplibs_check_method=$lt_cv_deplibs_check_method
 test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:108190: checking for object suffix" >&5
+echo "configure:107551: checking for object suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   rm -f conftest*
 echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:108196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:107557: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   for ac_file in conftest.*; do
     case $ac_file in
     *.c) ;;
@@ -108212,7 +107573,7 @@ ac_objext=$ac_cv_objext
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:108216: checking for executable suffix" >&5
+echo "configure:107577: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108222,7 +107583,7 @@ else
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:108226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:107587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
       *.c | *.o | *.obj) ;;
@@ -108268,7 +107629,7 @@ case $host in
 ia64-*-hpux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:108272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:107633: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.$ac_objext` in
     *ELF-32*)
       HPUX_IA64_MODE="32"
@@ -108282,8 +107643,8 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 108286 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:108287: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 107647 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:107648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    if test "$lt_cv_prog_gnu_ld" = yes; then
     case `/usr/bin/file conftest.$ac_objext` in
     *32-bit*)
@@ -108317,7 +107678,7 @@ x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 s390*-*linux*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:108321: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:107682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.o` in
     *32-bit*)
       case $host in
@@ -108367,7 +107728,7 @@ s390*-*linux*|sparc*-*linux*)
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:108371: checking whether the C compiler needs -belf" >&5
+echo "configure:107732: checking whether the C compiler needs -belf" >&5
 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108380,14 +107741,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
 cross_compiling=$ac_cv_prog_cc_cross
 
      cat > conftest.$ac_ext <<EOF
-#line 108384 "configure"
+#line 107745 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:108391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:107752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_needs_belf=yes
 else
@@ -108415,7 +107776,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
 sparc*-*solaris*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
-  if { (eval echo configure:108419: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:107780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case `/usr/bin/file conftest.o` in
     *64-bit*)
       case $lt_cv_prog_gnu_ld in
@@ -108444,7 +107805,7 @@ if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
     ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
     (test "X$CXX" != "Xg++"))) ; then
   echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
-echo "configure:108448: checking how to run the C++ preprocessor" >&5
+echo "configure:107809: checking how to run the C++ preprocessor" >&5
 if test -z "$CXXCPP"; then
 if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -108457,12 +107818,12 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
 cross_compiling=$ac_cv_prog_cxx_cross
   CXXCPP="${CXX-g++} -E"
   cat > conftest.$ac_ext <<EOF
-#line 108461 "configure"
+#line 107822 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:108466: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:107827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -108492,7 +107853,7 @@ fi
 # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
 # find the maximum length of command line arguments
 echo $ac_n "checking the maximum length of command line arguments""... $ac_c" 1>&6
-echo "configure:108496: checking the maximum length of command line arguments" >&5
+echo "configure:107857: checking the maximum length of command line arguments" >&5
 if eval "test \"`echo '$''{'lt_cv_sys_max_cmd_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108614,7 +107975,7 @@ fi
 
 # Check for command to grab the raw symbol name followed by C symbol from nm.
 echo $ac_n "checking command to parse $NM output from $compiler object""... $ac_c" 1>&6
-echo "configure:108618: checking command to parse $NM output from $compiler object" >&5
+echo "configure:107979: checking command to parse $NM output from $compiler object" >&5
 if eval "test \"`echo '$''{'lt_cv_sys_global_symbol_pipe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108718,10 +108079,10 @@ void nm_test_func(){}
 int main(){nm_test_var='a';nm_test_func();return(0);}
 EOF
 
-  if { (eval echo configure:108722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  if { (eval echo configure:108083: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if { (eval echo configure:108725: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then
+    if { (eval echo configure:108086: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\") 1>&5; (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5; } && test -s "$nlist"; then
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
 	mv -f "$nlist"T "$nlist"
@@ -108772,7 +108133,7 @@ EOF
 	  lt_save_CFLAGS="$CFLAGS"
 	  LIBS="conftstm.$ac_objext"
 	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
-	  if { (eval echo configure:108776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+	  if { (eval echo configure:108137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
 	    pipe_works=yes
 	  fi
 	  LIBS="$lt_save_LIBS"
@@ -108812,7 +108173,7 @@ else
 fi
 
 echo $ac_n "checking for objdir""... $ac_c" 1>&6
-echo "configure:108816: checking for objdir" >&5
+echo "configure:108177: checking for objdir" >&5
 if eval "test \"`echo '$''{'lt_cv_objdir'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108878,7 +108239,7 @@ with_gnu_ld="$lt_cv_prog_gnu_ld"
 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:108882: checking for $ac_word" >&5
+echo "configure:108243: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108910,7 +108271,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:108914: checking for $ac_word" >&5
+echo "configure:108275: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108945,7 +108306,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:108949: checking for $ac_word" >&5
+echo "configure:108310: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -108977,7 +108338,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:108981: checking for $ac_word" >&5
+echo "configure:108342: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109012,7 +108373,7 @@ fi
 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109016: checking for $ac_word" >&5
+echo "configure:108377: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109044,7 +108405,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109048: checking for $ac_word" >&5
+echo "configure:108409: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109131,7 +108492,7 @@ case $deplibs_check_method in
 file_magic*)
   if test "$file_magic_cmd" = '$MAGIC_CMD'; then
     echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
-echo "configure:109135: checking for ${ac_tool_prefix}file" >&5
+echo "configure:108496: checking for ${ac_tool_prefix}file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109191,7 +108552,7 @@ fi
 if test -z "$lt_cv_path_MAGIC_CMD"; then
   if test -n "$ac_tool_prefix"; then
     echo $ac_n "checking for file""... $ac_c" 1>&6
-echo "configure:109195: checking for file" >&5
+echo "configure:108556: checking for file" >&5
 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109263,7 +108624,7 @@ esac
     # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
 set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109267: checking for $ac_word" >&5
+echo "configure:108628: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DSYMUTIL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109295,7 +108656,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "dsymutil", so it can be a program name with args.
 set dummy dsymutil; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109299: checking for $ac_word" >&5
+echo "configure:108660: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_DSYMUTIL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109330,7 +108691,7 @@ fi
     # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
 set dummy ${ac_tool_prefix}nmedit; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109334: checking for $ac_word" >&5
+echo "configure:108695: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NMEDIT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109362,7 +108723,7 @@ if test -n "$ac_tool_prefix"; then
   # Extract the first word of "nmedit", so it can be a program name with args.
 set dummy nmedit; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:109366: checking for $ac_word" >&5
+echo "configure:108727: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_NMEDIT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109396,7 +108757,7 @@ fi
 
 
     echo $ac_n "checking for -single_module linker flag""... $ac_c" 1>&6
-echo "configure:109400: checking for -single_module linker flag" >&5
+echo "configure:108761: checking for -single_module linker flag" >&5
 if eval "test \"`echo '$''{'lt_cv_apple_cc_single_mod'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109419,7 +108780,7 @@ fi
 
 echo "$ac_t""$lt_cv_apple_cc_single_mod" 1>&6
     echo $ac_n "checking for -exported_symbols_list linker flag""... $ac_c" 1>&6
-echo "configure:109423: checking for -exported_symbols_list linker flag" >&5
+echo "configure:108784: checking for -exported_symbols_list linker flag" >&5
 if eval "test \"`echo '$''{'lt_cv_ld_exported_symbols_list'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109429,12 +108790,12 @@ else
       LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
       
 cat > conftest.$ac_ext <<EOF
-#line 109433 "configure"
+#line 108794 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:109438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:108799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  lt_cv_ld_exported_symbols_list=yes
   rm -rf conftest*
 else
@@ -109568,7 +108929,7 @@ if test "$GCC" = yes; then
 
   
 echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions""... $ac_c" 1>&6
-echo "configure:109572: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo "configure:108933: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_rtti_exceptions'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109585,11 +108946,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"configure:109589: $lt_compile\"" >&5)
+   (eval echo "\"configure:108950: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:109593: \$? = $ac_status" >&5
+   echo "configure:108954: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -109618,7 +108979,7 @@ lt_prog_compiler_pic=
 lt_prog_compiler_static=
 
 echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6
-echo "configure:109622: checking for $compiler option to produce PIC" >&5
+echo "configure:108983: checking for $compiler option to produce PIC" >&5
  
   if test "$GCC" = yes; then
     lt_prog_compiler_wl='-Wl,'
@@ -109865,7 +109226,7 @@ echo "$ac_t""$lt_prog_compiler_pic" 1>&6
 if test -n "$lt_prog_compiler_pic"; then
   
 echo $ac_n "checking if $compiler PIC flag $lt_prog_compiler_pic works""... $ac_c" 1>&6
-echo "configure:109869: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+echo "configure:109230: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_pic_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109882,11 +109243,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"configure:109886: $lt_compile\"" >&5)
+   (eval echo "\"configure:109247: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:109890: \$? = $ac_status" >&5
+   echo "configure:109251: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -109928,7 +109289,7 @@ esac
 #
 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
 echo $ac_n "checking if $compiler static flag $lt_tmp_static_flag works""... $ac_c" 1>&6
-echo "configure:109932: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo "configure:109293: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_static_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109966,7 +109327,7 @@ fi
 
 
 echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
-echo "configure:109970: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo "configure:109331: checking if $compiler supports -c -o file.$ac_objext" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_c_o'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -109986,11 +109347,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"configure:109990: $lt_compile\"" >&5)
+   (eval echo "\"configure:109351: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "configure:109994: \$? = $ac_status" >&5
+   echo "configure:109355: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -110020,7 +109381,7 @@ hard_links="nottested"
 if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
   # do not overwrite the value of need_locks provided by the user
   echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6
-echo "configure:110024: checking if we can lock with hard links" >&5
+echo "configure:109385: checking if we can lock with hard links" >&5
   hard_links=yes
   $rm conftest*
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
@@ -110037,7 +109398,7 @@ else
 fi
 
 echo $ac_n "checking whether the $compiler linker ($LD) supports shared libraries""... $ac_c" 1>&6
-echo "configure:110041: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:109402: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 
   runpath_var=
   allow_undefined_flag=
@@ -110448,12 +109809,12 @@ _LT_EOF
        # Determine the default libpath from the value encoded in an empty executable.
        
 cat > conftest.$ac_ext <<EOF
-#line 110452 "configure"
+#line 109813 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:110457: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:109818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  
 lt_aix_libpath_sed='
     /Import File Strings/,/^$/ {
@@ -110486,12 +109847,12 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	 # Determine the default libpath from the value encoded in an empty executable.
 	 
 cat > conftest.$ac_ext <<EOF
-#line 110490 "configure"
+#line 109851 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:110495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:109856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  
 lt_aix_libpath_sed='
     /Import File Strings/,/^$/ {
@@ -110981,11 +110342,11 @@ x|xyes)
       # systems, -lgcc has to come before -lc. If gcc already passes -lc
       # to ld, don't add -lc before -lgcc.
       echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6
-echo "configure:110985: checking whether -lc should be explicitly linked in" >&5
+echo "configure:110346: checking whether -lc should be explicitly linked in" >&5
       $rm conftest*
       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo configure:110989: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
+      if { (eval echo configure:110350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
         soname=conftest
         lib=conftest
         libobjs=conftest.$ac_objext
@@ -110999,7 +110360,7 @@ echo "configure:110985: checking whether -lc should be explicitly linked in" >&5
         libname=conftest
         lt_save_allow_undefined_flag=$allow_undefined_flag
         allow_undefined_flag=
-        if { (eval echo configure:111003: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
+        if { (eval echo configure:110364: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
         then
 	  archive_cmds_need_lc=no
         else
@@ -111018,7 +110379,7 @@ echo "configure:110985: checking whether -lc should be explicitly linked in" >&5
 esac
 
 echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
-echo "configure:111022: checking dynamic linker characteristics" >&5
+echo "configure:110383: checking dynamic linker characteristics" >&5
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -111643,7 +111004,7 @@ if test "$GCC" = yes; then
 fi
 
 echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
-echo "configure:111647: checking how to hardcode library paths into programs" >&5
+echo "configure:111008: checking how to hardcode library paths into programs" >&5
 hardcode_action=
 if test -n "$hardcode_libdir_flag_spec" || \
    test -n "$runpath_var" || \
@@ -111681,7 +111042,7 @@ fi
 striplib=
 old_striplib=
 echo $ac_n "checking whether stripping libraries is possible""... $ac_c" 1>&6
-echo "configure:111685: checking whether stripping libraries is possible" >&5
+echo "configure:111046: checking whether stripping libraries is possible" >&5
 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
   test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
   test -z "$striplib" && striplib="$STRIP --strip-unneeded"
@@ -111732,7 +111093,7 @@ else
   darwin*)
   # if libdl is installed we need to link against it
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:111736: checking for dlopen in -ldl" >&5
+echo "configure:111097: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -111740,7 +111101,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 111744 "configure"
+#line 111105 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -111751,7 +111112,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:111755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -111780,12 +111141,12 @@ fi
 
   *)
     echo $ac_n "checking for shl_load""... $ac_c" 1>&6
-echo "configure:111784: checking for shl_load" >&5
+echo "configure:111145: checking for shl_load" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 111789 "configure"
+#line 111150 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shl_load(); below.  */
@@ -111808,7 +111169,7 @@ shl_load();
 
 ; return 0; }
 EOF
-if { (eval echo configure:111812: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shl_load=yes"
 else
@@ -111826,7 +111187,7 @@ if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "configure:111830: checking for shl_load in -ldld" >&5
+echo "configure:111191: checking for shl_load in -ldld" >&5
 ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -111834,7 +111195,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 111838 "configure"
+#line 111199 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -111845,7 +111206,7 @@ int main() {
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo configure:111849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111210: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -111864,12 +111225,12 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:111868: checking for dlopen" >&5
+echo "configure:111229: checking for dlopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 111873 "configure"
+#line 111234 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); below.  */
@@ -111892,7 +111253,7 @@ dlopen();
 
 ; return 0; }
 EOF
-if { (eval echo configure:111896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dlopen=yes"
 else
@@ -111910,7 +111271,7 @@ if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:111914: checking for dlopen in -ldl" >&5
+echo "configure:111275: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -111918,7 +111279,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 111922 "configure"
+#line 111283 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -111929,7 +111290,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:111933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111294: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -111948,7 +111309,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen in -lsvld""... $ac_c" 1>&6
-echo "configure:111952: checking for dlopen in -lsvld" >&5
+echo "configure:111313: checking for dlopen in -lsvld" >&5
 ac_lib_var=`echo svld'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -111956,7 +111317,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsvld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 111960 "configure"
+#line 111321 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -111967,7 +111328,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:111971: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -111986,7 +111347,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
-echo "configure:111990: checking for dld_link in -ldld" >&5
+echo "configure:111351: checking for dld_link in -ldld" >&5
 ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -111994,7 +111355,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 111998 "configure"
+#line 111359 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -112005,7 +111366,7 @@ int main() {
 dld_link()
 ; return 0; }
 EOF
-if { (eval echo configure:112009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:111370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -112061,7 +111422,7 @@ fi
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
     echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
-echo "configure:112065: checking whether a program can dlopen itself" >&5
+echo "configure:111426: checking whether a program can dlopen itself" >&5
 if eval "test \"`echo '$''{'lt_cv_dlopen_self'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -112071,7 +111432,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 112075 "configure"
+#line 111436 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -112134,7 +111495,7 @@ int main ()
     exit (status);
 }
 EOF
-  if { (eval echo configure:112138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:111499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -112157,7 +111518,7 @@ echo "$ac_t""$lt_cv_dlopen_self" 1>&6
     if test "x$lt_cv_dlopen_self" = xyes; then
       wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
       echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
-echo "configure:112161: checking whether a statically linked program can dlopen itself" >&5
+echo "configure:111522: checking whether a statically linked program can dlopen itself" >&5
 if eval "test \"`echo '$''{'lt_cv_dlopen_self_static'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -112167,7 +111528,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 112171 "configure"
+#line 111532 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -112230,7 +111591,7 @@ int main ()
     exit (status);
 }
 EOF
-  if { (eval echo configure:112234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
+  if { (eval echo configure:111595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} 2>/dev/null; then
     (./conftest; exit; ) >&5 2>/dev/null
     lt_status=$?
     case x$lt_status in
@@ -112271,11 +111632,11 @@ fi
 
 # Report which library types will actually be built
 echo $ac_n "checking if libtool supports shared libraries""... $ac_c" 1>&6
-echo "configure:112275: checking if libtool supports shared libraries" >&5
+echo "configure:111636: checking if libtool supports shared libraries" >&5
 echo "$ac_t""$can_build_shared" 1>&6
 
 echo $ac_n "checking whether to build shared libraries""... $ac_c" 1>&6
-echo "configure:112279: checking whether to build shared libraries" >&5
+echo "configure:111640: checking whether to build shared libraries" >&5
 test "$can_build_shared" = "no" && enable_shared=no
 
 # On AIX, shared libraries and static libraries use the same namespace, and
@@ -112298,7 +111659,7 @@ esac
 echo "$ac_t""$enable_shared" 1>&6
 
 echo $ac_n "checking whether to build static libraries""... $ac_c" 1>&6
-echo "configure:112302: checking whether to build static libraries" >&5
+echo "configure:111663: checking whether to build static libraries" >&5
 # Make sure either enable_shared or enable_static is yes.
 test "$enable_shared" = yes || enable_static=yes
 echo "$ac_t""$enable_static" 1>&6
@@ -112984,7 +112345,7 @@ ac_prog=ld
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by $CC""... $ac_c" 1>&6
-echo "configure:112988: checking for ld used by $CC" >&5
+echo "configure:112349: checking for ld used by $CC" >&5
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -113014,10 +112375,10 @@ echo "configure:112988: checking for ld used by $CC" >&5
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:113018: checking for GNU ld" >&5
+echo "configure:112379: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:113021: checking for non-GNU ld" >&5
+echo "configure:112382: checking for non-GNU ld" >&5
 fi
 if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -113056,7 +112417,7 @@ else
 fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:113060: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:112421: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -113122,7 +112483,7 @@ fi
 
 # PORTME: fill in a description of your system's C++ link characteristics
 echo $ac_n "checking whether the $compiler linker ($LD) supports shared libraries""... $ac_c" 1>&6
-echo "configure:113126: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:112487: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 ld_shlibs_CXX=yes
 case $host_os in
   aix3*)
@@ -113220,12 +112581,12 @@ case $host_os in
       # Determine the default libpath from the value encoded in an empty executable.
       
 cat > conftest.$ac_ext <<EOF
-#line 113224 "configure"
+#line 112585 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:113229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:112590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  
 lt_aix_libpath_sed='
     /Import File Strings/,/^$/ {
@@ -113259,12 +112620,12 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 	# Determine the default libpath from the value encoded in an empty executable.
 	
 cat > conftest.$ac_ext <<EOF
-#line 113263 "configure"
+#line 112624 "configure"
 #include "confdefs.h"
 int main() {
 ; return 0; }
 EOF
-if { (eval echo configure:113268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:112629: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
  
 lt_aix_libpath_sed='
     /Import File Strings/,/^$/ {
@@ -114031,7 +113392,7 @@ private:
 };
 EOF
 
-if { (eval echo configure:114035: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:113396: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   # Parse the compiler output and extract the necessary
   # objects, libraries and library flags.
 
@@ -114187,7 +113548,7 @@ lt_prog_compiler_pic_CXX=
 lt_prog_compiler_static_CXX=
 
 echo $ac_n "checking for $compiler option to produce PIC""... $ac_c" 1>&6
-echo "configure:114191: checking for $compiler option to produce PIC" >&5
+echo "configure:113552: checking for $compiler option to produce PIC" >&5
  
   # C++ specific cases for pic, static, wl, etc.
   if test "$GXX" = yes; then
@@ -114484,7 +113845,7 @@ echo "$ac_t""$lt_prog_compiler_pic_CXX" 1>&6
 if test -n "$lt_prog_compiler_pic_CXX"; then
   
 echo $ac_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works""... $ac_c" 1>&6
-echo "configure:114488: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+echo "configure:113849: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_pic_works_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -114501,11 +113862,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"configure:114505: $lt_compile\"" >&5)
+   (eval echo "\"configure:113866: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "configure:114509: \$? = $ac_status" >&5
+   echo "configure:113870: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -114547,7 +113908,7 @@ esac
 #
 wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
 echo $ac_n "checking if $compiler static flag $lt_tmp_static_flag works""... $ac_c" 1>&6
-echo "configure:114551: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo "configure:113912: checking if $compiler static flag $lt_tmp_static_flag works" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_static_works_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -114585,7 +113946,7 @@ fi
 
 
 echo $ac_n "checking if $compiler supports -c -o file.$ac_objext""... $ac_c" 1>&6
-echo "configure:114589: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo "configure:113950: checking if $compiler supports -c -o file.$ac_objext" >&5
 if eval "test \"`echo '$''{'lt_cv_prog_compiler_c_o_CXX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -114605,11 +113966,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"configure:114609: $lt_compile\"" >&5)
+   (eval echo "\"configure:113970: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "configure:114613: \$? = $ac_status" >&5
+   echo "configure:113974: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -114639,7 +114000,7 @@ hard_links="nottested"
 if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
   # do not overwrite the value of need_locks provided by the user
   echo $ac_n "checking if we can lock with hard links""... $ac_c" 1>&6
-echo "configure:114643: checking if we can lock with hard links" >&5
+echo "configure:114004: checking if we can lock with hard links" >&5
   hard_links=yes
   $rm conftest*
   ln conftest.a conftest.b 2>/dev/null && hard_links=no
@@ -114656,7 +114017,7 @@ else
 fi
 
 echo $ac_n "checking whether the $compiler linker ($LD) supports shared libraries""... $ac_c" 1>&6
-echo "configure:114660: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo "configure:114021: checking whether the $compiler linker ($LD) supports shared libraries" >&5
 
   export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
@@ -114702,11 +114063,11 @@ x|xyes)
       # systems, -lgcc has to come before -lc. If gcc already passes -lc
       # to ld, don't add -lc before -lgcc.
       echo $ac_n "checking whether -lc should be explicitly linked in""... $ac_c" 1>&6
-echo "configure:114706: checking whether -lc should be explicitly linked in" >&5
+echo "configure:114067: checking whether -lc should be explicitly linked in" >&5
       $rm conftest*
       echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo configure:114710: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
+      if { (eval echo configure:114071: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } 2>conftest.err; then
         soname=conftest
         lib=conftest
         libobjs=conftest.$ac_objext
@@ -114720,7 +114081,7 @@ echo "configure:114706: checking whether -lc should be explicitly linked in" >&5
         libname=conftest
         lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
         allow_undefined_flag_CXX=
-        if { (eval echo configure:114724: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
+        if { (eval echo configure:114085: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\") 1>&5; (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5; }
         then
 	  archive_cmds_need_lc_CXX=no
         else
@@ -114739,7 +114100,7 @@ echo "configure:114706: checking whether -lc should be explicitly linked in" >&5
 esac
 
 echo $ac_n "checking dynamic linker characteristics""... $ac_c" 1>&6
-echo "configure:114743: checking dynamic linker characteristics" >&5
+echo "configure:114104: checking dynamic linker characteristics" >&5
 library_names_spec=
 libname_spec='lib$name'
 soname_spec=
@@ -115312,7 +114673,7 @@ if test "$GCC" = yes; then
 fi
 
 echo $ac_n "checking how to hardcode library paths into programs""... $ac_c" 1>&6
-echo "configure:115316: checking how to hardcode library paths into programs" >&5
+echo "configure:114677: checking how to hardcode library paths into programs" >&5
 hardcode_action_CXX=
 if test -n "$hardcode_libdir_flag_spec_CXX" || \
    test -n "$runpath_var_CXX" || \
@@ -116375,19 +115736,19 @@ $PHP_OUTPUT_FILES"
   for arg in $ac_configure_args; do
     case $arg in
       --with-*)
-      	arg_name="`echo $arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo $arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
         ;;
       --without-*)
-      	arg_name="`echo $arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
+        arg_name="`echo $arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
         ;;
       --enable-*)
-      	arg_name="`echo $arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo $arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
         ;;
       --disable-*)
-      	arg_name="`echo $arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
+        arg_name="`echo $arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
         ;;
       *)
-      	continue
+        continue
         ;;
     esac
     case $arg_name in
@@ -116577,14 +115938,11 @@ s%@YACC@%$YACC%g
 s%@RE2C@%$RE2C%g
 s%@SHLIB_SUFFIX_NAME@%$SHLIB_SUFFIX_NAME%g
 s%@SHLIB_DL_SUFFIX_NAME@%$SHLIB_DL_SUFFIX_NAME%g
-s%@LIBEVENT_CFLAGS@%$LIBEVENT_CFLAGS%g
-s%@LIBEVENT_LIBS@%$LIBEVENT_LIBS%g
-s%@LIBEVENT_PATH@%$LIBEVENT_PATH%g
-s%@fpm_version@%$fpm_version%g
 s%@php_fpm_user@%$php_fpm_user%g
 s%@php_fpm_group@%$php_fpm_group%g
 s%@php_fpm_sysconfdir@%$php_fpm_sysconfdir%g
 s%@php_fpm_localstatedir@%$php_fpm_localstatedir%g
+s%@php_fpm_prefix@%$php_fpm_prefix%g
 s%@PROG_SENDMAIL@%$PROG_SENDMAIL%g
 s%@LIBOBJS@%$LIBOBJS%g
 s%@ALLOCA@%$ALLOCA%g
diff --git a/configure.in b/configure.in
index af007a8..9056c67 100644
--- a/configure.in
+++ b/configure.in
@@ -1,4 +1,4 @@
-## $Id: configure.in 301439 2010-07-21 10:50:07Z johannes $ -*- autoconf -*-
+## $Id: configure.in 307133 2011-01-05 16:35:33Z johannes $ -*- autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -41,7 +41,7 @@ AC_CONFIG_HEADER(main/php_config.h)
 
 PHP_MAJOR_VERSION=5
 PHP_MINOR_VERSION=3
-PHP_RELEASE_VERSION=3
+PHP_RELEASE_VERSION=5
 PHP_EXTRA_VERSION=""
 PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
 PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
@@ -611,7 +611,7 @@ asprintf \
 )
 
 dnl Some systems (like OpenSolaris) do not have nanosleep in libc
-PHP_CHECK_FUNC(nanosleep, rt)
+PHP_CHECK_FUNC_LIB(nanosleep, rt)
 
 dnl Check for getaddrinfo, should be a better way, but...
 dnl Also check for working getaddrinfo
@@ -764,7 +764,7 @@ if test "$PHP_DEBUG" = "yes"; then
   changequote([,])
   dnl add -O0 only if GCC or ICC is used
   if test "$GCC" = "yes" || test "$ICC" = "yes"; then
-    CFLAGS="$CFLAGS -g -O0"
+    CFLAGS="$CFLAGS -O0"
     CXXFLAGS="$CXXFLAGS -g -O0"
   fi
   if test "$SUNCC" = "yes"; then
@@ -1329,8 +1329,8 @@ dnl Autoconf 2.13's libtool checks go slightly nuts on Mac OS X 10.5 and 10.6.
 dnl This hack works around it. Ugly.
 case $host_alias in
 *darwin9*|*darwin10*)
-	ac_cv_exeext=
-	;;
+  ac_cv_exeext=
+  ;;
 esac
 
 dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c
index e249738..f9cbe1b 100644
--- a/ext/bz2/bz2.c
+++ b/ext/bz2/bz2.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
  
-/* $Id: bz2.c 300764 2010-06-26 16:03:39Z felipe $ */
+/* $Id: bz2.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -317,7 +317,7 @@ static PHP_MINFO_FUNCTION(bz2)
 {
 	php_info_print_table_start();
 	php_info_print_table_row(2, "BZip2 Support", "Enabled");
-	php_info_print_table_row(2, "Stream Wrapper support", "compress.bz2://");
+	php_info_print_table_row(2, "Stream Wrapper support", "compress.bzip2://");
 	php_info_print_table_row(2, "Stream Filter support", "bzip2.decompress, bzip2.compress");
 	php_info_print_table_row(2, "BZip2 Version", (char *) BZ2_bzlibVersion());
 	php_info_print_table_end();
@@ -387,6 +387,9 @@ static PHP_FUNCTION(bzopen)
 	if (Z_TYPE_PP(file) == IS_STRING) {
 		convert_to_string_ex(file);
 
+		if (strlen(Z_STRVAL_PP(file)) != Z_STRLEN_PP(file)) {
+			RETURN_FALSE;
+		}
 		if (Z_STRLEN_PP(file) == 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "filename cannot be empty");
 			RETURN_FALSE;
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index 6884d17..b23b892 100644
--- a/ext/calendar/calendar.c
+++ b/ext/calendar/calendar.c
@@ -18,7 +18,7 @@
    |          Wez Furlong               <wez at thebrainroom.com>            |
    +----------------------------------------------------------------------+
  */
-/* $Id: calendar.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: calendar.c 303203 2010-09-09 06:41:23Z aharvey $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -348,8 +348,15 @@ PHP_FUNCTION(cal_days_in_month)
 	sdn_next = calendar->to_jd(year, 1 + month, 1);
 
 	if (sdn_next == 0) {
-/* if invalid, try first month of the next year... */
-		sdn_next = calendar->to_jd(year + 1, 1, 1);
+		/* If the next month is invalid, then we need to try the first month of
+		 * the next year, bearing in mind that the next year after 1 BCE is
+		 * actually 1 AD and not 0. */
+		if (year == -1) {
+			sdn_next = calendar->to_jd(1, 1, 1);
+		}
+		else {
+			sdn_next = calendar->to_jd(year + 1, 1, 1);
+		}
 	}
 
 	RETURN_LONG(sdn_next - sdn_start);
diff --git a/ext/calendar/tests/bug52744.phpt b/ext/calendar/tests/bug52744.phpt
new file mode 100644
index 0000000..886086a
--- /dev/null
+++ b/ext/calendar/tests/bug52744.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52744 (cal_days_in_month incorrect for December 1 BCE)
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+var_dump(cal_days_in_month(CAL_GREGORIAN, 12, -1));
+var_dump(cal_days_in_month(CAL_JULIAN, 12, -1));
+?>
+--EXPECT--
+int(31)
+int(31)
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index 7bfc341..cdbcf68 100755
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: com_persist.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: com_persist.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 /* Infrastructure for working with persistent COM objects.
  * Implements: IStream* wrapper for PHP streams.
@@ -389,6 +389,9 @@ CPH_METHOD(SaveToFile)
 		}
 
 		if (filename) {
+			if (strlen(filename) != filename_len) {
+				RETURN_FALSE;
+			}
 			fullpath = expand_filepath(filename, NULL TSRMLS_CC);
 			if (!fullpath) {
 				RETURN_FALSE;
@@ -453,6 +456,10 @@ CPH_METHOD(LoadFromFile)
 			return;
 		}
 
+		if (strlen(filename) != filename_len) {
+			RETURN_FALSE;
+		}
+
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
 			RETURN_FALSE;
 		}
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 35cc1d9..610861e 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: interface.c 298299 2010-04-22 08:58:07Z pajoye $ */
+/* $Id: interface.c 305850 2010-11-30 13:40:02Z iliaa $ */
 
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
@@ -1252,7 +1252,6 @@ static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
 /* }}} */
 #endif
 
-#if LIBCURL_VERSION_NUM < 0x071101
 /* {{{ curl_free_string
  */
 static void curl_free_string(void **string)
@@ -1260,7 +1259,6 @@ static void curl_free_string(void **string)
 	efree(*string);
 }
 /* }}} */
-#endif
 
 /* {{{ curl_free_post
  */
@@ -1337,9 +1335,7 @@ static void alloc_curl_handle(php_curl **ch)
 
 	memset(&(*ch)->err, 0, sizeof((*ch)->err));
 
-#if LIBCURL_VERSION_NUM < 0x071101
 	zend_llist_init(&(*ch)->to_free.str,   sizeof(char *),            (llist_dtor_func_t) curl_free_string, 0);
-#endif
 	zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist,  0);
 	zend_llist_init(&(*ch)->to_free.post,  sizeof(struct HttpPost),   (llist_dtor_func_t) curl_free_post,   0);
 }
@@ -1556,11 +1552,10 @@ PHP_FUNCTION(curl_copy_handle)
 	curl_easy_setopt(dupch->cp, CURLOPT_INFILE,            (void *) dupch);
 	curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER,       (void *) dupch);
 
-#if LIBCURL_VERSION_NUM < 0x071101
 	zend_llist_copy(&dupch->to_free.str, &ch->to_free.str);
 	/* Don't try to free copied strings, they're free'd when the original handle is destroyed */
 	dupch->to_free.str.dtor = NULL;
-#endif
+
 	zend_llist_copy(&dupch->to_free.slist, &ch->to_free.slist);
 	zend_llist_copy(&dupch->to_free.post, &ch->to_free.post);
 
@@ -1742,14 +1737,22 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 					return 1;
 				}
 			} else {
+				if (option == CURLOPT_PRIVATE) {
+					char *copystr;
+#if LIBCURL_VERSION_NUM < 0x071100
+string_copy:
+#endif
+					copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue));
+					error = curl_easy_setopt(ch->cp, option, copystr);
+					zend_llist_add_element(&ch->to_free.str, &copystr);
+				} else {
 #if LIBCURL_VERSION_NUM >= 0x071100
-				/* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
-				error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue));
-#else
-				copystr = estrndup(Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue));
-				error = curl_easy_setopt(ch->cp, option, copystr);
-				zend_llist_add_element(&ch->to_free.str, &copystr);
+					/* Strings passed to libcurl as ’char *’ arguments, are copied by the library... NOTE: before 7.17.0 strings were not copied. */
+					error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue));
+#else				
+					goto string_copy;			
 #endif
+				}
 			}
 			break;
 		}
@@ -1761,7 +1764,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 			int type;
 			void * what;
 
-			what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream());
+			what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream());
 			if (!what) {
 				RETVAL_FALSE;
 				return 1;
@@ -1816,7 +1819,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
 						}
 						zval_add_ref(zvalue);
 						ch->handlers->std_err = *zvalue;
-						zend_list_addref(Z_LVAL_PP(zvalue));
 					} else {
 						php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable");
 						RETVAL_FALSE;
@@ -2457,9 +2459,7 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
 	}
 
 	curl_easy_cleanup(ch->cp);
-#if LIBCURL_VERSION_NUM < 0x071101
 	zend_llist_clean(&ch->to_free.str);
-#endif
 
 	/* cURL destructors should be invoked only by last curl handle */
 	if (Z_REFCOUNT_P(ch->clone) <= 1) {
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 21e3ec1..a525cc6 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_curl.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_curl.h 305854 2010-11-30 16:11:27Z iliaa $ */
 
 #ifndef _PHP_CURL_H
 #define _PHP_CURL_H
@@ -124,9 +124,7 @@ struct _php_curl_send_headers {
 };
 
 struct _php_curl_free {
-#if LIBCURL_VERSION_NUM < 0x071100
 	zend_llist str;
-#endif
 	zend_llist post;
 	zend_llist slist;
 };
diff --git a/ext/curl/tests/bug52202.phpt b/ext/curl/tests/bug52202.phpt
new file mode 100644
index 0000000..a304d7f
--- /dev/null
+++ b/ext/curl/tests/bug52202.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #52202 (CURLOPT_PRIVATE gets clobbered)
+--SKIPIF--
+<?php
+if (!extension_loaded('curl')) exit("skip curl extension not loaded");
+?>
+--FILE--
+<?php
+$curl = curl_init("http://www.google.com");
+curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+curl_setopt($curl, CURLOPT_PRIVATE, "123");
+curl_exec($curl);
+
+var_dump(curl_getinfo($curl, CURLINFO_PRIVATE));
+--EXPECT--
+string(3) "123"
diff --git a/ext/curl/tests/bug52827.phpt b/ext/curl/tests/bug52827.phpt
new file mode 100644
index 0000000..85a73fa
--- /dev/null
+++ b/ext/curl/tests/bug52827.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #52827 (curl_setopt with CURLOPT_STDERR erroneously increments the resource refcount)
+--SKIPIF--
+<?php
+
+if (!extension_loaded('curl')) {
+	exit("skip curl extension not loaded");
+}
+
+?>
+--FILE--
+<?php
+$s = fopen('php://temp/maxmemory=1024','wb+');
+
+/* force conversion of inner stream to STDIO.
+ * This is not necessary in Windows because the
+ * cast to a FILE* handle in curl_setopt already
+ * forces the conversion in that platform. The
+ * reason for this conversion is that the memory
+ * stream has an ugly but working mechanism to
+ * prevent being double freed when it's encapsulated,
+ * while STDIO streams don't. */
+$i = 0;
+while ($i++ < 5000) {
+fwrite($s, str_repeat('a',1024));
+}
+$handle=curl_init('http://www.example.com');
+curl_setopt($handle, CURLOPT_STDERR, $s);
+
+echo "Done.";
+--EXPECTF--
+Done.
diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt
index 1434c58..bf17ab6 100644
--- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt
@@ -17,7 +17,7 @@ if (!extension_loaded('curl')) print 'skip';
 
 	//SET URL AND OTHER OPTIONS
 	curl_setopt($ch1, CURLOPT_URL, "http://php.net/robots.txt");
-	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
 	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
 	
@@ -55,5 +55,10 @@ Disallow: /source.php
 Disallow: /search.php
 Disallow: /mod.php
 Disallow: /manual/add-note.php
+
+Disallow: /harming/humans
+Disallow: /ignoring/human/orders
+Disallow: /harm/to/self
+
 CURL2
 
diff --git a/ext/curl/tests/curl_multi_getcontent_error1.phpt b/ext/curl/tests/curl_multi_getcontent_error1.phpt
index 88de0d7..2fb11b3 100644
--- a/ext/curl/tests/curl_multi_getcontent_error1.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error1.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
 	$ch2=curl_init();
 
 	//SET URL AND OTHER OPTIONS
-	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
-	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
 	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
 	
diff --git a/ext/curl/tests/curl_multi_getcontent_error2.phpt b/ext/curl/tests/curl_multi_getcontent_error2.phpt
index ad837d8..0145d6a 100644
--- a/ext/curl/tests/curl_multi_getcontent_error2.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error2.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
 	$ch2=curl_init();
 
 	//SET URL AND OTHER OPTIONS
-	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
-	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
 	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
 	
diff --git a/ext/curl/tests/curl_multi_getcontent_error3.phpt b/ext/curl/tests/curl_multi_getcontent_error3.phpt
index 6ffc6b7..2ad1480 100644
--- a/ext/curl/tests/curl_multi_getcontent_error3.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error3.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
 	$ch2=curl_init();
 
 	//SET URL AND OTHER OPTIONS
-	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
-	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
 	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
 	
diff --git a/ext/curl/tests/curl_multi_getcontent_error4.phpt b/ext/curl/tests/curl_multi_getcontent_error4.phpt
index 6892864..68bda37 100644
--- a/ext/curl/tests/curl_multi_getcontent_error4.phpt
+++ b/ext/curl/tests/curl_multi_getcontent_error4.phpt
@@ -16,8 +16,8 @@ if (!extension_loaded('curl')) print 'skip';
 	$ch2=curl_init();
 
 	//SET URL AND OTHER OPTIONS
-	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata1.txt");
-	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__)."/curl_testdata2.txt");
+	curl_setopt($ch1, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata1.txt");
+	curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt");
 	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
 	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
 	
diff --git a/ext/curl/tests/curl_setopt_basic001.phpt b/ext/curl/tests/curl_setopt_basic001.phpt
index 178fbf7..9c92785 100644
--- a/ext/curl/tests/curl_setopt_basic001.phpt
+++ b/ext/curl/tests/curl_setopt_basic001.phpt
@@ -27,7 +27,7 @@ curl_close($ch);
 var_dump( $curl_content );
 ?>
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
 *** Testing curl_setopt with CURLOPT_FOLLOWLOCATION in safemode
 
 Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in %s on line %d
diff --git a/ext/curl/tests/curl_setopt_error.phpt b/ext/curl/tests/curl_setopt_error.phpt
index 5489b34..ad73318 100644
--- a/ext/curl/tests/curl_setopt_error.phpt
+++ b/ext/curl/tests/curl_setopt_error.phpt
@@ -42,3 +42,4 @@ Warning: curl_setopt() expects parameter 1 to be resource, boolean given in %s o
 
 Warning: curl_setopt() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d
 
+Warning: curl_setopt(): Invalid curl configuration option in %scurl_setopt_error.php on line %d
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index 641a329..4f60d51 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 Fri Mar 26 12:00:44 2010 */
+/* Generated by re2c 0.13.5 on Sat Nov 13 14:58:02 2010 */
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.c 301252 2010-07-13 23:59:54Z kalle $ */
+/* $Id: parse_date.c 305316 2010-11-13 15:01:48Z derick $ */
 
 #include "timelib.h"
 
@@ -24693,6 +24693,10 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
 #endif
 	} while(t != EOI);
 
+	/* do funky checking whether the parsed time was valid time */
+	if (in.time->have_time && !timelib_valid_time( in.time->h, in.time->i, in.time->s)) {
+		add_warning(&in, "The parsed time was invalid");
+	}
 	/* do funky checking whether the parsed date was valid date */
 	if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
 		add_warning(&in, "The parsed date was invalid");
@@ -24888,7 +24892,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 				break;
 
 			case '#': /* separation symbol */
-				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
+				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-' || *ptr == '(' || *ptr == ')') {
 					++ptr;
 				} else {
 					add_pbf_error(s, "The separation symbol ([;:/.,-]) could not be found", string, begin);
@@ -24901,6 +24905,8 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 			case '.':
 			case ',':
 			case '-':
+			case '(':
+			case ')':
 				if (*ptr == *fptr) {
 					++ptr;
 				} else {
diff --git a/ext/date/lib/parse_date.c.orig b/ext/date/lib/parse_date.c.orig
index fa86b28..935f3e5 100644
--- a/ext/date/lib/parse_date.c.orig
+++ b/ext/date/lib/parse_date.c.orig
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Mar 26 12:00:44 2010 */
+/* Generated by re2c 0.13.5 on Sat Nov 13 14:58:02 2010 */
 #line 1 "ext/date/lib/parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.c 301252 2010-07-13 23:59:54Z kalle $ */
+/* $Id: parse_date.c 305316 2010-11-13 15:01:48Z derick $ */
 
 #include "timelib.h"
 
@@ -843,11 +843,11 @@ static int scan(Scanner *s)
 std:
 	s->tok = cursor;
 	s->len = 0;
-#line 967 "ext/date/lib/parse_date.re"
+#line 969 "ext/date/lib/parse_date.re"
 
 
 
-#line 849 "ext/date/lib/parse_date.c"
+#line 851 "ext/date/lib/parse_date.c"
 {
 	YYCTYPE yych;
 	unsigned int yyaccept = 0;
@@ -967,7 +967,7 @@ std:
 	}
 yy2:
 	YYDEBUG(2, *YYCURSOR);
-#line 1052 "ext/date/lib/parse_date.re"
+#line 1054 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("firstdayof | lastdayof");
 		TIMELIB_INIT;
@@ -983,7 +983,7 @@ yy2:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-#line 985 "ext/date/lib/parse_date.c"
+#line 987 "ext/date/lib/parse_date.c"
 yy3:
 	YYDEBUG(3, *YYCURSOR);
 	++YYCURSOR;
@@ -1006,7 +1006,7 @@ yy3:
 	}
 yy4:
 	YYDEBUG(4, *YYCURSOR);
-#line 1634 "ext/date/lib/parse_date.re"
+#line 1636 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("tzcorrection | tz");
@@ -1019,7 +1019,7 @@ yy4:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIMEZONE;
 	}
-#line 1021 "ext/date/lib/parse_date.c"
+#line 1023 "ext/date/lib/parse_date.c"
 yy5:
 	YYDEBUG(5, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -1330,12 +1330,12 @@ yy12:
 	if (yych <= '9') goto yy1385;
 yy13:
 	YYDEBUG(13, *YYCURSOR);
-#line 1729 "ext/date/lib/parse_date.re"
+#line 1731 "ext/date/lib/parse_date.re"
 	{
 		add_error(s, "Unexpected character");
 		goto std;
 	}
-#line 1337 "ext/date/lib/parse_date.c"
+#line 1339 "ext/date/lib/parse_date.c"
 yy14:
 	YYDEBUG(14, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -2392,11 +2392,11 @@ yy49:
 	if (yych <= '9') goto yy55;
 yy50:
 	YYDEBUG(50, *YYCURSOR);
-#line 1718 "ext/date/lib/parse_date.re"
+#line 1720 "ext/date/lib/parse_date.re"
 	{
 		goto std;
 	}
-#line 2398 "ext/date/lib/parse_date.c"
+#line 2400 "ext/date/lib/parse_date.c"
 yy51:
 	YYDEBUG(51, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -2405,12 +2405,12 @@ yy52:
 	YYDEBUG(52, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(53, *YYCURSOR);
-#line 1723 "ext/date/lib/parse_date.re"
+#line 1725 "ext/date/lib/parse_date.re"
 	{
 		s->pos = cursor; s->line++;
 		goto std;
 	}
-#line 2412 "ext/date/lib/parse_date.c"
+#line 2414 "ext/date/lib/parse_date.c"
 yy54:
 	YYDEBUG(54, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -2797,7 +2797,7 @@ yy72:
 	if (yych == 's') goto yy74;
 yy73:
 	YYDEBUG(73, *YYCURSOR);
-#line 1702 "ext/date/lib/parse_date.re"
+#line 1704 "ext/date/lib/parse_date.re"
 	{
 		timelib_ull i;
 		DEBUG_OUTPUT("relative");
@@ -2812,7 +2812,7 @@ yy73:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 2814 "ext/date/lib/parse_date.c"
+#line 2816 "ext/date/lib/parse_date.c"
 yy74:
 	YYDEBUG(74, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -3574,7 +3574,7 @@ yy166:
 	}
 yy167:
 	YYDEBUG(167, *YYCURSOR);
-#line 1565 "ext/date/lib/parse_date.re"
+#line 1567 "ext/date/lib/parse_date.re"
 	{
 		const timelib_relunit* relunit;
 		DEBUG_OUTPUT("daytext");
@@ -3591,7 +3591,7 @@ yy167:
 		TIMELIB_DEINIT;
 		return TIMELIB_WEEKDAY;
 	}
-#line 3593 "ext/date/lib/parse_date.c"
+#line 3595 "ext/date/lib/parse_date.c"
 yy168:
 	YYDEBUG(168, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -4111,7 +4111,7 @@ yy193:
 	}
 yy194:
 	YYDEBUG(194, *YYCURSOR);
-#line 1624 "ext/date/lib/parse_date.re"
+#line 1626 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("monthtext");
 		TIMELIB_INIT;
@@ -4120,7 +4120,7 @@ yy194:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 4122 "ext/date/lib/parse_date.c"
+#line 4124 "ext/date/lib/parse_date.c"
 yy195:
 	YYDEBUG(195, *YYCURSOR);
 	++YYCURSOR;
@@ -4171,7 +4171,7 @@ yy198:
 	}
 yy199:
 	YYDEBUG(199, *YYCURSOR);
-#line 1374 "ext/date/lib/parse_date.re"
+#line 1376 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datetextual | datenoyear");
 		TIMELIB_INIT;
@@ -4183,7 +4183,7 @@ yy199:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 4185 "ext/date/lib/parse_date.c"
+#line 4187 "ext/date/lib/parse_date.c"
 yy200:
 	YYDEBUG(200, *YYCURSOR);
 	yyaccept = 6;
@@ -4452,7 +4452,7 @@ yy222:
 	}
 yy223:
 	YYDEBUG(223, *YYCURSOR);
-#line 1672 "ext/date/lib/parse_date.re"
+#line 1674 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -4481,7 +4481,7 @@ yy223:
 		TIMELIB_DEINIT;
 		return TIMELIB_SHORTDATE_WITH_TIME;
 	}
-#line 4483 "ext/date/lib/parse_date.c"
+#line 4485 "ext/date/lib/parse_date.c"
 yy224:
 	YYDEBUG(224, *YYCURSOR);
 	yyaccept = 7;
@@ -5179,7 +5179,7 @@ yy278:
 	YYDEBUG(278, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(279, *YYCURSOR);
-#line 1648 "ext/date/lib/parse_date.re"
+#line 1650 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
 		TIMELIB_INIT;
@@ -5202,7 +5202,7 @@ yy278:
 		TIMELIB_DEINIT;
 		return TIMELIB_SHORTDATE_WITH_TIME;
 	}
-#line 5204 "ext/date/lib/parse_date.c"
+#line 5206 "ext/date/lib/parse_date.c"
 yy280:
 	YYDEBUG(280, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -5380,7 +5380,7 @@ yy294:
 	++YYCURSOR;
 yy295:
 	YYDEBUG(295, *YYCURSOR);
-#line 1348 "ext/date/lib/parse_date.re"
+#line 1350 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenoday");
 		TIMELIB_INIT;
@@ -5392,7 +5392,7 @@ yy295:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NO_DAY;
 	}
-#line 5394 "ext/date/lib/parse_date.c"
+#line 5396 "ext/date/lib/parse_date.c"
 yy296:
 	YYDEBUG(296, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -6612,7 +6612,7 @@ yy362:
 	if (yych <= '9') goto yy365;
 yy364:
 	YYDEBUG(364, *YYCURSOR);
-#line 1488 "ext/date/lib/parse_date.re"
+#line 1490 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgtextshort");
 		TIMELIB_INIT;
@@ -6624,7 +6624,7 @@ yy364:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_TEXT;
 	}
-#line 6626 "ext/date/lib/parse_date.c"
+#line 6628 "ext/date/lib/parse_date.c"
 yy365:
 	YYDEBUG(365, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -7262,7 +7262,7 @@ yy392:
 	}
 yy393:
 	YYDEBUG(393, *YYCURSOR);
-#line 1544 "ext/date/lib/parse_date.re"
+#line 1546 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("ago");
 		TIMELIB_INIT;
@@ -7282,7 +7282,7 @@ yy393:
 		TIMELIB_DEINIT;
 		return TIMELIB_AGO;
 	}
-#line 7284 "ext/date/lib/parse_date.c"
+#line 7286 "ext/date/lib/parse_date.c"
 yy394:
 	YYDEBUG(394, *YYCURSOR);
 	yyaccept = 5;
@@ -9032,7 +9032,7 @@ yy454:
 	++YYCURSOR;
 yy455:
 	YYDEBUG(455, *YYCURSOR);
-#line 1258 "ext/date/lib/parse_date.re"
+#line 1260 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
 		TIMELIB_INIT;
@@ -9043,7 +9043,7 @@ yy455:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 9045 "ext/date/lib/parse_date.c"
+#line 9047 "ext/date/lib/parse_date.c"
 yy456:
 	YYDEBUG(456, *YYCURSOR);
 	yyaccept = 0;
@@ -9603,7 +9603,7 @@ yy475:
 	}
 yy476:
 	YYDEBUG(476, *YYCURSOR);
-#line 1387 "ext/date/lib/parse_date.re"
+#line 1389 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenoyearrev");
 		TIMELIB_INIT;
@@ -9614,7 +9614,7 @@ yy476:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_TEXT;
 	}
-#line 9616 "ext/date/lib/parse_date.c"
+#line 9618 "ext/date/lib/parse_date.c"
 yy477:
 	YYDEBUG(477, *YYCURSOR);
 	yyaccept = 10;
@@ -9755,7 +9755,7 @@ yy488:
 	YYDEBUG(488, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(489, *YYCURSOR);
-#line 1114 "ext/date/lib/parse_date.re"
+#line 1116 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
 		TIMELIB_INIT;
@@ -9771,7 +9771,7 @@ yy488:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME12;
 	}
-#line 9773 "ext/date/lib/parse_date.c"
+#line 9775 "ext/date/lib/parse_date.c"
 yy490:
 	YYDEBUG(490, *YYCURSOR);
 	yyaccept = 11;
@@ -9784,7 +9784,7 @@ yy490:
 	}
 yy491:
 	YYDEBUG(491, *YYCURSOR);
-#line 1151 "ext/date/lib/parse_date.re"
+#line 1153 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -9809,7 +9809,7 @@ yy491:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME24_WITH_ZONE;
 	}
-#line 9811 "ext/date/lib/parse_date.c"
+#line 9813 "ext/date/lib/parse_date.c"
 yy492:
 	YYDEBUG(492, *YYCURSOR);
 	yyaccept = 11;
@@ -10119,7 +10119,7 @@ yy523:
 	YYDEBUG(523, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(524, *YYCURSOR);
-#line 1131 "ext/date/lib/parse_date.re"
+#line 1133 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("mssqltime");
 		TIMELIB_INIT;
@@ -10138,7 +10138,7 @@ yy523:
 		TIMELIB_DEINIT;
 		return TIMELIB_TIME24_WITH_ZONE;
 	}
-#line 10140 "ext/date/lib/parse_date.c"
+#line 10142 "ext/date/lib/parse_date.c"
 yy525:
 	YYDEBUG(525, *YYCURSOR);
 	yyaccept = 11;
@@ -10244,7 +10244,7 @@ yy534:
 	if (yych <= '9') goto yy541;
 yy535:
 	YYDEBUG(535, *YYCURSOR);
-#line 1309 "ext/date/lib/parse_date.re"
+#line 1311 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datefull");
 		TIMELIB_INIT;
@@ -10257,7 +10257,7 @@ yy535:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL;
 	}
-#line 10259 "ext/date/lib/parse_date.c"
+#line 10261 "ext/date/lib/parse_date.c"
 yy536:
 	YYDEBUG(536, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -10994,7 +10994,7 @@ yy605:
 	YYDEBUG(606, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(607, *YYCURSOR);
-#line 1323 "ext/date/lib/parse_date.re"
+#line 1325 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pointed date YYYY");
 		TIMELIB_INIT;
@@ -11005,7 +11005,7 @@ yy605:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL_POINTED;
 	}
-#line 11007 "ext/date/lib/parse_date.c"
+#line 11009 "ext/date/lib/parse_date.c"
 yy608:
 	YYDEBUG(608, *YYCURSOR);
 	yyaccept = 11;
@@ -11041,7 +11041,7 @@ yy611:
 	if (yych <= '9') goto yy605;
 yy612:
 	YYDEBUG(612, *YYCURSOR);
-#line 1335 "ext/date/lib/parse_date.re"
+#line 1337 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pointed date YY");
 		TIMELIB_INIT;
@@ -11053,7 +11053,7 @@ yy612:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_FULL_POINTED;
 	}
-#line 11055 "ext/date/lib/parse_date.c"
+#line 11057 "ext/date/lib/parse_date.c"
 yy613:
 	YYDEBUG(613, *YYCURSOR);
 	yyaccept = 11;
@@ -11694,7 +11694,7 @@ yy656:
 	}
 yy657:
 	YYDEBUG(657, *YYCURSOR);
-#line 1296 "ext/date/lib/parse_date.re"
+#line 1298 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnudateshort");
 		TIMELIB_INIT;
@@ -11706,7 +11706,7 @@ yy657:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 11708 "ext/date/lib/parse_date.c"
+#line 11710 "ext/date/lib/parse_date.c"
 yy658:
 	YYDEBUG(658, *YYCURSOR);
 	yyaccept = 13;
@@ -11812,7 +11812,7 @@ yy666:
 	}
 yy667:
 	YYDEBUG(667, *YYCURSOR);
-#line 1243 "ext/date/lib/parse_date.re"
+#line 1245 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("americanshort | american");
 		TIMELIB_INIT;
@@ -11826,7 +11826,7 @@ yy667:
 		TIMELIB_DEINIT;
 		return TIMELIB_AMERICAN;
 	}
-#line 11828 "ext/date/lib/parse_date.c"
+#line 11830 "ext/date/lib/parse_date.c"
 yy668:
 	YYDEBUG(668, *YYCURSOR);
 	yyaccept = 14;
@@ -12059,7 +12059,7 @@ yy700:
 	if (yych <= ':') goto yy704;
 yy701:
 	YYDEBUG(701, *YYCURSOR);
-#line 1514 "ext/date/lib/parse_date.re"
+#line 1516 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("clf");
@@ -12079,7 +12079,7 @@ yy701:
 		TIMELIB_DEINIT;
 		return TIMELIB_CLF;
 	}
-#line 12081 "ext/date/lib/parse_date.c"
+#line 12083 "ext/date/lib/parse_date.c"
 yy702:
 	YYDEBUG(702, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12631,7 +12631,7 @@ yy763:
 	}
 yy764:
 	YYDEBUG(764, *YYCURSOR);
-#line 1270 "ext/date/lib/parse_date.re"
+#line 1272 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("iso8601date2");
 		TIMELIB_INIT;
@@ -12643,7 +12643,7 @@ yy764:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 12645 "ext/date/lib/parse_date.c"
+#line 12647 "ext/date/lib/parse_date.c"
 yy765:
 	YYDEBUG(765, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12682,7 +12682,7 @@ yy771:
 	YYDEBUG(771, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(772, *YYCURSOR);
-#line 1501 "ext/date/lib/parse_date.re"
+#line 1503 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgtextreverse");
 		TIMELIB_INIT;
@@ -12694,7 +12694,7 @@ yy771:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_TEXT;
 	}
-#line 12696 "ext/date/lib/parse_date.c"
+#line 12698 "ext/date/lib/parse_date.c"
 yy773:
 	YYDEBUG(773, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12832,7 +12832,7 @@ yy783:
 	}
 yy784:
 	YYDEBUG(784, *YYCURSOR);
-#line 1535 "ext/date/lib/parse_date.re"
+#line 1537 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("year4");
 		TIMELIB_INIT;
@@ -12840,7 +12840,7 @@ yy784:
 		TIMELIB_DEINIT;
 		return TIMELIB_CLF;
 	}
-#line 12842 "ext/date/lib/parse_date.c"
+#line 12844 "ext/date/lib/parse_date.c"
 yy785:
 	YYDEBUG(785, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -12991,7 +12991,7 @@ yy793:
 	}
 yy794:
 	YYDEBUG(794, *YYCURSOR);
-#line 1361 "ext/date/lib/parse_date.re"
+#line 1363 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenodayrev");
 		TIMELIB_INIT;
@@ -13003,7 +13003,7 @@ yy794:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NO_DAY;
 	}
-#line 13005 "ext/date/lib/parse_date.c"
+#line 13007 "ext/date/lib/parse_date.c"
 yy795:
 	YYDEBUG(795, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13218,7 +13218,7 @@ yy814:
 	if (yych <= '7') goto yy817;
 yy815:
 	YYDEBUG(815, *YYCURSOR);
-#line 1469 "ext/date/lib/parse_date.re"
+#line 1471 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll w, d;
 		DEBUG_OUTPUT("isoweek");
@@ -13236,7 +13236,7 @@ yy815:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_WEEK;
 	}
-#line 13238 "ext/date/lib/parse_date.c"
+#line 13240 "ext/date/lib/parse_date.c"
 yy816:
 	YYDEBUG(816, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13246,7 +13246,7 @@ yy817:
 	YYDEBUG(817, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(818, *YYCURSOR);
-#line 1450 "ext/date/lib/parse_date.re"
+#line 1452 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll w, d;
 		DEBUG_OUTPUT("isoweekday");
@@ -13264,7 +13264,7 @@ yy817:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_WEEK;
 	}
-#line 13266 "ext/date/lib/parse_date.c"
+#line 13268 "ext/date/lib/parse_date.c"
 yy819:
 	YYDEBUG(819, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13328,7 +13328,7 @@ yy821:
 	}
 yy822:
 	YYDEBUG(822, *YYCURSOR);
-#line 1437 "ext/date/lib/parse_date.re"
+#line 1439 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("pgydotd");
 		TIMELIB_INIT;
@@ -13340,7 +13340,7 @@ yy822:
 		TIMELIB_DEINIT;
 		return TIMELIB_PG_YEARDAY;
 	}
-#line 13342 "ext/date/lib/parse_date.c"
+#line 13344 "ext/date/lib/parse_date.c"
 yy823:
 	YYDEBUG(823, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13443,7 +13443,7 @@ yy842:
 	++YYCURSOR;
 yy843:
 	YYDEBUG(843, *YYCURSOR);
-#line 1411 "ext/date/lib/parse_date.re"
+#line 1413 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13468,7 +13468,7 @@ yy843:
 		TIMELIB_DEINIT;
 		return TIMELIB_XMLRPC_SOAP;
 	}
-#line 13470 "ext/date/lib/parse_date.c"
+#line 13472 "ext/date/lib/parse_date.c"
 yy844:
 	YYDEBUG(844, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -13730,7 +13730,7 @@ yy848:
 	}
 yy849:
 	YYDEBUG(849, *YYCURSOR);
-#line 1399 "ext/date/lib/parse_date.re"
+#line 1401 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("datenocolon");
 		TIMELIB_INIT;
@@ -13741,7 +13741,7 @@ yy849:
 		TIMELIB_DEINIT;
 		return TIMELIB_DATE_NOCOLON;
 	}
-#line 13743 "ext/date/lib/parse_date.c"
+#line 13745 "ext/date/lib/parse_date.c"
 yy850:
 	YYDEBUG(850, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -14661,7 +14661,7 @@ yy973:
 	if (yych <= '9') goto yy996;
 yy974:
 	YYDEBUG(974, *YYCURSOR);
-#line 1283 "ext/date/lib/parse_date.re"
+#line 1285 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnudateshorter");
 		TIMELIB_INIT;
@@ -14673,7 +14673,7 @@ yy974:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_DATE;
 	}
-#line 14675 "ext/date/lib/parse_date.c"
+#line 14677 "ext/date/lib/parse_date.c"
 yy975:
 	YYDEBUG(975, *YYCURSOR);
 	yyaccept = 22;
@@ -15682,7 +15682,7 @@ yy1066:
 	}
 yy1068:
 	YYDEBUG(1068, *YYCURSOR);
-#line 1177 "ext/date/lib/parse_date.re"
+#line 1179 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("gnunocolon");
 		TIMELIB_INIT;
@@ -15704,7 +15704,7 @@ yy1068:
 		TIMELIB_DEINIT;
 		return TIMELIB_GNU_NOCOLON;
 	}
-#line 15706 "ext/date/lib/parse_date.c"
+#line 15708 "ext/date/lib/parse_date.c"
 yy1069:
 	YYDEBUG(1069, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -15796,7 +15796,7 @@ yy1075:
 	}
 yy1076:
 	YYDEBUG(1076, *YYCURSOR);
-#line 1223 "ext/date/lib/parse_date.re"
+#line 1225 "ext/date/lib/parse_date.re"
 	{
 		int tz_not_found;
 		DEBUG_OUTPUT("iso8601nocolon");
@@ -15815,7 +15815,7 @@ yy1076:
 		TIMELIB_DEINIT;
 		return TIMELIB_ISO_NOCOLON;
 	}
-#line 15817 "ext/date/lib/parse_date.c"
+#line 15819 "ext/date/lib/parse_date.c"
 yy1077:
 	YYDEBUG(1077, *YYCURSOR);
 	yyaccept = 25;
@@ -16713,7 +16713,7 @@ yy1117:
 	}
 yy1118:
 	YYDEBUG(1118, *YYCURSOR);
-#line 1607 "ext/date/lib/parse_date.re"
+#line 1609 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16729,7 +16729,7 @@ yy1118:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 16731 "ext/date/lib/parse_date.c"
+#line 16733 "ext/date/lib/parse_date.c"
 yy1119:
 	YYDEBUG(1119, *YYCURSOR);
 	++YYCURSOR;
@@ -16780,7 +16780,7 @@ yy1126:
 	YYDEBUG(1126, *YYCURSOR);
 	++YYCURSOR;
 	YYDEBUG(1127, *YYCURSOR);
-#line 1092 "ext/date/lib/parse_date.re"
+#line 1094 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16801,7 +16801,7 @@ yy1126:
 		TIMELIB_DEINIT;
 		return TIMELIB_WEEK_DAY_OF_MONTH;
 	}
-#line 16803 "ext/date/lib/parse_date.c"
+#line 16805 "ext/date/lib/parse_date.c"
 yy1128:
 	YYDEBUG(1128, *YYCURSOR);
 	yyaccept = 26;
@@ -16909,7 +16909,7 @@ yy1141:
 	}
 yy1142:
 	YYDEBUG(1142, *YYCURSOR);
-#line 1583 "ext/date/lib/parse_date.re"
+#line 1585 "ext/date/lib/parse_date.re"
 	{
 		timelib_sll i;
 		int         behavior = 0;
@@ -16932,7 +16932,7 @@ yy1142:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 16934 "ext/date/lib/parse_date.c"
+#line 16936 "ext/date/lib/parse_date.c"
 yy1143:
 	YYDEBUG(1143, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -19609,7 +19609,7 @@ yy1294:
 	goto yy1298;
 yy1295:
 	YYDEBUG(1295, *YYCURSOR);
-#line 1069 "ext/date/lib/parse_date.re"
+#line 1071 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("backof | frontof");
 		TIMELIB_INIT;
@@ -19631,7 +19631,7 @@ yy1295:
 		TIMELIB_DEINIT;
 		return TIMELIB_LF_DAY_OF_MONTH;
 	}
-#line 19633 "ext/date/lib/parse_date.c"
+#line 19635 "ext/date/lib/parse_date.c"
 yy1296:
 	YYDEBUG(1296, *YYCURSOR);
 	yyaccept = 28;
@@ -21322,7 +21322,7 @@ yy1385:
 	if (yych <= '9') goto yy1385;
 yy1387:
 	YYDEBUG(1387, *YYCURSOR);
-#line 1027 "ext/date/lib/parse_date.re"
+#line 1029 "ext/date/lib/parse_date.re"
 	{
 		timelib_ull i;
 
@@ -21346,7 +21346,7 @@ yy1387:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 21348 "ext/date/lib/parse_date.c"
+#line 21350 "ext/date/lib/parse_date.c"
 yy1388:
 	YYDEBUG(1388, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -21782,7 +21782,7 @@ yy1416:
 	++YYCURSOR;
 yy1417:
 	YYDEBUG(1417, *YYCURSOR);
-#line 1015 "ext/date/lib/parse_date.re"
+#line 1017 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("tomorrow");
 		TIMELIB_INIT;
@@ -21793,7 +21793,7 @@ yy1417:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 21795 "ext/date/lib/parse_date.c"
+#line 21797 "ext/date/lib/parse_date.c"
 yy1418:
 	YYDEBUG(1418, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -21828,7 +21828,7 @@ yy1419:
 	}
 yy1420:
 	YYDEBUG(1420, *YYCURSOR);
-#line 1005 "ext/date/lib/parse_date.re"
+#line 1007 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("midnight | today");
 		TIMELIB_INIT;
@@ -21837,7 +21837,7 @@ yy1420:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 21839 "ext/date/lib/parse_date.c"
+#line 21841 "ext/date/lib/parse_date.c"
 yy1421:
 	YYDEBUG(1421, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -23849,7 +23849,7 @@ yy1499:
 	}
 yy1500:
 	YYDEBUG(1500, *YYCURSOR);
-#line 984 "ext/date/lib/parse_date.re"
+#line 986 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("now");
 		TIMELIB_INIT;
@@ -23857,7 +23857,7 @@ yy1500:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 23859 "ext/date/lib/parse_date.c"
+#line 23861 "ext/date/lib/parse_date.c"
 yy1501:
 	YYDEBUG(1501, *YYCURSOR);
 	yych = *++YYCURSOR;
@@ -23996,7 +23996,7 @@ yy1507:
 	}
 yy1508:
 	YYDEBUG(1508, *YYCURSOR);
-#line 993 "ext/date/lib/parse_date.re"
+#line 995 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("noon");
 		TIMELIB_INIT;
@@ -24007,7 +24007,7 @@ yy1508:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 24009 "ext/date/lib/parse_date.c"
+#line 24011 "ext/date/lib/parse_date.c"
 yy1509:
 	YYDEBUG(1509, *YYCURSOR);
 	yyaccept = 0;
@@ -24540,7 +24540,7 @@ yy1530:
 	++YYCURSOR;
 yy1531:
 	YYDEBUG(1531, *YYCURSOR);
-#line 972 "ext/date/lib/parse_date.re"
+#line 974 "ext/date/lib/parse_date.re"
 	{
 		DEBUG_OUTPUT("yesterday");
 		TIMELIB_INIT;
@@ -24551,7 +24551,7 @@ yy1531:
 		TIMELIB_DEINIT;
 		return TIMELIB_RELATIVE;
 	}
-#line 24553 "ext/date/lib/parse_date.c"
+#line 24555 "ext/date/lib/parse_date.c"
 yy1532:
 	YYDEBUG(1532, *YYCURSOR);
 	yyaccept = 0;
@@ -24724,7 +24724,7 @@ yy1537:
 		goto yy1531;
 	}
 }
-#line 1733 "ext/date/lib/parse_date.re"
+#line 1735 "ext/date/lib/parse_date.re"
 
 }
 
@@ -24791,6 +24791,10 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
 #endif
 	} while(t != EOI);
 
+	/* do funky checking whether the parsed time was valid time */
+	if (in.time->have_time && !timelib_valid_time( in.time->h, in.time->i, in.time->s)) {
+		add_warning(&in, "The parsed time was invalid");
+	}
 	/* do funky checking whether the parsed date was valid date */
 	if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
 		add_warning(&in, "The parsed date was invalid");
@@ -24986,7 +24990,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 				break;
 
 			case '#': /* separation symbol */
-				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
+				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-' || *ptr == '(' || *ptr == ')') {
 					++ptr;
 				} else {
 					add_pbf_error(s, "The separation symbol ([;:/.,-]) could not be found", string, begin);
@@ -24999,6 +25003,8 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 			case '.':
 			case ',':
 			case '-':
+			case '(':
+			case ')':
 				if (*ptr == *fptr) {
 					++ptr;
 				} else {
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index 73b3cad..4943c36 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_date.re 301253 2010-07-14 00:04:43Z kalle $ */
+/* $Id: parse_date.re 305316 2010-11-13 15:01:48Z derick $ */
 
 #include "timelib.h"
 
@@ -1798,6 +1798,10 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
 #endif
 	} while(t != EOI);
 
+	/* do funky checking whether the parsed time was valid time */
+	if (in.time->have_time && !timelib_valid_time( in.time->h, in.time->i, in.time->s)) {
+		add_warning(&in, "The parsed time was invalid");
+	}
 	/* do funky checking whether the parsed date was valid date */
 	if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m, in.time->d)) {
 		add_warning(&in, "The parsed date was invalid");
@@ -1993,7 +1997,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 				break;
 
 			case '#': /* separation symbol */
-				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
+				if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-' || *ptr == '(' || *ptr == ')') {
 					++ptr;
 				} else {
 					add_pbf_error(s, "The separation symbol ([;:/.,-]) could not be found", string, begin);
@@ -2006,6 +2010,8 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
 			case '.':
 			case ',':
 			case '-':
+			case '(':
+			case ')':
 				if (*ptr == *fptr) {
 					++ptr;
 				} else {
diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c
index d1e3a63..bb26712 100644
--- a/ext/date/lib/parse_iso_intervals.c
+++ b/ext/date/lib/parse_iso_intervals.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Mar 26 12:12:03 2010 */
+/* Generated by re2c 0.13.5 on Sat Nov 13 14:57:59 2010 */
 #line 1 "ext/date/lib/parse_iso_intervals.re"
 /*
    +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: parse_iso_intervals.c 296828 2010-03-26 04:31:26Z aharvey $ */
+/* $Id: parse_iso_intervals.c 305316 2010-11-13 15:01:48Z derick $ */
 
 #include "timelib.h"
 
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index 84001d3..dce2238 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: timelib.c 305315 2010-11-13 14:57:47Z derick $ */
 
 #include "timelib.h"
 #include <ctype.h>
@@ -46,6 +46,19 @@ timelib_rel_time* timelib_rel_time_ctor(void)
 	return t;
 }
 
+timelib_time* timelib_time_clone(timelib_time *orig)
+{
+	timelib_time *tmp = timelib_time_ctor();
+	memcpy(tmp, orig, sizeof(timelib_time));
+	if (orig->tz_abbr) {
+		tmp->tz_abbr = strdup(orig->tz_abbr);
+	}
+	if (orig->tz_info) {
+		tmp->tz_info = orig->tz_info;
+	}
+	return tmp;
+}
+
 timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *rel)
 {
 	timelib_rel_time *tmp = timelib_rel_time_ctor();
@@ -217,8 +230,6 @@ void timelib_dump_date(timelib_time *d, int options)
 				printf(" %05d%s", d->z, d->dst == 1 ? " (DST)" : "");
 				break;
 		}
-	} else {
-		printf(" GMT 00000");
 	}
 
 	if ((options & 1) == 1) {
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 33eb6eb..b6be125 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: timelib.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: timelib.h 302887 2010-08-30 15:32:09Z derick $ */
 
 #ifndef __TIMELIB_H__
 #define __TIMELIB_H__
@@ -109,6 +109,7 @@ timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *tz);
 timelib_time* timelib_time_ctor(void);
 void timelib_time_set_option(timelib_time* tm, int option, void* option_value);
 void timelib_time_dtor(timelib_time* t);
+timelib_time* timelib_time_clone(timelib_time* orig);
 
 timelib_time_offset* timelib_time_offset_ctor(void);
 void timelib_time_offset_dtor(timelib_time_offset* t);
diff --git a/ext/date/lib/timezonedb.h b/ext/date/lib/timezonedb.h
index 6d7ee59..9156523 100644
--- a/ext/date/lib/timezonedb.h
+++ b/ext/date/lib/timezonedb.h
@@ -1,4 +1,4 @@
-const timelib_tzdb_index_entry timezonedb_idx_builtin[565] = {
+const timelib_tzdb_index_entry timezonedb_idx_builtin[568] = {
 	{ "Africa/Abidjan"                    , 0x000000 },
 	{ "Africa/Accra"                      , 0x000055 },
 	{ "Africa/Addis_Ababa"                , 0x0000FD },
@@ -13,560 +13,563 @@ const timelib_tzdb_index_entry timezonedb_idx_builtin[565] = {
 	{ "Africa/Brazzaville"                , 0x00051C },
 	{ "Africa/Bujumbura"                  , 0x000571 },
 	{ "Africa/Cairo"                      , 0x0005B5 },
-	{ "Africa/Casablanca"                 , 0x00097C },
-	{ "Africa/Ceuta"                      , 0x000A62 },
-	{ "Africa/Conakry"                    , 0x000D69 },
-	{ "Africa/Dakar"                      , 0x000DD4 },
-	{ "Africa/Dar_es_Salaam"              , 0x000E3A },
-	{ "Africa/Djibouti"                   , 0x000EA7 },
-	{ "Africa/Douala"                     , 0x000EFC },
-	{ "Africa/El_Aaiun"                   , 0x000F51 },
-	{ "Africa/Freetown"                   , 0x000FB7 },
-	{ "Africa/Gaborone"                   , 0x0010C6 },
-	{ "Africa/Harare"                     , 0x001121 },
-	{ "Africa/Johannesburg"               , 0x001176 },
-	{ "Africa/Kampala"                    , 0x0011E4 },
-	{ "Africa/Khartoum"                   , 0x001263 },
-	{ "Africa/Kigali"                     , 0x001376 },
-	{ "Africa/Kinshasa"                   , 0x0013CB },
-	{ "Africa/Lagos"                      , 0x001426 },
-	{ "Africa/Libreville"                 , 0x00147B },
-	{ "Africa/Lome"                       , 0x0014D0 },
-	{ "Africa/Luanda"                     , 0x001514 },
-	{ "Africa/Lubumbashi"                 , 0x001569 },
-	{ "Africa/Lusaka"                     , 0x0015C4 },
-	{ "Africa/Malabo"                     , 0x001619 },
-	{ "Africa/Maputo"                     , 0x00167F },
-	{ "Africa/Maseru"                     , 0x0016D4 },
-	{ "Africa/Mbabane"                    , 0x00173C },
-	{ "Africa/Mogadishu"                  , 0x001792 },
-	{ "Africa/Monrovia"                   , 0x0017ED },
-	{ "Africa/Nairobi"                    , 0x001853 },
-	{ "Africa/Ndjamena"                   , 0x0018D2 },
-	{ "Africa/Niamey"                     , 0x00193E },
-	{ "Africa/Nouakchott"                 , 0x0019B1 },
-	{ "Africa/Ouagadougou"                , 0x001A1C },
-	{ "Africa/Porto-Novo"                 , 0x001A71 },
-	{ "Africa/Sao_Tome"                   , 0x001AD7 },
-	{ "Africa/Timbuktu"                   , 0x001B2C },
-	{ "Africa/Tripoli"                    , 0x001B97 },
-	{ "Africa/Tunis"                      , 0x001C91 },
-	{ "Africa/Windhoek"                   , 0x001DA3 },
-	{ "America/Adak"                      , 0x001FEA },
-	{ "America/Anchorage"                 , 0x002360 },
-	{ "America/Anguilla"                  , 0x0026D4 },
-	{ "America/Antigua"                   , 0x002729 },
-	{ "America/Araguaina"                 , 0x00278F },
-	{ "America/Argentina/Buenos_Aires"    , 0x0028EA },
-	{ "America/Argentina/Catamarca"       , 0x002A98 },
-	{ "America/Argentina/ComodRivadavia"  , 0x002C59 },
-	{ "America/Argentina/Cordoba"         , 0x002DFF },
-	{ "America/Argentina/Jujuy"           , 0x002FD4 },
-	{ "America/Argentina/La_Rioja"        , 0x003188 },
-	{ "America/Argentina/Mendoza"         , 0x003340 },
-	{ "America/Argentina/Rio_Gallegos"    , 0x003500 },
-	{ "America/Argentina/Salta"           , 0x0036B5 },
-	{ "America/Argentina/San_Juan"        , 0x003861 },
-	{ "America/Argentina/San_Luis"        , 0x003A19 },
-	{ "America/Argentina/Tucuman"         , 0x003BDF },
-	{ "America/Argentina/Ushuaia"         , 0x003D9B },
-	{ "America/Aruba"                     , 0x003F56 },
-	{ "America/Asuncion"                  , 0x003FBC },
-	{ "America/Atikokan"                  , 0x0042A1 },
-	{ "America/Atka"                      , 0x004377 },
-	{ "America/Bahia"                     , 0x0046DD },
-	{ "America/Barbados"                  , 0x004866 },
-	{ "America/Belem"                     , 0x004900 },
-	{ "America/Belize"                    , 0x0049FB },
-	{ "America/Blanc-Sablon"              , 0x004B77 },
-	{ "America/Boa_Vista"                 , 0x004C2B },
-	{ "America/Bogota"                    , 0x004D34 },
-	{ "America/Boise"                     , 0x004DA0 },
-	{ "America/Buenos_Aires"              , 0x005137 },
-	{ "America/Cambridge_Bay"             , 0x0052D0 },
-	{ "America/Campo_Grande"              , 0x0055F8 },
-	{ "America/Cancun"                    , 0x0058E7 },
-	{ "America/Caracas"                   , 0x005B29 },
-	{ "America/Catamarca"                 , 0x005B90 },
-	{ "America/Cayenne"                   , 0x005D36 },
-	{ "America/Cayman"                    , 0x005D98 },
-	{ "America/Chicago"                   , 0x005DED },
-	{ "America/Chihuahua"                 , 0x006304 },
-	{ "America/Coral_Harbour"             , 0x00656F },
-	{ "America/Cordoba"                   , 0x006601 },
-	{ "America/Costa_Rica"                , 0x0067A7 },
-	{ "America/Cuiaba"                    , 0x006831 },
-	{ "America/Curacao"                   , 0x006B0F },
-	{ "America/Danmarkshavn"              , 0x006B75 },
-	{ "America/Dawson"                    , 0x006CB9 },
-	{ "America/Dawson_Creek"              , 0x006FD6 },
-	{ "America/Denver"                    , 0x0071B0 },
-	{ "America/Detroit"                   , 0x007536 },
-	{ "America/Dominica"                  , 0x007895 },
-	{ "America/Edmonton"                  , 0x0078EA },
-	{ "America/Eirunepe"                  , 0x007CA2 },
-	{ "America/El_Salvador"               , 0x007DB5 },
-	{ "America/Ensenada"                  , 0x007E2A },
-	{ "America/Fort_Wayne"                , 0x0082D1 },
-	{ "America/Fortaleza"                 , 0x008193 },
-	{ "America/Glace_Bay"                 , 0x00853B },
-	{ "America/Godthab"                   , 0x0088B2 },
-	{ "America/Goose_Bay"                 , 0x008B76 },
-	{ "America/Grand_Turk"                , 0x009033 },
-	{ "America/Grenada"                   , 0x0092E2 },
-	{ "America/Guadeloupe"                , 0x009337 },
-	{ "America/Guatemala"                 , 0x00938C },
-	{ "America/Guayaquil"                 , 0x009415 },
-	{ "America/Guyana"                    , 0x009472 },
-	{ "America/Halifax"                   , 0x0094F3 },
-	{ "America/Havana"                    , 0x009A09 },
-	{ "America/Hermosillo"                , 0x009D7C },
-	{ "America/Indiana/Indianapolis"      , 0x009E5A },
-	{ "America/Indiana/Knox"              , 0x00A0EB },
-	{ "America/Indiana/Marengo"           , 0x00A482 },
-	{ "America/Indiana/Petersburg"        , 0x00A728 },
-	{ "America/Indiana/Tell_City"         , 0x00AC75 },
-	{ "America/Indiana/Vevay"             , 0x00AF0E },
-	{ "America/Indiana/Vincennes"         , 0x00B149 },
-	{ "America/Indiana/Winamac"           , 0x00B3FD },
-	{ "America/Indianapolis"              , 0x00AA0B },
-	{ "America/Inuvik"                    , 0x00B6B6 },
-	{ "America/Iqaluit"                   , 0x00B9AD },
-	{ "America/Jamaica"                   , 0x00BCCF },
-	{ "America/Jujuy"                     , 0x00BD94 },
-	{ "America/Juneau"                    , 0x00BF3E },
-	{ "America/Kentucky/Louisville"       , 0x00C2BC },
-	{ "America/Kentucky/Monticello"       , 0x00C6DA },
-	{ "America/Knox_IN"                   , 0x00CA5F },
-	{ "America/La_Paz"                    , 0x00CDD0 },
-	{ "America/Lima"                      , 0x00CE37 },
-	{ "America/Los_Angeles"               , 0x00CEDF },
-	{ "America/Louisville"                , 0x00D2F0 },
-	{ "America/Maceio"                    , 0x00D6E5 },
-	{ "America/Managua"                   , 0x00D81F },
-	{ "America/Manaus"                    , 0x00D8D2 },
-	{ "America/Marigot"                   , 0x00D9D4 },
-	{ "America/Martinique"                , 0x00DA29 },
-	{ "America/Matamoros"                 , 0x00DA95 },
-	{ "America/Mazatlan"                  , 0x00DCEE },
-	{ "America/Mendoza"                   , 0x00DF5B },
-	{ "America/Menominee"                 , 0x00E10F },
-	{ "America/Merida"                    , 0x00E490 },
-	{ "America/Mexico_City"               , 0x00E6CB },
-	{ "America/Miquelon"                  , 0x00E946 },
-	{ "America/Moncton"                   , 0x00EBB8 },
-	{ "America/Monterrey"                 , 0x00F04F },
-	{ "America/Montevideo"                , 0x00F2B2 },
-	{ "America/Montreal"                  , 0x00F5C4 },
-	{ "America/Montserrat"                , 0x00FADA },
-	{ "America/Nassau"                    , 0x00FB2F },
-	{ "America/New_York"                  , 0x00FE74 },
-	{ "America/Nipigon"                   , 0x01037F },
-	{ "America/Nome"                      , 0x0106D0 },
-	{ "America/Noronha"                   , 0x010A4E },
-	{ "America/North_Dakota/Center"       , 0x010B7E },
-	{ "America/North_Dakota/New_Salem"    , 0x010F12 },
-	{ "America/Ojinaga"                   , 0x0112BB },
-	{ "America/Panama"                    , 0x01151C },
-	{ "America/Pangnirtung"               , 0x011571 },
-	{ "America/Paramaribo"                , 0x0118A7 },
-	{ "America/Phoenix"                   , 0x011939 },
-	{ "America/Port-au-Prince"            , 0x0119E7 },
-	{ "America/Port_of_Spain"             , 0x011C02 },
-	{ "America/Porto_Acre"                , 0x011B03 },
-	{ "America/Porto_Velho"               , 0x011C57 },
-	{ "America/Puerto_Rico"               , 0x011D4D },
-	{ "America/Rainy_River"               , 0x011DB8 },
-	{ "America/Rankin_Inlet"              , 0x0120F0 },
-	{ "America/Recife"                    , 0x0123D6 },
-	{ "America/Regina"                    , 0x012500 },
-	{ "America/Resolute"                  , 0x0126BE },
-	{ "America/Rio_Branco"                , 0x0129B7 },
-	{ "America/Rosario"                   , 0x012ABA },
-	{ "America/Santa_Isabel"              , 0x012C60 },
-	{ "America/Santarem"                  , 0x013003 },
-	{ "America/Santiago"                  , 0x013108 },
-	{ "America/Santo_Domingo"             , 0x0134B1 },
-	{ "America/Sao_Paulo"                 , 0x013577 },
-	{ "America/Scoresbysund"              , 0x013886 },
-	{ "America/Shiprock"                  , 0x013B74 },
-	{ "America/St_Barthelemy"             , 0x013F03 },
-	{ "America/St_Johns"                  , 0x013F58 },
-	{ "America/St_Kitts"                  , 0x0144AB },
-	{ "America/St_Lucia"                  , 0x014500 },
-	{ "America/St_Thomas"                 , 0x014555 },
-	{ "America/St_Vincent"                , 0x0145AA },
-	{ "America/Swift_Current"             , 0x0145FF },
-	{ "America/Tegucigalpa"               , 0x014720 },
-	{ "America/Thule"                     , 0x01479F },
-	{ "America/Thunder_Bay"               , 0x0149E6 },
-	{ "America/Tijuana"                   , 0x014D2F },
-	{ "America/Toronto"                   , 0x0150C8 },
-	{ "America/Tortola"                   , 0x0155DF },
-	{ "America/Vancouver"                 , 0x015634 },
-	{ "America/Virgin"                    , 0x015A71 },
-	{ "America/Whitehorse"                , 0x015AC6 },
-	{ "America/Winnipeg"                  , 0x015DE3 },
-	{ "America/Yakutat"                   , 0x016223 },
-	{ "America/Yellowknife"               , 0x01658E },
-	{ "Antarctica/Casey"                  , 0x01689E },
-	{ "Antarctica/Davis"                  , 0x016929 },
-	{ "Antarctica/DumontDUrville"         , 0x0169C0 },
-	{ "Antarctica/Macquarie"              , 0x016A52 },
-	{ "Antarctica/Mawson"                 , 0x016CCC },
-	{ "Antarctica/McMurdo"                , 0x016D48 },
-	{ "Antarctica/Palmer"                 , 0x01704A },
-	{ "Antarctica/Rothera"                , 0x017366 },
-	{ "Antarctica/South_Pole"             , 0x0173DC },
-	{ "Antarctica/Syowa"                  , 0x0176E4 },
-	{ "Antarctica/Vostok"                 , 0x017752 },
-	{ "Arctic/Longyearbyen"               , 0x0177C7 },
-	{ "Asia/Aden"                         , 0x017AF9 },
-	{ "Asia/Almaty"                       , 0x017B4E },
-	{ "Asia/Amman"                        , 0x017CCD },
-	{ "Asia/Anadyr"                       , 0x017F8D },
-	{ "Asia/Aqtau"                        , 0x01827B },
-	{ "Asia/Aqtobe"                       , 0x01847A },
-	{ "Asia/Ashgabat"                     , 0x018632 },
-	{ "Asia/Ashkhabad"                    , 0x01874F },
-	{ "Asia/Baghdad"                      , 0x01886C },
-	{ "Asia/Bahrain"                      , 0x0189E1 },
-	{ "Asia/Baku"                         , 0x018A47 },
-	{ "Asia/Bangkok"                      , 0x018D2F },
-	{ "Asia/Beirut"                       , 0x018D84 },
-	{ "Asia/Bishkek"                      , 0x019091 },
-	{ "Asia/Brunei"                       , 0x01923D },
-	{ "Asia/Calcutta"                     , 0x01929F },
-	{ "Asia/Choibalsan"                   , 0x019318 },
-	{ "Asia/Chongqing"                    , 0x019491 },
-	{ "Asia/Chungking"                    , 0x019580 },
-	{ "Asia/Colombo"                      , 0x01962F },
-	{ "Asia/Dacca"                        , 0x0196CB },
-	{ "Asia/Damascus"                     , 0x019771 },
-	{ "Asia/Dhaka"                        , 0x019AC1 },
-	{ "Asia/Dili"                         , 0x019B67 },
-	{ "Asia/Dubai"                        , 0x019BF0 },
-	{ "Asia/Dushanbe"                     , 0x019C45 },
-	{ "Asia/Gaza"                         , 0x019D48 },
-	{ "Asia/Harbin"                       , 0x01A091 },
-	{ "Asia/Ho_Chi_Minh"                  , 0x01A178 },
-	{ "Asia/Hong_Kong"                    , 0x01A1F0 },
-	{ "Asia/Hovd"                         , 0x01A3BC },
-	{ "Asia/Irkutsk"                      , 0x01A534 },
-	{ "Asia/Istanbul"                     , 0x01A81B },
-	{ "Asia/Jakarta"                      , 0x01AC08 },
-	{ "Asia/Jayapura"                     , 0x01ACB2 },
-	{ "Asia/Jerusalem"                    , 0x01AD36 },
-	{ "Asia/Kabul"                        , 0x01B065 },
-	{ "Asia/Kamchatka"                    , 0x01B0B6 },
-	{ "Asia/Karachi"                      , 0x01B39B },
-	{ "Asia/Kashgar"                      , 0x01B450 },
-	{ "Asia/Kathmandu"                    , 0x01B521 },
-	{ "Asia/Katmandu"                     , 0x01B587 },
-	{ "Asia/Kolkata"                      , 0x01B5ED },
-	{ "Asia/Krasnoyarsk"                  , 0x01B666 },
-	{ "Asia/Kuala_Lumpur"                 , 0x01B94F },
-	{ "Asia/Kuching"                      , 0x01BA0C },
-	{ "Asia/Kuwait"                       , 0x01BAFA },
-	{ "Asia/Macao"                        , 0x01BB4F },
-	{ "Asia/Macau"                        , 0x01BC8A },
-	{ "Asia/Magadan"                      , 0x01BDC5 },
-	{ "Asia/Makassar"                     , 0x01C0A8 },
-	{ "Asia/Manila"                       , 0x01C161 },
-	{ "Asia/Muscat"                       , 0x01C1E6 },
-	{ "Asia/Nicosia"                      , 0x01C23B },
-	{ "Asia/Novokuznetsk"                 , 0x01C523 },
-	{ "Asia/Novosibirsk"                  , 0x01C826 },
-	{ "Asia/Omsk"                         , 0x01CB1A },
-	{ "Asia/Oral"                         , 0x01CE02 },
-	{ "Asia/Phnom_Penh"                   , 0x01CFD2 },
-	{ "Asia/Pontianak"                    , 0x01D04A },
-	{ "Asia/Pyongyang"                    , 0x01D10B },
-	{ "Asia/Qatar"                        , 0x01D178 },
-	{ "Asia/Qyzylorda"                    , 0x01D1DE },
-	{ "Asia/Rangoon"                      , 0x01D3B4 },
-	{ "Asia/Riyadh"                       , 0x01D42C },
-	{ "Asia/Saigon"                       , 0x01D481 },
-	{ "Asia/Sakhalin"                     , 0x01D4F9 },
-	{ "Asia/Samarkand"                    , 0x01D7F9 },
-	{ "Asia/Seoul"                        , 0x01D92F },
-	{ "Asia/Shanghai"                     , 0x01D9D3 },
-	{ "Asia/Singapore"                    , 0x01DAB3 },
-	{ "Asia/Taipei"                       , 0x01DB6A },
-	{ "Asia/Tashkent"                     , 0x01DC82 },
-	{ "Asia/Tbilisi"                      , 0x01DDB3 },
-	{ "Asia/Tehran"                       , 0x01DF6D },
-	{ "Asia/Tel_Aviv"                     , 0x01E1DB },
-	{ "Asia/Thimbu"                       , 0x01E50A },
-	{ "Asia/Thimphu"                      , 0x01E570 },
-	{ "Asia/Tokyo"                        , 0x01E5D6 },
-	{ "Asia/Ujung_Pandang"                , 0x01E65F },
-	{ "Asia/Ulaanbaatar"                  , 0x01E6DB },
-	{ "Asia/Ulan_Bator"                   , 0x01E836 },
-	{ "Asia/Urumqi"                       , 0x01E983 },
-	{ "Asia/Vientiane"                    , 0x01EA4A },
-	{ "Asia/Vladivostok"                  , 0x01EAC2 },
-	{ "Asia/Yakutsk"                      , 0x01EDAF },
-	{ "Asia/Yekaterinburg"                , 0x01F095 },
-	{ "Asia/Yerevan"                      , 0x01F3A1 },
-	{ "Atlantic/Azores"                   , 0x01F6A5 },
-	{ "Atlantic/Bermuda"                  , 0x01FBA8 },
-	{ "Atlantic/Canary"                   , 0x01FE89 },
-	{ "Atlantic/Cape_Verde"               , 0x02015F },
-	{ "Atlantic/Faeroe"                   , 0x0201D8 },
-	{ "Atlantic/Faroe"                    , 0x02047C },
-	{ "Atlantic/Jan_Mayen"                , 0x020720 },
-	{ "Atlantic/Madeira"                  , 0x020A52 },
-	{ "Atlantic/Reykjavik"                , 0x020F5B },
-	{ "Atlantic/South_Georgia"            , 0x021114 },
-	{ "Atlantic/St_Helena"                , 0x02142C },
-	{ "Atlantic/Stanley"                  , 0x021158 },
-	{ "Australia/ACT"                     , 0x021481 },
-	{ "Australia/Adelaide"                , 0x02179E },
-	{ "Australia/Brisbane"                , 0x021ACA },
-	{ "Australia/Broken_Hill"             , 0x021B91 },
-	{ "Australia/Canberra"                , 0x021ECF },
-	{ "Australia/Currie"                  , 0x0221EC },
-	{ "Australia/Darwin"                  , 0x02251F },
-	{ "Australia/Eucla"                   , 0x0225A5 },
-	{ "Australia/Hobart"                  , 0x02267A },
-	{ "Australia/LHI"                     , 0x0229D8 },
-	{ "Australia/Lindeman"                , 0x022C73 },
-	{ "Australia/Lord_Howe"               , 0x022D54 },
-	{ "Australia/Melbourne"               , 0x022FFF },
-	{ "Australia/North"                   , 0x023324 },
-	{ "Australia/NSW"                     , 0x023398 },
-	{ "Australia/Perth"                   , 0x0236B5 },
-	{ "Australia/Queensland"              , 0x02378D },
-	{ "Australia/South"                   , 0x023839 },
-	{ "Australia/Sydney"                  , 0x023B56 },
-	{ "Australia/Tasmania"                , 0x023E93 },
-	{ "Australia/Victoria"                , 0x0241D8 },
-	{ "Australia/West"                    , 0x0244F5 },
-	{ "Australia/Yancowinna"              , 0x0245AB },
-	{ "Brazil/Acre"                       , 0x0248CD },
-	{ "Brazil/DeNoronha"                  , 0x0249CC },
-	{ "Brazil/East"                       , 0x024AEC },
-	{ "Brazil/West"                       , 0x024DC9 },
-	{ "Canada/Atlantic"                   , 0x024EC1 },
-	{ "Canada/Central"                    , 0x0253A9 },
-	{ "Canada/East-Saskatchewan"          , 0x025CB3 },
-	{ "Canada/Eastern"                    , 0x0257C3 },
-	{ "Canada/Mountain"                   , 0x025E3C },
-	{ "Canada/Newfoundland"               , 0x0261B2 },
-	{ "Canada/Pacific"                    , 0x0266DD },
-	{ "Canada/Saskatchewan"               , 0x026AF6 },
-	{ "Canada/Yukon"                      , 0x026C7F },
-	{ "CET"                               , 0x026F82 },
-	{ "Chile/Continental"                 , 0x02728B },
-	{ "Chile/EasterIsland"                , 0x027626 },
-	{ "CST6CDT"                           , 0x027968 },
-	{ "Cuba"                              , 0x027CB9 },
-	{ "EET"                               , 0x02802C },
-	{ "Egypt"                             , 0x0282DF },
-	{ "Eire"                              , 0x0286A6 },
-	{ "EST"                               , 0x028BB7 },
-	{ "EST5EDT"                           , 0x028BFB },
-	{ "Etc/GMT"                           , 0x028F4C },
-	{ "Etc/GMT+0"                         , 0x029018 },
-	{ "Etc/GMT+1"                         , 0x0290A2 },
-	{ "Etc/GMT+10"                        , 0x02912F },
-	{ "Etc/GMT+11"                        , 0x0291BD },
-	{ "Etc/GMT+12"                        , 0x02924B },
-	{ "Etc/GMT+2"                         , 0x029366 },
-	{ "Etc/GMT+3"                         , 0x0293F2 },
-	{ "Etc/GMT+4"                         , 0x02947E },
-	{ "Etc/GMT+5"                         , 0x02950A },
-	{ "Etc/GMT+6"                         , 0x029596 },
-	{ "Etc/GMT+7"                         , 0x029622 },
-	{ "Etc/GMT+8"                         , 0x0296AE },
-	{ "Etc/GMT+9"                         , 0x02973A },
-	{ "Etc/GMT-0"                         , 0x028FD4 },
-	{ "Etc/GMT-1"                         , 0x02905C },
-	{ "Etc/GMT-10"                        , 0x0290E8 },
-	{ "Etc/GMT-11"                        , 0x029176 },
-	{ "Etc/GMT-12"                        , 0x029204 },
-	{ "Etc/GMT-13"                        , 0x029292 },
-	{ "Etc/GMT-14"                        , 0x0292D9 },
-	{ "Etc/GMT-2"                         , 0x029320 },
-	{ "Etc/GMT-3"                         , 0x0293AC },
-	{ "Etc/GMT-4"                         , 0x029438 },
-	{ "Etc/GMT-5"                         , 0x0294C4 },
-	{ "Etc/GMT-6"                         , 0x029550 },
-	{ "Etc/GMT-7"                         , 0x0295DC },
-	{ "Etc/GMT-8"                         , 0x029668 },
-	{ "Etc/GMT-9"                         , 0x0296F4 },
-	{ "Etc/GMT0"                          , 0x028F90 },
-	{ "Etc/Greenwich"                     , 0x029780 },
-	{ "Etc/UCT"                           , 0x0297C4 },
-	{ "Etc/Universal"                     , 0x029808 },
-	{ "Etc/UTC"                           , 0x02984C },
-	{ "Etc/Zulu"                          , 0x029890 },
-	{ "Europe/Amsterdam"                  , 0x0298D4 },
-	{ "Europe/Andorra"                    , 0x029D12 },
-	{ "Europe/Athens"                     , 0x029F8E },
-	{ "Europe/Belfast"                    , 0x02A2D1 },
-	{ "Europe/Belgrade"                   , 0x02A808 },
-	{ "Europe/Berlin"                     , 0x02AAD1 },
-	{ "Europe/Bratislava"                 , 0x02AE27 },
-	{ "Europe/Brussels"                   , 0x02B159 },
-	{ "Europe/Bucharest"                  , 0x02B590 },
-	{ "Europe/Budapest"                   , 0x02B8BA },
-	{ "Europe/Chisinau"                   , 0x02BC2D },
-	{ "Europe/Copenhagen"                 , 0x02BFBB },
-	{ "Europe/Dublin"                     , 0x02C2C5 },
-	{ "Europe/Gibraltar"                  , 0x02C7D6 },
-	{ "Europe/Guernsey"                   , 0x02CC2D },
-	{ "Europe/Helsinki"                   , 0x02D164 },
-	{ "Europe/Isle_of_Man"                , 0x02D41A },
-	{ "Europe/Istanbul"                   , 0x02D951 },
-	{ "Europe/Jersey"                     , 0x02DD3E },
-	{ "Europe/Kaliningrad"                , 0x02E275 },
-	{ "Europe/Kiev"                       , 0x02E5D8 },
-	{ "Europe/Lisbon"                     , 0x02E8EF },
-	{ "Europe/Ljubljana"                  , 0x02EDF3 },
-	{ "Europe/London"                     , 0x02F0BC },
-	{ "Europe/Luxembourg"                 , 0x02F5F3 },
-	{ "Europe/Madrid"                     , 0x02FA49 },
-	{ "Europe/Malta"                      , 0x02FE0F },
-	{ "Europe/Mariehamn"                  , 0x0301C8 },
-	{ "Europe/Minsk"                      , 0x03047E },
-	{ "Europe/Monaco"                     , 0x030789 },
-	{ "Europe/Moscow"                     , 0x030BC4 },
-	{ "Europe/Nicosia"                    , 0x030F16 },
-	{ "Europe/Oslo"                       , 0x0311FE },
-	{ "Europe/Paris"                      , 0x031530 },
-	{ "Europe/Podgorica"                  , 0x031976 },
-	{ "Europe/Prague"                     , 0x031C3F },
-	{ "Europe/Riga"                       , 0x031F71 },
-	{ "Europe/Rome"                       , 0x0322B6 },
-	{ "Europe/Samara"                     , 0x032679 },
-	{ "Europe/San_Marino"                 , 0x0329B2 },
-	{ "Europe/Sarajevo"                   , 0x032D75 },
-	{ "Europe/Simferopol"                 , 0x03303E },
-	{ "Europe/Skopje"                     , 0x033369 },
-	{ "Europe/Sofia"                      , 0x033632 },
-	{ "Europe/Stockholm"                  , 0x03393A },
-	{ "Europe/Tallinn"                    , 0x033BE9 },
-	{ "Europe/Tirane"                     , 0x033F23 },
-	{ "Europe/Tiraspol"                   , 0x034229 },
-	{ "Europe/Uzhgorod"                   , 0x0345B7 },
-	{ "Europe/Vaduz"                      , 0x0348CE },
-	{ "Europe/Vatican"                    , 0x034B61 },
-	{ "Europe/Vienna"                     , 0x034F24 },
-	{ "Europe/Vilnius"                    , 0x035251 },
-	{ "Europe/Volgograd"                  , 0x035590 },
-	{ "Europe/Warsaw"                     , 0x035899 },
-	{ "Europe/Zagreb"                     , 0x035C7A },
-	{ "Europe/Zaporozhye"                 , 0x035F43 },
-	{ "Europe/Zurich"                     , 0x036284 },
-	{ "Factory"                           , 0x036533 },
-	{ "GB"                                , 0x0365A4 },
-	{ "GB-Eire"                           , 0x036ADB },
-	{ "GMT"                               , 0x037012 },
-	{ "GMT+0"                             , 0x0370DE },
-	{ "GMT-0"                             , 0x03709A },
-	{ "GMT0"                              , 0x037056 },
-	{ "Greenwich"                         , 0x037122 },
-	{ "Hongkong"                          , 0x037166 },
-	{ "HST"                               , 0x037332 },
-	{ "Iceland"                           , 0x037376 },
-	{ "Indian/Antananarivo"               , 0x03752F },
-	{ "Indian/Chagos"                     , 0x0375A3 },
-	{ "Indian/Christmas"                  , 0x037605 },
-	{ "Indian/Cocos"                      , 0x037649 },
-	{ "Indian/Comoro"                     , 0x03768D },
-	{ "Indian/Kerguelen"                  , 0x0376E2 },
-	{ "Indian/Mahe"                       , 0x037737 },
-	{ "Indian/Maldives"                   , 0x03778C },
-	{ "Indian/Mauritius"                  , 0x0377E1 },
-	{ "Indian/Mayotte"                    , 0x037857 },
-	{ "Indian/Reunion"                    , 0x0378AC },
-	{ "Iran"                              , 0x037901 },
-	{ "Israel"                            , 0x037B6F },
-	{ "Jamaica"                           , 0x037E9E },
-	{ "Japan"                             , 0x037F63 },
-	{ "Kwajalein"                         , 0x037FEC },
-	{ "Libya"                             , 0x03804F },
-	{ "MET"                               , 0x038149 },
-	{ "Mexico/BajaNorte"                  , 0x038452 },
-	{ "Mexico/BajaSur"                    , 0x0387BB },
-	{ "Mexico/General"                    , 0x038A00 },
-	{ "MST"                               , 0x038C5E },
-	{ "MST7MDT"                           , 0x038CA2 },
-	{ "Navajo"                            , 0x038FF3 },
-	{ "NZ"                                , 0x03936C },
-	{ "NZ-CHAT"                           , 0x0396EA },
-	{ "Pacific/Apia"                      , 0x0399D2 },
-	{ "Pacific/Auckland"                  , 0x039A50 },
-	{ "Pacific/Chatham"                   , 0x039DDC },
-	{ "Pacific/Easter"                    , 0x03A0D3 },
-	{ "Pacific/Efate"                     , 0x03A431 },
-	{ "Pacific/Enderbury"                 , 0x03A4F7 },
-	{ "Pacific/Fakaofo"                   , 0x03A565 },
-	{ "Pacific/Fiji"                      , 0x03A5A9 },
-	{ "Pacific/Funafuti"                  , 0x03A633 },
-	{ "Pacific/Galapagos"                 , 0x03A677 },
-	{ "Pacific/Gambier"                   , 0x03A6EF },
-	{ "Pacific/Guadalcanal"               , 0x03A754 },
-	{ "Pacific/Guam"                      , 0x03A7A9 },
-	{ "Pacific/Honolulu"                  , 0x03A7FF },
-	{ "Pacific/Johnston"                  , 0x03A893 },
-	{ "Pacific/Kiritimati"                , 0x03A8E5 },
-	{ "Pacific/Kosrae"                    , 0x03A950 },
-	{ "Pacific/Kwajalein"                 , 0x03A9AD },
-	{ "Pacific/Majuro"                    , 0x03AA19 },
-	{ "Pacific/Marquesas"                 , 0x03AA78 },
-	{ "Pacific/Midway"                    , 0x03AADF },
-	{ "Pacific/Nauru"                     , 0x03AB69 },
-	{ "Pacific/Niue"                      , 0x03ABE1 },
-	{ "Pacific/Norfolk"                   , 0x03AC3F },
-	{ "Pacific/Noumea"                    , 0x03AC94 },
-	{ "Pacific/Pago_Pago"                 , 0x03AD24 },
-	{ "Pacific/Palau"                     , 0x03ADAD },
-	{ "Pacific/Pitcairn"                  , 0x03ADF1 },
-	{ "Pacific/Ponape"                    , 0x03AE46 },
-	{ "Pacific/Port_Moresby"              , 0x03AE9B },
-	{ "Pacific/Rarotonga"                 , 0x03AEDF },
-	{ "Pacific/Saipan"                    , 0x03AFBB },
-	{ "Pacific/Samoa"                     , 0x03B01E },
-	{ "Pacific/Tahiti"                    , 0x03B0A7 },
-	{ "Pacific/Tarawa"                    , 0x03B10C },
-	{ "Pacific/Tongatapu"                 , 0x03B160 },
-	{ "Pacific/Truk"                      , 0x03B1EC },
-	{ "Pacific/Wake"                      , 0x03B245 },
-	{ "Pacific/Wallis"                    , 0x03B295 },
-	{ "Pacific/Yap"                       , 0x03B2D9 },
-	{ "Poland"                            , 0x03B31E },
-	{ "Portugal"                          , 0x03B6FF },
-	{ "PRC"                               , 0x03BBFB },
-	{ "PST8PDT"                           , 0x03BCAC },
-	{ "ROC"                               , 0x03BFFD },
-	{ "ROK"                               , 0x03C115 },
-	{ "Singapore"                         , 0x03C1B9 },
-	{ "Turkey"                            , 0x03C270 },
-	{ "UCT"                               , 0x03C65D },
-	{ "Universal"                         , 0x03C6A1 },
-	{ "US/Alaska"                         , 0x03C6E5 },
-	{ "US/Aleutian"                       , 0x03CA4E },
-	{ "US/Arizona"                        , 0x03CDB4 },
-	{ "US/Central"                        , 0x03CE42 },
-	{ "US/East-Indiana"                   , 0x03D84C },
-	{ "US/Eastern"                        , 0x03D34D },
-	{ "US/Hawaii"                         , 0x03DAB6 },
-	{ "US/Indiana-Starke"                 , 0x03DB44 },
-	{ "US/Michigan"                       , 0x03DEB5 },
-	{ "US/Mountain"                       , 0x03E1EC },
-	{ "US/Pacific"                        , 0x03E565 },
-	{ "US/Pacific-New"                    , 0x03E96A },
-	{ "US/Samoa"                          , 0x03ED6F },
-	{ "UTC"                               , 0x03EDF8 },
-	{ "W-SU"                              , 0x03F0EF },
-	{ "WET"                               , 0x03EE3C },
-	{ "Zulu"                              , 0x03F42A },
+	{ "Africa/Casablanca"                 , 0x000986 },
+	{ "Africa/Ceuta"                      , 0x000A6C },
+	{ "Africa/Conakry"                    , 0x000D73 },
+	{ "Africa/Dakar"                      , 0x000DDE },
+	{ "Africa/Dar_es_Salaam"              , 0x000E44 },
+	{ "Africa/Djibouti"                   , 0x000EB1 },
+	{ "Africa/Douala"                     , 0x000F06 },
+	{ "Africa/El_Aaiun"                   , 0x000F5B },
+	{ "Africa/Freetown"                   , 0x000FC1 },
+	{ "Africa/Gaborone"                   , 0x0010D0 },
+	{ "Africa/Harare"                     , 0x00112B },
+	{ "Africa/Johannesburg"               , 0x001180 },
+	{ "Africa/Kampala"                    , 0x0011EE },
+	{ "Africa/Khartoum"                   , 0x00126D },
+	{ "Africa/Kigali"                     , 0x001380 },
+	{ "Africa/Kinshasa"                   , 0x0013D5 },
+	{ "Africa/Lagos"                      , 0x001430 },
+	{ "Africa/Libreville"                 , 0x001485 },
+	{ "Africa/Lome"                       , 0x0014DA },
+	{ "Africa/Luanda"                     , 0x00151E },
+	{ "Africa/Lubumbashi"                 , 0x001573 },
+	{ "Africa/Lusaka"                     , 0x0015CE },
+	{ "Africa/Malabo"                     , 0x001623 },
+	{ "Africa/Maputo"                     , 0x001689 },
+	{ "Africa/Maseru"                     , 0x0016DE },
+	{ "Africa/Mbabane"                    , 0x001746 },
+	{ "Africa/Mogadishu"                  , 0x00179C },
+	{ "Africa/Monrovia"                   , 0x0017F7 },
+	{ "Africa/Nairobi"                    , 0x00185D },
+	{ "Africa/Ndjamena"                   , 0x0018DC },
+	{ "Africa/Niamey"                     , 0x001948 },
+	{ "Africa/Nouakchott"                 , 0x0019BB },
+	{ "Africa/Ouagadougou"                , 0x001A26 },
+	{ "Africa/Porto-Novo"                 , 0x001A7B },
+	{ "Africa/Sao_Tome"                   , 0x001AE1 },
+	{ "Africa/Timbuktu"                   , 0x001B36 },
+	{ "Africa/Tripoli"                    , 0x001BA1 },
+	{ "Africa/Tunis"                      , 0x001C9B },
+	{ "Africa/Windhoek"                   , 0x001DAD },
+	{ "America/Adak"                      , 0x001FF4 },
+	{ "America/Anchorage"                 , 0x00236A },
+	{ "America/Anguilla"                  , 0x0026DE },
+	{ "America/Antigua"                   , 0x002733 },
+	{ "America/Araguaina"                 , 0x002799 },
+	{ "America/Argentina/Buenos_Aires"    , 0x0028F4 },
+	{ "America/Argentina/Catamarca"       , 0x002AA2 },
+	{ "America/Argentina/ComodRivadavia"  , 0x002C63 },
+	{ "America/Argentina/Cordoba"         , 0x002E09 },
+	{ "America/Argentina/Jujuy"           , 0x002FDE },
+	{ "America/Argentina/La_Rioja"        , 0x003192 },
+	{ "America/Argentina/Mendoza"         , 0x00334A },
+	{ "America/Argentina/Rio_Gallegos"    , 0x00350A },
+	{ "America/Argentina/Salta"           , 0x0036BF },
+	{ "America/Argentina/San_Juan"        , 0x00386B },
+	{ "America/Argentina/San_Luis"        , 0x003A23 },
+	{ "America/Argentina/Tucuman"         , 0x003BE9 },
+	{ "America/Argentina/Ushuaia"         , 0x003DA5 },
+	{ "America/Aruba"                     , 0x003F60 },
+	{ "America/Asuncion"                  , 0x003FC6 },
+	{ "America/Atikokan"                  , 0x0042AB },
+	{ "America/Atka"                      , 0x004381 },
+	{ "America/Bahia"                     , 0x0046E7 },
+	{ "America/Bahia_Banderas"            , 0x004870 },
+	{ "America/Barbados"                  , 0x004AE9 },
+	{ "America/Belem"                     , 0x004B83 },
+	{ "America/Belize"                    , 0x004C7E },
+	{ "America/Blanc-Sablon"              , 0x004DFA },
+	{ "America/Boa_Vista"                 , 0x004EAE },
+	{ "America/Bogota"                    , 0x004FB7 },
+	{ "America/Boise"                     , 0x005023 },
+	{ "America/Buenos_Aires"              , 0x0053BA },
+	{ "America/Cambridge_Bay"             , 0x005553 },
+	{ "America/Campo_Grande"              , 0x00587B },
+	{ "America/Cancun"                    , 0x005B6A },
+	{ "America/Caracas"                   , 0x005DAC },
+	{ "America/Catamarca"                 , 0x005E13 },
+	{ "America/Cayenne"                   , 0x005FB9 },
+	{ "America/Cayman"                    , 0x00601B },
+	{ "America/Chicago"                   , 0x006070 },
+	{ "America/Chihuahua"                 , 0x006587 },
+	{ "America/Coral_Harbour"             , 0x0067F2 },
+	{ "America/Cordoba"                   , 0x006884 },
+	{ "America/Costa_Rica"                , 0x006A2A },
+	{ "America/Cuiaba"                    , 0x006AB4 },
+	{ "America/Curacao"                   , 0x006D92 },
+	{ "America/Danmarkshavn"              , 0x006DF8 },
+	{ "America/Dawson"                    , 0x006F3C },
+	{ "America/Dawson_Creek"              , 0x007259 },
+	{ "America/Denver"                    , 0x007433 },
+	{ "America/Detroit"                   , 0x0077B9 },
+	{ "America/Dominica"                  , 0x007B18 },
+	{ "America/Edmonton"                  , 0x007B6D },
+	{ "America/Eirunepe"                  , 0x007F25 },
+	{ "America/El_Salvador"               , 0x008038 },
+	{ "America/Ensenada"                  , 0x0080AD },
+	{ "America/Fort_Wayne"                , 0x008554 },
+	{ "America/Fortaleza"                 , 0x008416 },
+	{ "America/Glace_Bay"                 , 0x0087BE },
+	{ "America/Godthab"                   , 0x008B35 },
+	{ "America/Goose_Bay"                 , 0x008DF9 },
+	{ "America/Grand_Turk"                , 0x0092B6 },
+	{ "America/Grenada"                   , 0x009565 },
+	{ "America/Guadeloupe"                , 0x0095BA },
+	{ "America/Guatemala"                 , 0x00960F },
+	{ "America/Guayaquil"                 , 0x009698 },
+	{ "America/Guyana"                    , 0x0096F5 },
+	{ "America/Halifax"                   , 0x009776 },
+	{ "America/Havana"                    , 0x009C8C },
+	{ "America/Hermosillo"                , 0x009FFF },
+	{ "America/Indiana/Indianapolis"      , 0x00A0DD },
+	{ "America/Indiana/Knox"              , 0x00A36E },
+	{ "America/Indiana/Marengo"           , 0x00A705 },
+	{ "America/Indiana/Petersburg"        , 0x00A9AB },
+	{ "America/Indiana/Tell_City"         , 0x00AEF8 },
+	{ "America/Indiana/Vevay"             , 0x00B191 },
+	{ "America/Indiana/Vincennes"         , 0x00B3CC },
+	{ "America/Indiana/Winamac"           , 0x00B680 },
+	{ "America/Indianapolis"              , 0x00AC8E },
+	{ "America/Inuvik"                    , 0x00B939 },
+	{ "America/Iqaluit"                   , 0x00BC30 },
+	{ "America/Jamaica"                   , 0x00BF52 },
+	{ "America/Jujuy"                     , 0x00C017 },
+	{ "America/Juneau"                    , 0x00C1C1 },
+	{ "America/Kentucky/Louisville"       , 0x00C53F },
+	{ "America/Kentucky/Monticello"       , 0x00C95D },
+	{ "America/Knox_IN"                   , 0x00CCE2 },
+	{ "America/La_Paz"                    , 0x00D053 },
+	{ "America/Lima"                      , 0x00D0BA },
+	{ "America/Los_Angeles"               , 0x00D162 },
+	{ "America/Louisville"                , 0x00D573 },
+	{ "America/Maceio"                    , 0x00D968 },
+	{ "America/Managua"                   , 0x00DAA2 },
+	{ "America/Manaus"                    , 0x00DB55 },
+	{ "America/Marigot"                   , 0x00DC57 },
+	{ "America/Martinique"                , 0x00DCAC },
+	{ "America/Matamoros"                 , 0x00DD18 },
+	{ "America/Mazatlan"                  , 0x00DF71 },
+	{ "America/Mendoza"                   , 0x00E1DE },
+	{ "America/Menominee"                 , 0x00E392 },
+	{ "America/Merida"                    , 0x00E713 },
+	{ "America/Mexico_City"               , 0x00E94E },
+	{ "America/Miquelon"                  , 0x00EBC9 },
+	{ "America/Moncton"                   , 0x00EE3B },
+	{ "America/Monterrey"                 , 0x00F2D2 },
+	{ "America/Montevideo"                , 0x00F535 },
+	{ "America/Montreal"                  , 0x00F847 },
+	{ "America/Montserrat"                , 0x00FD5D },
+	{ "America/Nassau"                    , 0x00FDB2 },
+	{ "America/New_York"                  , 0x0100F7 },
+	{ "America/Nipigon"                   , 0x010602 },
+	{ "America/Nome"                      , 0x010953 },
+	{ "America/Noronha"                   , 0x010CD1 },
+	{ "America/North_Dakota/Center"       , 0x010E01 },
+	{ "America/North_Dakota/New_Salem"    , 0x011195 },
+	{ "America/Ojinaga"                   , 0x01153E },
+	{ "America/Panama"                    , 0x01179F },
+	{ "America/Pangnirtung"               , 0x0117F4 },
+	{ "America/Paramaribo"                , 0x011B2A },
+	{ "America/Phoenix"                   , 0x011BBC },
+	{ "America/Port-au-Prince"            , 0x011C6A },
+	{ "America/Port_of_Spain"             , 0x011E85 },
+	{ "America/Porto_Acre"                , 0x011D86 },
+	{ "America/Porto_Velho"               , 0x011EDA },
+	{ "America/Puerto_Rico"               , 0x011FD0 },
+	{ "America/Rainy_River"               , 0x01203B },
+	{ "America/Rankin_Inlet"              , 0x012373 },
+	{ "America/Recife"                    , 0x012659 },
+	{ "America/Regina"                    , 0x012783 },
+	{ "America/Resolute"                  , 0x012941 },
+	{ "America/Rio_Branco"                , 0x012C3A },
+	{ "America/Rosario"                   , 0x012D3D },
+	{ "America/Santa_Isabel"              , 0x012EE3 },
+	{ "America/Santarem"                  , 0x013286 },
+	{ "America/Santiago"                  , 0x01338B },
+	{ "America/Santo_Domingo"             , 0x013734 },
+	{ "America/Sao_Paulo"                 , 0x0137FA },
+	{ "America/Scoresbysund"              , 0x013B09 },
+	{ "America/Shiprock"                  , 0x013DF7 },
+	{ "America/St_Barthelemy"             , 0x014186 },
+	{ "America/St_Johns"                  , 0x0141DB },
+	{ "America/St_Kitts"                  , 0x01472E },
+	{ "America/St_Lucia"                  , 0x014783 },
+	{ "America/St_Thomas"                 , 0x0147D8 },
+	{ "America/St_Vincent"                , 0x01482D },
+	{ "America/Swift_Current"             , 0x014882 },
+	{ "America/Tegucigalpa"               , 0x0149A3 },
+	{ "America/Thule"                     , 0x014A22 },
+	{ "America/Thunder_Bay"               , 0x014C69 },
+	{ "America/Tijuana"                   , 0x014FB2 },
+	{ "America/Toronto"                   , 0x01534B },
+	{ "America/Tortola"                   , 0x015862 },
+	{ "America/Vancouver"                 , 0x0158B7 },
+	{ "America/Virgin"                    , 0x015CF4 },
+	{ "America/Whitehorse"                , 0x015D49 },
+	{ "America/Winnipeg"                  , 0x016066 },
+	{ "America/Yakutat"                   , 0x0164A6 },
+	{ "America/Yellowknife"               , 0x016811 },
+	{ "Antarctica/Casey"                  , 0x016B21 },
+	{ "Antarctica/Davis"                  , 0x016BAC },
+	{ "Antarctica/DumontDUrville"         , 0x016C43 },
+	{ "Antarctica/Macquarie"              , 0x016CD5 },
+	{ "Antarctica/Mawson"                 , 0x016F4F },
+	{ "Antarctica/McMurdo"                , 0x016FCB },
+	{ "Antarctica/Palmer"                 , 0x0172CD },
+	{ "Antarctica/Rothera"                , 0x0175E9 },
+	{ "Antarctica/South_Pole"             , 0x01765F },
+	{ "Antarctica/Syowa"                  , 0x017967 },
+	{ "Antarctica/Vostok"                 , 0x0179D5 },
+	{ "Arctic/Longyearbyen"               , 0x017A46 },
+	{ "Asia/Aden"                         , 0x017D78 },
+	{ "Asia/Almaty"                       , 0x017DCD },
+	{ "Asia/Amman"                        , 0x017F4C },
+	{ "Asia/Anadyr"                       , 0x01820C },
+	{ "Asia/Aqtau"                        , 0x0184FA },
+	{ "Asia/Aqtobe"                       , 0x0186F9 },
+	{ "Asia/Ashgabat"                     , 0x0188B1 },
+	{ "Asia/Ashkhabad"                    , 0x0189CE },
+	{ "Asia/Baghdad"                      , 0x018AEB },
+	{ "Asia/Bahrain"                      , 0x018C60 },
+	{ "Asia/Baku"                         , 0x018CC6 },
+	{ "Asia/Bangkok"                      , 0x018FAE },
+	{ "Asia/Beirut"                       , 0x019003 },
+	{ "Asia/Bishkek"                      , 0x019310 },
+	{ "Asia/Brunei"                       , 0x0194BC },
+	{ "Asia/Calcutta"                     , 0x01951E },
+	{ "Asia/Choibalsan"                   , 0x019597 },
+	{ "Asia/Chongqing"                    , 0x019710 },
+	{ "Asia/Chungking"                    , 0x0197FF },
+	{ "Asia/Colombo"                      , 0x0198AE },
+	{ "Asia/Dacca"                        , 0x01994A },
+	{ "Asia/Damascus"                     , 0x0199F0 },
+	{ "Asia/Dhaka"                        , 0x019D40 },
+	{ "Asia/Dili"                         , 0x019DE6 },
+	{ "Asia/Dubai"                        , 0x019E6F },
+	{ "Asia/Dushanbe"                     , 0x019EC4 },
+	{ "Asia/Gaza"                         , 0x019FC7 },
+	{ "Asia/Harbin"                       , 0x01A310 },
+	{ "Asia/Ho_Chi_Minh"                  , 0x01A3F7 },
+	{ "Asia/Hong_Kong"                    , 0x01A46F },
+	{ "Asia/Hovd"                         , 0x01A631 },
+	{ "Asia/Irkutsk"                      , 0x01A7A9 },
+	{ "Asia/Istanbul"                     , 0x01AA90 },
+	{ "Asia/Jakarta"                      , 0x01AE7D },
+	{ "Asia/Jayapura"                     , 0x01AF27 },
+	{ "Asia/Jerusalem"                    , 0x01AFAB },
+	{ "Asia/Kabul"                        , 0x01B2DA },
+	{ "Asia/Kamchatka"                    , 0x01B32B },
+	{ "Asia/Karachi"                      , 0x01B610 },
+	{ "Asia/Kashgar"                      , 0x01B6C5 },
+	{ "Asia/Kathmandu"                    , 0x01B796 },
+	{ "Asia/Katmandu"                     , 0x01B7FC },
+	{ "Asia/Kolkata"                      , 0x01B862 },
+	{ "Asia/Krasnoyarsk"                  , 0x01B8DB },
+	{ "Asia/Kuala_Lumpur"                 , 0x01BBC4 },
+	{ "Asia/Kuching"                      , 0x01BC81 },
+	{ "Asia/Kuwait"                       , 0x01BD6F },
+	{ "Asia/Macao"                        , 0x01BDC4 },
+	{ "Asia/Macau"                        , 0x01BEFF },
+	{ "Asia/Magadan"                      , 0x01C03A },
+	{ "Asia/Makassar"                     , 0x01C31D },
+	{ "Asia/Manila"                       , 0x01C3D6 },
+	{ "Asia/Muscat"                       , 0x01C45B },
+	{ "Asia/Nicosia"                      , 0x01C4B0 },
+	{ "Asia/Novokuznetsk"                 , 0x01C798 },
+	{ "Asia/Novosibirsk"                  , 0x01CA9B },
+	{ "Asia/Omsk"                         , 0x01CD8F },
+	{ "Asia/Oral"                         , 0x01D077 },
+	{ "Asia/Phnom_Penh"                   , 0x01D247 },
+	{ "Asia/Pontianak"                    , 0x01D2BF },
+	{ "Asia/Pyongyang"                    , 0x01D380 },
+	{ "Asia/Qatar"                        , 0x01D3ED },
+	{ "Asia/Qyzylorda"                    , 0x01D453 },
+	{ "Asia/Rangoon"                      , 0x01D629 },
+	{ "Asia/Riyadh"                       , 0x01D6A1 },
+	{ "Asia/Saigon"                       , 0x01D6F6 },
+	{ "Asia/Sakhalin"                     , 0x01D76E },
+	{ "Asia/Samarkand"                    , 0x01DA6E },
+	{ "Asia/Seoul"                        , 0x01DBA4 },
+	{ "Asia/Shanghai"                     , 0x01DC48 },
+	{ "Asia/Singapore"                    , 0x01DD28 },
+	{ "Asia/Taipei"                       , 0x01DDDF },
+	{ "Asia/Tashkent"                     , 0x01DEF7 },
+	{ "Asia/Tbilisi"                      , 0x01E028 },
+	{ "Asia/Tehran"                       , 0x01E1E2 },
+	{ "Asia/Tel_Aviv"                     , 0x01E450 },
+	{ "Asia/Thimbu"                       , 0x01E77F },
+	{ "Asia/Thimphu"                      , 0x01E7E5 },
+	{ "Asia/Tokyo"                        , 0x01E84B },
+	{ "Asia/Ujung_Pandang"                , 0x01E8D4 },
+	{ "Asia/Ulaanbaatar"                  , 0x01E950 },
+	{ "Asia/Ulan_Bator"                   , 0x01EAAB },
+	{ "Asia/Urumqi"                       , 0x01EBF8 },
+	{ "Asia/Vientiane"                    , 0x01ECBF },
+	{ "Asia/Vladivostok"                  , 0x01ED37 },
+	{ "Asia/Yakutsk"                      , 0x01F024 },
+	{ "Asia/Yekaterinburg"                , 0x01F30A },
+	{ "Asia/Yerevan"                      , 0x01F616 },
+	{ "Atlantic/Azores"                   , 0x01F91A },
+	{ "Atlantic/Bermuda"                  , 0x01FE1D },
+	{ "Atlantic/Canary"                   , 0x0200FE },
+	{ "Atlantic/Cape_Verde"               , 0x0203D4 },
+	{ "Atlantic/Faeroe"                   , 0x02044D },
+	{ "Atlantic/Faroe"                    , 0x0206F1 },
+	{ "Atlantic/Jan_Mayen"                , 0x020995 },
+	{ "Atlantic/Madeira"                  , 0x020CC7 },
+	{ "Atlantic/Reykjavik"                , 0x0211D0 },
+	{ "Atlantic/South_Georgia"            , 0x021389 },
+	{ "Atlantic/St_Helena"                , 0x0216A1 },
+	{ "Atlantic/Stanley"                  , 0x0213CD },
+	{ "Australia/ACT"                     , 0x0216F6 },
+	{ "Australia/Adelaide"                , 0x021A13 },
+	{ "Australia/Brisbane"                , 0x021D3F },
+	{ "Australia/Broken_Hill"             , 0x021E06 },
+	{ "Australia/Canberra"                , 0x022144 },
+	{ "Australia/Currie"                  , 0x022461 },
+	{ "Australia/Darwin"                  , 0x022794 },
+	{ "Australia/Eucla"                   , 0x02281A },
+	{ "Australia/Hobart"                  , 0x0228EF },
+	{ "Australia/LHI"                     , 0x022C4D },
+	{ "Australia/Lindeman"                , 0x022EE8 },
+	{ "Australia/Lord_Howe"               , 0x022FC9 },
+	{ "Australia/Melbourne"               , 0x023274 },
+	{ "Australia/North"                   , 0x023599 },
+	{ "Australia/NSW"                     , 0x02360D },
+	{ "Australia/Perth"                   , 0x02392A },
+	{ "Australia/Queensland"              , 0x023A02 },
+	{ "Australia/South"                   , 0x023AAE },
+	{ "Australia/Sydney"                  , 0x023DCB },
+	{ "Australia/Tasmania"                , 0x024108 },
+	{ "Australia/Victoria"                , 0x02444D },
+	{ "Australia/West"                    , 0x02476A },
+	{ "Australia/Yancowinna"              , 0x024820 },
+	{ "Brazil/Acre"                       , 0x024B42 },
+	{ "Brazil/DeNoronha"                  , 0x024C41 },
+	{ "Brazil/East"                       , 0x024D61 },
+	{ "Brazil/West"                       , 0x02503E },
+	{ "Canada/Atlantic"                   , 0x025136 },
+	{ "Canada/Central"                    , 0x02561E },
+	{ "Canada/East-Saskatchewan"          , 0x025F28 },
+	{ "Canada/Eastern"                    , 0x025A38 },
+	{ "Canada/Mountain"                   , 0x0260B1 },
+	{ "Canada/Newfoundland"               , 0x026427 },
+	{ "Canada/Pacific"                    , 0x026952 },
+	{ "Canada/Saskatchewan"               , 0x026D6B },
+	{ "Canada/Yukon"                      , 0x026EF4 },
+	{ "CET"                               , 0x0271F7 },
+	{ "Chile/Continental"                 , 0x027500 },
+	{ "Chile/EasterIsland"                , 0x02789B },
+	{ "CST6CDT"                           , 0x027BDD },
+	{ "Cuba"                              , 0x027F2E },
+	{ "EET"                               , 0x0282A1 },
+	{ "Egypt"                             , 0x028554 },
+	{ "Eire"                              , 0x028925 },
+	{ "EST"                               , 0x028E36 },
+	{ "EST5EDT"                           , 0x028E7A },
+	{ "Etc/GMT"                           , 0x0291CB },
+	{ "Etc/GMT+0"                         , 0x029297 },
+	{ "Etc/GMT+1"                         , 0x029321 },
+	{ "Etc/GMT+10"                        , 0x0293AE },
+	{ "Etc/GMT+11"                        , 0x02943C },
+	{ "Etc/GMT+12"                        , 0x0294CA },
+	{ "Etc/GMT+2"                         , 0x0295E5 },
+	{ "Etc/GMT+3"                         , 0x029671 },
+	{ "Etc/GMT+4"                         , 0x0296FD },
+	{ "Etc/GMT+5"                         , 0x029789 },
+	{ "Etc/GMT+6"                         , 0x029815 },
+	{ "Etc/GMT+7"                         , 0x0298A1 },
+	{ "Etc/GMT+8"                         , 0x02992D },
+	{ "Etc/GMT+9"                         , 0x0299B9 },
+	{ "Etc/GMT-0"                         , 0x029253 },
+	{ "Etc/GMT-1"                         , 0x0292DB },
+	{ "Etc/GMT-10"                        , 0x029367 },
+	{ "Etc/GMT-11"                        , 0x0293F5 },
+	{ "Etc/GMT-12"                        , 0x029483 },
+	{ "Etc/GMT-13"                        , 0x029511 },
+	{ "Etc/GMT-14"                        , 0x029558 },
+	{ "Etc/GMT-2"                         , 0x02959F },
+	{ "Etc/GMT-3"                         , 0x02962B },
+	{ "Etc/GMT-4"                         , 0x0296B7 },
+	{ "Etc/GMT-5"                         , 0x029743 },
+	{ "Etc/GMT-6"                         , 0x0297CF },
+	{ "Etc/GMT-7"                         , 0x02985B },
+	{ "Etc/GMT-8"                         , 0x0298E7 },
+	{ "Etc/GMT-9"                         , 0x029973 },
+	{ "Etc/GMT0"                          , 0x02920F },
+	{ "Etc/Greenwich"                     , 0x0299FF },
+	{ "Etc/UCT"                           , 0x029A43 },
+	{ "Etc/Universal"                     , 0x029A87 },
+	{ "Etc/UTC"                           , 0x029ACB },
+	{ "Etc/Zulu"                          , 0x029B0F },
+	{ "Europe/Amsterdam"                  , 0x029B53 },
+	{ "Europe/Andorra"                    , 0x029F91 },
+	{ "Europe/Athens"                     , 0x02A20D },
+	{ "Europe/Belfast"                    , 0x02A550 },
+	{ "Europe/Belgrade"                   , 0x02AA87 },
+	{ "Europe/Berlin"                     , 0x02AD50 },
+	{ "Europe/Bratislava"                 , 0x02B0A6 },
+	{ "Europe/Brussels"                   , 0x02B3D8 },
+	{ "Europe/Bucharest"                  , 0x02B80F },
+	{ "Europe/Budapest"                   , 0x02BB39 },
+	{ "Europe/Chisinau"                   , 0x02BEAC },
+	{ "Europe/Copenhagen"                 , 0x02C23A },
+	{ "Europe/Dublin"                     , 0x02C544 },
+	{ "Europe/Gibraltar"                  , 0x02CA55 },
+	{ "Europe/Guernsey"                   , 0x02CEAC },
+	{ "Europe/Helsinki"                   , 0x02D3E3 },
+	{ "Europe/Isle_of_Man"                , 0x02D699 },
+	{ "Europe/Istanbul"                   , 0x02DBD0 },
+	{ "Europe/Jersey"                     , 0x02DFBD },
+	{ "Europe/Kaliningrad"                , 0x02E4F4 },
+	{ "Europe/Kiev"                       , 0x02E857 },
+	{ "Europe/Lisbon"                     , 0x02EB6E },
+	{ "Europe/Ljubljana"                  , 0x02F072 },
+	{ "Europe/London"                     , 0x02F33B },
+	{ "Europe/Luxembourg"                 , 0x02F872 },
+	{ "Europe/Madrid"                     , 0x02FCC8 },
+	{ "Europe/Malta"                      , 0x03008E },
+	{ "Europe/Mariehamn"                  , 0x030447 },
+	{ "Europe/Minsk"                      , 0x0306FD },
+	{ "Europe/Monaco"                     , 0x030A08 },
+	{ "Europe/Moscow"                     , 0x030E43 },
+	{ "Europe/Nicosia"                    , 0x031195 },
+	{ "Europe/Oslo"                       , 0x03147D },
+	{ "Europe/Paris"                      , 0x0317AF },
+	{ "Europe/Podgorica"                  , 0x031BF5 },
+	{ "Europe/Prague"                     , 0x031EBE },
+	{ "Europe/Riga"                       , 0x0321F0 },
+	{ "Europe/Rome"                       , 0x032535 },
+	{ "Europe/Samara"                     , 0x0328F8 },
+	{ "Europe/San_Marino"                 , 0x032C31 },
+	{ "Europe/Sarajevo"                   , 0x032FF4 },
+	{ "Europe/Simferopol"                 , 0x0332BD },
+	{ "Europe/Skopje"                     , 0x0335E8 },
+	{ "Europe/Sofia"                      , 0x0338B1 },
+	{ "Europe/Stockholm"                  , 0x033BB9 },
+	{ "Europe/Tallinn"                    , 0x033E68 },
+	{ "Europe/Tirane"                     , 0x0341A2 },
+	{ "Europe/Tiraspol"                   , 0x0344A8 },
+	{ "Europe/Uzhgorod"                   , 0x034836 },
+	{ "Europe/Vaduz"                      , 0x034B4D },
+	{ "Europe/Vatican"                    , 0x034DE0 },
+	{ "Europe/Vienna"                     , 0x0351A3 },
+	{ "Europe/Vilnius"                    , 0x0354D0 },
+	{ "Europe/Volgograd"                  , 0x03580F },
+	{ "Europe/Warsaw"                     , 0x035B18 },
+	{ "Europe/Zagreb"                     , 0x035EF9 },
+	{ "Europe/Zaporozhye"                 , 0x0361C2 },
+	{ "Europe/Zurich"                     , 0x036503 },
+	{ "Factory"                           , 0x0367B2 },
+	{ "GB"                                , 0x036823 },
+	{ "GB-Eire"                           , 0x036D5A },
+	{ "GMT"                               , 0x037291 },
+	{ "GMT+0"                             , 0x03735D },
+	{ "GMT-0"                             , 0x037319 },
+	{ "GMT0"                              , 0x0372D5 },
+	{ "Greenwich"                         , 0x0373A1 },
+	{ "Hongkong"                          , 0x0373E5 },
+	{ "HST"                               , 0x0375A7 },
+	{ "Iceland"                           , 0x0375EB },
+	{ "Indian/Antananarivo"               , 0x0377A4 },
+	{ "Indian/Chagos"                     , 0x037818 },
+	{ "Indian/Christmas"                  , 0x03787A },
+	{ "Indian/Cocos"                      , 0x0378BE },
+	{ "Indian/Comoro"                     , 0x037902 },
+	{ "Indian/Kerguelen"                  , 0x037957 },
+	{ "Indian/Mahe"                       , 0x0379AC },
+	{ "Indian/Maldives"                   , 0x037A01 },
+	{ "Indian/Mauritius"                  , 0x037A56 },
+	{ "Indian/Mayotte"                    , 0x037ACC },
+	{ "Indian/Reunion"                    , 0x037B21 },
+	{ "Iran"                              , 0x037B76 },
+	{ "Israel"                            , 0x037DE4 },
+	{ "Jamaica"                           , 0x038113 },
+	{ "Japan"                             , 0x0381D8 },
+	{ "Kwajalein"                         , 0x038261 },
+	{ "Libya"                             , 0x0382C4 },
+	{ "MET"                               , 0x0383BE },
+	{ "Mexico/BajaNorte"                  , 0x0386C7 },
+	{ "Mexico/BajaSur"                    , 0x038A30 },
+	{ "Mexico/General"                    , 0x038C75 },
+	{ "MST"                               , 0x038ED3 },
+	{ "MST7MDT"                           , 0x038F17 },
+	{ "Navajo"                            , 0x039268 },
+	{ "NZ"                                , 0x0395E1 },
+	{ "NZ-CHAT"                           , 0x03995F },
+	{ "Pacific/Apia"                      , 0x039C47 },
+	{ "Pacific/Auckland"                  , 0x039CC5 },
+	{ "Pacific/Chatham"                   , 0x03A051 },
+	{ "Pacific/Chuuk"                     , 0x03A348 },
+	{ "Pacific/Easter"                    , 0x03A3A1 },
+	{ "Pacific/Efate"                     , 0x03A6FF },
+	{ "Pacific/Enderbury"                 , 0x03A7C5 },
+	{ "Pacific/Fakaofo"                   , 0x03A833 },
+	{ "Pacific/Fiji"                      , 0x03A877 },
+	{ "Pacific/Funafuti"                  , 0x03A901 },
+	{ "Pacific/Galapagos"                 , 0x03A945 },
+	{ "Pacific/Gambier"                   , 0x03A9BD },
+	{ "Pacific/Guadalcanal"               , 0x03AA22 },
+	{ "Pacific/Guam"                      , 0x03AA77 },
+	{ "Pacific/Honolulu"                  , 0x03AACD },
+	{ "Pacific/Johnston"                  , 0x03AB61 },
+	{ "Pacific/Kiritimati"                , 0x03ABB3 },
+	{ "Pacific/Kosrae"                    , 0x03AC1E },
+	{ "Pacific/Kwajalein"                 , 0x03AC7B },
+	{ "Pacific/Majuro"                    , 0x03ACE7 },
+	{ "Pacific/Marquesas"                 , 0x03AD46 },
+	{ "Pacific/Midway"                    , 0x03ADAD },
+	{ "Pacific/Nauru"                     , 0x03AE37 },
+	{ "Pacific/Niue"                      , 0x03AEAF },
+	{ "Pacific/Norfolk"                   , 0x03AF0D },
+	{ "Pacific/Noumea"                    , 0x03AF62 },
+	{ "Pacific/Pago_Pago"                 , 0x03AFF2 },
+	{ "Pacific/Palau"                     , 0x03B07B },
+	{ "Pacific/Pitcairn"                  , 0x03B0BF },
+	{ "Pacific/Pohnpei"                   , 0x03B114 },
+	{ "Pacific/Ponape"                    , 0x03B169 },
+	{ "Pacific/Port_Moresby"              , 0x03B1AE },
+	{ "Pacific/Rarotonga"                 , 0x03B1F2 },
+	{ "Pacific/Saipan"                    , 0x03B2CE },
+	{ "Pacific/Samoa"                     , 0x03B331 },
+	{ "Pacific/Tahiti"                    , 0x03B3BA },
+	{ "Pacific/Tarawa"                    , 0x03B41F },
+	{ "Pacific/Tongatapu"                 , 0x03B473 },
+	{ "Pacific/Truk"                      , 0x03B4FF },
+	{ "Pacific/Wake"                      , 0x03B544 },
+	{ "Pacific/Wallis"                    , 0x03B594 },
+	{ "Pacific/Yap"                       , 0x03B5D8 },
+	{ "Poland"                            , 0x03B61D },
+	{ "Portugal"                          , 0x03B9FE },
+	{ "PRC"                               , 0x03BEFA },
+	{ "PST8PDT"                           , 0x03BFAB },
+	{ "ROC"                               , 0x03C2FC },
+	{ "ROK"                               , 0x03C414 },
+	{ "Singapore"                         , 0x03C4B8 },
+	{ "Turkey"                            , 0x03C56F },
+	{ "UCT"                               , 0x03C95C },
+	{ "Universal"                         , 0x03C9A0 },
+	{ "US/Alaska"                         , 0x03C9E4 },
+	{ "US/Aleutian"                       , 0x03CD4D },
+	{ "US/Arizona"                        , 0x03D0B3 },
+	{ "US/Central"                        , 0x03D141 },
+	{ "US/East-Indiana"                   , 0x03DB4B },
+	{ "US/Eastern"                        , 0x03D64C },
+	{ "US/Hawaii"                         , 0x03DDB5 },
+	{ "US/Indiana-Starke"                 , 0x03DE43 },
+	{ "US/Michigan"                       , 0x03E1B4 },
+	{ "US/Mountain"                       , 0x03E4EB },
+	{ "US/Pacific"                        , 0x03E864 },
+	{ "US/Pacific-New"                    , 0x03EC69 },
+	{ "US/Samoa"                          , 0x03F06E },
+	{ "UTC"                               , 0x03F0F7 },
+	{ "W-SU"                              , 0x03F3EE },
+	{ "WET"                               , 0x03F13B },
+	{ "Zulu"                              , 0x03F729 },
 };
 /* This is a generated file, do not modify */
-const unsigned char timelib_timezone_db_data_builtin[259182] = {
+const unsigned char timelib_timezone_db_data_builtin[259949] = {
 
 
 /* Africa/Abidjan */
@@ -697,7 +700,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 /* Africa/Cairo */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x45, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0xAE, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0xC8, 0x93, 0xB4, 0xE0, 
+0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0xC8, 0x93, 0xB4, 0xE0, 
 0xC8, 0xFA, 0x7B, 0xD0, 0xC9, 0xFC, 0xEF, 0xE0, 0xCA, 0xC7, 0xE8, 0xD0, 0xCB, 0xCB, 0xAE, 0x60, 
 0xCC, 0xDF, 0x29, 0xD0, 0xCD, 0xAC, 0xE1, 0xE0, 0xCE, 0xC6, 0xF4, 0xD0, 0xCF, 0x8F, 0x66, 0xE0, 
 0xD0, 0xA9, 0x79, 0xD0, 0xD1, 0x84, 0x60, 0xE0, 0xD2, 0x8A, 0xAD, 0x50, 0xE8, 0x36, 0x63, 0x60, 
@@ -727,35 +730,36 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x3F, 0x73, 0x57, 0x50, 0x40, 0x91, 0x7A, 0xE0, 0x41, 0x5C, 0x73, 0xD0, 0x42, 0x71, 0x5C, 0xE0, 
 0x43, 0x3C, 0x55, 0xD0, 0x44, 0x51, 0x3E, 0xE0, 0x45, 0x12, 0xFD, 0x50, 0x46, 0x31, 0x20, 0xE0, 
 0x46, 0xE0, 0x6A, 0x50, 0x48, 0x11, 0x02, 0xE0, 0x48, 0xB7, 0x11, 0xD0, 0x49, 0xF0, 0xE4, 0xE0, 
-0x4A, 0x8D, 0xB9, 0x50, 0x4B, 0xDA, 0x01, 0x60, 0x4C, 0xA4, 0xFA, 0x50, 0x4D, 0xB9, 0xE3, 0x60, 
-0x4E, 0x84, 0xDC, 0x50, 0x4F, 0x99, 0xC5, 0x60, 0x50, 0x64, 0xBE, 0x50, 0x51, 0x79, 0xA7, 0x60, 
-0x52, 0x44, 0xA0, 0x50, 0x53, 0x59, 0x89, 0x60, 0x54, 0x24, 0x82, 0x50, 0x55, 0x39, 0x6B, 0x60, 
-0x56, 0x04, 0x64, 0x50, 0x57, 0x22, 0x87, 0xE0, 0x57, 0xED, 0x80, 0xD0, 0x59, 0x02, 0x69, 0xE0, 
-0x59, 0xCD, 0x62, 0xD0, 0x5A, 0xE2, 0x4B, 0xE0, 0x5B, 0xAD, 0x44, 0xD0, 0x5C, 0xC2, 0x2D, 0xE0, 
-0x5D, 0x8D, 0x26, 0xD0, 0x5E, 0xA2, 0x0F, 0xE0, 0x5F, 0x6D, 0x08, 0xD0, 0x60, 0x8B, 0x2C, 0x60, 
-0x61, 0x56, 0x25, 0x50, 0x62, 0x6B, 0x0E, 0x60, 0x63, 0x36, 0x07, 0x50, 0x64, 0x4A, 0xF0, 0x60, 
-0x65, 0x15, 0xE9, 0x50, 0x66, 0x2A, 0xD2, 0x60, 0x66, 0xF5, 0xCB, 0x50, 0x68, 0x0A, 0xB4, 0x60, 
-0x68, 0xD5, 0xAD, 0x50, 0x69, 0xEA, 0x96, 0x60, 0x6A, 0xB5, 0x8F, 0x50, 0x6B, 0xD3, 0xB2, 0xE0, 
-0x6C, 0x9E, 0xAB, 0xD0, 0x6D, 0xB3, 0x94, 0xE0, 0x6E, 0x7E, 0x8D, 0xD0, 0x6F, 0x93, 0x76, 0xE0, 
-0x70, 0x5E, 0x6F, 0xD0, 0x71, 0x73, 0x58, 0xE0, 0x72, 0x3E, 0x51, 0xD0, 0x73, 0x53, 0x3A, 0xE0, 
-0x74, 0x1E, 0x33, 0xD0, 0x75, 0x3C, 0x57, 0x60, 0x76, 0x07, 0x50, 0x50, 0x77, 0x1C, 0x39, 0x60, 
-0x77, 0xE7, 0x32, 0x50, 0x78, 0xFC, 0x1B, 0x60, 0x79, 0xC7, 0x14, 0x50, 0x7A, 0xDB, 0xFD, 0x60, 
-0x7B, 0xA6, 0xF6, 0x50, 0x7C, 0xBB, 0xDF, 0x60, 0x7D, 0x86, 0xD8, 0x50, 0x7E, 0x9B, 0xC1, 0x60, 
-0x7F, 0x66, 0xBA, 0x50, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
+0x4A, 0x8D, 0xB9, 0x50, 0x4B, 0xDA, 0x01, 0x60, 0x4C, 0x61, 0xBD, 0xD0, 0x4C, 0x89, 0x58, 0xE0, 
+0x4C, 0xA4, 0xFA, 0x50, 0x4D, 0xB9, 0xE3, 0x60, 0x4E, 0x84, 0xDC, 0x50, 0x4F, 0x99, 0xC5, 0x60, 
+0x50, 0x64, 0xBE, 0x50, 0x51, 0x79, 0xA7, 0x60, 0x52, 0x44, 0xA0, 0x50, 0x53, 0x59, 0x89, 0x60, 
+0x54, 0x24, 0x82, 0x50, 0x55, 0x39, 0x6B, 0x60, 0x56, 0x04, 0x64, 0x50, 0x57, 0x22, 0x87, 0xE0, 
+0x57, 0xED, 0x80, 0xD0, 0x59, 0x02, 0x69, 0xE0, 0x59, 0xCD, 0x62, 0xD0, 0x5A, 0xE2, 0x4B, 0xE0, 
+0x5B, 0xAD, 0x44, 0xD0, 0x5C, 0xC2, 0x2D, 0xE0, 0x5D, 0x8D, 0x26, 0xD0, 0x5E, 0xA2, 0x0F, 0xE0, 
+0x5F, 0x6D, 0x08, 0xD0, 0x60, 0x8B, 0x2C, 0x60, 0x61, 0x56, 0x25, 0x50, 0x62, 0x6B, 0x0E, 0x60, 
+0x63, 0x36, 0x07, 0x50, 0x64, 0x4A, 0xF0, 0x60, 0x65, 0x15, 0xE9, 0x50, 0x66, 0x2A, 0xD2, 0x60, 
+0x66, 0xF5, 0xCB, 0x50, 0x68, 0x0A, 0xB4, 0x60, 0x68, 0xD5, 0xAD, 0x50, 0x69, 0xEA, 0x96, 0x60, 
+0x6A, 0xB5, 0x8F, 0x50, 0x6B, 0xD3, 0xB2, 0xE0, 0x6C, 0x9E, 0xAB, 0xD0, 0x6D, 0xB3, 0x94, 0xE0, 
+0x6E, 0x7E, 0x8D, 0xD0, 0x6F, 0x93, 0x76, 0xE0, 0x70, 0x5E, 0x6F, 0xD0, 0x71, 0x73, 0x58, 0xE0, 
+0x72, 0x3E, 0x51, 0xD0, 0x73, 0x53, 0x3A, 0xE0, 0x74, 0x1E, 0x33, 0xD0, 0x75, 0x3C, 0x57, 0x60, 
+0x76, 0x07, 0x50, 0x50, 0x77, 0x1C, 0x39, 0x60, 0x77, 0xE7, 0x32, 0x50, 0x78, 0xFC, 0x1B, 0x60, 
+0x79, 0xC7, 0x14, 0x50, 0x7A, 0xDB, 0xFD, 0x60, 0x7B, 0xA6, 0xF6, 0x50, 0x7C, 0xBB, 0xDF, 0x60, 
+0x7D, 0x86, 0xD8, 0x50, 0x7E, 0x9B, 0xC1, 0x60, 0x7F, 0x66, 0xBA, 0x50, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
-0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
+0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
+0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
+0x02, 0x03, 0x02, 0x01, 0x00, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x00, 0x00, 
-0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x45, 0x45, 0x53, 0x54, 0x00, 0x45, 
-0x45, 0x54, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB7, 0x2E, 0x88, 0x01, 
-0x42, 0x57, 0x88, 0x00, 0x00, 0x00, 0x00, 
+0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x00, 0x00, 0x2A, 0x30, 
+0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 
+0x1C, 0x20, 0x00, 0x05, 0x45, 0x45, 0x53, 0x54, 0x00, 0x45, 0x45, 0x54, 0x00, 0x00, 0x00, 0x01, 
+0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB7, 0x2E, 0x88, 0x01, 0x42, 0x57, 0x88, 0x00, 0x00, 0x00, 
+0x00, 
 
 /* Africa/Casablanca */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -1921,6 +1925,48 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x84, 0xA2, 0x00, 0xD7, 0xE2, 0xED, 
 0x00, 0x00, 0x00, 0x05, 0x42, 0x61, 0x68, 0x69, 0x61, 
 
+/* America/Bahia_Banderas */
+0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0xA5, 0xB6, 0xE8, 0x70, 
+0xAF, 0xF2, 0x6E, 0xE0, 0xB6, 0x66, 0x56, 0x60, 0xB7, 0x43, 0xD2, 0x60, 0xB8, 0x0C, 0x36, 0x60, 
+0xB8, 0xFD, 0x86, 0xF0, 0xCB, 0xEA, 0x71, 0x60, 0xD8, 0x91, 0xB4, 0xF0, 0x00, 0x00, 0x70, 0x80, 
+0x31, 0x67, 0x84, 0x10, 0x32, 0x73, 0x16, 0x80, 0x33, 0x47, 0x66, 0x10, 0x34, 0x52, 0xF8, 0x80, 
+0x35, 0x27, 0x48, 0x10, 0x36, 0x32, 0xDA, 0x80, 0x37, 0x07, 0x2A, 0x10, 0x38, 0x1B, 0xF7, 0x00, 
+0x38, 0xE7, 0x0C, 0x10, 0x39, 0xFB, 0xD9, 0x00, 0x3A, 0xF5, 0x12, 0x90, 0x3B, 0xB6, 0xD1, 0x00, 
+0x3C, 0xB0, 0x0A, 0x90, 0x3D, 0xBB, 0x9D, 0x00, 0x3E, 0x8F, 0xEC, 0x90, 0x3F, 0x9B, 0x7F, 0x00, 
+0x40, 0x6F, 0xCE, 0x90, 0x41, 0x84, 0x9B, 0x80, 0x42, 0x4F, 0xB0, 0x90, 0x43, 0x64, 0x7D, 0x80, 
+0x44, 0x2F, 0x92, 0x90, 0x45, 0x44, 0x5F, 0x80, 0x46, 0x0F, 0x74, 0x90, 0x47, 0x24, 0x41, 0x80, 
+0x47, 0xF8, 0x91, 0x10, 0x49, 0x04, 0x23, 0x80, 0x49, 0xD8, 0x73, 0x10, 0x4A, 0xE4, 0x05, 0x80, 
+0x4B, 0xB8, 0x55, 0x10, 0x4C, 0xCD, 0x13, 0xF0, 0x4D, 0x98, 0x29, 0x00, 0x4E, 0xAC, 0xF5, 0xF0, 
+0x4F, 0x78, 0x0B, 0x00, 0x50, 0x8C, 0xD7, 0xF0, 0x51, 0x61, 0x27, 0x80, 0x52, 0x6C, 0xB9, 0xF0, 
+0x53, 0x41, 0x09, 0x80, 0x54, 0x4C, 0x9B, 0xF0, 0x55, 0x20, 0xEB, 0x80, 0x56, 0x2C, 0x7D, 0xF0, 
+0x57, 0x00, 0xCD, 0x80, 0x58, 0x15, 0x9A, 0x70, 0x58, 0xE0, 0xAF, 0x80, 0x59, 0xF5, 0x7C, 0x70, 
+0x5A, 0xC0, 0x91, 0x80, 0x5B, 0xD5, 0x5E, 0x70, 0x5C, 0xA9, 0xAE, 0x00, 0x5D, 0xB5, 0x40, 0x70, 
+0x5E, 0x89, 0x90, 0x00, 0x5F, 0x95, 0x22, 0x70, 0x60, 0x69, 0x72, 0x00, 0x61, 0x7E, 0x3E, 0xF0, 
+0x62, 0x49, 0x54, 0x00, 0x63, 0x5E, 0x20, 0xF0, 0x64, 0x29, 0x36, 0x00, 0x65, 0x3E, 0x02, 0xF0, 
+0x66, 0x12, 0x52, 0x80, 0x67, 0x1D, 0xE4, 0xF0, 0x67, 0xF2, 0x34, 0x80, 0x68, 0xFD, 0xC6, 0xF0, 
+0x69, 0xD2, 0x16, 0x80, 0x6A, 0xDD, 0xA8, 0xF0, 0x6B, 0xB1, 0xF8, 0x80, 0x6C, 0xC6, 0xC5, 0x70, 
+0x6D, 0x91, 0xDA, 0x80, 0x6E, 0xA6, 0xA7, 0x70, 0x6F, 0x71, 0xBC, 0x80, 0x70, 0x86, 0x89, 0x70, 
+0x71, 0x5A, 0xD9, 0x00, 0x72, 0x66, 0x6B, 0x70, 0x73, 0x3A, 0xBB, 0x00, 0x74, 0x46, 0x4D, 0x70, 
+0x75, 0x1A, 0x9D, 0x00, 0x76, 0x2F, 0x69, 0xF0, 0x76, 0xFA, 0x7F, 0x00, 0x78, 0x0F, 0x4B, 0xF0, 
+0x78, 0xDA, 0x61, 0x00, 0x79, 0xEF, 0x2D, 0xF0, 0x7A, 0xBA, 0x43, 0x00, 0x7B, 0xCF, 0x0F, 0xF0, 
+0x7C, 0xA3, 0x5F, 0x80, 0x7D, 0xAE, 0xF1, 0xF0, 0x7E, 0x83, 0x41, 0x80, 0x7F, 0x8E, 0xD3, 0xF0, 
+0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x03, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 
+0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 0x01, 0x04, 
+0x01, 0x04, 0x01, 0x04, 0x01, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 
+0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 
+0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 
+0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0xFF, 0xFF, 0x9D, 
+0x54, 0x00, 0x00, 0xFF, 0xFF, 0x9D, 0x90, 0x00, 0x04, 0xFF, 0xFF, 0xAB, 0xA0, 0x00, 0x08, 0xFF, 
+0xFF, 0x8F, 0x80, 0x00, 0x0C, 0xFF, 0xFF, 0xAB, 0xA0, 0x01, 0x10, 0xFF, 0xFF, 0xB9, 0xB0, 0x01, 
+0x14, 0x4C, 0x4D, 0x54, 0x00, 0x4D, 0x53, 0x54, 0x00, 0x43, 0x53, 0x54, 0x00, 0x50, 0x53, 0x54, 
+0x00, 0x4D, 0x44, 0x54, 0x00, 0x43, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA9, 0x11, 0x40, 0x00, 0x72, 0x0F, 0x38, 0x00, 0x00, 0x00, 
+0x28, 0x4D, 0x65, 0x78, 0x69, 0x63, 0x61, 0x6E, 0x20, 0x43, 0x65, 0x6E, 0x74, 0x72, 0x61, 0x6C, 
+0x20, 0x54, 0x69, 0x6D, 0x65, 0x20, 0x2D, 0x20, 0x42, 0x61, 0x68, 0x69, 0x61, 0x20, 0x64, 0x65, 
+0x20, 0x42, 0x61, 0x6E, 0x64, 0x65, 0x72, 0x61, 0x73, 
+
 /* America/Barbados */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
@@ -7139,9 +7185,9 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0xE9, 0x58, 0x89, 0x80, 
 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x60, 0x00, 0x04, 0x7A, 0x7A, 0x7A, 
 0x00, 0x56, 0x4F, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xB3, 0x3F, 0x01, 0xB5, 
-0xC6, 0x4F, 0x00, 0x00, 0x00, 0x1F, 0x56, 0x6F, 0x73, 0x74, 0x6F, 0x6B, 0x20, 0x53, 0x74, 0x61, 
-0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x20, 0x53, 0x20, 0x4D, 0x61, 0x67, 0x6E, 0x65, 0x74, 0x69, 0x63, 
-0x20, 0x50, 0x6F, 0x6C, 0x65, 
+0xC6, 0x4F, 0x00, 0x00, 0x00, 0x1B, 0x56, 0x6F, 0x73, 0x74, 0x6F, 0x6B, 0x20, 0x53, 0x74, 0x61, 
+0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x20, 0x4C, 0x61, 0x6B, 0x65, 0x20, 0x56, 0x6F, 0x73, 0x74, 0x6F, 
+0x6B, 
 
 /* Arctic/Longyearbyen */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x53, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -7836,7 +7882,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x41, 0x5C, 0x81, 0xE0, 0x42, 0x5E, 0xE7, 0xE0, 0x43, 0x41, 0xB7, 0xF0, 0x44, 0x2D, 0xA6, 0x60, 
 0x45, 0x12, 0xFD, 0x50, 0x46, 0x0E, 0xD9, 0xE0, 0x46, 0xE8, 0x6F, 0x70, 0x47, 0xF1, 0x5E, 0xE0, 
 0x48, 0xB7, 0x2D, 0xF0, 0x49, 0xCB, 0xFA, 0xE0, 0x4A, 0xA0, 0x4A, 0x70, 0x4B, 0xAD, 0x2E, 0x9C, 
-0x4C, 0x80, 0x2C, 0x70, 0x4D, 0x8D, 0x10, 0x9C, 0x4E, 0x60, 0x0E, 0x70, 0x4F, 0x76, 0x2D, 0x1C, 
+0x4C, 0x61, 0xBD, 0xD0, 0x4D, 0x8D, 0x10, 0x9C, 0x4E, 0x60, 0x0E, 0x70, 0x4F, 0x76, 0x2D, 0x1C, 
 0x50, 0x49, 0x2A, 0xF0, 0x51, 0x56, 0x0F, 0x1C, 0x52, 0x29, 0x0C, 0xF0, 0x53, 0x35, 0xF1, 0x1C, 
 0x54, 0x08, 0xEE, 0xF0, 0x55, 0x15, 0xD3, 0x1C, 0x55, 0xE8, 0xD0, 0xF0, 0x56, 0xF5, 0xB5, 0x1C, 
 0x57, 0xC8, 0xB2, 0xF0, 0x58, 0xD5, 0x97, 0x1C, 0x59, 0xA8, 0x94, 0xF0, 0x5A, 0xBE, 0xB3, 0x9C, 
@@ -7895,7 +7941,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 /* Asia/Hong_Kong */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x48, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x11, 0x85, 0x69, 0x5A, 0xFC, 
+0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x11, 0x85, 0x69, 0x5A, 0xFC, 
 0xC9, 0xEA, 0x57, 0xB8, 0xCA, 0xDA, 0x3A, 0xA8, 0xCB, 0x4B, 0x78, 0x80, 0xD2, 0x4C, 0x62, 0x70, 
 0xD3, 0x6A, 0xB7, 0x38, 0xD4, 0x93, 0x4A, 0xA8, 0xD5, 0x42, 0xB0, 0x38, 0xD6, 0x9A, 0xB9, 0xA8, 
 0xD7, 0x3E, 0x41, 0xB8, 0xD8, 0x2E, 0x24, 0xA8, 0xD8, 0xF9, 0x39, 0xB8, 0xDA, 0x0E, 0x06, 0xA8, 
@@ -7912,16 +7958,16 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x8E, 0x22, 0xB8, 0x01, 0x7E, 0x05, 0xA8, 0x02, 0x6E, 0x04, 0xB8, 0x03, 0x5D, 0xE7, 0xA8, 
 0x04, 0x4D, 0xE6, 0xB8, 0x05, 0x47, 0x04, 0x28, 0x06, 0x37, 0x03, 0x38, 0x07, 0x26, 0xE6, 0x28, 
 0x07, 0x83, 0x3D, 0x38, 0x09, 0x06, 0xC8, 0x28, 0x09, 0xF6, 0xC7, 0x38, 0x0A, 0xE6, 0xAA, 0x28, 
-0x0B, 0xD6, 0xA9, 0x38, 0x0C, 0xC6, 0x8C, 0x28, 0x0D, 0xB6, 0x8B, 0x38, 0x0E, 0xA6, 0x6E, 0x28, 
-0x11, 0x9B, 0x39, 0x38, 0x12, 0x6F, 0x6C, 0xA8, 0x02, 0x01, 0x02, 0x03, 0x02, 0x01, 0x02, 0x01, 
+0x0B, 0xD6, 0xA9, 0x38, 0x0C, 0xC6, 0x8C, 0x28, 0x11, 0x9B, 0x39, 0x38, 0x12, 0x6F, 0x6C, 0xA8, 
+0x02, 0x01, 0x02, 0x03, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
-0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 
-0x00, 0x6B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 0x04, 0x00, 0x00, 0x70, 0x80, 0x00, 
-0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x48, 0x4B, 0x53, 0x54, 0x00, 
-0x48, 0x4B, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0xAB, 0x54, 0xAD, 0x01, 0xC0, 0xD6, 0x57, 0x00, 0x00, 0x00, 0x00, 
+0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x6B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 
+0x04, 0x00, 0x00, 0x70, 0x80, 0x00, 0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 
+0x00, 0x48, 0x4B, 0x53, 0x54, 0x00, 0x48, 0x4B, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0x54, 0xAD, 0x01, 0xC0, 0xD6, 0x57, 0x00, 0x00, 
+0x00, 0x00, 
 
 /* Asia/Hovd */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x4D, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -11781,7 +11827,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 /* Egypt */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0xAE, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0xC8, 0x93, 0xB4, 0xE0, 
+0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0xC8, 0x93, 0xB4, 0xE0, 
 0xC8, 0xFA, 0x7B, 0xD0, 0xC9, 0xFC, 0xEF, 0xE0, 0xCA, 0xC7, 0xE8, 0xD0, 0xCB, 0xCB, 0xAE, 0x60, 
 0xCC, 0xDF, 0x29, 0xD0, 0xCD, 0xAC, 0xE1, 0xE0, 0xCE, 0xC6, 0xF4, 0xD0, 0xCF, 0x8F, 0x66, 0xE0, 
 0xD0, 0xA9, 0x79, 0xD0, 0xD1, 0x84, 0x60, 0xE0, 0xD2, 0x8A, 0xAD, 0x50, 0xE8, 0x36, 0x63, 0x60, 
@@ -11811,35 +11857,36 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x3F, 0x73, 0x57, 0x50, 0x40, 0x91, 0x7A, 0xE0, 0x41, 0x5C, 0x73, 0xD0, 0x42, 0x71, 0x5C, 0xE0, 
 0x43, 0x3C, 0x55, 0xD0, 0x44, 0x51, 0x3E, 0xE0, 0x45, 0x12, 0xFD, 0x50, 0x46, 0x31, 0x20, 0xE0, 
 0x46, 0xE0, 0x6A, 0x50, 0x48, 0x11, 0x02, 0xE0, 0x48, 0xB7, 0x11, 0xD0, 0x49, 0xF0, 0xE4, 0xE0, 
-0x4A, 0x8D, 0xB9, 0x50, 0x4B, 0xDA, 0x01, 0x60, 0x4C, 0xA4, 0xFA, 0x50, 0x4D, 0xB9, 0xE3, 0x60, 
-0x4E, 0x84, 0xDC, 0x50, 0x4F, 0x99, 0xC5, 0x60, 0x50, 0x64, 0xBE, 0x50, 0x51, 0x79, 0xA7, 0x60, 
-0x52, 0x44, 0xA0, 0x50, 0x53, 0x59, 0x89, 0x60, 0x54, 0x24, 0x82, 0x50, 0x55, 0x39, 0x6B, 0x60, 
-0x56, 0x04, 0x64, 0x50, 0x57, 0x22, 0x87, 0xE0, 0x57, 0xED, 0x80, 0xD0, 0x59, 0x02, 0x69, 0xE0, 
-0x59, 0xCD, 0x62, 0xD0, 0x5A, 0xE2, 0x4B, 0xE0, 0x5B, 0xAD, 0x44, 0xD0, 0x5C, 0xC2, 0x2D, 0xE0, 
-0x5D, 0x8D, 0x26, 0xD0, 0x5E, 0xA2, 0x0F, 0xE0, 0x5F, 0x6D, 0x08, 0xD0, 0x60, 0x8B, 0x2C, 0x60, 
-0x61, 0x56, 0x25, 0x50, 0x62, 0x6B, 0x0E, 0x60, 0x63, 0x36, 0x07, 0x50, 0x64, 0x4A, 0xF0, 0x60, 
-0x65, 0x15, 0xE9, 0x50, 0x66, 0x2A, 0xD2, 0x60, 0x66, 0xF5, 0xCB, 0x50, 0x68, 0x0A, 0xB4, 0x60, 
-0x68, 0xD5, 0xAD, 0x50, 0x69, 0xEA, 0x96, 0x60, 0x6A, 0xB5, 0x8F, 0x50, 0x6B, 0xD3, 0xB2, 0xE0, 
-0x6C, 0x9E, 0xAB, 0xD0, 0x6D, 0xB3, 0x94, 0xE0, 0x6E, 0x7E, 0x8D, 0xD0, 0x6F, 0x93, 0x76, 0xE0, 
-0x70, 0x5E, 0x6F, 0xD0, 0x71, 0x73, 0x58, 0xE0, 0x72, 0x3E, 0x51, 0xD0, 0x73, 0x53, 0x3A, 0xE0, 
-0x74, 0x1E, 0x33, 0xD0, 0x75, 0x3C, 0x57, 0x60, 0x76, 0x07, 0x50, 0x50, 0x77, 0x1C, 0x39, 0x60, 
-0x77, 0xE7, 0x32, 0x50, 0x78, 0xFC, 0x1B, 0x60, 0x79, 0xC7, 0x14, 0x50, 0x7A, 0xDB, 0xFD, 0x60, 
-0x7B, 0xA6, 0xF6, 0x50, 0x7C, 0xBB, 0xDF, 0x60, 0x7D, 0x86, 0xD8, 0x50, 0x7E, 0x9B, 0xC1, 0x60, 
-0x7F, 0x66, 0xBA, 0x50, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
+0x4A, 0x8D, 0xB9, 0x50, 0x4B, 0xDA, 0x01, 0x60, 0x4C, 0x61, 0xBD, 0xD0, 0x4C, 0x89, 0x58, 0xE0, 
+0x4C, 0xA4, 0xFA, 0x50, 0x4D, 0xB9, 0xE3, 0x60, 0x4E, 0x84, 0xDC, 0x50, 0x4F, 0x99, 0xC5, 0x60, 
+0x50, 0x64, 0xBE, 0x50, 0x51, 0x79, 0xA7, 0x60, 0x52, 0x44, 0xA0, 0x50, 0x53, 0x59, 0x89, 0x60, 
+0x54, 0x24, 0x82, 0x50, 0x55, 0x39, 0x6B, 0x60, 0x56, 0x04, 0x64, 0x50, 0x57, 0x22, 0x87, 0xE0, 
+0x57, 0xED, 0x80, 0xD0, 0x59, 0x02, 0x69, 0xE0, 0x59, 0xCD, 0x62, 0xD0, 0x5A, 0xE2, 0x4B, 0xE0, 
+0x5B, 0xAD, 0x44, 0xD0, 0x5C, 0xC2, 0x2D, 0xE0, 0x5D, 0x8D, 0x26, 0xD0, 0x5E, 0xA2, 0x0F, 0xE0, 
+0x5F, 0x6D, 0x08, 0xD0, 0x60, 0x8B, 0x2C, 0x60, 0x61, 0x56, 0x25, 0x50, 0x62, 0x6B, 0x0E, 0x60, 
+0x63, 0x36, 0x07, 0x50, 0x64, 0x4A, 0xF0, 0x60, 0x65, 0x15, 0xE9, 0x50, 0x66, 0x2A, 0xD2, 0x60, 
+0x66, 0xF5, 0xCB, 0x50, 0x68, 0x0A, 0xB4, 0x60, 0x68, 0xD5, 0xAD, 0x50, 0x69, 0xEA, 0x96, 0x60, 
+0x6A, 0xB5, 0x8F, 0x50, 0x6B, 0xD3, 0xB2, 0xE0, 0x6C, 0x9E, 0xAB, 0xD0, 0x6D, 0xB3, 0x94, 0xE0, 
+0x6E, 0x7E, 0x8D, 0xD0, 0x6F, 0x93, 0x76, 0xE0, 0x70, 0x5E, 0x6F, 0xD0, 0x71, 0x73, 0x58, 0xE0, 
+0x72, 0x3E, 0x51, 0xD0, 0x73, 0x53, 0x3A, 0xE0, 0x74, 0x1E, 0x33, 0xD0, 0x75, 0x3C, 0x57, 0x60, 
+0x76, 0x07, 0x50, 0x50, 0x77, 0x1C, 0x39, 0x60, 0x77, 0xE7, 0x32, 0x50, 0x78, 0xFC, 0x1B, 0x60, 
+0x79, 0xC7, 0x14, 0x50, 0x7A, 0xDB, 0xFD, 0x60, 0x7B, 0xA6, 0xF6, 0x50, 0x7C, 0xBB, 0xDF, 0x60, 
+0x7D, 0x86, 0xD8, 0x50, 0x7E, 0x9B, 0xC1, 0x60, 0x7F, 0x66, 0xBA, 0x50, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
-0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
+0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
+0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
+0x02, 0x03, 0x02, 0x01, 0x00, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 
-0x02, 0x03, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x00, 0x00, 
-0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x45, 0x45, 0x53, 0x54, 0x00, 0x45, 
-0x45, 0x54, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 
-0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, 
+0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x00, 0x00, 0x2A, 0x30, 
+0x01, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x00, 0x05, 0x00, 0x00, 0x2A, 0x30, 0x01, 0x00, 0x00, 0x00, 
+0x1C, 0x20, 0x00, 0x05, 0x45, 0x45, 0x53, 0x54, 0x00, 0x45, 0x45, 0x54, 0x00, 0x00, 0x00, 0x01, 
+0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 
+0x00, 
 
 /* Eire */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -13180,8 +13227,8 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x50, 0x48, 0x50, 0x31, 0x01, 0x46, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0D, 0xA4, 0x73, 0x6F, 0x18, 
-0xCB, 0xCE, 0x51, 0x60, 0xCC, 0xBF, 0x85, 0xD0, 0x15, 0x23, 0xEB, 0x90, 0x16, 0x13, 0xDC, 0x90, 
-0x17, 0x03, 0xCD, 0x90, 0x17, 0xF3, 0xBE, 0x90, 0x18, 0xE3, 0xAF, 0x90, 0x19, 0xD3, 0xA0, 0x90, 
+0xCB, 0xCE, 0x51, 0x60, 0xCC, 0xBF, 0x85, 0xD0, 0x15, 0x23, 0xDD, 0x80, 0x16, 0x13, 0xCE, 0x80, 
+0x17, 0x03, 0xBF, 0x80, 0x17, 0xF3, 0xB0, 0x80, 0x18, 0xE3, 0xAF, 0x90, 0x19, 0xD3, 0xA0, 0x90, 
 0x1A, 0xC3, 0x91, 0x90, 0x1B, 0xBC, 0xBD, 0x10, 0x1C, 0xAC, 0xAE, 0x10, 0x1D, 0x9C, 0x9F, 0x10, 
 0x1E, 0x8C, 0x90, 0x10, 0x1F, 0x7C, 0x81, 0x10, 0x20, 0x6C, 0x72, 0x10, 0x21, 0x5C, 0x63, 0x10, 
 0x22, 0x4C, 0x54, 0x10, 0x23, 0x3C, 0x45, 0x10, 0x24, 0x2C, 0x36, 0x10, 0x25, 0x1C, 0x27, 0x10, 
@@ -13209,7 +13256,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x75, 0x11, 0x00, 0x10, 0x76, 0x2F, 0x15, 0x90, 0x76, 0xF0, 0xE2, 0x10, 0x78, 0x0E, 0xF7, 0x90, 
 0x78, 0xD0, 0xC4, 0x10, 0x79, 0xEE, 0xD9, 0x90, 0x7A, 0xB0, 0xA6, 0x10, 0x7B, 0xCE, 0xBB, 0x90, 
 0x7C, 0x99, 0xC2, 0x90, 0x7D, 0xAE, 0x9D, 0x90, 0x7E, 0x79, 0xA4, 0x90, 0x7F, 0x8E, 0x7F, 0x90, 
-0x02, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
+0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
@@ -13985,8 +14032,8 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x50, 0x48, 0x50, 0x31, 0x01, 0x41, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0D, 0xA4, 0x73, 0x6F, 0x18, 
-0xCB, 0xCE, 0x51, 0x60, 0xCC, 0xBF, 0x85, 0xD0, 0x15, 0x23, 0xEB, 0x90, 0x16, 0x13, 0xDC, 0x90, 
-0x17, 0x03, 0xCD, 0x90, 0x17, 0xF3, 0xBE, 0x90, 0x18, 0xE3, 0xAF, 0x90, 0x19, 0xD3, 0xA0, 0x90, 
+0xCB, 0xCE, 0x51, 0x60, 0xCC, 0xBF, 0x85, 0xD0, 0x15, 0x23, 0xDD, 0x80, 0x16, 0x13, 0xCE, 0x80, 
+0x17, 0x03, 0xBF, 0x80, 0x17, 0xF3, 0xB0, 0x80, 0x18, 0xE3, 0xAF, 0x90, 0x19, 0xD3, 0xA0, 0x90, 
 0x1A, 0xC3, 0x91, 0x90, 0x1B, 0xBC, 0xBD, 0x10, 0x1C, 0xAC, 0xAE, 0x10, 0x1D, 0x9C, 0x9F, 0x10, 
 0x1E, 0x8C, 0x90, 0x10, 0x1F, 0x7C, 0x81, 0x10, 0x20, 0x6C, 0x72, 0x10, 0x21, 0x5C, 0x63, 0x10, 
 0x22, 0x4C, 0x54, 0x10, 0x23, 0x3C, 0x45, 0x10, 0x24, 0x2C, 0x36, 0x10, 0x25, 0x1C, 0x27, 0x10, 
@@ -14014,7 +14061,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x75, 0x11, 0x00, 0x10, 0x76, 0x2F, 0x15, 0x90, 0x76, 0xF0, 0xE2, 0x10, 0x78, 0x0E, 0xF7, 0x90, 
 0x78, 0xD0, 0xC4, 0x10, 0x79, 0xEE, 0xD9, 0x90, 0x7A, 0xB0, 0xA6, 0x10, 0x7B, 0xCE, 0xBB, 0x90, 
 0x7C, 0x99, 0xC2, 0x90, 0x7D, 0xAE, 0x9D, 0x90, 0x7E, 0x79, 0xA4, 0x90, 0x7F, 0x8E, 0x7F, 0x90, 
-0x02, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
+0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 0x04, 0x03, 
@@ -15870,7 +15917,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 /* Hongkong */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x11, 0x85, 0x69, 0x5A, 0xFC, 
+0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x11, 0x85, 0x69, 0x5A, 0xFC, 
 0xC9, 0xEA, 0x57, 0xB8, 0xCA, 0xDA, 0x3A, 0xA8, 0xCB, 0x4B, 0x78, 0x80, 0xD2, 0x4C, 0x62, 0x70, 
 0xD3, 0x6A, 0xB7, 0x38, 0xD4, 0x93, 0x4A, 0xA8, 0xD5, 0x42, 0xB0, 0x38, 0xD6, 0x9A, 0xB9, 0xA8, 
 0xD7, 0x3E, 0x41, 0xB8, 0xD8, 0x2E, 0x24, 0xA8, 0xD8, 0xF9, 0x39, 0xB8, 0xDA, 0x0E, 0x06, 0xA8, 
@@ -15887,16 +15934,16 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x8E, 0x22, 0xB8, 0x01, 0x7E, 0x05, 0xA8, 0x02, 0x6E, 0x04, 0xB8, 0x03, 0x5D, 0xE7, 0xA8, 
 0x04, 0x4D, 0xE6, 0xB8, 0x05, 0x47, 0x04, 0x28, 0x06, 0x37, 0x03, 0x38, 0x07, 0x26, 0xE6, 0x28, 
 0x07, 0x83, 0x3D, 0x38, 0x09, 0x06, 0xC8, 0x28, 0x09, 0xF6, 0xC7, 0x38, 0x0A, 0xE6, 0xAA, 0x28, 
-0x0B, 0xD6, 0xA9, 0x38, 0x0C, 0xC6, 0x8C, 0x28, 0x0D, 0xB6, 0x8B, 0x38, 0x0E, 0xA6, 0x6E, 0x28, 
-0x11, 0x9B, 0x39, 0x38, 0x12, 0x6F, 0x6C, 0xA8, 0x02, 0x01, 0x02, 0x03, 0x02, 0x01, 0x02, 0x01, 
+0x0B, 0xD6, 0xA9, 0x38, 0x0C, 0xC6, 0x8C, 0x28, 0x11, 0x9B, 0x39, 0x38, 0x12, 0x6F, 0x6C, 0xA8, 
+0x02, 0x01, 0x02, 0x03, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 
-0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 
-0x00, 0x6B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 0x04, 0x00, 0x00, 0x70, 0x80, 0x00, 
-0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x48, 0x4B, 0x53, 0x54, 0x00, 
-0x48, 0x4B, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 0x00, 0x00, 
+0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x6B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x90, 0x01, 
+0x04, 0x00, 0x00, 0x70, 0x80, 0x00, 0x09, 0x00, 0x00, 0x7E, 0x90, 0x00, 0x0D, 0x4C, 0x4D, 0x54, 
+0x00, 0x48, 0x4B, 0x53, 0x54, 0x00, 0x48, 0x4B, 0x54, 0x00, 0x4A, 0x53, 0x54, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 0x00, 0x00, 
+0x00, 0x00, 
 
 /* HST */
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -16592,7 +16639,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x50, 0x48, 0x50, 0x31, 0x01, 0x57, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x12, 0x91, 0x05, 0xFC, 0x00, 
-0xDA, 0x62, 0x04, 0x38, 0x4C, 0x9F, 0x27, 0xB0, 0x4D, 0x98, 0x45, 0x20, 0x01, 0x02, 0x03, 0x02, 
+0xDA, 0x62, 0x04, 0x38, 0x4C, 0x9F, 0x27, 0xB0, 0x4D, 0x98, 0x53, 0x30, 0x01, 0x02, 0x03, 0x02, 
 0xFF, 0xFF, 0x5F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x5E, 0x48, 0x00, 0x04, 0xFF, 0xFF, 0x65, 0x50, 
 0x00, 0x09, 0xFF, 0xFF, 0x73, 0x60, 0x01, 0x0D, 0x4C, 0x4D, 0x54, 0x00, 0x53, 0x41, 0x4D, 0x54, 
 0x00, 0x57, 0x53, 0x54, 0x00, 0x57, 0x53, 0x44, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -16707,6 +16754,14 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x05, 0x43, 0xA7, 0x00, 0x00, 0x00, 0x0F, 0x43, 0x68, 0x61, 0x74, 0x68, 0x61, 0x6D, 0x20, 
 0x49, 0x73, 0x6C, 0x61, 0x6E, 0x64, 0x73, 
 
+/* Pacific/Chuuk */
+0x50, 0x48, 0x50, 0x31, 0x01, 0x46, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x8C, 0xA0, 
+0x00, 0x00, 0x43, 0x48, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x94, 0xA5, 0x62, 0x01, 0xFA, 0x42, 
+0xDD, 0x00, 0x00, 0x00, 0x14, 0x43, 0x68, 0x75, 0x75, 0x6B, 0x20, 0x28, 0x54, 0x72, 0x75, 0x6B, 
+0x29, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x59, 0x61, 0x70, 
+
 /* Pacific/Easter */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x43, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 
@@ -16799,7 +16854,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0D, 0x9A, 0x13, 0xB2, 0x3C, 
 0x36, 0x3B, 0x17, 0xE0, 0x36, 0xD7, 0xFA, 0x60, 0x38, 0x24, 0x34, 0x60, 0x38, 0xB7, 0xDC, 0x60, 
-0x4B, 0x11, 0x2C, 0xE0, 0x4B, 0xAE, 0x0F, 0x60, 0x4C, 0xC2, 0xEA, 0x60, 0x4D, 0x8D, 0xF1, 0x60, 
+0x4B, 0x11, 0x2C, 0xE0, 0x4B, 0xAE, 0x0F, 0x60, 0x4C, 0xC2, 0xEA, 0x60, 0x4D, 0x72, 0x41, 0xE0, 
 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0xA7, 0x44, 0x00, 0x00, 0x00, 
 0x00, 0xB6, 0xD0, 0x01, 0x04, 0x00, 0x00, 0xA8, 0xC0, 0x00, 0x09, 0x4C, 0x4D, 0x54, 0x00, 0x46, 
 0x4A, 0x53, 0x54, 0x00, 0x46, 0x4A, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 
@@ -16985,13 +17040,20 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x50, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x14, 0x95, 0x00, 0x4C, 0x2A, 
 0xB2, 0x00, 0x00, 0x00, 0x00, 
 
-/* Pacific/Ponape */
+/* Pacific/Pohnpei */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x46, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x9A, 0xB0, 
 0x00, 0x00, 0x50, 0x4F, 0x4E, 0x54, 0x00, 0x00, 0x00, 0x00, 0x93, 0xF5, 0x9A, 0x02, 0x04, 0x13, 
-0xE2, 0x00, 0x00, 0x00, 0x10, 0x50, 0x6F, 0x6E, 0x61, 0x70, 0x65, 0x20, 0x28, 0x50, 0x6F, 0x68, 
-0x6E, 0x70, 0x65, 0x69, 0x29, 
+0xE2, 0x00, 0x00, 0x00, 0x10, 0x50, 0x6F, 0x68, 0x6E, 0x70, 0x65, 0x69, 0x20, 0x28, 0x50, 0x6F, 
+0x6E, 0x61, 0x70, 0x65, 0x29, 
+
+/* Pacific/Ponape */
+0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x9A, 0xB0, 
+0x00, 0x00, 0x50, 0x4F, 0x4E, 0x54, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 
+0x80, 0x00, 0x00, 0x00, 0x00, 
 
 /* Pacific/Port_Moresby */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -17065,12 +17127,11 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x69, 0x08, 0x05, 0x00, 0x07, 0x60, 0x05, 0x00, 0x00, 0x00, 0x00, 
 
 /* Pacific/Truk */
-0x50, 0x48, 0x50, 0x31, 0x01, 0x46, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x8C, 0xA0, 
-0x00, 0x00, 0x54, 0x52, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x94, 0xA5, 0x62, 0x01, 0xFA, 0x42, 
-0xDD, 0x00, 0x00, 0x00, 0x14, 0x54, 0x72, 0x75, 0x6B, 0x20, 0x28, 0x43, 0x68, 0x75, 0x75, 0x6B, 
-0x29, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x59, 0x61, 0x70, 
+0x00, 0x00, 0x43, 0x48, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 
+0x80, 0x00, 0x00, 0x00, 0x00, 
 
 /* Pacific/Wake */
 0x50, 0x48, 0x50, 0x31, 0x01, 0x55, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
@@ -17091,7 +17152,7 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x50, 0x48, 0x50, 0x31, 0x00, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x8C, 0xA0, 
-0x00, 0x00, 0x54, 0x52, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 
+0x00, 0x00, 0x43, 0x48, 0x55, 0x54, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 
 0x80, 0x00, 0x00, 0x00, 0x00, 
 
 /* Poland */
@@ -18208,4 +18269,4 @@ const unsigned char timelib_timezone_db_data_builtin[259182] = {
 0x00, 0x00, 0x55, 0x54, 0x43, 0x00, 0x00, 0x00, 0x00, 0x89, 0x54, 0x40, 0x01, 0x12, 0xA8, 0x80, 
 0x00, 0x00, 0x00, 0x00, };
 
-const timelib_tzdb timezonedb_builtin = { "2010.9", 565, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };
+const timelib_tzdb timezonedb_builtin = { "2010.15", 568, timezonedb_idx_builtin, timelib_timezone_db_data_builtin };
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c
index 81befbe..de877a3 100644
--- a/ext/date/lib/tm2unixtime.c
+++ b/ext/date/lib/tm2unixtime.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: tm2unixtime.c 298973 2010-05-04 15:11:41Z derick $ */
+/* $Id: tm2unixtime.c 302890 2010-08-30 16:25:52Z derick $ */
 
 #include "timelib.h"
 
@@ -444,6 +444,7 @@ void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi)
 	time->sse = res;
 
 	time->sse_uptodate = 1;
+	time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative = 0;
 }
 
 #if 0
diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c
index 416de9b..c12d9a3 100644
--- a/ext/date/lib/unixtime2tm.c
+++ b/ext/date/lib/unixtime2tm.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: unixtime2tm.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: unixtime2tm.c 307131 2011-01-05 15:34:34Z johannes $ */
 
 #include "timelib.h"
 
@@ -55,6 +55,12 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
 
 	if (ts >= 0) {
 		tmp_days = days + 1;
+
+		if (tmp_days >= DAYS_PER_LYEAR_PERIOD || tmp_days <= -DAYS_PER_LYEAR_PERIOD) {
+			cur_year += YEARS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
+			tmp_days -= DAYS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
+		}
+
 		while (tmp_days >= DAYS_PER_LYEAR) {
 			cur_year++;
 			if (timelib_is_leap(cur_year)) {
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index abf0547..8fd0a3d 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_date.c 300294 2010-06-08 21:23:48Z srinatar $ */
+/* $Id: php_date.c 305494 2010-11-18 11:33:42Z felipe $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -475,7 +475,6 @@ const zend_function_entry date_funcs_period[] = {
 
 static char* guess_timezone(const timelib_tzdb *tzdb TSRMLS_DC);
 static void date_register_classes(TSRMLS_D);
-static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
 /* }}} */
 
 ZEND_DECLARE_MODULE_GLOBALS(date)
@@ -1211,11 +1210,11 @@ PHPAPI int php_idate(char format, time_t ts, int localtime)
 	int retval = -1;
 	timelib_time_offset *offset = NULL;
 	timelib_sll isoweek, isoyear;
+	TSRMLS_FETCH();
 
 	t = timelib_time_ctor();
 
 	if (!localtime) {
-		TSRMLS_FETCH();
 		tzi = get_timezone_info(TSRMLS_C);
 		t->tz_info = tzi;
 		t->zone_type = TIMELIB_ZONETYPE_ID;
@@ -1822,7 +1821,7 @@ static int date_period_it_has_more(zend_object_iterator *iter TSRMLS_DC)
 {
 	date_period_it *iterator = (date_period_it *)iter;
 	php_period_obj *object   = iterator->object;
-	timelib_time   *it_time = object->start;
+	timelib_time   *it_time = object->current;
 
 	/* apply modification if it's not the first iteration */
 	if (!object->include_start_date || iterator->current_index > 0) {
@@ -1834,7 +1833,7 @@ static int date_period_it_has_more(zend_object_iterator *iter TSRMLS_DC)
 	}
 
 	if (object->end) {
-		return object->start->sse < object->end->sse ? SUCCESS : FAILURE;
+		return object->current->sse < object->end->sse ? SUCCESS : FAILURE;
 	} else {
 		return (iterator->current_index < object->recurrences) ? SUCCESS : FAILURE;
 	}
@@ -1847,12 +1846,12 @@ static void date_period_it_current_data(zend_object_iterator *iter, zval ***data
 {
 	date_period_it *iterator = (date_period_it *)iter;
 	php_period_obj *object   = iterator->object;
-	timelib_time   *it_time = object->start;
+	timelib_time   *it_time = object->current;
 	php_date_obj   *newdateobj;
 
 	/* Create new object */
 	MAKE_STD_ZVAL(iterator->current);
-	date_instantiate(date_ce_date, iterator->current TSRMLS_CC);
+	php_date_instantiate(date_ce_date, iterator->current TSRMLS_CC);
 	newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC);
 	newdateobj->time = timelib_time_ctor();
 	*newdateobj->time = *it_time;
@@ -1895,6 +1894,10 @@ static void date_period_it_rewind(zend_object_iterator *iter TSRMLS_DC)
 	date_period_it   *iterator = (date_period_it *)iter;
 
 	iterator->current_index = 0;
+	if (iterator->object->current) {
+		timelib_time_dtor(iterator->object->current);
+	}
+	iterator->object->current = timelib_time_clone(iterator->object->start);
 	date_period_it_invalidate_current(iter TSRMLS_CC);
 }
 /* }}} */
@@ -2085,7 +2088,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
 
 	dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
 
-	props = dateobj->std.properties;
+	props = zend_std_get_properties(object TSRMLS_CC);
 
 	if (!dateobj->time || GC_G(gc_active)) {
 		return props;
@@ -2228,7 +2231,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
 
 	intervalobj = (php_interval_obj *) zend_object_store_get_object(object TSRMLS_CC);
 
-	props = intervalobj->std.properties;
+	props = zend_std_get_properties(object TSRMLS_CC);
 
 	if (!intervalobj->initialized || GC_G(gc_active)) {
 		return props;
@@ -2335,6 +2338,10 @@ static void date_object_free_storage_period(void *object TSRMLS_DC)
 		timelib_time_dtor(intern->start);
 	}
 
+	if (intern->current) {
+		timelib_time_dtor(intern->current);
+	}
+
 	if (intern->end) {
 		timelib_time_dtor(intern->end);
 	}
@@ -2345,7 +2352,7 @@ static void date_object_free_storage_period(void *object TSRMLS_DC)
 }
 
 /* Advanced Interface */
-static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
+PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
 {
 	Z_TYPE_P(object) = IS_OBJECT;
 	object_init_ex(object, pce);
@@ -2365,7 +2372,7 @@ static void update_errors_warnings(timelib_error_container *last_errors TSRMLS_D
 	DATEG(last_errors) = last_errors;
 }
 
-static int date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC)
+PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC)
 {
 	timelib_time   *now;
 	timelib_tzinfo *tzi;
@@ -2460,8 +2467,8 @@ PHP_FUNCTION(date_create)
 		RETURN_FALSE;
 	}
 
-	date_instantiate(date_ce_date, return_value TSRMLS_CC);
-	if (!date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
+	php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
+	if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
 }
@@ -2480,8 +2487,8 @@ PHP_FUNCTION(date_create_from_format)
 		RETURN_FALSE;
 	}
 
-	date_instantiate(date_ce_date, return_value TSRMLS_CC);
-	if (!date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
+	php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
+	if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
 }
@@ -2499,7 +2506,7 @@ PHP_METHOD(DateTime, __construct)
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
 	if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
-		date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC);
+		php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC);
 	}
 	zend_restore_error_handling(&error_handling TSRMLS_CC);
 }
@@ -2526,7 +2533,7 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
 					case TIMELIB_ZONETYPE_ABBR: {
 						char *tmp = emalloc(Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2);
 						snprintf(tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2, "%s %s", Z_STRVAL_PP(z_date), Z_STRVAL_PP(z_timezone));
-						date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC);
+						php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC);
 						efree(tmp);
 						return 1;
 					}
@@ -2537,12 +2544,12 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
 						tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
 
 						ALLOC_INIT_ZVAL(tmp_obj);
-						tzobj = zend_object_store_get_object(date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC);
+						tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC);
 						tzobj->type = TIMELIB_ZONETYPE_ID;
 						tzobj->tzi.tz = tzi;
 						tzobj->initialized = 1;
 
-						date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC);
+						php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC);
 						zval_ptr_dtor(&tmp_obj);
 						return 1;
 				}
@@ -2566,7 +2573,7 @@ PHP_METHOD(DateTime, __set_state)
 
 	myht = HASH_OF(array);
 
-	date_instantiate(date_ce_date, return_value TSRMLS_CC);
+	php_date_instantiate(date_ce_date, return_value TSRMLS_CC);
 	dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
 	php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC);
 }
@@ -2907,7 +2914,7 @@ PHP_FUNCTION(date_timezone_get)
 	dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
 	DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
 	if (dateobj->time->is_localtime/* && dateobj->time->tz_info*/) {
-		date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
+		php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
 		tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
 		tzobj->initialized = 1;
 		tzobj->type = dateobj->time->zone_type;
@@ -3131,7 +3138,7 @@ PHP_FUNCTION(date_diff)
 	timelib_update_ts(dateobj1->time, NULL);
 	timelib_update_ts(dateobj2->time, NULL);
 
-	date_instantiate(date_ce_interval, return_value TSRMLS_CC);
+	php_date_instantiate(date_ce_interval, return_value TSRMLS_CC);
 	interval = zend_object_store_get_object(return_value TSRMLS_CC);
 	interval->diff = timelib_diff(dateobj1->time, dateobj2->time);
 	if (absolute) {
@@ -3177,7 +3184,7 @@ PHP_FUNCTION(timezone_open)
 	if (SUCCESS != timezone_initialize(&tzi, tz TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
-	tzobj = zend_object_store_get_object(date_instantiate(date_ce_timezone, return_value TSRMLS_CC) TSRMLS_CC);
+	tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC) TSRMLS_CC);
 	tzobj->type = TIMELIB_ZONETYPE_ID;
 	tzobj->tzi.tz = tzi;
 	tzobj->initialized = 1;
@@ -3569,7 +3576,7 @@ PHP_FUNCTION(date_interval_create_from_date_string)
 		RETURN_FALSE;
 	}
 
-	date_instantiate(date_ce_interval, return_value TSRMLS_CC);
+	php_date_instantiate(date_ce_interval, return_value TSRMLS_CC);
 
 	time = timelib_strtotime(time_str, time_str_len, &err, DATE_TIMEZONEDB);
 	diobj = (php_interval_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
@@ -3713,6 +3720,7 @@ PHP_METHOD(DatePeriod, __construct)
 	}
 
 	dpobj = zend_object_store_get_object(getThis() TSRMLS_CC);
+	dpobj->current = NULL;
 
 	if (isostr_len) {
 		date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), (int*) &recurrences, isostr, isostr_len TSRMLS_CC);
@@ -3754,14 +3762,7 @@ PHP_METHOD(DatePeriod, __construct)
 		/* end date */
 		if (end) {
 			dateobj = (php_date_obj *) zend_object_store_get_object(end TSRMLS_CC);
-			clone = timelib_time_ctor();
-			memcpy(clone, dateobj->time, sizeof(timelib_time));
-			if (dateobj->time->tz_abbr) {
-				clone->tz_abbr = strdup(dateobj->time->tz_abbr);
-			}
-			if (dateobj->time->tz_info) {
-				clone->tz_info = dateobj->time->tz_info;
-			}
+			clone = timelib_time_clone(dateobj->time);
 			dpobj->end = clone;
 		}
 	}
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index e26e96a..d683642 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_date.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_date.h 305492 2010-11-18 11:24:59Z derick $ */
 
 #ifndef PHP_DATE_H
 #define PHP_DATE_H
@@ -139,6 +139,7 @@ struct _php_interval_obj {
 struct _php_period_obj {
 	zend_object       std;
 	timelib_time     *start;
+	timelib_time     *current;
 	timelib_time     *end;
 	timelib_rel_time *interval;
 	int               recurrences;
@@ -177,4 +178,9 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
 PHPAPI zend_class_entry *php_date_get_date_ce(void);
 PHPAPI zend_class_entry *php_date_get_timezone_ce(void);
 
+/* Functions for creating DateTime objects, and initializing them from a string */
+PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC);
+PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int time_str_len, char *format, zval *timezone_object, int ctor TSRMLS_DC);
+
+
 #endif /* PHP_DATE_H */
diff --git a/ext/date/tests/010.phpt b/ext/date/tests/010.phpt
index 74b2b06..aad5b70 100644
--- a/ext/date/tests/010.phpt
+++ b/ext/date/tests/010.phpt
@@ -4,649 +4,82 @@ timezone_abbreviations_list() tests
 <?php
 date_default_timezone_set('UTC');
   $timezone_abbreviations = timezone_abbreviations_list();
-  var_dump($timezone_abbreviations["est"]);
+  var_dump($timezone_abbreviations["utc"]);
   echo "Done\n";
 ?>
 --EXPECTF--
-array(71) {
+array(8) {
   [0]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(16) "America/New_York"
+    string(13) "Etc/Universal"
   }
   [1]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(15) "America/Antigua"
+    string(7) "Etc/UTC"
   }
   [2]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(16) "America/Atikokan"
+    string(8) "Etc/Zulu"
   }
   [3]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(21) "America/Cambridge_Bay"
+    string(3) "GMT"
   }
   [4]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(14) "America/Cancun"
+    string(9) "Universal"
   }
   [5]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(14) "America/Cayman"
+    string(3) "UTC"
   }
   [6]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(15) "America/Chicago"
+    string(4) "Zulu"
   }
   [7]=>
   array(3) {
     ["dst"]=>
     bool(false)
     ["offset"]=>
-    int(-18000)
+    int(0)
     ["timezone_id"]=>
-    string(21) "America/Coral_Harbour"
-  }
-  [8]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Detroit"
-  }
-  [9]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(18) "America/Fort_Wayne"
-  }
-  [10]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(18) "America/Grand_Turk"
-  }
-  [11]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(28) "America/Indiana/Indianapolis"
-  }
-  [12]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(20) "America/Indiana/Knox"
-  }
-  [13]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(23) "America/Indiana/Marengo"
-  }
-  [14]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(26) "America/Indiana/Petersburg"
-  }
-  [15]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(21) "America/Indiana/Vevay"
-  }
-  [16]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(25) "America/Indiana/Vincennes"
-  }
-  [17]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(23) "America/Indiana/Winamac"
-  }
-  [18]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(20) "America/Indianapolis"
-  }
-  [19]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Iqaluit"
-  }
-  [20]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Jamaica"
-  }
-  [21]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(27) "America/Kentucky/Louisville"
-  }
-  [22]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(27) "America/Kentucky/Monticello"
-  }
-  [23]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Knox_IN"
-  }
-  [24]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(18) "America/Louisville"
-  }
-  [25]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Managua"
-  }
-  [26]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(17) "America/Menominee"
-  }
-  [27]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(14) "America/Merida"
-  }
-  [28]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(16) "America/Montreal"
-  }
-  [29]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(14) "America/Nassau"
-  }
-  [30]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Nipigon"
-  }
-  [31]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(14) "America/Panama"
-  }
-  [32]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(19) "America/Pangnirtung"
-  }
-  [33]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(22) "America/Port-au-Prince"
-  }
-  [34]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(20) "America/Rankin_Inlet"
-  }
-  [35]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(21) "America/Santo_Domingo"
-  }
-  [36]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(19) "America/Thunder_Bay"
-  }
-  [37]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "America/Toronto"
-  }
-  [38]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(14) "Canada/Eastern"
-  }
-  [39]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(3) "EST"
-  }
-  [40]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(7) "EST5EDT"
-  }
-  [41]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(7) "Jamaica"
-  }
-  [42]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(10) "US/Central"
-  }
-  [43]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(15) "US/East-Indiana"
-  }
-  [44]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(10) "US/Eastern"
-  }
-  [45]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(17) "US/Indiana-Starke"
-  }
-  [46]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(-18000)
-    ["timezone_id"]=>
-    string(11) "US/Michigan"
-  }
-  [47]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(13) "Australia/ACT"
-  }
-  [48]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(18) "Australia/Brisbane"
-  }
-  [49]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(18) "Australia/Canberra"
-  }
-  [50]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(16) "Australia/Currie"
-  }
-  [51]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(16) "Australia/Hobart"
-  }
-  [52]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(18) "Australia/Lindeman"
-  }
-  [53]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(19) "Australia/Melbourne"
-  }
-  [54]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(13) "Australia/NSW"
-  }
-  [55]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(20) "Australia/Queensland"
-  }
-  [56]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(16) "Australia/Sydney"
-  }
-  [57]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(18) "Australia/Tasmania"
-  }
-  [58]=>
-  array(3) {
-    ["dst"]=>
-    bool(false)
-    ["offset"]=>
-    int(36000)
-    ["timezone_id"]=>
-    string(18) "Australia/Victoria"
-  }
-  [59]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(19) "Australia/Melbourne"
-  }
-  [60]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(13) "Australia/ACT"
-  }
-  [61]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(18) "Australia/Brisbane"
-  }
-  [62]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(18) "Australia/Canberra"
-  }
-  [63]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(16) "Australia/Currie"
-  }
-  [64]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(16) "Australia/Hobart"
-  }
-  [65]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(18) "Australia/Lindeman"
-  }
-  [66]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(13) "Australia/NSW"
-  }
-  [67]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(20) "Australia/Queensland"
-  }
-  [68]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(16) "Australia/Sydney"
-  }
-  [69]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(18) "Australia/Tasmania"
-  }
-  [70]=>
-  array(3) {
-    ["dst"]=>
-    bool(true)
-    ["offset"]=>
-    int(39600)
-    ["timezone_id"]=>
-    string(18) "Australia/Victoria"
+    string(3) "UTC"
   }
 }
 Done
diff --git a/ext/date/tests/DateTime_modify_variation1.phpt b/ext/date/tests/DateTime_modify_variation1.phpt
index d1c8ed4..e4d9067 100644
--- a/ext/date/tests/DateTime_modify_variation1.phpt
+++ b/ext/date/tests/DateTime_modify_variation1.phpt
@@ -111,44 +111,24 @@ fclose( $file_handle );
 *** Testing DateTime::modify() : usage variation -  unexpected values to first argument $modify***
 
 -- int 0 --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (0) at position 0 (0): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- int 1 --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- int 12345 --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (12345) at position 4 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- int -12345 --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (-12345) at position 5 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- float 10.5 --
 object(DateTime)#3 (3) {
@@ -161,14 +141,9 @@ object(DateTime)#3 (3) {
 }
 
 -- float -10.5 --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- float .5 --
 object(DateTime)#3 (3) {
@@ -182,181 +157,106 @@ object(DateTime)#3 (3) {
 
 -- empty array --
 
-Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 
 -- int indexed array --
 
-Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 
 -- associative array --
 
-Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 
 -- nested arrays --
 
-Warning: DateTime::modify() expects parameter 1 to be string, array given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 
 -- uppercase NULL --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- lowercase null --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- lowercase true --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- lowercase false --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- uppercase TRUE --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- uppercase FALSE --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- empty string DQ --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- empty string SQ --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- string DQ --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- string SQ --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- mixed case string --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- heredoc --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- instance of classWithToString --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- instance of classWithoutToString --
 
-Warning: DateTime::modify() expects parameter 1 to be string, object given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, object given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 
 -- undefined var --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- unset var --
-object(DateTime)#3 (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: DateTime::modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
+bool(false)
 
 -- resource --
 
-Warning: DateTime::modify() expects parameter 1 to be string, resource given in %s on line %d
+Warning: DateTime::modify() expects parameter 1 to be string, resource given in /home/derick/dev/php/php-src/trunk/ext/date/tests/DateTime_modify_variation1.php on line 99
 bool(false)
 ===DONE===
diff --git a/ext/date/tests/big_year.phpt b/ext/date/tests/big_year.phpt
new file mode 100644
index 0000000..a15a093
--- /dev/null
+++ b/ext/date/tests/big_year.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Handling of large year values
+--SKIPIF--
+<?php echo PHP_INT_SIZE != 8 ? "skip 64-bit only" : "OK"; ?>
+--FILE--
+<?php
+date_default_timezone_set("America/Toronto");
+
+$t = mktime(0,0,0,1,1,292277026596); 
+
+var_dump(date("r", $t)); 
+
+echo "OK\n";
+?>
+--EXPECT--
+string(36) "Fri, 01 Jan 219250468 00:00:00 -0500"
+OK
diff --git a/ext/date/tests/bug33415-2.phpt b/ext/date/tests/bug33415-2.phpt
index a1e5930..9ea537a 100644
--- a/ext/date/tests/bug33415-2.phpt
+++ b/ext/date/tests/bug33415-2.phpt
@@ -250,8 +250,8 @@ wanted=Sunday            00:30:00
 
 TZ=Pacific/Truk - Is it OK for this to be 10 AM?  Note: does not
 appear to have a DST or timezone transition.
-tStamp=Thursday 1970-01-01 17:17:17 TRUT 0
-result=Tuesday 1970-01-06 00:00:00 TRUT 0
+tStamp=Thursday 1970-01-01 17:17:17 CHUT 0
+result=Tuesday 1970-01-06 00:00:00 CHUT 0
 wanted=Tuesday            00:00:00
 
 TZ=Pacific/Ponape - Is it OK for this to be 11 AM?  Note: does
diff --git a/ext/date/tests/bug46874.phpt b/ext/date/tests/bug46874.phpt
new file mode 100644
index 0000000..ee3546e
--- /dev/null
+++ b/ext/date/tests/bug46874.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #46874 (DatePeriod not resetting after foreach loop)
+--FILE--
+<?php
+$dp = new DatePeriod('R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M');
+
+foreach ($dp as $date) {
+    echo $date->format("Y-m-d H:i:s\n");
+}
+
+echo "\n";
+
+// this should repeat the same range
+foreach ($dp as $date) {
+    echo $date->format("Y-m-d H:i:s\n");
+}
+?>
+--EXPECT--
+2008-03-01 13:00:00
+2009-05-11 15:30:00
+2010-07-21 18:00:00
+2011-10-01 20:30:00
+2012-12-11 23:00:00
+2014-02-22 01:30:00
+
+2008-03-01 13:00:00
+2009-05-11 15:30:00
+2010-07-21 18:00:00
+2011-10-01 20:30:00
+2012-12-11 23:00:00
+2014-02-22 01:30:00
diff --git a/ext/date/tests/bug52342.phpt b/ext/date/tests/bug52342.phpt
new file mode 100644
index 0000000..45534a2
--- /dev/null
+++ b/ext/date/tests/bug52342.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #52342 (DateTime setIsoDate results in wrong timestamp)
+--FILE--
+<?php
+date_default_timezone_set('Europe/Berlin');
+$from = new DateTime();
+$from->setTime(0, 0, 0);
+$from->setISODate(2010, 28, 1); //Montag der 28ten Woche 2010
+ 
+echo $from->format('d.m.Y H:i'), "\n"; //A
+echo $from->getTimestamp(), "\n"; //B
+echo date('d.m.Y H:i', $from->getTimestamp()), "\n"; //C
+
+$from->add(new DateInterval('P0D'));
+echo $from->getTimestamp(), "\n"; //B
+echo date('d.m.Y H:i', $from->getTimestamp()), "\n"; //C
+?>
+--EXPECT--
+12.07.2010 00:00
+1278885600
+12.07.2010 00:00
+1278885600
+12.07.2010 00:00
diff --git a/ext/date/tests/bug52430.phpt b/ext/date/tests/bug52430.phpt
new file mode 100644
index 0000000..0f53708
--- /dev/null
+++ b/ext/date/tests/bug52430.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #52430 (date_parse parse 24:xx:xx as valid time)
+--FILE--
+<?php
+var_dump(date_parse('2010-1-1 24:59:59'));
+?>
+--EXPECT--
+array(12) {
+  ["year"]=>
+  int(2010)
+  ["month"]=>
+  int(1)
+  ["day"]=>
+  int(1)
+  ["hour"]=>
+  int(24)
+  ["minute"]=>
+  int(59)
+  ["second"]=>
+  int(59)
+  ["fraction"]=>
+  float(0)
+  ["warning_count"]=>
+  int(1)
+  ["warnings"]=>
+  array(1) {
+    [18]=>
+    string(27) "The parsed time was invalid"
+  }
+  ["error_count"]=>
+  int(0)
+  ["errors"]=>
+  array(0) {
+  }
+  ["is_localtime"]=>
+  bool(false)
+}
diff --git a/ext/date/tests/bug52454.phpt b/ext/date/tests/bug52454.phpt
new file mode 100644
index 0000000..e2a94dc
--- /dev/null
+++ b/ext/date/tests/bug52454.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #52454 (Relative dates and getTimestamp increments by one day)
+--FILE--
+<?php
+date_default_timezone_set('Europe/London');
+
+$endOfWeek = new DateTime('2010-07-27 09:46:49');
+$endOfWeek->modify('this week +6 days');
+
+echo $endOfWeek->format('Y-m-d H:i:s')."\n";
+echo $endOfWeek->format('U')."\n";
+
+/* Thar she blows! */
+echo $endOfWeek->getTimestamp()."\n";
+
+echo $endOfWeek->format('Y-m-d H:i:s')."\n";
+?>
+--EXPECT--
+2010-08-01 09:46:49
+1280652409
+1280652409
+2010-08-01 09:46:49
diff --git a/ext/date/tests/bug52577.phpt b/ext/date/tests/bug52577.phpt
new file mode 100644
index 0000000..7a58f2a
--- /dev/null
+++ b/ext/date/tests/bug52577.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #52577 (Incorrect date returning)
+--FILE--
+<?php
+date_default_timezone_set('Europe/Kiev');
+$date = '7.8.2010';
+echo "String: ".$date."\n";
+$date_format = DATE_RFC2822;
+$unixtime = strtotime($date);
+echo "Unixtime: ".$unixtime."\n";
+echo "Date(PHP): ".date($date_format,$unixtime)."\n";
+$date = new DateTime('@'.$unixtime);
+echo "DateTime(PHP Class): ".$date->format($date_format);
+?>
+--EXPECT--
+String: 7.8.2010
+Unixtime: 1281128400
+Date(PHP): Sat, 07 Aug 2010 00:00:00 +0300
+DateTime(PHP Class): Fri, 06 Aug 2010 21:00:00 +0000
diff --git a/ext/date/tests/bug52668.phpt b/ext/date/tests/bug52668.phpt
new file mode 100644
index 0000000..307a426
--- /dev/null
+++ b/ext/date/tests/bug52668.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #52668 (Iterating over a dateperiod twice is broken)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$start    = new DateTime('20101212');
+$interval = DateInterval::createFromDateString('next day');
+$dp = new DatePeriod($start, $interval, 1);
+foreach($dp as $dt) {
+    echo $dt->format('r') . "\n"; // Sun, 12 Dec 2010 00:00:00 +0100
+}
+echo $start->format('r'), "\n";
+foreach($dp as $dt) {
+    echo $dt->format('r') . "\n"; // Sun, 12 Dec 2010 00:00:00 +0100
+}
+echo $start->format('r'), "\n\n";
+?>
+--EXPECT--
+Sun, 12 Dec 2010 00:00:00 +0000
+Mon, 13 Dec 2010 00:00:00 +0000
+Sun, 12 Dec 2010 00:00:00 +0000
+Sun, 12 Dec 2010 00:00:00 +0000
+Mon, 13 Dec 2010 00:00:00 +0000
+Sun, 12 Dec 2010 00:00:00 +0000
diff --git a/ext/date/tests/date_modify_variation2.phpt b/ext/date/tests/date_modify_variation2.phpt
index 9689265..8dc563e 100644
--- a/ext/date/tests/date_modify_variation2.phpt
+++ b/ext/date/tests/date_modify_variation2.phpt
@@ -111,44 +111,24 @@ fclose( $file_handle );
 *** Testing date_modify() : usage variation -  unexpected values to second argument $format***
 
 -- int 0 --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (0) at position 0 (0): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- int 1 --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- int 12345 --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (12345) at position 4 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- int -12345 --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (-12345) at position 5 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- float 10.5 --
 object(DateTime)#%d (3) {
@@ -161,14 +141,9 @@ object(DateTime)#%d (3) {
 }
 
 -- float -10.5 --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (-10.5) at position 4 (5): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- float .5 --
 object(DateTime)#%d (3) {
@@ -182,181 +157,106 @@ object(DateTime)#%d (3) {
 
 -- empty array --
 
-Warning: date_modify() expects parameter 2 to be string, array given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 
 -- int indexed array --
 
-Warning: date_modify() expects parameter 2 to be string, array given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 
 -- associative array --
 
-Warning: date_modify() expects parameter 2 to be string, array given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 
 -- nested arrays --
 
-Warning: date_modify() expects parameter 2 to be string, array given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, array given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 
 -- uppercase NULL --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- lowercase null --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- lowercase true --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- lowercase false --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- uppercase TRUE --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (1) at position 0 (1): Unexpected character in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- uppercase FALSE --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- empty string DQ --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- empty string SQ --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- string DQ --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- string SQ --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (string) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- mixed case string --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (sTrInG) at position 0 (s): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- heredoc --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (hello world) at position 0 (h): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- instance of classWithToString --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string (Class A object) at position 0 (C): The timezone could not be found in the database in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- instance of classWithoutToString --
 
-Warning: date_modify() expects parameter 2 to be string, object given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, object given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 
 -- undefined var --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- unset var --
-object(DateTime)#%d (3) {
-  ["date"]=>
-  string(19) "2009-01-31 14:28:41"
-  ["timezone_type"]=>
-  int(3)
-  ["timezone"]=>
-  string(13) "Europe/London"
-}
+
+Warning: date_modify(): Failed to parse time string () at position 0 ( in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
+bool(false)
 
 -- resource --
 
-Warning: date_modify() expects parameter 2 to be string, resource given in %s on line %d
+Warning: date_modify() expects parameter 2 to be string, resource given in /home/derick/dev/php/php-src/trunk/ext/date/tests/date_modify_variation2.php on line 99
 bool(false)
 ===DONE===
diff --git a/ext/date/tests/timezone_abbreviations_list_basic1.phpt b/ext/date/tests/timezone_abbreviations_list_basic1.phpt
index 6fc3480..845a69c 100644
--- a/ext/date/tests/timezone_abbreviations_list_basic1.phpt
+++ b/ext/date/tests/timezone_abbreviations_list_basic1.phpt
@@ -26,7 +26,7 @@ var_dump( $abbr["acst"] );
 --EXPECT--
 *** Testing timezone_abbreviations_list() : basic functionality ***
 string(5) "array"
-int(338)
+int(399)
 
 -- Format a sample entry --
 array(4) {
@@ -67,4 +67,4 @@ array(4) {
     string(11) "Brazil/Acre"
   }
 }
-===DONE===
\ No newline at end of file
+===DONE===
diff --git a/ext/dba/config.m4 b/ext/dba/config.m4
index c24a2fc..83c6354 100644
--- a/ext/dba/config.m4
+++ b/ext/dba/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 300325 2010-06-09 17:33:44Z sixd $
+dnl $Id: config.m4 305894 2010-12-01 19:20:16Z sixd $
 dnl
 
 dnl Suppose we need FlatFile if no support or only CDB is used.
@@ -233,7 +233,7 @@ AC_DEFUN([PHP_DBA_DB_CHECK],[
     AC_MSG_CHECKING([for DB4 minor version and patch level])
     AC_EGREP_CPP(yes,[
 #include "$THIS_INCLUDE"
-#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR != 1) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
       yes
 #endif
     ],[
diff --git a/ext/dba/tests/dba_cdb_make.phpt b/ext/dba/tests/dba_cdb_make.phpt
index c1d0a01..e3ff966 100644
--- a/ext/dba/tests/dba_cdb_make.phpt
+++ b/ext/dba/tests/dba_cdb_make.phpt
@@ -37,7 +37,7 @@ magic_quotes_runtime=1
 	require(dirname(__FILE__) .'/clean.inc'); 
 ?>
 --EXPECT--
-Warning: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
 database handler: cdb_make
 string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
 string(32) "12fc5ba2b9dcfef2480e5324eeb5f3e5"
diff --git a/ext/dom/tests/bug52656.phpt b/ext/dom/tests/bug52656.phpt
new file mode 100644
index 0000000..860ef99
--- /dev/null
+++ b/ext/dom/tests/bug52656.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #52656 (DOMCdataSection does not work with splitText).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$CData = new DOMCdataSection('splithere!');
+$CDataSplit = $CData->splitText(5);
+var_dump($CDataSplit, $CDataSplit->data);
+?>
+--EXPECT--
+object(DOMText)#2 (0) {
+}
+string(5) "here!"
diff --git a/ext/dom/text.c b/ext/dom/text.c
index 2e5b237..8ad5ba9 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: text.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: text.c 305837 2010-11-29 14:48:53Z iliaa $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -160,7 +160,7 @@ PHP_FUNCTION(dom_text_split_text)
 	}
 	DOM_GET_OBJ(node, id, xmlNodePtr, intern);
 
-	if (node->type != XML_TEXT_NODE) {
+	if (node->type != XML_TEXT_NODE && node->type != XML_CDATA_SECTION_NODE) {
 		RETURN_FALSE;
 	}
 
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index 2fd93e0..e8637af 100755
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -16,7 +16,7 @@
   |         Ilia Alshanetsky <ilia at prohost.org>                          |
   +----------------------------------------------------------------------+
 
-  $Id: enchant.c 298870 2010-05-02 05:01:51Z geissert $
+  $Id: enchant.c 305507 2010-11-18 15:22:22Z pajoye $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -327,7 +327,7 @@ PHP_MINFO_FUNCTION(enchant)
 #elif defined(HAVE_ENCHANT_BROKER_SET_PARAM)
 	php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later");
 #endif
-	php_info_print_table_row(2, "Revision", "$Revision: 298870 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 305507 $");
 	php_info_print_table_end();
 
 	php_info_print_table_start();
@@ -433,6 +433,8 @@ PHP_FUNCTION(enchant_broker_set_dict_path)
 	if (!value_len) {
 		RETURN_FALSE;
 	}
+	
+	PHP_ENCHANT_GET_BROKER;
 
 	switch (dict_type) {
 		case PHP_ENCHANT_MYSPELL:
@@ -466,6 +468,8 @@ PHP_FUNCTION(enchant_broker_get_dict_path)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &broker, &dict_type) == FAILURE) {
 		RETURN_FALSE;
 	}
+	
+	PHP_ENCHANT_GET_BROKER;
 
 	switch (dict_type) {
 		case PHP_ENCHANT_MYSPELL:
@@ -587,6 +591,10 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
 		RETURN_FALSE;
 	}
 
+	if (strlen(pwl) != pwllen) {
+		RETURN_FALSE;
+	}
+
 #if PHP_API_VERSION < 20100412
 	if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl TSRMLS_CC)) {
 #else
diff --git a/ext/exif/tests/exif006.phpt b/ext/exif/tests/exif006.phpt
index cbd7191..10458c0 100644
--- a/ext/exif/tests/exif006.phpt
+++ b/ext/exif/tests/exif006.phpt
@@ -20,7 +20,7 @@ magic_quotes_runtime=1
 var_dump(exif_read_data(dirname(__FILE__).'/test6.jpg','',true,false));
 ?>
 --EXPECTF--
-Warning: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line 0
 array(5) {
   ["FILE"]=>
   array(6) {
diff --git a/ext/ext_skel b/ext/ext_skel
index c0eafbf..2492bf7 100755
--- a/ext/ext_skel
+++ b/ext/ext_skel
@@ -187,8 +187,8 @@ if (PHP_$EXTNAME != "no") {
 
 eof
 
-$ECHO_N " .cvsignore$ECHO_C"
-cat >.cvsignore <<eof
+$ECHO_N " .svnignore$ECHO_C"
+cat >.svnignore <<eof
 .deps
 *.lo
 *.la
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index d755b44..9eabcca 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: fileinfo.c 298947 2010-05-04 08:48:58Z pajoye $ */
+/* $Id: fileinfo.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -294,6 +294,9 @@ PHP_FUNCTION(finfo_open)
 	if (file_len == 0) {
 		file = NULL;
 	} else if (file && *file) { /* user specified file, perform open_basedir checks */
+		if (strlen(file) != file_len) {
+			RETURN_FALSE;
+		}
 		if (!VCWD_REALPATH(file, resolved_path)) {
 			RETURN_FALSE;
 		}
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index c6eebac..73b06be 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: logical_filters.c 297353 2010-04-02 18:27:48Z rasmus $ */
+/* $Id: logical_filters.c 305186 2010-11-08 04:36:15Z cataphract $ */
 
 #include "php_filter.h"
 #include "filter_private.h"
@@ -531,6 +531,11 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
 	int         matches;
 
 
+	/* The maximum length of an e-mail address is 320 octets, per RFC 2821. */
+	if (Z_STRLEN_P(value) > 320) {
+		RETURN_VALIDATION_FAILED
+	}
+
 	re = pcre_get_compiled_regex((char *)regexp, &pcre_extra, &preg_options TSRMLS_CC);
 	if (!re) {
 		RETURN_VALIDATION_FAILED
@@ -552,9 +557,11 @@ static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */
 	int n = 0;
 
 	while (str < end) {
+		int leading_zero;
 		if (*str < '0' || *str > '9') {
 			return 0;
 		}
+		leading_zero = (*str == '0');
 		m = 1;
 		num = ((*(str++)) - '0');
 		while (str < end && (*str >= '0' && *str <= '9')) {
@@ -563,6 +570,10 @@ static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */
 				return 0;
 			}
 		}
+		/* don't allow a leading 0; that introduces octal numbers,
+		 * which we don't support */
+		if (leading_zero && (num != 0 || m > 1))
+			return 0;
 		ip[n++] = num;
 		if (n == 4) {
 			return str == end;
@@ -577,7 +588,7 @@ static int _php_filter_validate_ipv4(char *str, int str_len, int *ip) /* {{{ */
 static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */
 {
 	int compressed = 0;
-	int blocks = 8;
+	int blocks = 0;
 	int n;
 	char *ipv4;
 	char *end;
@@ -598,32 +609,40 @@ static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */
 		if (!_php_filter_validate_ipv4(ipv4, (str_len - (ipv4 - str)), ip4elm)) {
 			return 0;
 		}
-		str_len = (ipv4 - str) - 1;
-		if (str_len == 1) {
-			return *str == ':';
+
+		str_len = ipv4 - str; /* length excluding ipv4 */
+		if (str_len < 2) {
+			return 0;
+		}
+
+		if (ipv4[-2] != ':') {
+			/* don't include : before ipv4 unless it's a :: */
+			str_len--;
 		}
-		blocks = 6;
+
+		blocks = 2;
 	}
 
 	end = str + str_len;
 
 	while (str < end) {
 		if (*str == ':') {
-			if (--blocks == 0) {
-				return 0;
-			}			
 			if (++str >= end) {
+				/* cannot end in : without previous : */
 				return 0;
 			}
 			if (*str == ':') {
-				if (compressed || --blocks == 0) {
+				if (compressed) {
 					return 0;
-				}			
-				if (++str == end) {
-					return 1;
 				}
+				blocks++; /* :: means 1 or more 16-bit 0 blocks */
 				compressed = 1;
+
+				if (++str == end) {
+					return (blocks <= 8);
+				}
 			} else if ((str - 1) == s) {
+				/* dont allow leading : without another : following */
 				return 0;
 			}				
 		}
@@ -638,8 +657,10 @@ static int _php_filter_validate_ipv6(char *str, int str_len TSRMLS_DC) /* {{{ */
 		if (n < 1 || n > 4) {
 			return 0;
 		}
+		if (++blocks > 8)
+			return 0;
 	}
-	return (compressed || blocks == 1);
+	return ((compressed && blocks <= 8) || blocks == 8);
 }
 /* }}} */
 
diff --git a/ext/filter/tests/030.phpt b/ext/filter/tests/030.phpt
index d3466f5..c5af15e 100644
--- a/ext/filter/tests/030.phpt
+++ b/ext/filter/tests/030.phpt
@@ -5,35 +5,56 @@ filter_var() and IPv6
 --FILE--
 <?php
 $ipv6_test = array(
-	"::127.0.0.1"				=> true,
-	"FF01::101:127.0.1" 		=> false,
-	"FF01:0:0:0:101:127.0.1.1"  => false,
-	"FF01:0:0:0:237:101:127.0.1.1"  => true,
-	"FF01::101"					=> true,
-	"A1080::8:800:200C:417A"	=> false,
-	"1080::8:Z00:200C:417A"		=> false,
-	"FF01::101::1"				=> false,
-	"1080::8:800:200C:417A"		=> true,
-	"1080:0:0:0:8:800:200C:417A" => true,
+	"::127.0.0.1"					=> true,
+	"FF01::101:127.0.1" 			=> false,
+	"FF01:0:0:0:101:127.0.1.1"		=> false,
+	"FF01:0:0:0:237:101:127.0.1.1"	=> true,
+	"FF01::101"						=> true,
+	"A1080::8:800:200C:417A"		=> false,
+	"1080::8:Z00:200C:417A"			=> false,
+	"FF01::101::1"					=> false,
+	"1080::8:800:200C:417A"			=> true,
+	"1080:0:0:0:8:800:200C:417A"	=> true,
 	"2001:ec8:1:1:1:1:1:1"			=> true,
 	"ffff::FFFF:129.144.52.38"		=> true,
 	"::ffff:1.2.3.4"				=> true,
-	"0:0:0:0:0:FFFF:129.144.52.38" => true,
-	"0:0:0:0:0:0:13.1.68.3"		=> true,
-	"::13.1.68.3"				=> true,
-    "::FFFF:129.144.52.38"		=> true,
+	"0:0:0:0:0:FFFF:129.144.52.38"	=> true,
+	"0:0:0:0:0:0:13.1.68.3"			=> true,
+    "0:0:0:0:0:0:0:13.1.68.3"		=> false,
+	"::13.1.68.3"					=> true,
+    "::FFFF:129.144.52.38"			=> true,
+    
     "1:2:3:4:5:6::129.144.52.38"	=> false,
     "::1:2:3:4:5:6:129.144.52.38"	=> false,
     "1:2:3::4:5:6:129.144.52.38"	=> false,
-    "1:2:3:4:5:6:7:8::"				=> false,
-    "::1:2:3:4:5:6:7:8"				=> false,
+    
     "1:2:3:4::5:6:7:8"				=> false,
+    "::1:2:3:4:5:6:7"				=> true,
+    "::1:2:3:4:5:6:7:8"				=> false,
+    "1:2:3:4:5:6:7::"				=> true,
+    "1:2:3:4:5:6:7:8::"				=> false,
+    "1:2:3:4:5:6:7::8"				=> false,
+    
+    "1:2:3:4:5:6:7:8g"				=> false,
+    "1:2:3:4:5:6:7:g"				=> false,
+    "1:2:3:4:5g:6:7:8"				=> false,
+    
+    'a:b:c:d:e::1.2.3.4'			=> true,
+    '::0:a:b:c:d:e:f'				=> true,
+    '0:a:b:c:d:e:f::'				=> true,
+    ':::1.2.3.4'					=> false,
+    '8:::1.2.3.4'					=> false,
+    '::01.02.03.04'					=> false,
+    '::1.00.3.4'					=> false,
+    '0:0:0:255.255.255.255'			=> false,
+    '0:0:0::255.255.255.255'		=> true,
 );
 foreach ($ipv6_test as $ip => $exp) {
 	$out = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
 	$out = (int) ($out === false ? 0 : 1);
 	if ($exp != $out) {
-		echo "$ip failed\n";
+		echo "$ip failed (expected ", $exp?"true":"false", ", got ", 
+            $out?"true":"false", ")\n";
 	}
 }
 
diff --git a/ext/filter/tests/bug39763.phpt b/ext/filter/tests/bug39763.phpt
index 1422f52..36ee415 100644
--- a/ext/filter/tests/bug39763.phpt
+++ b/ext/filter/tests/bug39763.phpt
@@ -12,6 +12,6 @@ parse_str("val=%22probably+a+bug%22");
 echo $val . "\n";
 ?>
 --EXPECT--	
-Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
 \"probably a bug\"
 \"probably a bug\"
\ No newline at end of file
diff --git a/ext/filter/tests/bug52929.phpt b/ext/filter/tests/bug52929.phpt
new file mode 100644
index 0000000..2933295
--- /dev/null
+++ b/ext/filter/tests/bug52929.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #52929 (Segfault in filter_var with FILTER_VALIDATE_EMAIL with large amount of data)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var('valid at email.address', FILTER_VALIDATE_EMAIL));
+
+// Beyond the allowable limit for an e-mail address.
+var_dump(filter_var('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx at yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.zz', FILTER_VALIDATE_EMAIL));
+
+// An invalid address likely to crash PHP due to stack exhaustion if it goes to
+// the validation regex.
+var_dump(filter_var(str_repeat('x', 8000), FILTER_VALIDATE_EMAIL));
+--EXPECT--	
+string(19) "valid at email.address"
+bool(false)
+bool(false)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 5fdfd9b..e20cef5 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd.c 293588 2010-01-15 17:09:14Z tabe $ */
+/* $Id: gd.c 306075 2010-12-08 08:45:56Z pajoye $ */
 
 /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
    Cold Spring Harbor Labs. */
@@ -2642,6 +2642,9 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
 	}
 
 	if (argc >= 2 && file_len) {
+		if (strlen(file) != file_len) {
+			RETURN_FALSE;
+		}
 		PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
 
 		fp = VCWD_FOPEN(fn, "wb");
@@ -4225,6 +4228,11 @@ PHP_FUNCTION(imagepstext)
 		return;
 	}
 
+	if (aa_steps != 4 || aa_steps != 16) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "AA steps must be 4 or 16");
+		RETURN_FALSE;
+	}
+
 	ZEND_FETCH_RESOURCE(bg_img, gdImagePtr, &img, -1, "Image", le_gd);
 	ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
 
@@ -4552,6 +4560,14 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
 	dest_width = width;
 	int_threshold = threshold;
 
+	if (strlen(f_org) != f_org_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(f_dest) != f_dest_len) {
+		RETURN_FALSE;
+	}
+
 	/* Check threshold value */
 	if (int_threshold < 0 || int_threshold > 8) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'", int_threshold);
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 13660e6..7a4f5f2 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd_ctx.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: gd_ctx.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include "php_gd.h"
 
@@ -91,6 +91,9 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
 	}
 
 	if (argc > 1 && file_len) {
+		if (strlen(file) != file_len) {
+			RETURN_FALSE;
+		}
 		PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
 
 		fp = VCWD_FOPEN(file, "wb");
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index f53dcd6..8d36c7f 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -316,6 +316,14 @@ static void _php_gmpnum_free(zend_rsrc_list_entry *rsrc TSRMLS_DC);
 #define GMP_ROUND_PLUSINF   1
 #define GMP_ROUND_MINUSINF  2
 
+/* The maximum base for input and output conversions is 62 from GMP 4.2
+ * onwards. */
+#if (__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2)
+#	define MAX_BASE 62
+#else
+#	define MAX_BASE 36
+#endif
+
 /* {{{ gmp_emalloc
  */
 static void *gmp_emalloc(size_t size)
@@ -484,8 +492,8 @@ typedef void (*gmp_binary_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);
 typedef unsigned long (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long);
 /* }}} */
 
-#define gmp_zval_binary_ui_op(r, a, b, o, u) gmp_zval_binary_ui_op_ex(r, a, b, o, u, 0, 0 TSRMLS_CC)
-#define gmp_zval_binary_ui_op2(r, a, b, o, u) gmp_zval_binary_ui_op2_ex(r, a, b, o, u, 0, 0 TSRMLS_CC)
+#define gmp_zval_binary_ui_op(r, a, b, o, u) gmp_zval_binary_ui_op_ex(r, a, b, o, u, 0, 0, 0 TSRMLS_CC)
+#define gmp_zval_binary_ui_op2(r, a, b, o, u) gmp_zval_binary_ui_op2_ex(r, a, b, o, u, 0, 0, 0 TSRMLS_CC)
 
 #define gmp_binary_ui_op(op, uop) _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, uop)
 #define gmp_binary_op(op)         _gmp_binary_ui_op(INTERNAL_FUNCTION_PARAM_PASSTHRU, op, NULL)
@@ -500,7 +508,7 @@ typedef unsigned long (*gmp_binary_ui_op2_t)(mpz_ptr, mpz_ptr, mpz_srcptr, unsig
    Execute GMP binary operation.
    May return GMP resource or long if operation allows this
 */
-static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return, int check_b_zero TSRMLS_DC) 
+static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zval **b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int allow_ui_return, int check_b_zero, int use_sign TSRMLS_DC) 
 {
 	mpz_t *gmpnum_a, *gmpnum_b, *gmpnum_result;
 	unsigned long long_result = 0;
@@ -536,7 +544,7 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
 	if (use_ui && gmp_ui_op) {
 		if (allow_ui_return) {
 			long_result = gmp_ui_op(*gmpnum_result, *gmpnum_a, (unsigned long)Z_LVAL_PP(b_arg));
-			if (mpz_sgn(*gmpnum_a) == -1) {
+			if (use_sign && mpz_sgn(*gmpnum_a) == -1) {
 				long_result = -long_result;
 			}
 		} else {
@@ -753,12 +761,8 @@ ZEND_FUNCTION(gmp_init)
 		return;
 	}
 
-#if (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2)
-	if (base && (base < 2 || base > 62)) {
-#else
-	if (base && (base < 2 || base > 36)) {
-#endif
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld (should be between 2 and 36)", base);
+	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);
 		RETURN_FALSE;
 	}
 
@@ -807,12 +811,15 @@ ZEND_FUNCTION(gmp_strval)
 		return;
 	}
 
-#if __GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2
-	if ((base < 2 && base > -2) || base > 62 || base < -36) {
+#if MAX_BASE == 62
+	/* 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);
 #else
-	if (base < 2 || base > 36) {
+	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);
 #endif
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad base for conversion: %ld", base);
 		RETURN_FALSE;
 	}
 
@@ -907,13 +914,13 @@ ZEND_FUNCTION(gmp_div_r)
 
 	switch (round) {
 	case GMP_ROUND_ZERO:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t)mpz_tdiv_r_ui, 1, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_r, (gmp_binary_ui_op_t)mpz_tdiv_r_ui, 1, 1, 1 TSRMLS_CC);
 		break;
 	case GMP_ROUND_PLUSINF:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t)mpz_cdiv_r_ui, 1, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_r, (gmp_binary_ui_op_t)mpz_cdiv_r_ui, 1, 1, 1 TSRMLS_CC);
 		break;
 	case GMP_ROUND_MINUSINF:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t)mpz_fdiv_r_ui, 1, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_r, (gmp_binary_ui_op_t)mpz_fdiv_r_ui, 1, 1, 1 TSRMLS_CC);
 		break;
 	}
 }
@@ -932,13 +939,13 @@ ZEND_FUNCTION(gmp_div_q)
 
 	switch (round) {
 	case GMP_ROUND_ZERO:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t)mpz_tdiv_q_ui, 0, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_tdiv_q, (gmp_binary_ui_op_t)mpz_tdiv_q_ui, 0, 1, 1 TSRMLS_CC);
 		break;
 	case GMP_ROUND_PLUSINF:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t)mpz_cdiv_q_ui, 0, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_cdiv_q, (gmp_binary_ui_op_t)mpz_cdiv_q_ui, 0, 1, 1 TSRMLS_CC);
 		break;
 	case GMP_ROUND_MINUSINF:
-		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t)mpz_fdiv_q_ui, 0, 1 TSRMLS_CC);
+		gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_fdiv_q, (gmp_binary_ui_op_t)mpz_fdiv_q_ui, 0, 1, 1 TSRMLS_CC);
 		break;
 	}
 							   
@@ -950,12 +957,14 @@ ZEND_FUNCTION(gmp_div_q)
 ZEND_FUNCTION(gmp_mod)
 {
 	zval **a_arg, **b_arg;
+	zval b_copy;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ", &a_arg, &b_arg) == FAILURE){
 		return;
 	}
+	
 
-	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_mod, (gmp_binary_ui_op_t)mpz_mod_ui, 1, 1 TSRMLS_CC);
+	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_mod, (gmp_binary_ui_op_t)mpz_mod_ui, 1, 1, 0 TSRMLS_CC);
 }
 /* }}} */
 
@@ -969,7 +978,7 @@ ZEND_FUNCTION(gmp_divexact)
 		return;
 	}
 	
-	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_divexact, NULL, 0, 1 TSRMLS_CC);
+	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_divexact, NULL, 0, 1, 1 TSRMLS_CC);
 }
 /* }}} */
 
@@ -1217,7 +1226,7 @@ ZEND_FUNCTION(gmp_gcd)
 		return;
 	}
 
-	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_gcd, (gmp_binary_ui_op_t)mpz_gcd_ui, 0, 0 TSRMLS_CC);
+	gmp_zval_binary_ui_op_ex(return_value, a_arg, b_arg, mpz_gcd, (gmp_binary_ui_op_t)mpz_gcd_ui, 0, 0, 1 TSRMLS_CC);
 }
 /* }}} */
 
diff --git a/ext/gmp/tests/005.phpt b/ext/gmp/tests/005.phpt
index 806b5e6..7907ffb 100644
--- a/ext/gmp/tests/005.phpt
+++ b/ext/gmp/tests/005.phpt
@@ -41,7 +41,7 @@ bool(false)
 Warning: gmp_strval() expects parameter 2 to be long, string given in %s on line %d
 NULL
 
-Warning: gmp_strval(): Bad base for conversion: -1 in %s on line %d
+Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
 bool(false)
 
 Warning: gmp_strval() expects parameter 2 to be long, string given in %s on line %d
@@ -51,18 +51,18 @@ Warning: gmp_strval(): supplied resource is not a valid GMP integer resource in
 bool(false)
 string(7) "9765456"
 
-Warning: gmp_strval(): Bad base for conversion: -1 in %s on line %d
+Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
 bool(false)
 
-Warning: gmp_strval(): Bad base for conversion: 100000 in %s on line %d
+Warning: gmp_strval(): Bad base for conversion: 100000 (should be between 2 and %d or -2 and -%d) in %s on line %d
 bool(false)
 string(7) "9765456"
 string(8) "-3373333"
 
-Warning: gmp_strval(): Bad base for conversion: -1 in %s on line %d
+Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
 bool(false)
 
-Warning: gmp_strval(): Bad base for conversion: 100000 in %s on line %d
+Warning: gmp_strval(): Bad base for conversion: 100000 (should be between 2 and %d or -2 and -%d) in %s on line %d
 bool(false)
 string(8) "-3373333"
 
diff --git a/ext/gmp/tests/040.phpt b/ext/gmp/tests/040.phpt
index 9864cde..3af18cc 100644
--- a/ext/gmp/tests/040.phpt
+++ b/ext/gmp/tests/040.phpt
@@ -32,7 +32,7 @@ NULL
 Warning: gmp_init() expects at most 2 parameters, 4 given in %s on line %d
 NULL
 
-Warning: gmp_init(): Bad base for conversion: -1 (should be between 2 and 36) in %s on line %d
+Warning: gmp_init(): Bad base for conversion: -1 (should be between 2 and %d) in %s on line %d
 bool(false)
 bool(false)
 bool(false)
diff --git a/ext/gmp/tests/bug50283.phpt b/ext/gmp/tests/bug50283.phpt
index e8132a7..13eef54 100644
--- a/ext/gmp/tests/bug50283.phpt
+++ b/ext/gmp/tests/bug50283.phpt
@@ -2,6 +2,7 @@
 Feature Request #50283 (allow base in gmp_strval to use full range: 2 to 62, and -2 to -36)
 --SKIPIF--
 <?php if (!extension_loaded("gmp")) print "skip"; ?>
+<?php if (version_compare(GMP_VERSION, "4.2.0", "<")) print "skip"; ?>
 --FILE--
 <?php
 $a = gmp_init("0x41682179fbf5");
@@ -19,18 +20,18 @@ printf("Base 32 and 62-based: %s\n", gmp_strval(gmp_init("gh82179fbf5", 32), 62)
 Decimal: 71915494046709, -36-based: PHPISCOOL
 Decimal: 71915494046709, 36-based: phpiscool
 
-Warning: gmp_strval(): Bad base for conversion: -1 in %s on line 5
+Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line 5
 Decimal: 71915494046709, -1-based: 
 
-Warning: gmp_strval(): Bad base for conversion: 1 in %s on line 6
+Warning: gmp_strval(): Bad base for conversion: 1 (should be between 2 and %d or -2 and -%d) in %s on line 6
 Decimal: 71915494046709, 1-based: 
 
-Warning: gmp_strval(): Bad base for conversion: -37 in %s on line 7
+Warning: gmp_strval(): Bad base for conversion: -37 (should be between 2 and %d or -2 and -%d) in %s on line 7
 Decimal: 71915494046709, -37-based: 
 Decimal: 71915494046709, 37-based: KHKATELJF
 Decimal: 71915494046709, 62-based: KQ6yq741
 
-Warning: gmp_strval(): Bad base for conversion: 63 in %s on line 10
+Warning: gmp_strval(): Bad base for conversion: 63 (should be between 2 and %d or -2 and -%d) in %s on line 10
 Decimal: 71915494046709, 63-based: 
 
 Base 32 and 62-based: 1NHkAcdIiD
diff --git a/ext/gmp/tests/bug52906.phpt b/ext/gmp/tests/bug52906.phpt
new file mode 100644
index 0000000..60fc741
--- /dev/null
+++ b/ext/gmp/tests/bug52906.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #52906 gmp_mod returns negative result when non-negative is expected
+--SKIPIF--
+<?php if (!extension_loaded("gmp")) print "skip"; ?>
+--FILE--
+<?php
+
+$vals = array(
+	array(7, 3),
+	array(2, 7),
+	array(12, 7),
+	array(-2, 7),
+	array(-12, 7),
+	array(2, -7),
+	array(12, -7),
+	array(-2, -7),
+	array(-12, -7),
+);
+foreach($vals as $data) {
+	echo "{$data[0]}%{$data[1]}=".gmp_strval(gmp_mod($data[0], $data[1]));
+	echo "\n";
+	echo "{$data[0]}%{$data[1]}=".gmp_strval(gmp_mod(gmp_init($data[0]), gmp_init($data[1])));
+	echo "\n";
+}
+echo "Done\n";
+?>
+--EXPECTF--	
+7%3=1
+7%3=1
+2%7=2
+2%7=2
+12%7=5
+12%7=5
+-2%7=5
+-2%7=5
+-12%7=2
+-12%7=2
+2%-7=2
+2%-7=2
+12%-7=5
+12%-7=5
+-2%-7=5
+-2%-7=5
+-12%-7=2
+-12%-7=2
+Done
diff --git a/ext/gmp/tests/gmp_nextprime.phpt b/ext/gmp/tests/gmp_nextprime.phpt
index 84d945b..65506ce 100644
--- a/ext/gmp/tests/gmp_nextprime.phpt
+++ b/ext/gmp/tests/gmp_nextprime.phpt
@@ -27,7 +27,7 @@ echo "Done\n";
 --EXPECTF--	
 string(1) "2"
 string(1) "2"
-string(4) "-997"
+string(1) "2"
 string(4) "1009"
 string(6) "100003"
 
diff --git a/ext/hash/php_hash_tiger.h b/ext/hash/php_hash_tiger.h
index 4949d47..3d4f4b8 100644
--- a/ext/hash/php_hash_tiger.h
+++ b/ext/hash/php_hash_tiger.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_hash_tiger.h 301252 2010-07-13 23:59:54Z kalle $ */
+/* $Id: php_hash_tiger.h 305650 2010-11-22 13:12:28Z iliaa $ */
 
 #ifndef PHP_HASH_TIGER_H
 #define PHP_HASH_TIGER_H
@@ -25,9 +25,9 @@
 typedef struct {
 	php_hash_uint64 state[3];
 	php_hash_uint64 passed;
+	unsigned char buffer[64];
 	unsigned int passes:1;
 	unsigned int length:7;
-	unsigned char buffer[64];
 } PHP_TIGER_CTX;
 
 PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context);
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 246e1d5..128c267 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iconv.c 298963 2010-05-04 11:56:59Z aharvey $ */
+/* $Id: iconv.c 305887 2010-12-01 14:03:36Z iliaa $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1457,16 +1457,43 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
 
 					if (cd == (iconv_t)(-1)) {
 						if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
+							/* Bad character set, but the user wants us to
+							 * press on. In this case, we'll just insert the
+							 * undecoded encoded word, since there isn't really
+							 * a more sensible behaviour available; the only
+							 * other options are to swallow the encoded word
+							 * entirely or decode it with an arbitrarily chosen
+							 * single byte encoding, both of which seem to have
+							 * a higher WTF factor than leaving it undecoded.
+							 *
+							 * Given this approach, we need to skip ahead to
+							 * the end of the encoded word. */
+							int qmarks = 2;
+							while (qmarks > 0 && str_left > 1) {
+								if (*(++p1) == '?') {
+									--qmarks;
+								}
+								--str_left;
+							}
+
+							/* Look ahead to check for the terminating = that
+							 * should be there as well; if it's there, we'll
+							 * also include that. If it's not, there isn't much
+							 * we can do at this point. */
+							if (*(p1 + 1) == '=') {
+								++p1;
+								--str_left;
+							}
+
 							err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); 
 							if (err != PHP_ICONV_ERR_SUCCESS) {
 								goto out;
 							}
-							encoded_word = NULL;
-							if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {
-								scan_stat = 12;
-							} else {
-								scan_stat = 0;
-							}
+
+							/* Let's go back and see if there are further
+							 * encoded words or bare content, and hope they
+							 * might actually have a valid character set. */
+							scan_stat = 12;
 							break;
 						} else {
 #if ICONV_SUPPORTS_ERRNO
@@ -1671,10 +1698,10 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
 							if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
 								/* pass the entire chunk through the converter */
 								err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl); 
+								encoded_word = NULL;
 								if (err != PHP_ICONV_ERR_SUCCESS) {
-									goto out;
+									break;
 								}
-								encoded_word = NULL;
 							} else {
 								goto out;
 							}
@@ -2340,7 +2367,13 @@ PHP_FUNCTION(ob_iconv_handler)
 				ICONVG(output_encoding), ICONVG(internal_encoding));
 		_php_iconv_show_error(err, ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
 		if (out_buffer != NULL) {
-			int len = spprintf(&content_type, 0, "Content-Type:%s; charset=%s", mimetype, ICONVG(output_encoding));
+			int len;
+			char *p = strstr(ICONVG(output_encoding), "//"); 
+			if (p) {
+				len = spprintf(&content_type, 0, "Content-Type:%s; charset=%.*s", mimetype, (int)(p - ICONVG(output_encoding)), ICONVG(output_encoding));
+			} else {
+				len = spprintf(&content_type, 0, "Content-Type:%s; charset=%s", mimetype, ICONVG(output_encoding));
+			}
 			if (content_type && sapi_add_header(content_type, len, 0) != FAILURE) {
 				SG(sapi_headers).send_default_content_type = 0;
 			}
diff --git a/ext/iconv/tests/bug51250.phpt b/ext/iconv/tests/bug51250.phpt
new file mode 100644
index 0000000..fd2e53b
--- /dev/null
+++ b/ext/iconv/tests/bug51250.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #51250 (iconv_mime_decode() does not ignore malformed Q-encoded words)
+--SKIPIF--
+<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
+--FILE--
+<?php
+$m = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
+
+var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?B?Kg==?= .", $m));
+var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?Q?*?= .", $m));
+var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?B?".chr(0xA1)."?= .", $m));
+var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?Q?".chr(0xA1)."?= .", $m));
+
+var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?B?Kg==?= ."));
+var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?Q?*?= ."));
+var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?B?".chr(0xA1)."?= ."));
+var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?Q?".chr(0xA1)."?= ."));
+?>
+--EXPECTF--
+string(23) "Legal encoded-word: * ."
+string(23) "Legal encoded-word: * ."
+string(24) "Illegal encoded-word:  ."
+string(23) "Illegal encoded-word: ."
+string(23) "Legal encoded-word: * ."
+string(23) "Legal encoded-word: * ."
+string(24) "Illegal encoded-word:  ."
+
+Notice: iconv_mime_decode(): Detected an illegal character in input string in %s on line %d
+bool(false)
diff --git a/ext/iconv/tests/bug52941.phpt b/ext/iconv/tests/bug52941.phpt
new file mode 100644
index 0000000..753c9ad
--- /dev/null
+++ b/ext/iconv/tests/bug52941.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #52941 (The 'iconv_mime_decode_headers' function is skipping headers)
+--SKIPIF--
+<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
+--FILE--
+<?php
+$headers = <<<HEADERS
+From: =?UTF-8?B?PGZvb0BleGFtcGxlLmNvbT4=?=
+Subject: =?ks_c_5601-1987?B?UkU6odk=?=
+X-Foo: =?ks_c_5601-1987?B?UkU6odk=?= Foo
+X-Bar: =?ks_c_5601-1987?B?UkU6odk=?= =?UTF-8?Q?Foo?=
+To: <test at example.com>
+HEADERS;
+
+$decoded = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
+
+var_dump($decoded['From']);
+var_dump($decoded['Subject']);
+var_dump($decoded['X-Foo']);
+var_dump($decoded['X-Bar']);
+var_dump($decoded['To']);
+
+$decoded = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR | ICONV_MIME_DECODE_STRICT, 'UTF-8');
+
+var_dump($decoded['From']);
+var_dump($decoded['Subject']);
+var_dump($decoded['X-Foo']);
+var_dump($decoded['X-Bar']);
+var_dump($decoded['To']);
+?>
+--EXPECT--
+string(17) "<foo at example.com>"
+string(29) "=?ks_c_5601-1987?B?UkU6odk=?="
+string(33) "=?ks_c_5601-1987?B?UkU6odk=?= Foo"
+string(32) "=?ks_c_5601-1987?B?UkU6odk=?=Foo"
+string(18) "<test at example.com>"
+string(17) "<foo at example.com>"
+string(29) "=?ks_c_5601-1987?B?UkU6odk=?="
+string(33) "=?ks_c_5601-1987?B?UkU6odk=?= Foo"
+string(32) "=?ks_c_5601-1987?B?UkU6odk=?=Foo"
+string(18) "<test at example.com>"
diff --git a/ext/iconv/tests/bug53304.phpt b/ext/iconv/tests/bug53304.phpt
new file mode 100644
index 0000000..7eb6c41
--- /dev/null
+++ b/ext/iconv/tests/bug53304.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #53304 (quot_print_decode does not handle lower-case hex digits)
+--SKIPIF--
+<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
+--FILE--
+<?php
+echo iconv_mime_decode('=?utf-8?Q?Nachricht_=c3=bcber_Kontaktformular_www.inexio.net?=', 0, 'UTF-8') . "\n";
+echo iconv_mime_decode('=?utf-8?Q?Nachricht_=C3=BCber_Kontaktformular_www.inexio.net?=', 0, 'UTF-8') . "\n";
+
+?>
+--EXPECT--
+Nachricht über Kontaktformular www.inexio.net
+Nachricht über Kontaktformular www.inexio.net
diff --git a/ext/iconv/tests/iconv_stream_filter_delimiter.phpt b/ext/iconv/tests/iconv_stream_filter_delimiter.phpt
index e28ebab..895f614 100644
--- a/ext/iconv/tests/iconv_stream_filter_delimiter.phpt
+++ b/ext/iconv/tests/iconv_stream_filter_delimiter.phpt
@@ -44,7 +44,7 @@ string(20) "a4b3a4f3a4cba4c1a4cf"
 string(10) "69636f6e76"
 string(2) "0a"
 
-Warning: stream_filter_append(): unable to create or locate filter "convert.iconv.ISO-2022-JP\0EUC-JP" in %s/iconv_stream_filter_delimiter.php on line %d
+Warning: stream_filter_append(): unable to create or locate filter "convert.iconv.ISO-2022-JP\0EUC-JP" in %siconv_stream_filter_delimiter.php on line %d
 string(20) "1b244224332473244b24"
 string(10) "41244f1b28"
 string(2) "42"
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 718c7f2..fbfbb6c 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -26,7 +26,7 @@
    | PHP 4.0 updates:  Zeev Suraski <zeev at zend.com>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_imap.c 297983 2010-04-14 09:45:37Z pajoye $ */
+/* $Id: php_imap.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #define IMAP41
 
@@ -1209,17 +1209,23 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 
 	if (IMAPG(imap_user)) {
 		efree(IMAPG(imap_user));
+		IMAPG(imap_user) = 0;
 	}
 
 	if (IMAPG(imap_password)) {
 		efree(IMAPG(imap_password));
+		IMAPG(imap_password) = 0;
 	}
 
 	/* local filename, need to perform open_basedir and safe_mode checks */
-	if (mailbox[0] != '{' &&
-			(php_check_open_basedir(mailbox TSRMLS_CC) ||
-			(PG(safe_mode) && !php_checkuid(mailbox, NULL, CHECKUID_CHECK_FILE_AND_DIR)))) {
-		RETURN_FALSE;
+	if (mailbox[0] != '{') {
+		if (strlen(mailbox) != mailbox_len) {
+			RETURN_FALSE;
+		}
+		if (php_check_open_basedir(mailbox TSRMLS_CC) ||
+			(PG(safe_mode) && !php_checkuid(mailbox, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+			RETURN_FALSE;
+		}
 	}
 
 	IMAPG(imap_user)     = estrndup(user, user_len);
diff --git a/ext/interbase/config.w32 b/ext/interbase/config.w32
index 357220b..51978e6 100644
--- a/ext/interbase/config.w32
+++ b/ext/interbase/config.w32
@@ -1,11 +1,12 @@
-// $Id: config.w32 158415 2004-05-12 14:29:42Z abies $
+// $Id: config.w32 305343 2010-11-14 22:40:30Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("interbase", "InterBase support", "no");
 
 if (PHP_INTERBASE != "no") {
 
-	if (CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_INTERBASE", PHP_PHP_BUILD + "\\interbase\\include;" + PHP_INTERBASE) &&
+	if (CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_INTERBASE", 
+				PHP_PHP_BUILD + "\\include\\interbase;" + PHP_PHP_BUILD + "\\interbase\\include;" + PHP_INTERBASE) &&
 			(CHECK_LIB("fbclient_ms.lib", "interbase", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_INTERBASE) ||
 			 CHECK_LIB("gds32_ms.lib", "interbase", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_INTERBASE))) {
 
diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c
index 5101289..7c6cef9 100755
--- a/ext/intl/dateformat/dateformat_attr.c
+++ b/ext/intl/dateformat/dateformat_attr.c
@@ -309,6 +309,7 @@ PHP_FUNCTION( datefmt_get_locale )
 	DATE_FORMAT_METHOD_FETCH_OBJECT;
 
 	loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type,&INTL_DATA_ERROR_CODE(dfo));
+	INTL_METHOD_CHECK_STATUS(dfo, "Error getting locale");
 	RETURN_STRING(loc, 1);
 }
 /* }}} */
diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.c
index e41b38b..4d03d92 100755
--- a/ext/intl/dateformat/dateformat_format.c
+++ b/ext/intl/dateformat/dateformat_format.c
@@ -27,6 +27,7 @@
 #include "dateformat_class.h"
 #include "dateformat_format.h"
 #include "dateformat_data.h"
+#include "ext/date/php_date.h"
 
 /* {{{ 
  * Internal function which calls the udat_format
@@ -158,9 +159,30 @@ PHP_FUNCTION(datefmt_format)
 			timestamp = internal_get_timestamp(dfo, hash_arr TSRMLS_CC);
 			INTL_METHOD_CHECK_STATUS( dfo, "datefmt_format: Date formatting failed" )
 			break;
+		case IS_OBJECT: {
+			zend_class_entry *date_ce = php_date_get_date_ce();
+			zval retval;
+			zval *zfuncname;
+			if(!instanceof_function(Z_OBJCE_P(zarg), date_ce TSRMLS_CC)) {
+				intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: object must be an instance of DateTime", 0 TSRMLS_CC );
+				RETURN_FALSE;
+			}
+			INIT_ZVAL(retval);
+			MAKE_STD_ZVAL(zfuncname);
+			ZVAL_STRING(zfuncname, "getTimestamp", 1);
+			if(call_user_function(NULL, &zarg, zfuncname, &retval, 0, NULL TSRMLS_CC) != SUCCESS || Z_TYPE(retval) != IS_LONG) {
+				intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: cannot get timestamp", 0 TSRMLS_CC );
+				zval_ptr_dtor(&zfuncname);
+				RETURN_FALSE;
+			}
+			zval_ptr_dtor(&zfuncname);
+			p_timestamp = Z_LVAL(retval);
+			timestamp = p_timestamp*1000;
+		}
+			break;
 		default:
-			intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
-				"datefmt_format: takes either an array  or an integer timestamp value ", 0 TSRMLS_CC );
+			intl_errors_set( INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
+				"datefmt_format: takes either an array or an integer timestamp value or a DateTime object", 0 TSRMLS_CC );
 			RETURN_FALSE;
 	}
 
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c
index c17089f..4193e89 100755
--- a/ext/intl/dateformat/dateformat_parse.c
+++ b/ext/intl/dateformat/dateformat_parse.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <unicode/ustring.h>
+#include <math.h>
 
 #include "php_intl.h"
 #include "intl_convert.h"
@@ -35,7 +36,7 @@
 */
 static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* text_to_parse, int32_t text_len, int32_t *parse_pos, zval *return_value TSRMLS_DC)
 {
-	long	result =  0;
+	double	result =  0;
 	UDate 	timestamp   =0;
 	UChar* 	text_utf16  = NULL;
 	int32_t text_utf16_len = 0;
@@ -52,12 +53,12 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex
 	INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );
 	
 	/* Since return is in  sec. */
-	result = (long )( timestamp / 1000 );
-	if( result != (timestamp/1000) ) {
-		intl_error_set( NULL, U_BUFFER_OVERFLOW_ERROR,
-                                "datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.\nThe valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.", 0 TSRMLS_CC );
+	result = (double)timestamp / U_MILLIS_PER_SECOND;
+	if(result > LONG_MAX || result < -LONG_MAX) {
+		ZVAL_DOUBLE(return_value, result<0?ceil(result):floor(result));
+	} else {
+		ZVAL_LONG(return_value, (long)result);
 	}
-	RETURN_LONG( result );
 }
 /* }}} */
 
diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.c
index d9b67dd..851b2b3 100755
--- a/ext/intl/formatter/formatter_attr.c
+++ b/ext/intl/formatter/formatter_attr.c
@@ -250,7 +250,7 @@ PHP_FUNCTION( numfmt_get_symbol )
 	long symbol;
 	UChar value_buf[4];
 	UChar *value = value_buf;
-	int length = USIZE(value);
+	int length = USIZE(value_buf);
 	FORMATTER_METHOD_INIT_VARS;
 
 	/* Parse parameters. */
@@ -262,12 +262,17 @@ PHP_FUNCTION( numfmt_get_symbol )
 
 		RETURN_FALSE;
 	}
+	
+	if(symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) {
+		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,	"numfmt_get_symbol: invalid symbol value", 0 TSRMLS_CC );
+		RETURN_FALSE;
+	}
 
 	/* Fetch the object. */
 	FORMATTER_METHOD_FETCH_OBJECT;
 
 	length = unum_getSymbol(FORMATTER_OBJECT(nfo), symbol, value_buf, length, &INTL_DATA_ERROR_CODE(nfo));
-	if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value )) {
+	if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value_buf )) {
 		++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
 		INTL_DATA_ERROR_CODE(nfo) = U_ZERO_ERROR;
 		value = eumalloc(length);
diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt
new file mode 100644
index 0000000..c39c333
--- /dev/null
+++ b/ext/intl/tests/bug50590.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #50590 (IntlDateFormatter::parse result is limited to the integer range)
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+$fmt = new IntlDateFormatter("en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL);
+var_dump($fmt->parse("Wednesday, January 20, 2038 3:14:07 AM GMT"));
+
+?>
+--EXPECTF--
+%s(2147570047)
diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt
index c4fed04..e554819 100755
--- a/ext/intl/tests/dateformat_format.phpt
+++ b/ext/intl/tests/dateformat_format.phpt
@@ -33,8 +33,8 @@ function ut_main()
 		0,
 		-1200000,
 		1200000,
-		2200000000,
-		-2200000000,
+		2200000000.0,
+		-2200000000.0,
 		90099999,
 		3600,
 		-3600
@@ -70,6 +70,15 @@ function ut_main()
 		$localtime_arr2,
 		$localtime_arr3
 	);
+	
+	$d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC"));
+	$d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC"));
+	$d2->setTimezone(new DateTimeZone("PDT"));
+	$dates = array(
+		$d1, 
+		$d2,
+		new StdClass(),
+	);
 
 	//Test format with input as a timestamp : integer
 	foreach( $time_arr as $timestamp_entry){
@@ -111,6 +120,24 @@ function ut_main()
 	}
 	}
 
+	foreach($dates as $date_entry) {
+		foreach( $locale_arr as $locale_entry ){
+			foreach( $datetype_arr as $datetype_entry ) {
+				$res_str .= "\n------------";
+				$res_str .= "\nDate is: ".var_export($date_entry, true);
+				$res_str .= "\n------------";
+				
+				$fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN );
+				$formatted1 = ut_datefmt_format( $fmt , $date_entry);
+				if( intl_get_error_code() == U_ZERO_ERROR){
+					$res_str .= "\nFormatted DateTime is : $formatted1";
+				}else{
+					$res_str .= "\nError while formatting as: '".intl_get_error_message()."'";
+				}
+			}
+		}
+	}
+
 	return $res_str;
 
 }
@@ -285,4 +312,109 @@ Formatted localtime_array is : Dec 17, 1895 12:13:11 AM
 IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 
 Formatted localtime_array is : 12/17/95 12:13 AM
 IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 
-Formatted localtime_array is : 18951217 12:13 AM
\ No newline at end of file
+Formatted localtime_array is : 18951217 12:13 AM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2010-01-01 01:02:03',
+   'timezone_type' => 3,
+   'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : Thursday, December 31, 2009 3:02:03 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2010-01-01 01:02:03',
+   'timezone_type' => 3,
+   'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : December 31, 2009 3:02:03 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2010-01-01 01:02:03',
+   'timezone_type' => 3,
+   'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : Dec 31, 2009 3:02:03 PM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2010-01-01 01:02:03',
+   'timezone_type' => 3,
+   'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : 12/31/09 3:02 PM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2010-01-01 01:02:03',
+   'timezone_type' => 3,
+   'timezone' => 'UTC',
+))
+------------
+Formatted DateTime is : 20091231 03:02 PM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2000-12-30 19:04:05',
+   'timezone_type' => 3,
+   'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : Saturday, December 30, 2000 5:04:05 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2000-12-30 19:04:05',
+   'timezone_type' => 3,
+   'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : December 30, 2000 5:04:05 PM GMT-10:00
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2000-12-30 19:04:05',
+   'timezone_type' => 3,
+   'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : Dec 30, 2000 5:04:05 PM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2000-12-30 19:04:05',
+   'timezone_type' => 3,
+   'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : 12/30/00 5:04 PM
+------------
+Date is: DateTime::__set_state(array(
+   'date' => '2000-12-30 19:04:05',
+   'timezone_type' => 3,
+   'timezone' => 'America/Los_Angeles',
+))
+------------
+Formatted DateTime is : 20001230 05:04 PM
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
+------------
+Date is: stdClass::__set_state(array(
+))
+------------
+Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR'
diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt
index eb4e989..bd41d71 100755
--- a/ext/intl/tests/dateformat_format_parse.phpt
+++ b/ext/intl/tests/dateformat_format_parse.phpt
@@ -187,16 +187,13 @@ Input timestamp is : 2200000000
 
 IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 
 Formatted timestamp is : Monday, September 19, 2039 4:06:40 AM GMT+05:00
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : 2200000000
 IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 
 Formatted timestamp is : September 19, 2039 4:06:40 AM GMT+05:00
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : 2200000000
 IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 
 Formatted timestamp is : Sep 19, 2039 4:06:40 AM
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : 2200000000
 ------------
 
 Input timestamp is : -2200000000
@@ -204,16 +201,13 @@ Input timestamp is : -2200000000
 
 IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 
 Formatted timestamp is : Sunday, April 15, 1900 5:53:20 AM GMT+05:00
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : -2200000000
 IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 
 Formatted timestamp is : April 15, 1900 5:53:20 AM GMT+05:00
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : -2200000000
 IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 
 Formatted timestamp is : Apr 15, 1900 5:53:20 AM
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed timestamp is : -2200000000
 ------------
 
 Input timestamp is : 90099999
@@ -297,4 +291,4 @@ Formatted localtime_array is : December 17, 1895 12:13:11 AM GMT+05:00
 Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' , 
 IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 
 Formatted localtime_array is : Dec 17, 1895 12:13:11 AM
-Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
\ No newline at end of file
+Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' ,
diff --git a/ext/intl/tests/dateformat_get_locale.phpt b/ext/intl/tests/dateformat_get_locale.phpt
index 2626972..17fcca3 100755
--- a/ext/intl/tests/dateformat_get_locale.phpt
+++ b/ext/intl/tests/dateformat_get_locale.phpt
@@ -29,6 +29,12 @@ function ut_main()
 		$res_str .= "\nAfter call to get_locale :  locale= $locale";
 		$res_str .= "\n";
 	}
+	$badvals = array(100, -1, 4294901761);
+	foreach($badvals as $badval) {
+		if(ut_datefmt_get_locale($fmt, $badval)) {
+			$res_str .= "datefmt_get_locale should return false for bad argument $badval\n";
+		}
+	}
 
 	return $res_str;
 
diff --git a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
index fa40257..b7e8203 100755
--- a/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
+++ b/ext/intl/tests/dateformat_parse_timestamp_parsepos.phpt
@@ -76,8 +76,7 @@ Input text is : Sunday, September 18, 3039 4:06:40 PM PT
 Locale is : en_US_CA
 ------------
 datetype = 0 ,timetype =0 
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed text is : 33756908800
 datetype = 1 ,timetype =1 
 Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
 datetype = 2 ,timetype =2 
@@ -117,8 +116,7 @@ Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
 datetype = 3 ,timetype =3 
 Error while parsing as: 'Date parsing failed: U_PARSE_ERROR'
 datetype = -1 ,timetype =-1 
-Error while parsing as: 'datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.
-The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.: U_BUFFER_OVERFLOW_ERROR'
+Parsed text is : -2178601860
 ------------
 
 Input text is : 19691218 08:49 AM
diff --git a/ext/intl/tests/formatter_get_set_symbol.phpt b/ext/intl/tests/formatter_get_set_symbol.phpt
index a1a4302..40bbd25 100755
--- a/ext/intl/tests/formatter_get_set_symbol.phpt
+++ b/ext/intl/tests/formatter_get_set_symbol.phpt
@@ -73,7 +73,12 @@ function ut_main()
         // Restore attribute's symbol.
         ut_nfmt_set_symbol( $fmt, $symb, $orig_val );
     }
-
+    $badvals = array(2147483648, -2147483648, -1, 4294901761);
+    foreach($badvals as $badval) {
+	    if(ut_nfmt_get_symbol( $fmt, 2147483648 ))  {
+		$res_str .= "Bad value $badval should return false!\n";
+	    }
+    }
     return $res_str;
 }
 
diff --git a/ext/json/json.c b/ext/json/json.c
index 3e5d23f..a5a981f 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: json.c 301028 2010-07-06 17:01:30Z scottmac $ */
+/* $Id: json.c 303350 2010-09-14 03:46:28Z aharvey $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -505,7 +505,7 @@ PHP_JSON_API void php_json_decode(zval *return_value, char *str, int str_len, ze
 	}
 
 	if (depth <= 0) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must greater than zero");
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must be greater than zero");
 		efree(utf16);
 		RETURN_NULL();
 	}
diff --git a/ext/ldap/config.w32 b/ext/ldap/config.w32
index 42d285f..5a71b76 100644
--- a/ext/ldap/config.w32
+++ b/ext/ldap/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 299434 2010-05-17 20:09:42Z pajoye $
+// $Id: config.w32 301590 2010-07-26 22:28:38Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("ldap", "LDAP support", "no");
@@ -11,16 +11,19 @@ if (PHP_LDAP != "no") {
 			CHECK_LIB("ssleay32.lib", "ldap", PHP_LDAP) &&
 			CHECK_LIB("libeay32.lib", "ldap", PHP_LDAP) &&
 			CHECK_LIB("oldap32_a.lib", "ldap", PHP_LDAP) &&
-			CHECK_LIB("olber32_a.lib", "ldap", PHP_LDAP)&&
-			CHECK_LIB("libsasl.lib", "ldap", PHP_LDAP)) {
+			CHECK_LIB("olber32_a.lib", "ldap", PHP_LDAP)
+			) {
+		if (CHECK_LIB("libsasl.lib", "ldap", PHP_LDAP)) {
+			AC_DEFINE('HAVE_LDAP_SASL', 1);
+			AC_DEFINE('HAVE_LDAP_SASL_SASL_H', 1);
+			PHP_LDAP = 1;
+		}
 		EXTENSION('ldap', 'ldap.c');
 
 		AC_DEFINE('HAVE_LDAP_PARSE_RESULT', 1);
 		AC_DEFINE('HAVE_LDAP_PARSE_REFERENCE', 1);
 		AC_DEFINE('HAVE_LDAP_START_TLS_S', 1);
 		AC_DEFINE('HAVE_LDAP', 1);
-		AC_DEFINE('HAVE_LDAP_SASL', 1);
-		AC_DEFINE('HAVE_LDAP_SASL_SASL_H', 1);
 		AC_DEFINE('LDAP_DEPRECATED', 1);
 
 	} else {
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c
index d11cebe..b8b1db2 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfilter.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c
@@ -1397,6 +1397,10 @@ mbfl_strcut(
 			start = string->val + from;
 			end   = start + (length & -4);
 		} else if ((encoding->flag & MBFL_ENCTYPE_SBCS)) {
+			if (from + length >= string->len) {
+				length = string->len - from;
+			}
+
 			start = string->val + from;
 			end = start + length;
 		} else if (encoding->mblen_table != NULL) {
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 2d24597..75cb090 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: mbstring.c 303805 2010-09-27 23:09:00Z felipe $ */
 
 /*
  * PHP 4 Multibyte String module "mbstring"
@@ -196,7 +196,7 @@ static const struct mb_overload_def mb_ovld[] = {
 	{MB_OVERLOAD_STRING, "strpos", "mb_strpos", "mb_orig_strpos"},
 	{MB_OVERLOAD_STRING, "strrpos", "mb_strrpos", "mb_orig_strrpos"},
 	{MB_OVERLOAD_STRING, "stripos", "mb_stripos", "mb_orig_stripos"},
-	{MB_OVERLOAD_STRING, "strripos", "mb_strripos", "mb_orig_stripos"},
+	{MB_OVERLOAD_STRING, "strripos", "mb_strripos", "mb_orig_strripos"},
 	{MB_OVERLOAD_STRING, "strstr", "mb_strstr", "mb_orig_strstr"},
 	{MB_OVERLOAD_STRING, "strrchr", "mb_strrchr", "mb_orig_strrchr"},
 	{MB_OVERLOAD_STRING, "stristr", "mb_stristr", "mb_orig_stristr"},
@@ -4044,7 +4044,7 @@ PHP_FUNCTION(mb_send_mail)
 	}
 
 	/* other headers */
-#define PHP_MBSTR_MAIL_MIME_HEADER1 "Mime-Version: 1.0"
+#define PHP_MBSTR_MAIL_MIME_HEADER1 "MIME-Version: 1.0"
 #define PHP_MBSTR_MAIL_MIME_HEADER2 "Content-Type: text/plain"
 #define PHP_MBSTR_MAIL_MIME_HEADER3 "; charset="
 #define PHP_MBSTR_MAIL_MIME_HEADER4 "Content-Transfer-Encoding: "
@@ -4057,8 +4057,10 @@ PHP_FUNCTION(mb_send_mail)
 		}
 	}
 
-	mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER1, sizeof(PHP_MBSTR_MAIL_MIME_HEADER1) - 1);
-	mbfl_memory_device_strncat(&device, "\n", 1);
+	if (!zend_hash_exists(&ht_headers, "MIME-VERSION", sizeof("MIME-VERSION") - 1)) {
+		mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER1, sizeof(PHP_MBSTR_MAIL_MIME_HEADER1) - 1);
+		mbfl_memory_device_strncat(&device, "\n", 1);
+	}
 
 	if (!suppressed_hdrs.cnt_type) {
 		mbfl_memory_device_strncat(&device, PHP_MBSTR_MAIL_MIME_HEADER2, sizeof(PHP_MBSTR_MAIL_MIME_HEADER2) - 1);
diff --git a/ext/mbstring/tests/bug43301.phpt b/ext/mbstring/tests/bug43301.phpt
index 71b169c..310426a 100644
--- a/ext/mbstring/tests/bug43301.phpt
+++ b/ext/mbstring/tests/bug43301.phpt
@@ -15,7 +15,7 @@ echo mb_ereg_replace($ptr,'$1',$txt,'e');
 
 ?>
 --EXPECTF--
-Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in %s/bug43301.php(%d) : mbregex replace on line 1
+Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in %sbug43301.php(%d) : mbregex replace on line 1
 
 Fatal error: mb_ereg_replace(): Failed evaluating code: 
-$1 in %s/bug43301.php on line %d
+$1 in %sbug43301.php on line %d
diff --git a/ext/mbstring/tests/bug52861.phpt b/ext/mbstring/tests/bug52861.phpt
new file mode 100644
index 0000000..085f3ba
--- /dev/null
+++ b/ext/mbstring/tests/bug52861.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #52681 (mb_send_mail() appends an extra MIME-Version header)
+--SKIPIF--
+<?php
+if (!function_exists("mb_send_mail") || !mb_language("neutral")) {
+	die("skip mb_send_mail() not available");
+}
+?>
+--INI--
+sendmail_path=/bin/cat
+mail.add_x_header=off
+--FILE--
+<?php
+$to = 'example at example.com';
+$headers = 'MIME-Version: 2.0';
+
+mb_send_mail($to, mb_language(), "test", $headers);
+?>
+--EXPECTF--
+To: example at example.com
+Subject: %s
+MIME-Version: 2.0
+Content-Type: text/plain; charset=%s
+Content-Transfer-Encoding: %s
+
+%s
diff --git a/ext/mbstring/tests/bug52931.phpt b/ext/mbstring/tests/bug52931.phpt
new file mode 100644
index 0000000..9669d88
--- /dev/null
+++ b/ext/mbstring/tests/bug52931.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #52931 (strripos not overloaded with function overloading enabled)
+--INI--
+mbstring.func_overload = 7
+mbstring.internal_encoding = utf-8
+--FILE--
+<?php
+
+$string = '<body>Umlauttest öüä</body>';
+
+var_dump(strlen($string));
+var_dump(mb_strlen($string));
+
+var_dump(strripos($string, '</body>'));
+var_dump(mb_strripos($string, '</body>'));
+
+?>
+--EXPECTF--
+int(27)
+int(27)
+int(20)
+int(20)
diff --git a/ext/mbstring/tests/bug52981.phpt b/ext/mbstring/tests/bug52981.phpt
new file mode 100644
index 0000000..fe96a56
--- /dev/null
+++ b/ext/mbstring/tests/bug52981.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #52981 (Unicode properties are outdated (from Unicode 3.2))
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+function test($str)
+{
+	$upper = mb_strtoupper($str, 'UTF-8');
+	$len = strlen($upper);
+	for ($i = 0; $i < $len; ++$i) echo dechex(ord($upper[$i])) . ' ';
+	echo "\n";
+}
+
+// OK
+test("\xF0\x90\x90\xB8");// U+10438 DESERET SMALL LETTER H (added in 3.1.0, March 2001)
+// not OK
+test("\xE2\xB0\xB0");	// U+2C30 GLAGOLITIC SMALL LETTER AZU (added in 4.1.0, March 2005)
+test("\xD4\xA5");		// U+0525 CYRILLIC SMALL LETTER PE WITH DESCENDER (added in 5.2.0, October 2009)
+--EXPECTF--
+f0 90 90 90 
+e2 b0 80 
+d4 a4 
diff --git a/ext/mbstring/tests/mb_decode_mimeheader_variation1.phpt b/ext/mbstring/tests/mb_decode_mimeheader_variation1.phpt
index 7a1c886..e07ccad 100644
--- a/ext/mbstring/tests/mb_decode_mimeheader_variation1.phpt
+++ b/ext/mbstring/tests/mb_decode_mimeheader_variation1.phpt
@@ -1,10 +1,7 @@
 --TEST--
-p8_only
-Title: Test mb_decode_mimeheader() function : usage variation 
-Internal Reason: we output an extra warning message
-P8 only feature: Yes
-Author: D. Kelsey
-Date: 01/09/2008
+Test mb_decode_mimeheader() function : usage variation 
+--CREDITS--
+D. Kesley
 --SKIPIF--
 <?php
 extension_loaded('mbstring') or die('skip');
diff --git a/ext/mbstring/tests/mb_send_mail01.phpt b/ext/mbstring/tests/mb_send_mail01.phpt
index 90cc3aa..28a401e 100644
--- a/ext/mbstring/tests/mb_send_mail01.phpt
+++ b/ext/mbstring/tests/mb_send_mail01.phpt
@@ -25,14 +25,14 @@ if (mb_language("neutral")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: test neutral
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: BASE64
 
diff --git a/ext/mbstring/tests/mb_send_mail02.phpt b/ext/mbstring/tests/mb_send_mail02.phpt
index 81f2464..af335cc 100644
--- a/ext/mbstring/tests/mb_send_mail02.phpt
+++ b/ext/mbstring/tests/mb_send_mail02.phpt
@@ -25,14 +25,14 @@ if (mb_language("japanese")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: =?ISO-2022-JP?B?GyRCJUYlOSVIGyhCIEphcGFuZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=ISO-2022-JP
 Content-Transfer-Encoding: 7bit
 
diff --git a/ext/mbstring/tests/mb_send_mail03.phpt b/ext/mbstring/tests/mb_send_mail03.phpt
index 1334fad..23a988f 100644
--- a/ext/mbstring/tests/mb_send_mail03.phpt
+++ b/ext/mbstring/tests/mb_send_mail03.phpt
@@ -25,14 +25,14 @@ if (mb_language("english")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: test English
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s-8859-1
 Content-Transfer-Encoding: 8bit
 
diff --git a/ext/mbstring/tests/mb_send_mail04.phpt b/ext/mbstring/tests/mb_send_mail04.phpt
index 0dcc318..49bda09 100644
--- a/ext/mbstring/tests/mb_send_mail04.phpt
+++ b/ext/mbstring/tests/mb_send_mail04.phpt
@@ -25,14 +25,14 @@ if (mb_language("german")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: =?ISO-8859-15?Q?Pr=FCfung=20German?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s-8859-15
 Content-Transfer-Encoding: 8bit
 
diff --git a/ext/mbstring/tests/mb_send_mail05.phpt b/ext/mbstring/tests/mb_send_mail05.phpt
index a93fa79..1bbaaad 100644
--- a/ext/mbstring/tests/mb_send_mail05.phpt
+++ b/ext/mbstring/tests/mb_send_mail05.phpt
@@ -28,7 +28,7 @@ if (mb_language("simplified chinese")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
@@ -36,7 +36,7 @@ Content-Transfer-Encoding: %s
 To: example at example.com
 Subject: =?HZ-GB-2312?B?fnsyYlFpfn0gU2ltcGxpZmllZCBD?=
  =?HZ-GB-2312?B?aGluZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=HZ-GB-2312
 Content-Transfer-Encoding: 7bit
 
diff --git a/ext/mbstring/tests/mb_send_mail06.phpt b/ext/mbstring/tests/mb_send_mail06.phpt
index 9970340..4eb5492 100644
--- a/ext/mbstring/tests/mb_send_mail06.phpt
+++ b/ext/mbstring/tests/mb_send_mail06.phpt
@@ -28,14 +28,14 @@ if (mb_language("traditional chinese")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: =?BIG5?B?tPrF5yBUcmFkaXRpb25hbCBDaGluZXNl?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=BIG5
 Content-Transfer-Encoding: 8bit
 
diff --git a/ext/mbstring/tests/mb_send_mail07.phpt b/ext/mbstring/tests/mb_send_mail07.phpt
index afd9a0b..42b91fa 100644
--- a/ext/mbstring/tests/mb_send_mail07.phpt
+++ b/ext/mbstring/tests/mb_send_mail07.phpt
@@ -28,14 +28,14 @@ if (mb_language("korean")) {
 --EXPECTF--
 To: example at example.com
 Subject: %s
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=%s
 Content-Transfer-Encoding: %s
 
 %s
 To: example at example.com
 Subject: =?ISO-2022-KR?B?GyQpQw5FVz06Ri4PIEtvcmVhbg8=?=
-Mime-Version: 1.0
+MIME-Version: 1.0
 Content-Type: text/plain; charset=ISO-2022-KR
 Content-Transfer-Encoding: 7bit
 
diff --git a/ext/mbstring/tests/mb_strcut_missing_boundary_check.phpt b/ext/mbstring/tests/mb_strcut_missing_boundary_check.phpt
new file mode 100644
index 0000000..a67b99e
--- /dev/null
+++ b/ext/mbstring/tests/mb_strcut_missing_boundary_check.phpt
@@ -0,0 +1,31 @@
+--TEST--
+mb_strcut() missing boundary check.
+--SKIPIF--
+<?php
+extension_loaded('mbstring') or die('skip');
+function_exists('mb_convert_encoding') or die("skip mb_convert_encoding() is not available in this build");
+?>
+--FILE--
+<?php
+mb_internal_encoding("UCS-4LE");
+var_dump(bin2hex(mb_strcut("\x61\x00\x00\x00\x62\x00\x00\x00\x63\x00\x00\x00", 0, 32)));
+mb_internal_encoding("UCS-4BE");
+var_dump(bin2hex(mb_strcut("\x00\x00\x00\x61\x00\x00\x00\x62\x00\x00\x00\x63", 0, 32)));
+mb_internal_encoding("UCS-2LE");
+var_dump(bin2hex(mb_strcut("\x61\x00\x62\x00\x63\x00", 0, 32)));
+mb_internal_encoding("UCS-2BE");
+var_dump(bin2hex(mb_strcut("\x00\x61\x00\x62\x00\x63", 0, 32)));
+mb_internal_encoding("UTF-16");
+var_dump(bin2hex(mb_strcut("\x00\x61\x00\x62\x00\x63", 0, 32)));
+mb_internal_encoding("UTF-8");
+var_dump(bin2hex(mb_strcut("abc", 0, 32)));
+mb_internal_encoding("ISO-8859-1");
+var_dump(bin2hex(mb_strcut("abc", 0, 32)));
+--EXPECT--
+string(24) "610000006200000063000000"
+string(24) "000000610000006200000063"
+string(12) "610062006300"
+string(12) "006100620063"
+string(12) "006100620063"
+string(6) "616263"
+string(6) "616263"
diff --git a/ext/mbstring/ucgendat/OPENLDAP_LICENSE b/ext/mbstring/ucgendat/OPENLDAP_LICENSE
new file mode 100644
index 0000000..6295703
--- /dev/null
+++ b/ext/mbstring/ucgendat/OPENLDAP_LICENSE
@@ -0,0 +1,47 @@
+The OpenLDAP Public License
+  Version 2.8, 17 August 2003
+
+Redistribution and use of this software and associated documentation
+("Software"), with or without modification, are permitted provided
+that the following conditions are met:
+
+1. Redistributions in source form must retain copyright statements
+   and notices,
+
+2. Redistributions in binary form must reproduce applicable copyright
+   statements and notices, this list of conditions, and the following
+   disclaimer in the documentation and/or other materials provided
+   with the distribution, and
+
+3. Redistributions must contain a verbatim copy of this document.
+
+The OpenLDAP Foundation may revise this license from time to time.
+Each revision is distinguished by a version number.  You may use
+this Software under terms of this license revision or under the
+terms of any subsequent revision of the license.
+
+THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
+CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT
+SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
+OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+The names of the authors and copyright holders must not be used in
+advertising or otherwise to promote the sale, use or other dealing
+in this Software without specific, written prior permission.  Title
+to copyright in this Software shall at all times remain with copyright
+holders.
+
+OpenLDAP is a registered trademark of the OpenLDAP Foundation.
+
+Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
+California, USA.  All Rights Reserved.  Permission to copy and
+distribute verbatim copies of this document is granted.
\ No newline at end of file
diff --git a/ext/mbstring/ucgendat/README b/ext/mbstring/ucgendat/README
new file mode 100644
index 0000000..7717bf8
--- /dev/null
+++ b/ext/mbstring/ucgendat/README
@@ -0,0 +1,9 @@
+This file is not necessary to build PHP.
+
+It's only necessary to rebuild unicode_data.h from Unicode ucd files.
+
+Example usage:
+./ucgendat UnicodeData-6.0.0d7.txt -x CompositionExclusions-6.0.0d2.txt
+
+
+
diff --git a/ext/mbstring/ucgendat/ucgendat.c b/ext/mbstring/ucgendat/ucgendat.c
new file mode 100644
index 0000000..963fe49
--- /dev/null
+++ b/ext/mbstring/ucgendat/ucgendat.c
@@ -0,0 +1,1985 @@
+/* Further modified for PHP */
+/* $Id: ucgendat.c 304057 2010-10-05 02:34:35Z cataphract $ */
+
+/* $OpenLDAP: pkg/ldap/libraries/liblunicode/ucdata/ucgendat.c,v 1.36.2.4 2007/01/02 21:43:51 kurt Exp $ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2007 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+
+/* Copyright 2001 Computing Research Labs, New Mexico State University
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* orig Id: ucgendat.c,v 1.4 2001/01/02 18:46:20 mleisher Exp $" */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define ac_uint2 unsigned short
+#define ac_uint4 unsigned int
+#define LDAP_DIRSEP "/"
+#define AC_MEMCPY memcpy
+
+#ifndef HARDCODE_DATA
+#define	HARDCODE_DATA	1
+#endif
+
+#undef ishdigit
+#define ishdigit(cc) (((cc) >= '0' && (cc) <= '9') ||\
+                      ((cc) >= 'A' && (cc) <= 'F') ||\
+                      ((cc) >= 'a' && (cc) <= 'f'))
+
+/*
+ * A header written to the output file with the byte-order-mark and the number
+ * of property nodes.
+ */
+static ac_uint2 hdr[2] = {0xfeff, 0};
+
+#define NUMPROPS 50
+#define NEEDPROPS (NUMPROPS + (4 - (NUMPROPS & 3)))
+
+typedef struct {
+    char *name;
+    int len;
+} _prop_t;
+
+/*
+ * List of properties expected to be found in the Unicode Character Database
+ * including some implementation specific properties.
+ *
+ * The implementation specific properties are:
+ * Cm = Composed (can be decomposed)
+ * Nb = Non-breaking
+ * Sy = Symmetric (has left and right forms)
+ * Hd = Hex digit
+ * Qm = Quote marks
+ * Mr = Mirroring
+ * Ss = Space, other
+ * Cp = Defined character
+ */
+static _prop_t props[NUMPROPS] = {
+    {"Mn", 2}, {"Mc", 2}, {"Me", 2}, {"Nd", 2}, {"Nl", 2}, {"No", 2},
+    {"Zs", 2}, {"Zl", 2}, {"Zp", 2}, {"Cc", 2}, {"Cf", 2}, {"Cs", 2},
+    {"Co", 2}, {"Cn", 2}, {"Lu", 2}, {"Ll", 2}, {"Lt", 2}, {"Lm", 2},
+    {"Lo", 2}, {"Pc", 2}, {"Pd", 2}, {"Ps", 2}, {"Pe", 2}, {"Po", 2},
+    {"Sm", 2}, {"Sc", 2}, {"Sk", 2}, {"So", 2}, {"L",  1}, {"R",  1},
+    {"EN", 2}, {"ES", 2}, {"ET", 2}, {"AN", 2}, {"CS", 2}, {"B",  1},
+    {"S",  1}, {"WS", 2}, {"ON", 2},
+    {"Cm", 2}, {"Nb", 2}, {"Sy", 2}, {"Hd", 2}, {"Qm", 2}, {"Mr", 2},
+    {"Ss", 2}, {"Cp", 2}, {"Pi", 2}, {"Pf", 2}, {"AL", 2}
+};
+
+typedef struct {
+    ac_uint4 *ranges;
+    ac_uint2 used;
+    ac_uint2 size;
+} _ranges_t;
+
+static _ranges_t proptbl[NUMPROPS];
+
+/*
+ * Make sure this array is sized to be on a 4-byte boundary at compile time.
+ */
+static ac_uint2 propcnt[NEEDPROPS];
+
+/*
+ * Array used to collect a decomposition before adding it to the decomposition
+ * table.
+ */
+static ac_uint4 dectmp[64];
+static ac_uint4 dectmp_size;
+
+typedef struct {
+    ac_uint4 code;
+    ac_uint2 size;
+    ac_uint2 used;
+    ac_uint4 *decomp;
+} _decomp_t;
+
+/*
+ * List of decomposition.  Created and expanded in order as the characters are
+ * encountered. First list contains canonical mappings, second also includes
+ * compatibility mappings.
+ */
+static _decomp_t *decomps;
+static ac_uint4 decomps_used;
+static ac_uint4 decomps_size;
+
+static _decomp_t *kdecomps;
+static ac_uint4 kdecomps_used;
+static ac_uint4 kdecomps_size;
+
+/*
+ * Composition exclusion table stuff.
+ */
+#define COMPEX_SET(c) (compexs[(c) >> 5] |= (1 << ((c) & 31)))
+#define COMPEX_TEST(c) (compexs[(c) >> 5] & (1 << ((c) & 31)))
+static ac_uint4 compexs[8192];
+
+/*
+ * Struct for holding a composition pair, and array of composition pairs
+ */
+typedef struct {
+    ac_uint4 comp;
+    ac_uint4 count;
+    ac_uint4 code1;
+    ac_uint4 code2;
+} _comp_t;
+
+#if 0
+static _comp_t *comps;
+#endif
+static ac_uint4 comps_used;
+
+/*
+ * Types and lists for handling lists of case mappings.
+ */
+typedef struct {
+    ac_uint4 key;
+    ac_uint4 other1;
+    ac_uint4 other2;
+} _case_t;
+
+static _case_t *upper;
+static _case_t *lower;
+static _case_t *title;
+static ac_uint4 upper_used;
+static ac_uint4 upper_size;
+static ac_uint4 lower_used;
+static ac_uint4 lower_size;
+static ac_uint4 title_used;
+static ac_uint4 title_size;
+
+/*
+ * Array used to collect case mappings before adding them to a list.
+ */
+static ac_uint4 cases[3];
+
+/*
+ * An array to hold ranges for combining classes.
+ */
+static ac_uint4 *ccl;
+static ac_uint4 ccl_used;
+static ac_uint4 ccl_size;
+
+/*
+ * Structures for handling numbers.
+ */
+typedef struct {
+    ac_uint4 code;
+    ac_uint4 idx;
+} _codeidx_t;
+
+typedef struct {
+    short numerator;
+    short denominator;
+} _num_t;
+
+/*
+ * Arrays to hold the mapping of codes to numbers.
+ */
+static _codeidx_t *ncodes;
+static ac_uint4 ncodes_used;
+static ac_uint4 ncodes_size;
+
+static _num_t *nums;
+static ac_uint4 nums_used;
+static ac_uint4 nums_size;
+
+/*
+ * Array for holding numbers.
+ */
+static _num_t *nums;
+static ac_uint4 nums_used;
+static ac_uint4 nums_size;
+
+static void
+add_range(ac_uint4 start, ac_uint4 end, char *p1, char *p2)
+{
+    int i, j, k, len;
+    _ranges_t *rlp;
+    char *name;
+
+    for (k = 0; k < 2; k++) {
+        if (k == 0) {
+            name = p1;
+            len = 2;
+        } else {
+            if (p2 == 0)
+              break;
+
+            name = p2;
+            len = 1;
+        }
+
+        for (i = 0; i < NUMPROPS; i++) {
+            if (props[i].len == len && memcmp(props[i].name, name, len) == 0)
+              break;
+        }
+
+        if (i == NUMPROPS)
+          continue;
+
+        rlp = &proptbl[i];
+
+        /*
+         * Resize the range list if necessary.
+         */
+        if (rlp->used == rlp->size) {
+            if (rlp->size == 0)
+              rlp->ranges = (ac_uint4 *)
+                  malloc(sizeof(ac_uint4) << 3);
+            else
+              rlp->ranges = (ac_uint4 *)
+                  realloc((char *) rlp->ranges,
+                          sizeof(ac_uint4) * (rlp->size + 8));
+            rlp->size += 8;
+        }
+
+        /*
+         * If this is the first code for this property list, just add it
+         * and return.
+         */
+        if (rlp->used == 0) {
+            rlp->ranges[0] = start;
+            rlp->ranges[1] = end;
+            rlp->used += 2;
+            continue;
+        }
+
+        /*
+         * Optimize the case of adding the range to the end.
+         */
+        j = rlp->used - 1;
+        if (start > rlp->ranges[j]) {
+            j = rlp->used;
+            rlp->ranges[j++] = start;
+            rlp->ranges[j++] = end;
+            rlp->used = j;
+            continue;
+        }
+
+        /*
+         * Need to locate the insertion point.
+         */
+        for (i = 0;
+             i < rlp->used && start > rlp->ranges[i + 1] + 1; i += 2) ;
+
+        /*
+         * If the start value lies in the current range, then simply set the
+         * new end point of the range to the end value passed as a parameter.
+         */
+        if (rlp->ranges[i] <= start && start <= rlp->ranges[i + 1] + 1) {
+            rlp->ranges[i + 1] = end;
+            return;
+        }
+
+        /*
+         * Shift following values up by two.
+         */
+        for (j = rlp->used; j > i; j -= 2) {
+            rlp->ranges[j] = rlp->ranges[j - 2];
+            rlp->ranges[j + 1] = rlp->ranges[j - 1];
+        }
+
+        /*
+         * Add the new range at the insertion point.
+         */
+        rlp->ranges[i] = start;
+        rlp->ranges[i + 1] = end;
+        rlp->used += 2;
+    }
+}
+
+static void
+ordered_range_insert(ac_uint4 c, char *name, int len)
+{
+    int i, j;
+    ac_uint4 s, e;
+    _ranges_t *rlp;
+
+    if (len == 0)
+      return;
+
+    /*
+     * Deal with directionality codes introduced in Unicode 3.0.
+     */
+    if ((len == 2 && memcmp(name, "BN", 2) == 0) ||
+        (len == 3 &&
+         (memcmp(name, "NSM", 3) == 0 || memcmp(name, "PDF", 3) == 0 ||
+          memcmp(name, "LRE", 3) == 0 || memcmp(name, "LRO", 3) == 0 ||
+          memcmp(name, "RLE", 3) == 0 || memcmp(name, "RLO", 3) == 0))) {
+        /*
+         * Mark all of these as Other Neutral to preserve compatibility with
+         * older versions.
+         */
+        len = 2;
+        name = "ON";
+    }
+
+    for (i = 0; i < NUMPROPS; i++) {
+        if (props[i].len == len && memcmp(props[i].name, name, len) == 0)
+          break;
+    }
+
+    if (i == NUMPROPS)
+      return;
+
+    /*
+     * Have a match, so insert the code in order.
+     */
+    rlp = &proptbl[i];
+
+    /*
+     * Resize the range list if necessary.
+     */
+    if (rlp->used == rlp->size) {
+        if (rlp->size == 0)
+          rlp->ranges = (ac_uint4 *)
+              malloc(sizeof(ac_uint4) << 3);
+        else
+          rlp->ranges = (ac_uint4 *)
+              realloc((char *) rlp->ranges,
+                      sizeof(ac_uint4) * (rlp->size + 8));
+        rlp->size += 8;
+    }
+
+    /*
+     * If this is the first code for this property list, just add it
+     * and return.
+     */
+    if (rlp->used == 0) {
+        rlp->ranges[0] = rlp->ranges[1] = c;
+        rlp->used += 2;
+        return;
+    }
+
+    /*
+     * Optimize the cases of extending the last range and adding new ranges to
+     * the end.
+     */
+    j = rlp->used - 1;
+    e = rlp->ranges[j];
+    s = rlp->ranges[j - 1];
+
+    if (c == e + 1) {
+        /*
+         * Extend the last range.
+         */
+        rlp->ranges[j] = c;
+        return;
+    }
+
+    if (c > e + 1) {
+        /*
+         * Start another range on the end.
+         */
+        j = rlp->used;
+        rlp->ranges[j] = rlp->ranges[j + 1] = c;
+        rlp->used += 2;
+        return;
+    }
+
+    if (c >= s)
+      /*
+       * The code is a duplicate of a code in the last range, so just return.
+       */
+      return;
+
+    /*
+     * The code should be inserted somewhere before the last range in the
+     * list.  Locate the insertion point.
+     */
+    for (i = 0;
+         i < rlp->used && c > rlp->ranges[i + 1] + 1; i += 2) ;
+
+    s = rlp->ranges[i];
+    e = rlp->ranges[i + 1];
+
+    if (c == e + 1)
+      /*
+       * Simply extend the current range.
+       */
+      rlp->ranges[i + 1] = c;
+    else if (c < s) {
+        /*
+         * Add a new entry before the current location.  Shift all entries
+         * before the current one up by one to make room.
+         */
+        for (j = rlp->used; j > i; j -= 2) {
+            rlp->ranges[j] = rlp->ranges[j - 2];
+            rlp->ranges[j + 1] = rlp->ranges[j - 1];
+        }
+        rlp->ranges[i] = rlp->ranges[i + 1] = c;
+
+        rlp->used += 2;
+    }
+}
+
+static void
+add_decomp(ac_uint4 code, short compat)
+{
+    ac_uint4 i, j, size;
+    _decomp_t **pdecomps;
+    ac_uint4 *pdecomps_used;
+    ac_uint4 *pdecomps_size;
+
+    if (compat) {
+	pdecomps = &kdecomps;
+	pdecomps_used = &kdecomps_used;
+	pdecomps_size = &kdecomps_size;
+    } else {
+	pdecomps = &decomps;
+	pdecomps_used = &decomps_used;
+	pdecomps_size = &decomps_size;
+    }
+    
+    /*
+     * Add the code to the composite property.
+     */
+    if (!compat) {
+	ordered_range_insert(code, "Cm", 2);
+    }
+
+    /*
+     * Locate the insertion point for the code.
+     */
+    for (i = 0; i < *pdecomps_used && code > (*pdecomps)[i].code; i++) ;
+
+    /*
+     * Allocate space for a new decomposition.
+     */
+    if (*pdecomps_used == *pdecomps_size) {
+        if (*pdecomps_size == 0)
+          *pdecomps = (_decomp_t *) malloc(sizeof(_decomp_t) << 3);
+        else
+          *pdecomps = (_decomp_t *)
+              realloc((char *) *pdecomps,
+                      sizeof(_decomp_t) * (*pdecomps_size + 8));
+        (void) memset((char *) (*pdecomps + *pdecomps_size), '\0',
+                      sizeof(_decomp_t) << 3);
+        *pdecomps_size += 8;
+    }
+
+    if (i < *pdecomps_used && code != (*pdecomps)[i].code) {
+        /*
+         * Shift the decomps up by one if the codes don't match.
+         */
+        for (j = *pdecomps_used; j > i; j--)
+          (void) AC_MEMCPY((char *) &(*pdecomps)[j], (char *) &(*pdecomps)[j - 1],
+                        sizeof(_decomp_t));
+    }
+
+    /*
+     * Insert or replace a decomposition.
+     */
+    size = dectmp_size + (4 - (dectmp_size & 3));
+    if ((*pdecomps)[i].size < size) {
+        if ((*pdecomps)[i].size == 0)
+          (*pdecomps)[i].decomp = (ac_uint4 *)
+              malloc(sizeof(ac_uint4) * size);
+        else
+          (*pdecomps)[i].decomp = (ac_uint4 *)
+              realloc((char *) (*pdecomps)[i].decomp,
+                      sizeof(ac_uint4) * size);
+        (*pdecomps)[i].size = size;
+    }
+
+    if ((*pdecomps)[i].code != code)
+      (*pdecomps_used)++;
+
+    (*pdecomps)[i].code = code;
+    (*pdecomps)[i].used = dectmp_size;
+    (void) AC_MEMCPY((char *) (*pdecomps)[i].decomp, (char *) dectmp,
+                  sizeof(ac_uint4) * dectmp_size);
+
+    /*
+     * NOTICE: This needs changing later so it is more general than simply
+     * pairs.  This calculation is done here to simplify allocation elsewhere.
+     */
+    if (!compat && dectmp_size == 2)
+      comps_used++;
+}
+
+static void
+add_title(ac_uint4 code)
+{
+    ac_uint4 i, j;
+
+    /*
+     * Always map the code to itself.
+     */
+    cases[2] = code;
+
+    if (title_used == title_size) {
+        if (title_size == 0)
+          title = (_case_t *) malloc(sizeof(_case_t) << 3);
+        else
+          title = (_case_t *) realloc((char *) title,
+                                      sizeof(_case_t) * (title_size + 8));
+        title_size += 8;
+    }
+
+    /*
+     * Locate the insertion point.
+     */
+    for (i = 0; i < title_used && code > title[i].key; i++) ;
+
+    if (i < title_used) {
+        /*
+         * Shift the array up by one.
+         */
+        for (j = title_used; j > i; j--)
+          (void) AC_MEMCPY((char *) &title[j], (char *) &title[j - 1],
+                        sizeof(_case_t));
+    }
+
+    title[i].key = cases[2];    /* Title */
+    title[i].other1 = cases[0]; /* Upper */
+    title[i].other2 = cases[1]; /* Lower */
+
+    title_used++;
+}
+
+static void
+add_upper(ac_uint4 code)
+{
+    ac_uint4 i, j;
+
+    /*
+     * Always map the code to itself.
+     */
+    cases[0] = code;
+
+    /*
+     * If the title case character is not present, then make it the same as
+     * the upper case.
+     */
+    if (cases[2] == 0)
+      cases[2] = code;
+
+    if (upper_used == upper_size) {
+        if (upper_size == 0)
+          upper = (_case_t *) malloc(sizeof(_case_t) << 3);
+        else
+          upper = (_case_t *) realloc((char *) upper,
+                                      sizeof(_case_t) * (upper_size + 8));
+        upper_size += 8;
+    }
+
+    /*
+     * Locate the insertion point.
+     */
+    for (i = 0; i < upper_used && code > upper[i].key; i++) ;
+
+    if (i < upper_used) {
+        /*
+         * Shift the array up by one.
+         */
+        for (j = upper_used; j > i; j--)
+          (void) AC_MEMCPY((char *) &upper[j], (char *) &upper[j - 1],
+                        sizeof(_case_t));
+    }
+
+    upper[i].key = cases[0];    /* Upper */
+    upper[i].other1 = cases[1]; /* Lower */
+    upper[i].other2 = cases[2]; /* Title */
+
+    upper_used++;
+}
+
+static void
+add_lower(ac_uint4 code)
+{
+    ac_uint4 i, j;
+
+    /*
+     * Always map the code to itself.
+     */
+    cases[1] = code;
+
+    /*
+     * If the title case character is empty, then make it the same as the
+     * upper case.
+     */
+    if (cases[2] == 0)
+      cases[2] = cases[0];
+
+    if (lower_used == lower_size) {
+        if (lower_size == 0)
+          lower = (_case_t *) malloc(sizeof(_case_t) << 3);
+        else
+          lower = (_case_t *) realloc((char *) lower,
+                                      sizeof(_case_t) * (lower_size + 8));
+        lower_size += 8;
+    }
+
+    /*
+     * Locate the insertion point.
+     */
+    for (i = 0; i < lower_used && code > lower[i].key; i++) ;
+
+    if (i < lower_used) {
+        /*
+         * Shift the array up by one.
+         */
+        for (j = lower_used; j > i; j--)
+          (void) AC_MEMCPY((char *) &lower[j], (char *) &lower[j - 1],
+                        sizeof(_case_t));
+    }
+
+    lower[i].key = cases[1];    /* Lower */
+    lower[i].other1 = cases[0]; /* Upper */
+    lower[i].other2 = cases[2]; /* Title */
+
+    lower_used++;
+}
+
+static void
+ordered_ccl_insert(ac_uint4 c, ac_uint4 ccl_code)
+{
+    ac_uint4 i, j;
+
+    if (ccl_used == ccl_size) {
+        if (ccl_size == 0)
+          ccl = (ac_uint4 *) malloc(sizeof(ac_uint4) * 24);
+        else
+          ccl = (ac_uint4 *)
+              realloc((char *) ccl, sizeof(ac_uint4) * (ccl_size + 24));
+        ccl_size += 24;
+    }
+
+    /*
+     * Optimize adding the first item.
+     */
+    if (ccl_used == 0) {
+        ccl[0] = ccl[1] = c;
+        ccl[2] = ccl_code;
+        ccl_used += 3;
+        return;
+    }
+
+    /*
+     * Handle the special case of extending the range on the end.  This
+     * requires that the combining class codes are the same.
+     */
+    if (ccl_code == ccl[ccl_used - 1] && c == ccl[ccl_used - 2] + 1) {
+        ccl[ccl_used - 2] = c;
+        return;
+    }
+
+    /*
+     * Handle the special case of adding another range on the end.
+     */
+    if (c > ccl[ccl_used - 2] + 1 ||
+        (c == ccl[ccl_used - 2] + 1 && ccl_code != ccl[ccl_used - 1])) {
+        ccl[ccl_used++] = c;
+        ccl[ccl_used++] = c;
+        ccl[ccl_used++] = ccl_code;
+        return;
+    }
+
+    /*
+     * Locate either the insertion point or range for the code.
+     */
+    for (i = 0; i < ccl_used && c > ccl[i + 1] + 1; i += 3) ;
+
+    if (ccl_code == ccl[i + 2] && c == ccl[i + 1] + 1) {
+        /*
+         * Extend an existing range.
+         */
+        ccl[i + 1] = c;
+        return;
+    } else if (c < ccl[i]) {
+        /*
+         * Start a new range before the current location.
+         */
+        for (j = ccl_used; j > i; j -= 3) {
+            ccl[j] = ccl[j - 3];
+            ccl[j - 1] = ccl[j - 4];
+            ccl[j - 2] = ccl[j - 5];
+        }
+        ccl[i] = ccl[i + 1] = c;
+        ccl[i + 2] = ccl_code;
+    }
+}
+
+/*
+ * Adds a number if it does not already exist and returns an index value
+ * multiplied by 2.
+ */
+static ac_uint4
+make_number(short num, short denom)
+{
+    ac_uint4 n;
+
+    /*
+     * Determine if the number already exists.
+     */
+    for (n = 0; n < nums_used; n++) {
+        if (nums[n].numerator == num && nums[n].denominator == denom)
+          return n << 1;
+    }
+
+    if (nums_used == nums_size) {
+        if (nums_size == 0)
+          nums = (_num_t *) malloc(sizeof(_num_t) << 3);
+        else
+          nums = (_num_t *) realloc((char *) nums,
+                                    sizeof(_num_t) * (nums_size + 8));
+        nums_size += 8;
+    }
+
+    n = nums_used++;
+    nums[n].numerator = num;
+    nums[n].denominator = denom;
+
+    return n << 1;
+}
+
+static void
+add_number(ac_uint4 code, short num, short denom)
+{
+    ac_uint4 i, j;
+
+    /*
+     * Insert the code in order.
+     */
+    for (i = 0; i < ncodes_used && code > ncodes[i].code; i++) ;
+
+    /*
+     * Handle the case of the codes matching and simply replace the number
+     * that was there before.
+     */
+    if (i < ncodes_used && code == ncodes[i].code) {
+        ncodes[i].idx = make_number(num, denom);
+        return;
+    }
+
+    /*
+     * Resize the array if necessary.
+     */
+    if (ncodes_used == ncodes_size) {
+        if (ncodes_size == 0)
+          ncodes = (_codeidx_t *) malloc(sizeof(_codeidx_t) << 3);
+        else
+          ncodes = (_codeidx_t *)
+              realloc((char *) ncodes, sizeof(_codeidx_t) * (ncodes_size + 8));
+
+        ncodes_size += 8;
+    }
+
+    /*
+     * Shift things around to insert the code if necessary.
+     */
+    if (i < ncodes_used) {
+        for (j = ncodes_used; j > i; j--) {
+            ncodes[j].code = ncodes[j - 1].code;
+            ncodes[j].idx = ncodes[j - 1].idx;
+        }
+    }
+    ncodes[i].code = code;
+    ncodes[i].idx = make_number(num, denom);
+
+    ncodes_used++;
+}
+
+/*
+ * This routine assumes that the line is a valid Unicode Character Database
+ * entry.
+ */
+static void
+read_cdata(FILE *in)
+{
+    ac_uint4 i, lineno, skip, code, ccl_code;
+    short wnum, neg, number[2], compat;
+    char line[512], *s, *e;
+
+    lineno = skip = 0;
+    while (fgets(line, sizeof(line), in)) {
+	if( (s=strchr(line, '\n')) ) *s = '\0';
+        lineno++;
+
+        /*
+         * Skip blank lines and lines that start with a '#'.
+         */
+        if (line[0] == 0 || line[0] == '#')
+          continue;
+
+        /*
+         * If lines need to be skipped, do it here.
+         */
+        if (skip) {
+            skip--;
+            continue;
+        }
+
+        /*
+         * Collect the code.  The code can be up to 6 hex digits in length to
+         * allow surrogates to be specified.
+         */
+        for (s = line, i = code = 0; *s != ';' && i < 6; i++, s++) {
+            code <<= 4;
+            if (*s >= '0' && *s <= '9')
+              code += *s - '0';
+            else if (*s >= 'A' && *s <= 'F')
+              code += (*s - 'A') + 10;
+            else if (*s >= 'a' && *s <= 'f')
+              code += (*s - 'a') + 10;
+        }
+
+        /*
+         * Handle the following special cases:
+         * 1. 4E00-9FA5 CJK Ideographs.
+         * 2. AC00-D7A3 Hangul Syllables.
+         * 3. D800-DFFF Surrogates.
+         * 4. E000-F8FF Private Use Area.
+         * 5. F900-FA2D Han compatibility.
+	 * ...Plus additional ranges in newer Unicode versions...
+         */
+        switch (code) {
+	  case 0x3400:
+	    /* CJK Ideograph Extension A */
+            add_range(0x3400, 0x4db5, "Lo", "L");
+
+            add_range(0x3400, 0x4db5, "Cp", 0);
+
+	    skip = 1;
+	    break;
+          case 0x4e00:
+            /*
+             * The Han ideographs.
+             */
+            add_range(0x4e00, 0x9fff, "Lo", "L");
+
+            /*
+             * Add the characters to the defined category.
+             */
+            add_range(0x4e00, 0x9fa5, "Cp", 0);
+
+            skip = 1;
+            break;
+          case 0xac00:
+            /*
+             * The Hangul syllables.
+             */
+            add_range(0xac00, 0xd7a3, "Lo", "L");
+
+            /*
+             * Add the characters to the defined category.
+             */
+            add_range(0xac00, 0xd7a3, "Cp", 0);
+
+            skip = 1;
+            break;
+          case 0xd800:
+            /*
+             * Make a range of all surrogates and assume some default
+             * properties.
+             */
+            add_range(0x010000, 0x10ffff, "Cs", "L");
+            skip = 5;
+            break;
+          case 0xe000:
+            /*
+             * The Private Use area.  Add with a default set of properties.
+             */
+            add_range(0xe000, 0xf8ff, "Co", "L");
+            skip = 1;
+            break;
+          case 0xf900:
+            /*
+             * The CJK compatibility area.
+             */
+            add_range(0xf900, 0xfaff, "Lo", "L");
+
+            /*
+             * Add the characters to the defined category.
+             */
+            add_range(0xf900, 0xfaff, "Cp", 0);
+
+            skip = 1;
+	    break;
+	  case 0x20000:
+	    /* CJK Ideograph Extension B */
+            add_range(0x20000, 0x2a6d6, "Lo", "L");
+
+            add_range(0x20000, 0x2a6d6, "Cp", 0);
+
+	    skip = 1;
+	    break;
+	  case 0xf0000:
+	    /* Plane 15 private use */
+	    add_range(0xf0000, 0xffffd, "Co", "L");
+	    skip = 1;
+	    break;
+
+	  case 0x100000:
+	    /* Plane 16 private use */
+	    add_range(0x100000, 0x10fffd, "Co", "L");
+	    skip = 1;
+	    break;
+        }
+
+        if (skip)
+          continue;
+
+        /*
+         * Add the code to the defined category.
+         */
+        ordered_range_insert(code, "Cp", 2);
+
+        /*
+         * Locate the first character property field.
+         */
+        for (i = 0; *s != 0 && i < 2; s++) {
+            if (*s == ';')
+              i++;
+        }
+        for (e = s; *e && *e != ';'; e++) ;
+    
+        ordered_range_insert(code, s, e - s);
+
+        /*
+         * Locate the combining class code.
+         */
+        for (s = e; *s != 0 && i < 3; s++) {
+            if (*s == ';')
+              i++;
+        }
+
+        /*
+         * Convert the combining class code from decimal.
+         */
+        for (ccl_code = 0, e = s; *e && *e != ';'; e++)
+          ccl_code = (ccl_code * 10) + (*e - '0');
+
+        /*
+         * Add the code if it not 0.
+         */
+        if (ccl_code != 0)
+          ordered_ccl_insert(code, ccl_code);
+
+        /*
+         * Locate the second character property field.
+         */
+        for (s = e; *s != 0 && i < 4; s++) {
+            if (*s == ';')
+              i++;
+        }
+        for (e = s; *e && *e != ';'; e++) ;
+
+        ordered_range_insert(code, s, e - s);
+
+        /*
+         * Check for a decomposition.
+         */
+        s = ++e;
+        if (*s != ';') {
+	    compat = *s == '<';
+	    if (compat) {
+		/*
+		 * Skip compatibility formatting tag.
+		 */
+		while (*s++ != '>');
+	    }
+            /*
+             * Collect the codes of the decomposition.
+             */
+            for (dectmp_size = 0; *s != ';'; ) {
+                /*
+                 * Skip all leading non-hex digits.
+                 */
+                while (!ishdigit(*s))
+ 		  s++;
+
+                for (dectmp[dectmp_size] = 0; ishdigit(*s); s++) {
+                    dectmp[dectmp_size] <<= 4;
+                    if (*s >= '0' && *s <= '9')
+                      dectmp[dectmp_size] += *s - '0';
+                    else if (*s >= 'A' && *s <= 'F')
+                      dectmp[dectmp_size] += (*s - 'A') + 10;
+                    else if (*s >= 'a' && *s <= 'f')
+                      dectmp[dectmp_size] += (*s - 'a') + 10;
+                }
+                dectmp_size++;
+            }
+
+            /*
+             * If there are any codes in the temporary decomposition array,
+             * then add the character with its decomposition.
+             */
+            if (dectmp_size > 0) {
+		if (!compat) {
+		    add_decomp(code, 0);
+		}
+		add_decomp(code, 1);
+	    }
+        }
+
+        /*
+         * Skip to the number field.
+         */
+        for (i = 0; i < 3 && *s; s++) {
+            if (*s == ';')
+              i++;
+        }
+
+        /*
+         * Scan the number in.
+         */
+        number[0] = number[1] = 0;
+        for (e = s, neg = wnum = 0; *e && *e != ';'; e++) {
+            if (*e == '-') {
+                neg = 1;
+                continue;
+            }
+
+            if (*e == '/') {
+                /*
+                 * Move the the denominator of the fraction.
+                 */
+                if (neg)
+                  number[wnum] *= -1;
+                neg = 0;
+                e++;
+                wnum++;
+            }
+            number[wnum] = (number[wnum] * 10) + (*e - '0');
+        }
+
+        if (e > s) {
+            /*
+             * Adjust the denominator in case of integers and add the number.
+             */
+            if (wnum == 0)
+              number[1] = 1;
+
+            add_number(code, number[0], number[1]);
+        }
+
+        /*
+         * Skip to the start of the possible case mappings.
+         */
+        for (s = e, i = 0; i < 4 && *s; s++) {
+            if (*s == ';')
+              i++;
+        }
+
+        /*
+         * Collect the case mappings.
+         */
+        cases[0] = cases[1] = cases[2] = 0;
+        for (i = 0; i < 3; i++) {
+            while (ishdigit(*s)) {
+                cases[i] <<= 4;
+                if (*s >= '0' && *s <= '9')
+                  cases[i] += *s - '0';
+                else if (*s >= 'A' && *s <= 'F')
+                  cases[i] += (*s - 'A') + 10;
+                else if (*s >= 'a' && *s <= 'f')
+                  cases[i] += (*s - 'a') + 10;
+                s++;
+            }
+            if (*s == ';')
+              s++;
+        }
+        if (cases[0] && cases[1])
+          /*
+           * Add the upper and lower mappings for a title case character.
+           */
+          add_title(code);
+        else if (cases[1])
+          /*
+           * Add the lower and title case mappings for the upper case
+           * character.
+           */
+          add_upper(code);
+        else if (cases[0])
+          /*
+           * Add the upper and title case mappings for the lower case
+           * character.
+           */
+          add_lower(code);
+    }
+}
+
+#if 0
+
+static _decomp_t *
+find_decomp(ac_uint4 code, short compat)
+{
+    long l, r, m;
+    _decomp_t *decs;
+    
+    l = 0;
+    r = (compat ? kdecomps_used : decomps_used) - 1;
+    decs = compat ? kdecomps : decomps;
+    while (l <= r) {
+        m = (l + r) >> 1;
+        if (code > decs[m].code)
+          l = m + 1;
+        else if (code < decs[m].code)
+          r = m - 1;
+        else
+          return &decs[m];
+    }
+    return 0;
+}
+
+static void
+decomp_it(_decomp_t *d, short compat)
+{
+    ac_uint4 i;
+    _decomp_t *dp;
+
+    for (i = 0; i < d->used; i++) {
+        if ((dp = find_decomp(d->decomp[i], compat)) != 0)
+          decomp_it(dp, compat);
+        else
+          dectmp[dectmp_size++] = d->decomp[i];
+    }
+}
+
+
+/*
+ * Expand all decompositions by recursively decomposing each character
+ * in the decomposition.
+ */
+static void
+expand_decomp(void)
+{
+    ac_uint4 i;
+
+    for (i = 0; i < decomps_used; i++) {
+        dectmp_size = 0;
+        decomp_it(&decomps[i], 0);
+        if (dectmp_size > 0)
+          add_decomp(decomps[i].code, 0);
+    }
+
+    for (i = 0; i < kdecomps_used; i++) {
+        dectmp_size = 0;
+        decomp_it(&kdecomps[i], 1);
+        if (dectmp_size > 0)
+          add_decomp(kdecomps[i].code, 1);
+    }
+}
+
+static int
+cmpcomps(const void *v_comp1, const void *v_comp2)
+{
+	const _comp_t *comp1 = v_comp1, *comp2 = v_comp2;
+    long diff = comp1->code1 - comp2->code1;
+
+    if (!diff)
+	diff = comp1->code2 - comp2->code2;
+    return (int) diff;
+}
+
+#endif
+
+/*
+ * Load composition exclusion data
+ */
+static void
+read_compexdata(FILE *in)
+{
+    ac_uint2 i;
+    ac_uint4 code;
+    char line[512], *s;
+
+    (void) memset((char *) compexs, 0, sizeof(compexs));
+
+    while (fgets(line, sizeof(line), in)) {
+	if( (s=strchr(line, '\n')) ) *s = '\0';
+        /*
+         * Skip blank lines and lines that start with a '#'.
+         */
+        if (line[0] == 0 || line[0] == '#')
+	    continue;
+
+	/*
+         * Collect the code.  Assume max 6 digits
+         */
+
+	for (s = line, i = code = 0; *s != '#' && i < 6; i++, s++) {
+	    if (isspace((unsigned char)*s)) break;
+            code <<= 4;
+            if (*s >= '0' && *s <= '9')
+		code += *s - '0';
+            else if (*s >= 'A' && *s <= 'F')
+		code += (*s - 'A') + 10;
+            else if (*s >= 'a' && *s <= 'f')
+		code += (*s - 'a') + 10;
+        }
+        COMPEX_SET(code);
+    }
+}
+
+#if 0
+
+/*
+ * Creates array of compositions from decomposition array
+ */
+static void
+create_comps(void)
+{
+    ac_uint4 i, cu;
+
+    comps = (_comp_t *) malloc(comps_used * sizeof(_comp_t));
+
+    for (i = cu = 0; i < decomps_used; i++) {
+	if (decomps[i].used != 2 || COMPEX_TEST(decomps[i].code))
+	    continue;
+	comps[cu].comp = decomps[i].code;
+	comps[cu].count = 2;
+	comps[cu].code1 = decomps[i].decomp[0];
+	comps[cu].code2 = decomps[i].decomp[1];
+	cu++;
+    }
+    comps_used = cu;
+    qsort(comps, comps_used, sizeof(_comp_t), cmpcomps);
+}
+
+#endif
+
+#if HARDCODE_DATA
+static void
+write_case(FILE *out, _case_t *tab, int num, int first)
+{
+    int i;
+
+    for (i=0; i<num; i++) {
+	if (first) first = 0;
+	else fprintf(out, ",");
+	fprintf(out, "\n\t0x%08lx, 0x%08lx, 0x%08lx",
+		(unsigned long) tab[i].key, (unsigned long) tab[i].other1,
+		(unsigned long) tab[i].other2);
+    }
+}
+
+#define PREF "static const "
+
+#endif
+
+static void
+write_cdata(char *opath)
+{
+    FILE *out;
+	ac_uint4 bytes;
+    ac_uint4 i, idx, nprops;
+#if !(HARDCODE_DATA)
+    ac_uint2 casecnt[2];
+#endif
+    char path[BUFSIZ];
+#if HARDCODE_DATA
+    int j, k;
+
+    /*****************************************************************
+     *
+     * Generate the ctype data.
+     *
+     *****************************************************************/
+
+    /*
+     * Open the output file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "uctable.h", opath);
+    if ((out = fopen(path, "w")) == 0)
+      return;
+#else
+    /*
+     * Open the ctype.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "ctype.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+#endif
+
+    /*
+     * Collect the offsets for the properties.  The offsets array is
+     * on a 4-byte boundary to keep things efficient for architectures
+     * that need such a thing.
+     */
+    for (i = idx = 0; i < NUMPROPS; i++) {
+        propcnt[i] = (proptbl[i].used != 0) ? idx : 0xffff;
+        idx += proptbl[i].used;
+    }
+
+    /*
+     * Add the sentinel index which is used by the binary search as the upper
+     * bound for a search.
+     */
+    propcnt[i] = idx;
+
+    /*
+     * Record the actual number of property lists.  This may be different than
+     * the number of offsets actually written because of aligning on a 4-byte
+     * boundary.
+     */
+    hdr[1] = NUMPROPS;
+
+    /*
+     * Calculate the byte count needed and pad the property counts array to a
+     * 4-byte boundary.
+     */
+    if ((bytes = sizeof(ac_uint2) * (NUMPROPS + 1)) & 3)
+      bytes += 4 - (bytes & 3);
+    nprops = bytes / sizeof(ac_uint2);
+    bytes += sizeof(ac_uint4) * idx;
+
+#if HARDCODE_DATA
+    fprintf(out,
+        "/* This file was generated from a modified version UCData's ucgendat.\n"
+        " *\n"
+        " *                     DO NOT EDIT THIS FILE!\n"
+        " * \n"
+        " * Instead, compile ucgendat.c (bundled with PHP in ext/mbstring), download\n"
+        " * the appropriate UnicodeData-x.x.x.txt and CompositionExclusions-x.x.x.txt\n"
+        " * files from  http://www.unicode.org/Public/ and run this program.\n"
+        " *\n"
+        " * More information can be found in the UCData package. Unfortunately,\n"
+        " * the project's page doesn't seem to be live anymore, so you can use\n"
+        " * OpenLDAPs modified copy (look in libraries/liblunicode/ucdata) */\n\n");
+
+    fprintf(out, PREF "unsigned short _ucprop_size = %d;\n\n", NUMPROPS);
+
+    fprintf(out, PREF "unsigned short  _ucprop_offsets[] = {");
+
+    for (i = 0; i<nprops; i++) {
+       if (i) fprintf(out, ",");
+       if (!(i&7)) fprintf(out, "\n\t");
+       else fprintf(out, " ");
+       fprintf(out, "0x%04x", propcnt[i]);
+    }
+    fprintf(out, "\n};\n\n");
+
+    fprintf(out, PREF "unsigned int _ucprop_ranges[] = {");
+
+    k = 0;
+    for (i = 0; i < NUMPROPS; i++) {
+	if (proptbl[i].used > 0) {
+	  for (j=0; j<proptbl[i].used; j++) {
+	    if (k) fprintf(out, ",");
+	    if (!(k&3)) fprintf(out,"\n\t");
+	    else fprintf(out, " ");
+	    k++;
+	    fprintf(out, "0x%08lx", (unsigned long) proptbl[i].ranges[j]);
+	  }
+	}
+    }
+    fprintf(out, "\n};\n\n");
+#else
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write the byte count.
+     */
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+    /*
+     * Write the property list counts.
+     */
+    fwrite((char *) propcnt, sizeof(ac_uint2), nprops, out);
+
+    /*
+     * Write the property lists.
+     */
+    for (i = 0; i < NUMPROPS; i++) {
+        if (proptbl[i].used > 0)
+          fwrite((char *) proptbl[i].ranges, sizeof(ac_uint4),
+                 proptbl[i].used, out);
+    }
+
+    fclose(out);
+#endif
+
+    /*****************************************************************
+     *
+     * Generate the case mapping data.
+     *
+     *****************************************************************/
+
+#if HARDCODE_DATA
+    fprintf(out, PREF "unsigned int _uccase_size = %ld;\n\n",
+        (long) (upper_used + lower_used + title_used));
+
+    fprintf(out,
+        "/* Starting indexes of the case tables\n"
+        " * UpperIndex = 0\n"
+        " * LowerIndex = _uccase_len[0]\n"
+        " * TitleIndex = LowerIndex + _uccase_len[1] */\n\n");
+    fprintf(out, PREF "unsigned short _uccase_len[2] = {%ld, %ld};\n\n",
+        (long) upper_used * 3, (long) lower_used * 3);
+    fprintf(out, PREF "unsigned int _uccase_map[] = {");
+
+    if (upper_used > 0)
+      /*
+       * Write the upper case table.
+       */
+      write_case(out, upper, upper_used, 1);
+
+    if (lower_used > 0)
+      /*
+       * Write the lower case table.
+       */
+      write_case(out, lower, lower_used, !upper_used);
+
+    if (title_used > 0)
+      /*
+       * Write the title case table.
+       */
+      write_case(out, title, title_used, !(upper_used||lower_used));
+
+    if (!(upper_used || lower_used || title_used))
+	fprintf(out, "\t0");
+
+    fprintf(out, "\n};\n\n");
+#else
+    /*
+     * Open the case.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "case.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+
+    /*
+     * Write the case mapping tables.
+     */
+    hdr[1] = upper_used + lower_used + title_used;
+    casecnt[0] = upper_used;
+    casecnt[1] = lower_used;
+
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write the upper and lower case table sizes.
+     */
+    fwrite((char *) casecnt, sizeof(ac_uint2), 2, out);
+
+    if (upper_used > 0)
+      /*
+       * Write the upper case table.
+       */
+      fwrite((char *) upper, sizeof(_case_t), upper_used, out);
+
+    if (lower_used > 0)
+      /*
+       * Write the lower case table.
+       */
+      fwrite((char *) lower, sizeof(_case_t), lower_used, out);
+
+    if (title_used > 0)
+      /*
+       * Write the title case table.
+       */
+      fwrite((char *) title, sizeof(_case_t), title_used, out);
+
+    fclose(out);
+#endif
+
+#if 0
+
+    /*****************************************************************
+     *
+     * Generate the composition data.
+     *
+     *****************************************************************/
+    
+    /*
+     * Create compositions from decomposition data
+     */
+    create_comps();
+    
+#if HARDCODE_DATA
+    fprintf(out, PREF "ac_uint4 _uccomp_size = %ld;\n\n",
+        comps_used * 4L);
+
+    fprintf(out, PREF "ac_uint4 _uccomp_data[] = {");
+
+     /*
+      * Now, if comps exist, write them out.
+      */
+    if (comps_used > 0) {
+	for (i=0; i<comps_used; i++) {
+	    if (i) fprintf(out, ",");
+	    fprintf(out, "\n\t0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx",
+	        (unsigned long) comps[i].comp, (unsigned long) comps[i].count,
+	        (unsigned long) comps[i].code1, (unsigned long) comps[i].code2);
+	}
+    } else {
+	fprintf(out, "\t0");
+    }
+    fprintf(out, "\n};\n\n");
+#else
+    /*
+     * Open the comp.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "comp.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+	return;
+    
+    /*
+     * Write the header.
+     */
+    hdr[1] = (ac_uint2) comps_used * 4;
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+    
+    /*
+     * Write out the byte count to maintain header size.
+     */
+    bytes = comps_used * sizeof(_comp_t);
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+    
+    /*
+     * Now, if comps exist, write them out.
+     */
+    if (comps_used > 0)
+        fwrite((char *) comps, sizeof(_comp_t), comps_used, out);
+    
+    fclose(out);
+#endif
+    
+    /*****************************************************************
+     *
+     * Generate the decomposition data.
+     *
+     *****************************************************************/
+
+    /*
+     * Fully expand all decompositions before generating the output file.
+     */
+    expand_decomp();
+
+#if HARDCODE_DATA
+    fprintf(out, PREF "ac_uint4 _ucdcmp_size = %ld;\n\n",
+        decomps_used * 2L);
+
+    fprintf(out, PREF "ac_uint4 _ucdcmp_nodes[] = {");
+
+    if (decomps_used) {
+	/*
+	 * Write the list of decomp nodes.
+	 */
+	for (i = idx = 0; i < decomps_used; i++) {
+	    fprintf(out, "\n\t0x%08lx, 0x%08lx,",
+	        (unsigned long) decomps[i].code, (unsigned long) idx);
+	    idx += decomps[i].used;
+	}
+
+	/*
+	 * Write the sentinel index as the last decomp node.
+	 */
+	fprintf(out, "\n\t0x%08lx\n};\n\n", (unsigned long) idx);
+
+	fprintf(out, PREF "ac_uint4 _ucdcmp_decomp[] = {");
+	/*
+	 * Write the decompositions themselves.
+	 */
+	k = 0;
+	for (i = 0; i < decomps_used; i++)
+	  for (j=0; j<decomps[i].used; j++) {
+	    if (k) fprintf(out, ",");
+	    if (!(k&3)) fprintf(out,"\n\t");
+	    else fprintf(out, " ");
+	    k++;
+	    fprintf(out, "0x%08lx", (unsigned long) decomps[i].decomp[j]);
+	  }
+	fprintf(out, "\n};\n\n");
+    }
+#else
+    /*
+     * Open the decomp.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "decomp.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+
+    hdr[1] = decomps_used;
+
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write a temporary byte count which will be calculated as the
+     * decompositions are written out.
+     */
+    bytes = 0;
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+    if (decomps_used) {
+        /*
+         * Write the list of decomp nodes.
+         */
+        for (i = idx = 0; i < decomps_used; i++) {
+            fwrite((char *) &decomps[i].code, sizeof(ac_uint4), 1, out);
+            fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
+            idx += decomps[i].used;
+        }
+
+        /*
+         * Write the sentinel index as the last decomp node.
+         */
+        fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
+
+        /*
+         * Write the decompositions themselves.
+         */
+        for (i = 0; i < decomps_used; i++)
+          fwrite((char *) decomps[i].decomp, sizeof(ac_uint4),
+                 decomps[i].used, out);
+
+        /*
+         * Seek back to the beginning and write the byte count.
+         */
+        bytes = (sizeof(ac_uint4) * idx) +
+            (sizeof(ac_uint4) * ((hdr[1] << 1) + 1));
+        fseek(out, sizeof(ac_uint2) << 1, 0L);
+        fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+        fclose(out);
+    }
+#endif
+
+#ifdef HARDCODE_DATA
+    fprintf(out, PREF "ac_uint4 _uckdcmp_size = %ld;\n\n",
+        kdecomps_used * 2L);
+
+    fprintf(out, PREF "ac_uint4 _uckdcmp_nodes[] = {");
+
+    if (kdecomps_used) {
+	/*
+	 * Write the list of kdecomp nodes.
+	 */
+	for (i = idx = 0; i < kdecomps_used; i++) {
+	    fprintf(out, "\n\t0x%08lx, 0x%08lx,",
+	        (unsigned long) kdecomps[i].code, (unsigned long) idx);
+	    idx += kdecomps[i].used;
+	}
+
+	/*
+	 * Write the sentinel index as the last decomp node.
+	 */
+	fprintf(out, "\n\t0x%08lx\n};\n\n", (unsigned long) idx);
+
+	fprintf(out, PREF "ac_uint4 _uckdcmp_decomp[] = {");
+
+	/*
+	 * Write the decompositions themselves.
+	 */
+	k = 0;
+	for (i = 0; i < kdecomps_used; i++)
+	  for (j=0; j<kdecomps[i].used; j++) {
+	    if (k) fprintf(out, ",");
+	    if (!(k&3)) fprintf(out,"\n\t");
+	    else fprintf(out, " ");
+	    k++;
+	    fprintf(out, "0x%08lx", (unsigned long) kdecomps[i].decomp[j]);
+	  }
+	fprintf(out, "\n};\n\n");
+    }
+#else
+    /*
+     * Open the kdecomp.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "kdecomp.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+
+    hdr[1] = kdecomps_used;
+
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write a temporary byte count which will be calculated as the
+     * decompositions are written out.
+     */
+    bytes = 0;
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+    if (kdecomps_used) {
+        /*
+         * Write the list of kdecomp nodes.
+         */
+        for (i = idx = 0; i < kdecomps_used; i++) {
+            fwrite((char *) &kdecomps[i].code, sizeof(ac_uint4), 1, out);
+            fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
+            idx += kdecomps[i].used;
+        }
+
+        /*
+         * Write the sentinel index as the last decomp node.
+         */
+        fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
+
+        /*
+         * Write the decompositions themselves.
+         */
+        for (i = 0; i < kdecomps_used; i++)
+          fwrite((char *) kdecomps[i].decomp, sizeof(ac_uint4),
+                 kdecomps[i].used, out);
+
+        /*
+         * Seek back to the beginning and write the byte count.
+         */
+        bytes = (sizeof(ac_uint4) * idx) +
+            (sizeof(ac_uint4) * ((hdr[1] << 1) + 1));
+        fseek(out, sizeof(ac_uint2) << 1, 0L);
+        fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+        fclose(out);
+    }
+#endif
+
+    /*****************************************************************
+     *
+     * Generate the combining class data.
+     *
+     *****************************************************************/
+#ifdef HARDCODE_DATA
+    fprintf(out, PREF "ac_uint4 _uccmcl_size = %ld;\n\n", (long) ccl_used);
+
+    fprintf(out, PREF "ac_uint4 _uccmcl_nodes[] = {");
+
+    if (ccl_used > 0) {
+	/*
+	 * Write the combining class ranges out.
+	 */
+	for (i = 0; i<ccl_used; i++) {
+	    if (i) fprintf(out, ",");
+	    if (!(i&3)) fprintf(out, "\n\t");
+	    else fprintf(out, " ");
+	    fprintf(out, "0x%08lx", (unsigned long) ccl[i]);
+	}
+    } else {
+	fprintf(out, "\t0");
+    }
+    fprintf(out, "\n};\n\n");
+#else
+    /*
+     * Open the cmbcl.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "cmbcl.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+
+    /*
+     * Set the number of ranges used.  Each range has a combining class which
+     * means each entry is a 3-tuple.
+     */
+    hdr[1] = ccl_used / 3;
+
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write out the byte count to maintain header size.
+     */
+    bytes = ccl_used * sizeof(ac_uint4);
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+    if (ccl_used > 0)
+      /*
+       * Write the combining class ranges out.
+       */
+      fwrite((char *) ccl, sizeof(ac_uint4), ccl_used, out);
+
+    fclose(out);
+#endif
+
+    /*****************************************************************
+     *
+     * Generate the number data.
+     *
+     *****************************************************************/
+
+#if HARDCODE_DATA
+    fprintf(out, PREF "ac_uint4 _ucnum_size = %lu;\n\n",
+        (unsigned long)ncodes_used<<1);
+
+    fprintf(out, PREF "ac_uint4 _ucnum_nodes[] = {");
+
+    /*
+     * Now, if number mappings exist, write them out.
+     */
+    if (ncodes_used > 0) {
+	for (i = 0; i<ncodes_used; i++) {
+	    if (i) fprintf(out, ",");
+	    if (!(i&1)) fprintf(out, "\n\t");
+	    else fprintf(out, " ");
+	    fprintf(out, "0x%08lx, 0x%08lx",
+	        (unsigned long) ncodes[i].code, (unsigned long) ncodes[i].idx);
+	}
+	fprintf(out, "\n};\n\n");
+
+	fprintf(out, PREF "short _ucnum_vals[] = {");
+	for (i = 0; i<nums_used; i++) {
+	    if (i) fprintf(out, ",");
+	    if (!(i&3)) fprintf(out, "\n\t");
+	    else fprintf(out, " ");
+	    if (nums[i].numerator < 0) {
+		fprintf(out, "%6d, 0x%04x",
+		  nums[i].numerator, nums[i].denominator);
+	    } else {
+		fprintf(out, "0x%04x, 0x%04x",
+		  nums[i].numerator, nums[i].denominator);
+	    }
+	}
+	fprintf(out, "\n};\n\n");
+    }
+#else
+    /*
+     * Open the num.dat file.
+     */
+    snprintf(path, sizeof path, "%s" LDAP_DIRSEP "num.dat", opath);
+    if ((out = fopen(path, "wb")) == 0)
+      return;
+
+    /*
+     * The count part of the header will be the total number of codes that
+     * have numbers.
+     */
+    hdr[1] = (ac_uint2) (ncodes_used << 1);
+    bytes = (ncodes_used * sizeof(_codeidx_t)) + (nums_used * sizeof(_num_t));
+
+    /*
+     * Write the header.
+     */
+    fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
+
+    /*
+     * Write out the byte count to maintain header size.
+     */
+    fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
+
+    /*
+     * Now, if number mappings exist, write them out.
+     */
+    if (ncodes_used > 0) {
+        fwrite((char *) ncodes, sizeof(_codeidx_t), ncodes_used, out);
+        fwrite((char *) nums, sizeof(_num_t), nums_used, out);
+    }
+#endif
+
+#endif
+
+    fclose(out);
+}
+
+static void
+usage(char *prog)
+{
+    fprintf(stderr,
+            "Usage: %s [-o output-directory|-x composition-exclusions]", prog);
+    fprintf(stderr, " datafile1 datafile2 ...\n\n");
+    fprintf(stderr,
+            "-o output-directory\n\t\tWrite the output files to a different");
+    fprintf(stderr, " directory (default: .).\n");
+    fprintf(stderr,
+            "-x composition-exclusion\n\t\tFile of composition codes");
+    fprintf(stderr, " that should be excluded.\n");
+    exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+    FILE *in;
+    char *prog, *opath;
+
+    prog = argv[1];
+
+    opath = 0;
+    in = stdin;
+
+    argc--;
+    argv++;
+
+    while (argc > 0) {
+        if (argv[0][0] == '-') {
+            switch (argv[0][1]) {
+              case 'o':
+                argc--;
+                argv++;
+                opath = argv[0];
+                break;
+              case 'x':
+                argc--;
+                argv++;
+                if ((in = fopen(argv[0], "r")) == 0)
+                  fprintf(stderr,
+                          "%s: unable to open composition exclusion file %s\n",
+                          prog, argv[0]);
+                else {
+                    read_compexdata(in);
+                    fclose(in);
+                    in = 0;
+                }
+                break;
+              default:
+                usage(prog);
+            }
+        } else {
+            if (in != stdin && in != NULL)
+              fclose(in);
+            if ((in = fopen(argv[0], "r")) == 0)
+              fprintf(stderr, "%s: unable to open ctype file %s\n",
+                      prog, argv[0]);
+            else {
+                read_cdata(in);
+                fclose(in);
+                in = 0;
+	    }
+        }
+        argc--;
+        argv++;
+    }
+
+    if (opath == 0)
+      opath = ".";
+    write_cdata(opath);
+
+    return 0;
+}
diff --git a/ext/mbstring/unicode_data.h b/ext/mbstring/unicode_data.h
index 3cdd073..1edec4c 100644
--- a/ext/mbstring/unicode_data.h
+++ b/ext/mbstring/unicode_data.h
@@ -1,2738 +1,4272 @@
-/* This file holds unicode properties and case folding information.
- * It was generated by a modified version of ucgendat, part of the ucdata-2.5 package */
+/* This file was generated from a modified version UCData's ucgendat.
+ *
+ *                     DO NOT EDIT THIS FILE!
+ * 
+ * Instead, compile ucgendat.c (bundled with PHP in ext/mbstring), download
+ * the appropriate UnicodeData-x.x.x.txt and CompositionExclusions-x.x.x.txt
+ * files from  http://www.unicode.org/Public/ and run this program.
+ *
+ * More information can be found in the UCData package. Unfortunately,
+ * the project's page doesn't seem to be live anymore, so you can use
+ * OpenLDAPs modified copy (look in libraries/liblunicode/ucdata) */
 
-/* {{{ ctype data */
-static unsigned short _ucprop_size = 0x0032;
-static unsigned short _ucprop_offsets[] = {
-0x0000, 0x00d0, 0x0138, 0x0140, 0x016a, 0x0176, 0x019e, 
-0x01ac, 0x01ae, 0x01b0, 0x01b4, 0x01cc, 0x01ce, 0xffff, 0x01d8, 
-0x051e, 0x0866, 0x087a, 0x08a2, 0x0a3a, 0x0a48, 0x0a60, 0x0ae0, 
-0x0b5c, 0x0be8, 0x0c5c, 0x0c72, 0x0c9e, 0x0d6e, 0x0ff2, 0x100e, 
-0x1024, 0x1028, 0x1058, 0x105c, 0x1072, 0x107c, 0x1082, 0x1092, 
-0x1244, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x13ec, 
-0x16f4, 0x16fe, 0x1706, 0x1730, 0x0000, };
-static unsigned long _ucprop_ranges[] = {
-0x00000300, 0x0000034f, 0x00000360, 0x0000036f, 
-0x00000483, 0x00000486, 0x00000591, 0x000005a1, 0x000005a3, 
-0x000005b9, 0x000005bb, 0x000005bd, 0x000005bf, 0x000005bf, 
-0x000005c1, 0x000005c2, 0x000005c4, 0x000005c4, 0x0000064b, 
-0x00000655, 0x00000670, 0x00000670, 0x000006d6, 0x000006dc, 
-0x000006df, 0x000006e4, 0x000006e7, 0x000006e8, 0x000006ea, 
-0x000006ed, 0x00000711, 0x00000711, 0x00000730, 0x0000074a, 
-0x000007a6, 0x000007b0, 0x00000901, 0x00000902, 0x0000093c, 
-0x0000093c, 0x00000941, 0x00000948, 0x0000094d, 0x0000094d, 
-0x00000951, 0x00000954, 0x00000962, 0x00000963, 0x00000981, 
-0x00000981, 0x000009bc, 0x000009bc, 0x000009c1, 0x000009c4, 
-0x000009cd, 0x000009cd, 0x000009e2, 0x000009e3, 0x00000a02, 
-0x00000a02, 0x00000a3c, 0x00000a3c, 0x00000a41, 0x00000a42, 
-0x00000a47, 0x00000a48, 0x00000a4b, 0x00000a4d, 0x00000a70, 
-0x00000a71, 0x00000a81, 0x00000a82, 0x00000abc, 0x00000abc, 
-0x00000ac1, 0x00000ac5, 0x00000ac7, 0x00000ac8, 0x00000acd, 
-0x00000acd, 0x00000b01, 0x00000b01, 0x00000b3c, 0x00000b3c, 
-0x00000b3f, 0x00000b3f, 0x00000b41, 0x00000b43, 0x00000b4d, 
-0x00000b4d, 0x00000b56, 0x00000b56, 0x00000b82, 0x00000b82, 
-0x00000bc0, 0x00000bc0, 0x00000bcd, 0x00000bcd, 0x00000c3e, 
-0x00000c40, 0x00000c46, 0x00000c48, 0x00000c4a, 0x00000c4d, 
-0x00000c55, 0x00000c56, 0x00000cbf, 0x00000cbf, 0x00000cc6, 
-0x00000cc6, 0x00000ccc, 0x00000ccd, 0x00000d41, 0x00000d43, 
-0x00000d4d, 0x00000d4d, 0x00000dca, 0x00000dca, 0x00000dd2, 
-0x00000dd4, 0x00000dd6, 0x00000dd6, 0x00000e31, 0x00000e31, 
-0x00000e34, 0x00000e3a, 0x00000e47, 0x00000e4e, 0x00000eb1, 
-0x00000eb1, 0x00000eb4, 0x00000eb9, 0x00000ebb, 0x00000ebc, 
-0x00000ec8, 0x00000ecd, 0x00000f18, 0x00000f19, 0x00000f35, 
-0x00000f35, 0x00000f37, 0x00000f37, 0x00000f39, 0x00000f39, 
-0x00000f71, 0x00000f7e, 0x00000f80, 0x00000f84, 0x00000f86, 
-0x00000f87, 0x00000f90, 0x00000f97, 0x00000f99, 0x00000fbc, 
-0x00000fc6, 0x00000fc6, 0x0000102d, 0x00001030, 0x00001032, 
-0x00001032, 0x00001036, 0x00001037, 0x00001039, 0x00001039, 
-0x00001058, 0x00001059, 0x00001712, 0x00001714, 0x00001732, 
-0x00001734, 0x00001752, 0x00001753, 0x00001772, 0x00001773, 
-0x000017b7, 0x000017bd, 0x000017c6, 0x000017c6, 0x000017c9, 
-0x000017d3, 0x0000180b, 0x0000180d, 0x000018a9, 0x000018a9, 
-0x000020d0, 0x000020dc, 0x000020e1, 0x000020e1, 0x000020e5, 
-0x000020ea, 0x0000302a, 0x0000302f, 0x00003099, 0x0000309a, 
-0x0000fb1e, 0x0000fb1e, 0x0000fe00, 0x0000fe0f, 0x0000fe20, 
-0x0000fe23, 0x0001d167, 0x0001d169, 0x0001d17b, 0x0001d182, 
-0x0001d185, 0x0001d18b, 0x0001d1aa, 0x0001d1ad, 
-0x00000903, 0x00000903, 0x0000093e, 0x00000940, 
-0x00000949, 0x0000094c, 0x00000982, 0x00000983, 0x000009be, 
-0x000009c0, 0x000009c7, 0x000009c8, 0x000009cb, 0x000009cc, 
-0x000009d7, 0x000009d7, 0x00000a3e, 0x00000a40, 0x00000a83, 
-0x00000a83, 0x00000abe, 0x00000ac0, 0x00000ac9, 0x00000ac9, 
-0x00000acb, 0x00000acc, 0x00000b02, 0x00000b03, 0x00000b3e, 
-0x00000b3e, 0x00000b40, 0x00000b40, 0x00000b47, 0x00000b48, 
-0x00000b4b, 0x00000b4c, 0x00000b57, 0x00000b57, 0x00000bbe, 
-0x00000bbf, 0x00000bc1, 0x00000bc2, 0x00000bc6, 0x00000bc8, 
-0x00000bca, 0x00000bcc, 0x00000bd7, 0x00000bd7, 0x00000c01, 
-0x00000c03, 0x00000c41, 0x00000c44, 0x00000c82, 0x00000c83, 
-0x00000cbe, 0x00000cbe, 0x00000cc0, 0x00000cc4, 0x00000cc7, 
-0x00000cc8, 0x00000cca, 0x00000ccb, 0x00000cd5, 0x00000cd6, 
-0x00000d02, 0x00000d03, 0x00000d3e, 0x00000d40, 0x00000d46, 
-0x00000d48, 0x00000d4a, 0x00000d4c, 0x00000d57, 0x00000d57, 
-0x00000d82, 0x00000d83, 0x00000dcf, 0x00000dd1, 0x00000dd8, 
-0x00000ddf, 0x00000df2, 0x00000df3, 0x00000f3e, 0x00000f3f, 
-0x00000f7f, 0x00000f7f, 0x0000102c, 0x0000102c, 0x00001031, 
-0x00001031, 0x00001038, 0x00001038, 0x00001056, 0x00001057, 
-0x000017b4, 0x000017b6, 0x000017be, 0x000017c5, 0x000017c7, 
-0x000017c8, 0x0001d165, 0x0001d166, 0x0001d16d, 0x0001d172, 
-0x00000488, 0x00000489, 0x000006de, 0x000006de, 
-0x000020dd, 0x000020e0, 0x000020e2, 0x000020e4, 
-0x00000030, 0x00000039, 0x00000660, 0x00000669, 
-0x000006f0, 0x000006f9, 0x00000966, 0x0000096f, 0x000009e6, 
-0x000009ef, 0x00000a66, 0x00000a6f, 0x00000ae6, 0x00000aef, 
-0x00000b66, 0x00000b6f, 0x00000be7, 0x00000bef, 0x00000c66, 
-0x00000c6f, 0x00000ce6, 0x00000cef, 0x00000d66, 0x00000d6f, 
-0x00000e50, 0x00000e59, 0x00000ed0, 0x00000ed9, 0x00000f20, 
-0x00000f29, 0x00001040, 0x00001049, 0x00001369, 0x00001371, 
-0x000017e0, 0x000017e9, 0x00001810, 0x00001819, 0x0000ff10, 
-0x0000ff19, 0x0001d7ce, 0x0001d7ff, 
-0x000016ee, 0x000016f0, 0x00002160, 0x00002183, 
-0x00003007, 0x00003007, 0x00003021, 0x00003029, 0x00003038, 
-0x0000303a, 0x0001034a, 0x0001034a, 
-0x000000b2, 0x000000b3, 0x000000b9, 0x000000b9, 
-0x000000bc, 0x000000be, 0x000009f4, 0x000009f9, 0x00000bf0, 
-0x00000bf2, 0x00000f2a, 0x00000f33, 0x00001372, 0x0000137c, 
-0x00002070, 0x00002070, 0x00002074, 0x00002079, 0x00002080, 
-0x00002089, 0x00002153, 0x0000215f, 0x00002460, 0x0000249b, 
-0x000024ea, 0x000024fe, 0x00002776, 0x00002793, 0x00003192, 
-0x00003195, 0x00003220, 0x00003229, 0x00003251, 0x0000325f, 
-0x00003280, 0x00003289, 0x000032b1, 0x000032bf, 0x00010320, 
-0x00010323, 
-0x00000020, 0x00000020, 0x000000a0, 0x000000a0, 
-0x00001680, 0x00001680, 0x00002000, 0x0000200b, 0x0000202f, 
-0x0000202f, 0x0000205f, 0x0000205f, 0x00003000, 0x00003000, 
-0x00002028, 0x00002028, 
-0x00002029, 0x00002029, 
-0x00000000, 0x0000001f, 0x0000007f, 0x0000009f, 
-0x000006dd, 0x000006dd, 0x0000070f, 0x0000070f, 
-0x0000180e, 0x0000180e, 0x0000200c, 0x0000200f, 0x0000202a, 
-0x0000202e, 0x00002060, 0x00002063, 0x0000206a, 0x0000206f, 
-0x0000feff, 0x0000feff, 0x0000fff9, 0x0000fffb, 0x0001d173, 
-0x0001d17a, 0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f, 
-0x00010000, 0x0010ffff, 
-0x0000e000, 0x0000f8ff, 0x000f0000, 0x000f0000, 
-0x000ffffd, 0x000ffffd, 0x00100000, 0x00100000, 0x0010fffd, 
-0x0010fffd, 
-0x00000041, 0x0000005a, 0x000000c0, 0x000000d6, 
-0x000000d8, 0x000000de, 0x00000100, 0x00000100, 0x00000102, 
-0x00000102, 0x00000104, 0x00000104, 0x00000106, 0x00000106, 
-0x00000108, 0x00000108, 0x0000010a, 0x0000010a, 0x0000010c, 
-0x0000010c, 0x0000010e, 0x0000010e, 0x00000110, 0x00000110, 
-0x00000112, 0x00000112, 0x00000114, 0x00000114, 0x00000116, 
-0x00000116, 0x00000118, 0x00000118, 0x0000011a, 0x0000011a, 
-0x0000011c, 0x0000011c, 0x0000011e, 0x0000011e, 0x00000120, 
-0x00000120, 0x00000122, 0x00000122, 0x00000124, 0x00000124, 
-0x00000126, 0x00000126, 0x00000128, 0x00000128, 0x0000012a, 
-0x0000012a, 0x0000012c, 0x0000012c, 0x0000012e, 0x0000012e, 
-0x00000130, 0x00000130, 0x00000132, 0x00000132, 0x00000134, 
-0x00000134, 0x00000136, 0x00000136, 0x00000139, 0x00000139, 
-0x0000013b, 0x0000013b, 0x0000013d, 0x0000013d, 0x0000013f, 
-0x0000013f, 0x00000141, 0x00000141, 0x00000143, 0x00000143, 
-0x00000145, 0x00000145, 0x00000147, 0x00000147, 0x0000014a, 
-0x0000014a, 0x0000014c, 0x0000014c, 0x0000014e, 0x0000014e, 
-0x00000150, 0x00000150, 0x00000152, 0x00000152, 0x00000154, 
-0x00000154, 0x00000156, 0x00000156, 0x00000158, 0x00000158, 
-0x0000015a, 0x0000015a, 0x0000015c, 0x0000015c, 0x0000015e, 
-0x0000015e, 0x00000160, 0x00000160, 0x00000162, 0x00000162, 
-0x00000164, 0x00000164, 0x00000166, 0x00000166, 0x00000168, 
-0x00000168, 0x0000016a, 0x0000016a, 0x0000016c, 0x0000016c, 
-0x0000016e, 0x0000016e, 0x00000170, 0x00000170, 0x00000172, 
-0x00000172, 0x00000174, 0x00000174, 0x00000176, 0x00000176, 
-0x00000178, 0x00000179, 0x0000017b, 0x0000017b, 0x0000017d, 
-0x0000017d, 0x00000181, 0x00000182, 0x00000184, 0x00000184, 
-0x00000186, 0x00000187, 0x00000189, 0x0000018b, 0x0000018e, 
-0x00000191, 0x00000193, 0x00000194, 0x00000196, 0x00000198, 
-0x0000019c, 0x0000019d, 0x0000019f, 0x000001a0, 0x000001a2, 
-0x000001a2, 0x000001a4, 0x000001a4, 0x000001a6, 0x000001a7, 
-0x000001a9, 0x000001a9, 0x000001ac, 0x000001ac, 0x000001ae, 
-0x000001af, 0x000001b1, 0x000001b3, 0x000001b5, 0x000001b5, 
-0x000001b7, 0x000001b8, 0x000001bc, 0x000001bc, 0x000001c4, 
-0x000001c4, 0x000001c7, 0x000001c7, 0x000001ca, 0x000001ca, 
-0x000001cd, 0x000001cd, 0x000001cf, 0x000001cf, 0x000001d1, 
-0x000001d1, 0x000001d3, 0x000001d3, 0x000001d5, 0x000001d5, 
-0x000001d7, 0x000001d7, 0x000001d9, 0x000001d9, 0x000001db, 
-0x000001db, 0x000001de, 0x000001de, 0x000001e0, 0x000001e0, 
-0x000001e2, 0x000001e2, 0x000001e4, 0x000001e4, 0x000001e6, 
-0x000001e6, 0x000001e8, 0x000001e8, 0x000001ea, 0x000001ea, 
-0x000001ec, 0x000001ec, 0x000001ee, 0x000001ee, 0x000001f1, 
-0x000001f1, 0x000001f4, 0x000001f4, 0x000001f6, 0x000001f8, 
-0x000001fa, 0x000001fa, 0x000001fc, 0x000001fc, 0x000001fe, 
-0x000001fe, 0x00000200, 0x00000200, 0x00000202, 0x00000202, 
-0x00000204, 0x00000204, 0x00000206, 0x00000206, 0x00000208, 
-0x00000208, 0x0000020a, 0x0000020a, 0x0000020c, 0x0000020c, 
-0x0000020e, 0x0000020e, 0x00000210, 0x00000210, 0x00000212, 
-0x00000212, 0x00000214, 0x00000214, 0x00000216, 0x00000216, 
-0x00000218, 0x00000218, 0x0000021a, 0x0000021a, 0x0000021c, 
-0x0000021c, 0x0000021e, 0x0000021e, 0x00000220, 0x00000220, 
-0x00000222, 0x00000222, 0x00000224, 0x00000224, 0x00000226, 
-0x00000226, 0x00000228, 0x00000228, 0x0000022a, 0x0000022a, 
-0x0000022c, 0x0000022c, 0x0000022e, 0x0000022e, 0x00000230, 
-0x00000230, 0x00000232, 0x00000232, 0x00000386, 0x00000386, 
-0x00000388, 0x0000038a, 0x0000038c, 0x0000038c, 0x0000038e, 
-0x0000038f, 0x00000391, 0x000003a1, 0x000003a3, 0x000003ab, 
-0x000003d2, 0x000003d4, 0x000003d8, 0x000003d8, 0x000003da, 
-0x000003da, 0x000003dc, 0x000003dc, 0x000003de, 0x000003de, 
-0x000003e0, 0x000003e0, 0x000003e2, 0x000003e2, 0x000003e4, 
-0x000003e4, 0x000003e6, 0x000003e6, 0x000003e8, 0x000003e8, 
-0x000003ea, 0x000003ea, 0x000003ec, 0x000003ec, 0x000003ee, 
-0x000003ee, 0x000003f4, 0x000003f4, 0x00000400, 0x0000042f, 
-0x00000460, 0x00000460, 0x00000462, 0x00000462, 0x00000464, 
-0x00000464, 0x00000466, 0x00000466, 0x00000468, 0x00000468, 
-0x0000046a, 0x0000046a, 0x0000046c, 0x0000046c, 0x0000046e, 
-0x0000046e, 0x00000470, 0x00000470, 0x00000472, 0x00000472, 
-0x00000474, 0x00000474, 0x00000476, 0x00000476, 0x00000478, 
-0x00000478, 0x0000047a, 0x0000047a, 0x0000047c, 0x0000047c, 
-0x0000047e, 0x0000047e, 0x00000480, 0x00000480, 0x0000048a, 
-0x0000048a, 0x0000048c, 0x0000048c, 0x0000048e, 0x0000048e, 
-0x00000490, 0x00000490, 0x00000492, 0x00000492, 0x00000494, 
-0x00000494, 0x00000496, 0x00000496, 0x00000498, 0x00000498, 
-0x0000049a, 0x0000049a, 0x0000049c, 0x0000049c, 0x0000049e, 
-0x0000049e, 0x000004a0, 0x000004a0, 0x000004a2, 0x000004a2, 
-0x000004a4, 0x000004a4, 0x000004a6, 0x000004a6, 0x000004a8, 
-0x000004a8, 0x000004aa, 0x000004aa, 0x000004ac, 0x000004ac, 
-0x000004ae, 0x000004ae, 0x000004b0, 0x000004b0, 0x000004b2, 
-0x000004b2, 0x000004b4, 0x000004b4, 0x000004b6, 0x000004b6, 
-0x000004b8, 0x000004b8, 0x000004ba, 0x000004ba, 0x000004bc, 
-0x000004bc, 0x000004be, 0x000004be, 0x000004c0, 0x000004c1, 
-0x000004c3, 0x000004c3, 0x000004c5, 0x000004c5, 0x000004c7, 
-0x000004c7, 0x000004c9, 0x000004c9, 0x000004cb, 0x000004cb, 
-0x000004cd, 0x000004cd, 0x000004d0, 0x000004d0, 0x000004d2, 
-0x000004d2, 0x000004d4, 0x000004d4, 0x000004d6, 0x000004d6, 
-0x000004d8, 0x000004d8, 0x000004da, 0x000004da, 0x000004dc, 
-0x000004dc, 0x000004de, 0x000004de, 0x000004e0, 0x000004e0, 
-0x000004e2, 0x000004e2, 0x000004e4, 0x000004e4, 0x000004e6, 
-0x000004e6, 0x000004e8, 0x000004e8, 0x000004ea, 0x000004ea, 
-0x000004ec, 0x000004ec, 0x000004ee, 0x000004ee, 0x000004f0, 
-0x000004f0, 0x000004f2, 0x000004f2, 0x000004f4, 0x000004f4, 
-0x000004f8, 0x000004f8, 0x00000500, 0x00000500, 0x00000502, 
-0x00000502, 0x00000504, 0x00000504, 0x00000506, 0x00000506, 
-0x00000508, 0x00000508, 0x0000050a, 0x0000050a, 0x0000050c, 
-0x0000050c, 0x0000050e, 0x0000050e, 0x00000531, 0x00000556, 
-0x000010a0, 0x000010c5, 0x00001e00, 0x00001e00, 0x00001e02, 
-0x00001e02, 0x00001e04, 0x00001e04, 0x00001e06, 0x00001e06, 
-0x00001e08, 0x00001e08, 0x00001e0a, 0x00001e0a, 0x00001e0c, 
-0x00001e0c, 0x00001e0e, 0x00001e0e, 0x00001e10, 0x00001e10, 
-0x00001e12, 0x00001e12, 0x00001e14, 0x00001e14, 0x00001e16, 
-0x00001e16, 0x00001e18, 0x00001e18, 0x00001e1a, 0x00001e1a, 
-0x00001e1c, 0x00001e1c, 0x00001e1e, 0x00001e1e, 0x00001e20, 
-0x00001e20, 0x00001e22, 0x00001e22, 0x00001e24, 0x00001e24, 
-0x00001e26, 0x00001e26, 0x00001e28, 0x00001e28, 0x00001e2a, 
-0x00001e2a, 0x00001e2c, 0x00001e2c, 0x00001e2e, 0x00001e2e, 
-0x00001e30, 0x00001e30, 0x00001e32, 0x00001e32, 0x00001e34, 
-0x00001e34, 0x00001e36, 0x00001e36, 0x00001e38, 0x00001e38, 
-0x00001e3a, 0x00001e3a, 0x00001e3c, 0x00001e3c, 0x00001e3e, 
-0x00001e3e, 0x00001e40, 0x00001e40, 0x00001e42, 0x00001e42, 
-0x00001e44, 0x00001e44, 0x00001e46, 0x00001e46, 0x00001e48, 
-0x00001e48, 0x00001e4a, 0x00001e4a, 0x00001e4c, 0x00001e4c, 
-0x00001e4e, 0x00001e4e, 0x00001e50, 0x00001e50, 0x00001e52, 
-0x00001e52, 0x00001e54, 0x00001e54, 0x00001e56, 0x00001e56, 
-0x00001e58, 0x00001e58, 0x00001e5a, 0x00001e5a, 0x00001e5c, 
-0x00001e5c, 0x00001e5e, 0x00001e5e, 0x00001e60, 0x00001e60, 
-0x00001e62, 0x00001e62, 0x00001e64, 0x00001e64, 0x00001e66, 
-0x00001e66, 0x00001e68, 0x00001e68, 0x00001e6a, 0x00001e6a, 
-0x00001e6c, 0x00001e6c, 0x00001e6e, 0x00001e6e, 0x00001e70, 
-0x00001e70, 0x00001e72, 0x00001e72, 0x00001e74, 0x00001e74, 
-0x00001e76, 0x00001e76, 0x00001e78, 0x00001e78, 0x00001e7a, 
-0x00001e7a, 0x00001e7c, 0x00001e7c, 0x00001e7e, 0x00001e7e, 
-0x00001e80, 0x00001e80, 0x00001e82, 0x00001e82, 0x00001e84, 
-0x00001e84, 0x00001e86, 0x00001e86, 0x00001e88, 0x00001e88, 
-0x00001e8a, 0x00001e8a, 0x00001e8c, 0x00001e8c, 0x00001e8e, 
-0x00001e8e, 0x00001e90, 0x00001e90, 0x00001e92, 0x00001e92, 
-0x00001e94, 0x00001e94, 0x00001ea0, 0x00001ea0, 0x00001ea2, 
-0x00001ea2, 0x00001ea4, 0x00001ea4, 0x00001ea6, 0x00001ea6, 
-0x00001ea8, 0x00001ea8, 0x00001eaa, 0x00001eaa, 0x00001eac, 
-0x00001eac, 0x00001eae, 0x00001eae, 0x00001eb0, 0x00001eb0, 
-0x00001eb2, 0x00001eb2, 0x00001eb4, 0x00001eb4, 0x00001eb6, 
-0x00001eb6, 0x00001eb8, 0x00001eb8, 0x00001eba, 0x00001eba, 
-0x00001ebc, 0x00001ebc, 0x00001ebe, 0x00001ebe, 0x00001ec0, 
-0x00001ec0, 0x00001ec2, 0x00001ec2, 0x00001ec4, 0x00001ec4, 
-0x00001ec6, 0x00001ec6, 0x00001ec8, 0x00001ec8, 0x00001eca, 
-0x00001eca, 0x00001ecc, 0x00001ecc, 0x00001ece, 0x00001ece, 
-0x00001ed0, 0x00001ed0, 0x00001ed2, 0x00001ed2, 0x00001ed4, 
-0x00001ed4, 0x00001ed6, 0x00001ed6, 0x00001ed8, 0x00001ed8, 
-0x00001eda, 0x00001eda, 0x00001edc, 0x00001edc, 0x00001ede, 
-0x00001ede, 0x00001ee0, 0x00001ee0, 0x00001ee2, 0x00001ee2, 
-0x00001ee4, 0x00001ee4, 0x00001ee6, 0x00001ee6, 0x00001ee8, 
-0x00001ee8, 0x00001eea, 0x00001eea, 0x00001eec, 0x00001eec, 
-0x00001eee, 0x00001eee, 0x00001ef0, 0x00001ef0, 0x00001ef2, 
-0x00001ef2, 0x00001ef4, 0x00001ef4, 0x00001ef6, 0x00001ef6, 
-0x00001ef8, 0x00001ef8, 0x00001f08, 0x00001f0f, 0x00001f18, 
-0x00001f1d, 0x00001f28, 0x00001f2f, 0x00001f38, 0x00001f3f, 
-0x00001f48, 0x00001f4d, 0x00001f59, 0x00001f59, 0x00001f5b, 
-0x00001f5b, 0x00001f5d, 0x00001f5d, 0x00001f5f, 0x00001f5f, 
-0x00001f68, 0x00001f6f, 0x00001fb8, 0x00001fbb, 0x00001fc8, 
-0x00001fcb, 0x00001fd8, 0x00001fdb, 0x00001fe8, 0x00001fec, 
-0x00001ff8, 0x00001ffb, 0x00002102, 0x00002102, 0x00002107, 
-0x00002107, 0x0000210b, 0x0000210d, 0x00002110, 0x00002112, 
-0x00002115, 0x00002115, 0x00002119, 0x0000211d, 0x00002124, 
-0x00002124, 0x00002126, 0x00002126, 0x00002128, 0x00002128, 
-0x0000212a, 0x0000212d, 0x00002130, 0x00002131, 0x00002133, 
-0x00002133, 0x0000213e, 0x0000213f, 0x00002145, 0x00002145, 
-0x0000ff21, 0x0000ff3a, 0x00010400, 0x00010425, 0x0001d400, 
-0x0001d419, 0x0001d434, 0x0001d44d, 0x0001d468, 0x0001d481, 
-0x0001d49c, 0x0001d49c, 0x0001d49e, 0x0001d49f, 0x0001d4a2, 
-0x0001d4a2, 0x0001d4a5, 0x0001d4a6, 0x0001d4a9, 0x0001d4ac, 
-0x0001d4ae, 0x0001d4b5, 0x0001d4d0, 0x0001d4e9, 0x0001d504, 
-0x0001d505, 0x0001d507, 0x0001d50a, 0x0001d50d, 0x0001d514, 
-0x0001d516, 0x0001d51c, 0x0001d538, 0x0001d539, 0x0001d53b, 
-0x0001d53e, 0x0001d540, 0x0001d544, 0x0001d546, 0x0001d546, 
-0x0001d54a, 0x0001d550, 0x0001d56c, 0x0001d585, 0x0001d5a0, 
-0x0001d5b9, 0x0001d5d4, 0x0001d5ed, 0x0001d608, 0x0001d621, 
-0x0001d63c, 0x0001d655, 0x0001d670, 0x0001d689, 0x0001d6a8, 
-0x0001d6c0, 0x0001d6e2, 0x0001d6fa, 0x0001d71c, 0x0001d734, 
-0x0001d756, 0x0001d76e, 0x0001d790, 0x0001d7a8, 
-0x00000061, 0x0000007a, 0x000000aa, 0x000000aa, 
-0x000000b5, 0x000000b5, 0x000000ba, 0x000000ba, 0x000000df, 
-0x000000f6, 0x000000f8, 0x000000ff, 0x00000101, 0x00000101, 
-0x00000103, 0x00000103, 0x00000105, 0x00000105, 0x00000107, 
-0x00000107, 0x00000109, 0x00000109, 0x0000010b, 0x0000010b, 
-0x0000010d, 0x0000010d, 0x0000010f, 0x0000010f, 0x00000111, 
-0x00000111, 0x00000113, 0x00000113, 0x00000115, 0x00000115, 
-0x00000117, 0x00000117, 0x00000119, 0x00000119, 0x0000011b, 
-0x0000011b, 0x0000011d, 0x0000011d, 0x0000011f, 0x0000011f, 
-0x00000121, 0x00000121, 0x00000123, 0x00000123, 0x00000125, 
-0x00000125, 0x00000127, 0x00000127, 0x00000129, 0x00000129, 
-0x0000012b, 0x0000012b, 0x0000012d, 0x0000012d, 0x0000012f, 
-0x0000012f, 0x00000131, 0x00000131, 0x00000133, 0x00000133, 
-0x00000135, 0x00000135, 0x00000137, 0x00000138, 0x0000013a, 
-0x0000013a, 0x0000013c, 0x0000013c, 0x0000013e, 0x0000013e, 
-0x00000140, 0x00000140, 0x00000142, 0x00000142, 0x00000144, 
-0x00000144, 0x00000146, 0x00000146, 0x00000148, 0x00000149, 
-0x0000014b, 0x0000014b, 0x0000014d, 0x0000014d, 0x0000014f, 
-0x0000014f, 0x00000151, 0x00000151, 0x00000153, 0x00000153, 
-0x00000155, 0x00000155, 0x00000157, 0x00000157, 0x00000159, 
-0x00000159, 0x0000015b, 0x0000015b, 0x0000015d, 0x0000015d, 
-0x0000015f, 0x0000015f, 0x00000161, 0x00000161, 0x00000163, 
-0x00000163, 0x00000165, 0x00000165, 0x00000167, 0x00000167, 
-0x00000169, 0x00000169, 0x0000016b, 0x0000016b, 0x0000016d, 
-0x0000016d, 0x0000016f, 0x0000016f, 0x00000171, 0x00000171, 
-0x00000173, 0x00000173, 0x00000175, 0x00000175, 0x00000177, 
-0x00000177, 0x0000017a, 0x0000017a, 0x0000017c, 0x0000017c, 
-0x0000017e, 0x00000180, 0x00000183, 0x00000183, 0x00000185, 
-0x00000185, 0x00000188, 0x00000188, 0x0000018c, 0x0000018d, 
-0x00000192, 0x00000192, 0x00000195, 0x00000195, 0x00000199, 
-0x0000019b, 0x0000019e, 0x0000019e, 0x000001a1, 0x000001a1, 
-0x000001a3, 0x000001a3, 0x000001a5, 0x000001a5, 0x000001a8, 
-0x000001a8, 0x000001aa, 0x000001ab, 0x000001ad, 0x000001ad, 
-0x000001b0, 0x000001b0, 0x000001b4, 0x000001b4, 0x000001b6, 
-0x000001b6, 0x000001b9, 0x000001ba, 0x000001bd, 0x000001bf, 
-0x000001c6, 0x000001c6, 0x000001c9, 0x000001c9, 0x000001cc, 
-0x000001cc, 0x000001ce, 0x000001ce, 0x000001d0, 0x000001d0, 
-0x000001d2, 0x000001d2, 0x000001d4, 0x000001d4, 0x000001d6, 
-0x000001d6, 0x000001d8, 0x000001d8, 0x000001da, 0x000001da, 
-0x000001dc, 0x000001dd, 0x000001df, 0x000001df, 0x000001e1, 
-0x000001e1, 0x000001e3, 0x000001e3, 0x000001e5, 0x000001e5, 
-0x000001e7, 0x000001e7, 0x000001e9, 0x000001e9, 0x000001eb, 
-0x000001eb, 0x000001ed, 0x000001ed, 0x000001ef, 0x000001f0, 
-0x000001f3, 0x000001f3, 0x000001f5, 0x000001f5, 0x000001f9, 
-0x000001f9, 0x000001fb, 0x000001fb, 0x000001fd, 0x000001fd, 
-0x000001ff, 0x000001ff, 0x00000201, 0x00000201, 0x00000203, 
-0x00000203, 0x00000205, 0x00000205, 0x00000207, 0x00000207, 
-0x00000209, 0x00000209, 0x0000020b, 0x0000020b, 0x0000020d, 
-0x0000020d, 0x0000020f, 0x0000020f, 0x00000211, 0x00000211, 
-0x00000213, 0x00000213, 0x00000215, 0x00000215, 0x00000217, 
-0x00000217, 0x00000219, 0x00000219, 0x0000021b, 0x0000021b, 
-0x0000021d, 0x0000021d, 0x0000021f, 0x0000021f, 0x00000223, 
-0x00000223, 0x00000225, 0x00000225, 0x00000227, 0x00000227, 
-0x00000229, 0x00000229, 0x0000022b, 0x0000022b, 0x0000022d, 
-0x0000022d, 0x0000022f, 0x0000022f, 0x00000231, 0x00000231, 
-0x00000233, 0x00000233, 0x00000250, 0x000002ad, 0x00000390, 
-0x00000390, 0x000003ac, 0x000003ce, 0x000003d0, 0x000003d1, 
-0x000003d5, 0x000003d7, 0x000003d9, 0x000003d9, 0x000003db, 
-0x000003db, 0x000003dd, 0x000003dd, 0x000003df, 0x000003df, 
-0x000003e1, 0x000003e1, 0x000003e3, 0x000003e3, 0x000003e5, 
-0x000003e5, 0x000003e7, 0x000003e7, 0x000003e9, 0x000003e9, 
-0x000003eb, 0x000003eb, 0x000003ed, 0x000003ed, 0x000003ef, 
-0x000003f3, 0x000003f5, 0x000003f5, 0x00000430, 0x0000045f, 
-0x00000461, 0x00000461, 0x00000463, 0x00000463, 0x00000465, 
-0x00000465, 0x00000467, 0x00000467, 0x00000469, 0x00000469, 
-0x0000046b, 0x0000046b, 0x0000046d, 0x0000046d, 0x0000046f, 
-0x0000046f, 0x00000471, 0x00000471, 0x00000473, 0x00000473, 
-0x00000475, 0x00000475, 0x00000477, 0x00000477, 0x00000479, 
-0x00000479, 0x0000047b, 0x0000047b, 0x0000047d, 0x0000047d, 
-0x0000047f, 0x0000047f, 0x00000481, 0x00000481, 0x0000048b, 
-0x0000048b, 0x0000048d, 0x0000048d, 0x0000048f, 0x0000048f, 
-0x00000491, 0x00000491, 0x00000493, 0x00000493, 0x00000495, 
-0x00000495, 0x00000497, 0x00000497, 0x00000499, 0x00000499, 
-0x0000049b, 0x0000049b, 0x0000049d, 0x0000049d, 0x0000049f, 
-0x0000049f, 0x000004a1, 0x000004a1, 0x000004a3, 0x000004a3, 
-0x000004a5, 0x000004a5, 0x000004a7, 0x000004a7, 0x000004a9, 
-0x000004a9, 0x000004ab, 0x000004ab, 0x000004ad, 0x000004ad, 
-0x000004af, 0x000004af, 0x000004b1, 0x000004b1, 0x000004b3, 
-0x000004b3, 0x000004b5, 0x000004b5, 0x000004b7, 0x000004b7, 
-0x000004b9, 0x000004b9, 0x000004bb, 0x000004bb, 0x000004bd, 
-0x000004bd, 0x000004bf, 0x000004bf, 0x000004c2, 0x000004c2, 
-0x000004c4, 0x000004c4, 0x000004c6, 0x000004c6, 0x000004c8, 
-0x000004c8, 0x000004ca, 0x000004ca, 0x000004cc, 0x000004cc, 
-0x000004ce, 0x000004ce, 0x000004d1, 0x000004d1, 0x000004d3, 
-0x000004d3, 0x000004d5, 0x000004d5, 0x000004d7, 0x000004d7, 
-0x000004d9, 0x000004d9, 0x000004db, 0x000004db, 0x000004dd, 
-0x000004dd, 0x000004df, 0x000004df, 0x000004e1, 0x000004e1, 
-0x000004e3, 0x000004e3, 0x000004e5, 0x000004e5, 0x000004e7, 
-0x000004e7, 0x000004e9, 0x000004e9, 0x000004eb, 0x000004eb, 
-0x000004ed, 0x000004ed, 0x000004ef, 0x000004ef, 0x000004f1, 
-0x000004f1, 0x000004f3, 0x000004f3, 0x000004f5, 0x000004f5, 
-0x000004f9, 0x000004f9, 0x00000501, 0x00000501, 0x00000503, 
-0x00000503, 0x00000505, 0x00000505, 0x00000507, 0x00000507, 
-0x00000509, 0x00000509, 0x0000050b, 0x0000050b, 0x0000050d, 
-0x0000050d, 0x0000050f, 0x0000050f, 0x00000561, 0x00000587, 
-0x00001e01, 0x00001e01, 0x00001e03, 0x00001e03, 0x00001e05, 
-0x00001e05, 0x00001e07, 0x00001e07, 0x00001e09, 0x00001e09, 
-0x00001e0b, 0x00001e0b, 0x00001e0d, 0x00001e0d, 0x00001e0f, 
-0x00001e0f, 0x00001e11, 0x00001e11, 0x00001e13, 0x00001e13, 
-0x00001e15, 0x00001e15, 0x00001e17, 0x00001e17, 0x00001e19, 
-0x00001e19, 0x00001e1b, 0x00001e1b, 0x00001e1d, 0x00001e1d, 
-0x00001e1f, 0x00001e1f, 0x00001e21, 0x00001e21, 0x00001e23, 
-0x00001e23, 0x00001e25, 0x00001e25, 0x00001e27, 0x00001e27, 
-0x00001e29, 0x00001e29, 0x00001e2b, 0x00001e2b, 0x00001e2d, 
-0x00001e2d, 0x00001e2f, 0x00001e2f, 0x00001e31, 0x00001e31, 
-0x00001e33, 0x00001e33, 0x00001e35, 0x00001e35, 0x00001e37, 
-0x00001e37, 0x00001e39, 0x00001e39, 0x00001e3b, 0x00001e3b, 
-0x00001e3d, 0x00001e3d, 0x00001e3f, 0x00001e3f, 0x00001e41, 
-0x00001e41, 0x00001e43, 0x00001e43, 0x00001e45, 0x00001e45, 
-0x00001e47, 0x00001e47, 0x00001e49, 0x00001e49, 0x00001e4b, 
-0x00001e4b, 0x00001e4d, 0x00001e4d, 0x00001e4f, 0x00001e4f, 
-0x00001e51, 0x00001e51, 0x00001e53, 0x00001e53, 0x00001e55, 
-0x00001e55, 0x00001e57, 0x00001e57, 0x00001e59, 0x00001e59, 
-0x00001e5b, 0x00001e5b, 0x00001e5d, 0x00001e5d, 0x00001e5f, 
-0x00001e5f, 0x00001e61, 0x00001e61, 0x00001e63, 0x00001e63, 
-0x00001e65, 0x00001e65, 0x00001e67, 0x00001e67, 0x00001e69, 
-0x00001e69, 0x00001e6b, 0x00001e6b, 0x00001e6d, 0x00001e6d, 
-0x00001e6f, 0x00001e6f, 0x00001e71, 0x00001e71, 0x00001e73, 
-0x00001e73, 0x00001e75, 0x00001e75, 0x00001e77, 0x00001e77, 
-0x00001e79, 0x00001e79, 0x00001e7b, 0x00001e7b, 0x00001e7d, 
-0x00001e7d, 0x00001e7f, 0x00001e7f, 0x00001e81, 0x00001e81, 
-0x00001e83, 0x00001e83, 0x00001e85, 0x00001e85, 0x00001e87, 
-0x00001e87, 0x00001e89, 0x00001e89, 0x00001e8b, 0x00001e8b, 
-0x00001e8d, 0x00001e8d, 0x00001e8f, 0x00001e8f, 0x00001e91, 
-0x00001e91, 0x00001e93, 0x00001e93, 0x00001e95, 0x00001e9b, 
-0x00001ea1, 0x00001ea1, 0x00001ea3, 0x00001ea3, 0x00001ea5, 
-0x00001ea5, 0x00001ea7, 0x00001ea7, 0x00001ea9, 0x00001ea9, 
-0x00001eab, 0x00001eab, 0x00001ead, 0x00001ead, 0x00001eaf, 
-0x00001eaf, 0x00001eb1, 0x00001eb1, 0x00001eb3, 0x00001eb3, 
-0x00001eb5, 0x00001eb5, 0x00001eb7, 0x00001eb7, 0x00001eb9, 
-0x00001eb9, 0x00001ebb, 0x00001ebb, 0x00001ebd, 0x00001ebd, 
-0x00001ebf, 0x00001ebf, 0x00001ec1, 0x00001ec1, 0x00001ec3, 
-0x00001ec3, 0x00001ec5, 0x00001ec5, 0x00001ec7, 0x00001ec7, 
-0x00001ec9, 0x00001ec9, 0x00001ecb, 0x00001ecb, 0x00001ecd, 
-0x00001ecd, 0x00001ecf, 0x00001ecf, 0x00001ed1, 0x00001ed1, 
-0x00001ed3, 0x00001ed3, 0x00001ed5, 0x00001ed5, 0x00001ed7, 
-0x00001ed7, 0x00001ed9, 0x00001ed9, 0x00001edb, 0x00001edb, 
-0x00001edd, 0x00001edd, 0x00001edf, 0x00001edf, 0x00001ee1, 
-0x00001ee1, 0x00001ee3, 0x00001ee3, 0x00001ee5, 0x00001ee5, 
-0x00001ee7, 0x00001ee7, 0x00001ee9, 0x00001ee9, 0x00001eeb, 
-0x00001eeb, 0x00001eed, 0x00001eed, 0x00001eef, 0x00001eef, 
-0x00001ef1, 0x00001ef1, 0x00001ef3, 0x00001ef3, 0x00001ef5, 
-0x00001ef5, 0x00001ef7, 0x00001ef7, 0x00001ef9, 0x00001ef9, 
-0x00001f00, 0x00001f07, 0x00001f10, 0x00001f15, 0x00001f20, 
-0x00001f27, 0x00001f30, 0x00001f37, 0x00001f40, 0x00001f45, 
-0x00001f50, 0x00001f57, 0x00001f60, 0x00001f67, 0x00001f70, 
-0x00001f7d, 0x00001f80, 0x00001f87, 0x00001f90, 0x00001f97, 
-0x00001fa0, 0x00001fa7, 0x00001fb0, 0x00001fb4, 0x00001fb6, 
-0x00001fb7, 0x00001fbe, 0x00001fbe, 0x00001fc2, 0x00001fc4, 
-0x00001fc6, 0x00001fc7, 0x00001fd0, 0x00001fd3, 0x00001fd6, 
-0x00001fd7, 0x00001fe0, 0x00001fe7, 0x00001ff2, 0x00001ff4, 
-0x00001ff6, 0x00001ff7, 0x00002071, 0x00002071, 0x0000207f, 
-0x0000207f, 0x0000210a, 0x0000210a, 0x0000210e, 0x0000210f, 
-0x00002113, 0x00002113, 0x0000212f, 0x0000212f, 0x00002134, 
-0x00002134, 0x00002139, 0x00002139, 0x0000213d, 0x0000213d, 
-0x00002146, 0x00002149, 0x0000fb00, 0x0000fb06, 0x0000fb13, 
-0x0000fb17, 0x0000ff41, 0x0000ff5a, 0x00010428, 0x0001044d, 
-0x0001d41a, 0x0001d433, 0x0001d44e, 0x0001d454, 0x0001d456, 
-0x0001d467, 0x0001d482, 0x0001d49b, 0x0001d4b6, 0x0001d4b9, 
-0x0001d4bb, 0x0001d4bb, 0x0001d4bd, 0x0001d4c0, 0x0001d4c2, 
-0x0001d4c3, 0x0001d4c5, 0x0001d4cf, 0x0001d4ea, 0x0001d503, 
-0x0001d51e, 0x0001d537, 0x0001d552, 0x0001d56b, 0x0001d586, 
-0x0001d59f, 0x0001d5ba, 0x0001d5d3, 0x0001d5ee, 0x0001d607, 
-0x0001d622, 0x0001d63b, 0x0001d656, 0x0001d66f, 0x0001d68a, 
-0x0001d6a3, 0x0001d6c2, 0x0001d6da, 0x0001d6dc, 0x0001d6e1, 
-0x0001d6fc, 0x0001d714, 0x0001d716, 0x0001d71b, 0x0001d736, 
-0x0001d74e, 0x0001d750, 0x0001d755, 0x0001d770, 0x0001d788, 
-0x0001d78a, 0x0001d78f, 0x0001d7aa, 0x0001d7c2, 0x0001d7c4, 
-0x0001d7c9, 
-0x000001c5, 0x000001c5, 0x000001c8, 0x000001c8, 
-0x000001cb, 0x000001cb, 0x000001f2, 0x000001f2, 0x00001f88, 
-0x00001f8f, 0x00001f98, 0x00001f9f, 0x00001fa8, 0x00001faf, 
-0x00001fbc, 0x00001fbc, 0x00001fcc, 0x00001fcc, 0x00001ffc, 
-0x00001ffc, 
-0x000002b0, 0x000002b8, 0x000002bb, 0x000002c1, 
-0x000002d0, 0x000002d1, 0x000002e0, 0x000002e4, 0x000002ee, 
-0x000002ee, 0x0000037a, 0x0000037a, 0x00000559, 0x00000559, 
-0x00000640, 0x00000640, 0x000006e5, 0x000006e6, 0x00000e46, 
-0x00000e46, 0x00000ec6, 0x00000ec6, 0x000017d7, 0x000017d7, 
-0x00001843, 0x00001843, 0x00003005, 0x00003005, 0x00003031, 
-0x00003035, 0x0000303b, 0x0000303b, 0x0000309d, 0x0000309e, 
-0x000030fc, 0x000030fe, 0x0000ff70, 0x0000ff70, 0x0000ff9e, 
-0x0000ff9f, 
-0x000001bb, 0x000001bb, 0x000001c0, 0x000001c3, 
-0x000005d0, 0x000005ea, 0x000005f0, 0x000005f2, 0x00000621, 
-0x0000063a, 0x00000641, 0x0000064a, 0x0000066e, 0x0000066f, 
-0x00000671, 0x000006d3, 0x000006d5, 0x000006d5, 0x000006fa, 
-0x000006fc, 0x00000710, 0x00000710, 0x00000712, 0x0000072c, 
-0x00000780, 0x000007a5, 0x000007b1, 0x000007b1, 0x00000905, 
-0x00000939, 0x0000093d, 0x0000093d, 0x00000950, 0x00000950, 
-0x00000958, 0x00000961, 0x00000985, 0x0000098c, 0x0000098f, 
-0x00000990, 0x00000993, 0x000009a8, 0x000009aa, 0x000009b0, 
-0x000009b2, 0x000009b2, 0x000009b6, 0x000009b9, 0x000009dc, 
-0x000009dd, 0x000009df, 0x000009e1, 0x000009f0, 0x000009f1, 
-0x00000a05, 0x00000a0a, 0x00000a0f, 0x00000a10, 0x00000a13, 
-0x00000a28, 0x00000a2a, 0x00000a30, 0x00000a32, 0x00000a33, 
-0x00000a35, 0x00000a36, 0x00000a38, 0x00000a39, 0x00000a59, 
-0x00000a5c, 0x00000a5e, 0x00000a5e, 0x00000a72, 0x00000a74, 
-0x00000a85, 0x00000a8b, 0x00000a8d, 0x00000a8d, 0x00000a8f, 
-0x00000a91, 0x00000a93, 0x00000aa8, 0x00000aaa, 0x00000ab0, 
-0x00000ab2, 0x00000ab3, 0x00000ab5, 0x00000ab9, 0x00000abd, 
-0x00000abd, 0x00000ad0, 0x00000ad0, 0x00000ae0, 0x00000ae0, 
-0x00000b05, 0x00000b0c, 0x00000b0f, 0x00000b10, 0x00000b13, 
-0x00000b28, 0x00000b2a, 0x00000b30, 0x00000b32, 0x00000b33, 
-0x00000b36, 0x00000b39, 0x00000b3d, 0x00000b3d, 0x00000b5c, 
-0x00000b5d, 0x00000b5f, 0x00000b61, 0x00000b83, 0x00000b83, 
-0x00000b85, 0x00000b8a, 0x00000b8e, 0x00000b90, 0x00000b92, 
-0x00000b95, 0x00000b99, 0x00000b9a, 0x00000b9c, 0x00000b9c, 
-0x00000b9e, 0x00000b9f, 0x00000ba3, 0x00000ba4, 0x00000ba8, 
-0x00000baa, 0x00000bae, 0x00000bb5, 0x00000bb7, 0x00000bb9, 
-0x00000c05, 0x00000c0c, 0x00000c0e, 0x00000c10, 0x00000c12, 
-0x00000c28, 0x00000c2a, 0x00000c33, 0x00000c35, 0x00000c39, 
-0x00000c60, 0x00000c61, 0x00000c85, 0x00000c8c, 0x00000c8e, 
-0x00000c90, 0x00000c92, 0x00000ca8, 0x00000caa, 0x00000cb3, 
-0x00000cb5, 0x00000cb9, 0x00000cde, 0x00000cde, 0x00000ce0, 
-0x00000ce1, 0x00000d05, 0x00000d0c, 0x00000d0e, 0x00000d10, 
-0x00000d12, 0x00000d28, 0x00000d2a, 0x00000d39, 0x00000d60, 
-0x00000d61, 0x00000d85, 0x00000d96, 0x00000d9a, 0x00000db1, 
-0x00000db3, 0x00000dbb, 0x00000dbd, 0x00000dbd, 0x00000dc0, 
-0x00000dc6, 0x00000e01, 0x00000e30, 0x00000e32, 0x00000e33, 
-0x00000e40, 0x00000e45, 0x00000e81, 0x00000e82, 0x00000e84, 
-0x00000e84, 0x00000e87, 0x00000e88, 0x00000e8a, 0x00000e8a, 
-0x00000e8d, 0x00000e8d, 0x00000e94, 0x00000e97, 0x00000e99, 
-0x00000e9f, 0x00000ea1, 0x00000ea3, 0x00000ea5, 0x00000ea5, 
-0x00000ea7, 0x00000ea7, 0x00000eaa, 0x00000eab, 0x00000ead, 
-0x00000eb0, 0x00000eb2, 0x00000eb3, 0x00000ebd, 0x00000ebd, 
-0x00000ec0, 0x00000ec4, 0x00000edc, 0x00000edd, 0x00000f00, 
-0x00000f00, 0x00000f40, 0x00000f47, 0x00000f49, 0x00000f6a, 
-0x00000f88, 0x00000f8b, 0x00001000, 0x00001021, 0x00001023, 
-0x00001027, 0x00001029, 0x0000102a, 0x00001050, 0x00001055, 
-0x000010d0, 0x000010f8, 0x00001100, 0x00001159, 0x0000115f, 
-0x000011a2, 0x000011a8, 0x000011f9, 0x00001200, 0x00001206, 
-0x00001208, 0x00001246, 0x00001248, 0x00001248, 0x0000124a, 
-0x0000124d, 0x00001250, 0x00001256, 0x00001258, 0x00001258, 
-0x0000125a, 0x0000125d, 0x00001260, 0x00001286, 0x00001288, 
-0x00001288, 0x0000128a, 0x0000128d, 0x00001290, 0x000012ae, 
-0x000012b0, 0x000012b0, 0x000012b2, 0x000012b5, 0x000012b8, 
-0x000012be, 0x000012c0, 0x000012c0, 0x000012c2, 0x000012c5, 
-0x000012c8, 0x000012ce, 0x000012d0, 0x000012d6, 0x000012d8, 
-0x000012ee, 0x000012f0, 0x0000130e, 0x00001310, 0x00001310, 
-0x00001312, 0x00001315, 0x00001318, 0x0000131e, 0x00001320, 
-0x00001346, 0x00001348, 0x0000135a, 0x000013a0, 0x000013f4, 
-0x00001401, 0x0000166c, 0x0000166f, 0x00001676, 0x00001681, 
-0x0000169a, 0x000016a0, 0x000016ea, 0x00001700, 0x0000170c, 
-0x0000170e, 0x00001711, 0x00001720, 0x00001731, 0x00001740, 
-0x00001751, 0x00001760, 0x0000176c, 0x0000176e, 0x00001770, 
-0x00001780, 0x000017b3, 0x000017dc, 0x000017dc, 0x00001820, 
-0x00001842, 0x00001844, 0x00001877, 0x00001880, 0x000018a8, 
-0x00002135, 0x00002138, 0x00003006, 0x00003006, 0x0000303c, 
-0x0000303c, 0x00003041, 0x00003096, 0x0000309f, 0x0000309f, 
-0x000030a1, 0x000030fa, 0x000030ff, 0x000030ff, 0x00003105, 
-0x0000312c, 0x00003131, 0x0000318e, 0x000031a0, 0x000031b7, 
-0x000031f0, 0x000031ff, 0x00003400, 0x00003400, 0x00004db5, 
-0x00004db5, 0x00004e00, 0x0000a48c, 0x0000ac00, 0x0000d7a3, 
-0x0000f900, 0x0000faff, 0x0000fb1d, 0x0000fb1d, 0x0000fb1f, 
-0x0000fb28, 0x0000fb2a, 0x0000fb36, 0x0000fb38, 0x0000fb3c, 
-0x0000fb3e, 0x0000fb3e, 0x0000fb40, 0x0000fb41, 0x0000fb43, 
-0x0000fb44, 0x0000fb46, 0x0000fbb1, 0x0000fbd3, 0x0000fd3d, 
-0x0000fd50, 0x0000fd8f, 0x0000fd92, 0x0000fdc7, 0x0000fdf0, 
-0x0000fdfb, 0x0000fe70, 0x0000fe74, 0x0000fe76, 0x0000fefc, 
-0x0000ff66, 0x0000ff6f, 0x0000ff71, 0x0000ff9d, 0x0000ffa0, 
-0x0000ffbe, 0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf, 
-0x0000ffd2, 0x0000ffd7, 0x0000ffda, 0x0000ffdc, 0x00010300, 
-0x0001031e, 0x00010330, 0x00010349, 0x00020000, 0x00020000, 
-0x0002a6d6, 0x0002a6d6, 0x0002f800, 0x0002fa1d, 
-0x0000005f, 0x0000005f, 0x0000203f, 0x00002040, 
-0x000030fb, 0x000030fb, 0x0000fe33, 0x0000fe34, 0x0000fe4d, 
-0x0000fe4f, 0x0000ff3f, 0x0000ff3f, 0x0000ff65, 0x0000ff65, 
-0x0000002d, 0x0000002d, 0x000000ad, 0x000000ad, 
-0x0000058a, 0x0000058a, 0x00001806, 0x00001806, 0x00002010, 
-0x00002015, 0x0000301c, 0x0000301c, 0x00003030, 0x00003030, 
-0x000030a0, 0x000030a0, 0x0000fe31, 0x0000fe32, 0x0000fe58, 
-0x0000fe58, 0x0000fe63, 0x0000fe63, 0x0000ff0d, 0x0000ff0d, 
-0x00000028, 0x00000028, 0x0000005b, 0x0000005b, 
-0x0000007b, 0x0000007b, 0x00000f3a, 0x00000f3a, 0x00000f3c, 
-0x00000f3c, 0x0000169b, 0x0000169b, 0x0000201a, 0x0000201a, 
-0x0000201e, 0x0000201e, 0x00002045, 0x00002045, 0x0000207d, 
-0x0000207d, 0x0000208d, 0x0000208d, 0x00002329, 0x00002329, 
-0x000023b4, 0x000023b4, 0x00002768, 0x00002768, 0x0000276a, 
-0x0000276a, 0x0000276c, 0x0000276c, 0x0000276e, 0x0000276e, 
-0x00002770, 0x00002770, 0x00002772, 0x00002772, 0x00002774, 
-0x00002774, 0x000027e6, 0x000027e6, 0x000027e8, 0x000027e8, 
-0x000027ea, 0x000027ea, 0x00002983, 0x00002983, 0x00002985, 
-0x00002985, 0x00002987, 0x00002987, 0x00002989, 0x00002989, 
-0x0000298b, 0x0000298b, 0x0000298d, 0x0000298d, 0x0000298f, 
-0x0000298f, 0x00002991, 0x00002991, 0x00002993, 0x00002993, 
-0x00002995, 0x00002995, 0x00002997, 0x00002997, 0x000029d8, 
-0x000029d8, 0x000029da, 0x000029da, 0x000029fc, 0x000029fc, 
-0x00003008, 0x00003008, 0x0000300a, 0x0000300a, 0x0000300c, 
-0x0000300c, 0x0000300e, 0x0000300e, 0x00003010, 0x00003010, 
-0x00003014, 0x00003014, 0x00003016, 0x00003016, 0x00003018, 
-0x00003018, 0x0000301a, 0x0000301a, 0x0000301d, 0x0000301d, 
-0x0000fd3e, 0x0000fd3e, 0x0000fe35, 0x0000fe35, 0x0000fe37, 
-0x0000fe37, 0x0000fe39, 0x0000fe39, 0x0000fe3b, 0x0000fe3b, 
-0x0000fe3d, 0x0000fe3d, 0x0000fe3f, 0x0000fe3f, 0x0000fe41, 
-0x0000fe41, 0x0000fe43, 0x0000fe43, 0x0000fe59, 0x0000fe59, 
-0x0000fe5b, 0x0000fe5b, 0x0000fe5d, 0x0000fe5d, 0x0000ff08, 
-0x0000ff08, 0x0000ff3b, 0x0000ff3b, 0x0000ff5b, 0x0000ff5b, 
-0x0000ff5f, 0x0000ff5f, 0x0000ff62, 0x0000ff62, 
-0x00000029, 0x00000029, 0x0000005d, 0x0000005d, 
-0x0000007d, 0x0000007d, 0x00000f3b, 0x00000f3b, 0x00000f3d, 
-0x00000f3d, 0x0000169c, 0x0000169c, 0x00002046, 0x00002046, 
-0x0000207e, 0x0000207e, 0x0000208e, 0x0000208e, 0x0000232a, 
-0x0000232a, 0x000023b5, 0x000023b5, 0x00002769, 0x00002769, 
-0x0000276b, 0x0000276b, 0x0000276d, 0x0000276d, 0x0000276f, 
-0x0000276f, 0x00002771, 0x00002771, 0x00002773, 0x00002773, 
-0x00002775, 0x00002775, 0x000027e7, 0x000027e7, 0x000027e9, 
-0x000027e9, 0x000027eb, 0x000027eb, 0x00002984, 0x00002984, 
-0x00002986, 0x00002986, 0x00002988, 0x00002988, 0x0000298a, 
-0x0000298a, 0x0000298c, 0x0000298c, 0x0000298e, 0x0000298e, 
-0x00002990, 0x00002990, 0x00002992, 0x00002992, 0x00002994, 
-0x00002994, 0x00002996, 0x00002996, 0x00002998, 0x00002998, 
-0x000029d9, 0x000029d9, 0x000029db, 0x000029db, 0x000029fd, 
-0x000029fd, 0x00003009, 0x00003009, 0x0000300b, 0x0000300b, 
-0x0000300d, 0x0000300d, 0x0000300f, 0x0000300f, 0x00003011, 
-0x00003011, 0x00003015, 0x00003015, 0x00003017, 0x00003017, 
-0x00003019, 0x00003019, 0x0000301b, 0x0000301b, 0x0000301e, 
-0x0000301f, 0x0000fd3f, 0x0000fd3f, 0x0000fe36, 0x0000fe36, 
-0x0000fe38, 0x0000fe38, 0x0000fe3a, 0x0000fe3a, 0x0000fe3c, 
-0x0000fe3c, 0x0000fe3e, 0x0000fe3e, 0x0000fe40, 0x0000fe40, 
-0x0000fe42, 0x0000fe42, 0x0000fe44, 0x0000fe44, 0x0000fe5a, 
-0x0000fe5a, 0x0000fe5c, 0x0000fe5c, 0x0000fe5e, 0x0000fe5e, 
-0x0000ff09, 0x0000ff09, 0x0000ff3d, 0x0000ff3d, 0x0000ff5d, 
-0x0000ff5d, 0x0000ff60, 0x0000ff60, 0x0000ff63, 0x0000ff63, 
-0x00000021, 0x00000023, 0x00000025, 0x00000027, 
-0x0000002a, 0x0000002a, 0x0000002c, 0x0000002c, 0x0000002e, 
-0x0000002f, 0x0000003a, 0x0000003b, 0x0000003f, 0x00000040, 
-0x0000005c, 0x0000005c, 0x000000a1, 0x000000a1, 0x000000b7, 
-0x000000b7, 0x000000bf, 0x000000bf, 0x0000037e, 0x0000037e, 
-0x00000387, 0x00000387, 0x0000055a, 0x0000055f, 0x00000589, 
-0x00000589, 0x000005be, 0x000005be, 0x000005c0, 0x000005c0, 
-0x000005c3, 0x000005c3, 0x000005f3, 0x000005f4, 0x0000060c, 
-0x0000060c, 0x0000061b, 0x0000061b, 0x0000061f, 0x0000061f, 
-0x0000066a, 0x0000066d, 0x000006d4, 0x000006d4, 0x00000700, 
-0x0000070d, 0x00000964, 0x00000965, 0x00000970, 0x00000970, 
-0x00000df4, 0x00000df4, 0x00000e4f, 0x00000e4f, 0x00000e5a, 
-0x00000e5b, 0x00000f04, 0x00000f12, 0x00000f85, 0x00000f85, 
-0x0000104a, 0x0000104f, 0x000010fb, 0x000010fb, 0x00001361, 
-0x00001368, 0x0000166d, 0x0000166e, 0x000016eb, 0x000016ed, 
-0x00001735, 0x00001736, 0x000017d4, 0x000017d6, 0x000017d8, 
-0x000017da, 0x00001800, 0x00001805, 0x00001807, 0x0000180a, 
-0x00002016, 0x00002017, 0x00002020, 0x00002027, 0x00002030, 
-0x00002038, 0x0000203b, 0x0000203e, 0x00002041, 0x00002043, 
-0x00002047, 0x00002051, 0x00002057, 0x00002057, 0x000023b6, 
-0x000023b6, 0x00003001, 0x00003003, 0x0000303d, 0x0000303d, 
-0x0000fe30, 0x0000fe30, 0x0000fe45, 0x0000fe46, 0x0000fe49, 
-0x0000fe4c, 0x0000fe50, 0x0000fe52, 0x0000fe54, 0x0000fe57, 
-0x0000fe5f, 0x0000fe61, 0x0000fe68, 0x0000fe68, 0x0000fe6a, 
-0x0000fe6b, 0x0000ff01, 0x0000ff03, 0x0000ff05, 0x0000ff07, 
-0x0000ff0a, 0x0000ff0a, 0x0000ff0c, 0x0000ff0c, 0x0000ff0e, 
-0x0000ff0f, 0x0000ff1a, 0x0000ff1b, 0x0000ff1f, 0x0000ff20, 
-0x0000ff3c, 0x0000ff3c, 0x0000ff61, 0x0000ff61, 0x0000ff64, 
-0x0000ff64, 
-0x0000002b, 0x0000002b, 0x0000003c, 0x0000003e, 
-0x0000007c, 0x0000007c, 0x0000007e, 0x0000007e, 0x000000ac, 
-0x000000ac, 0x000000b1, 0x000000b1, 0x000000d7, 0x000000d7, 
-0x000000f7, 0x000000f7, 0x000003f6, 0x000003f6, 0x00002044, 
-0x00002044, 0x00002052, 0x00002052, 0x0000207a, 0x0000207c, 
-0x0000208a, 0x0000208c, 0x00002140, 0x00002144, 0x0000214b, 
-0x0000214b, 0x00002190, 0x00002194, 0x0000219a, 0x0000219b, 
-0x000021a0, 0x000021a0, 0x000021a3, 0x000021a3, 0x000021a6, 
-0x000021a6, 0x000021ae, 0x000021ae, 0x000021ce, 0x000021cf, 
-0x000021d2, 0x000021d2, 0x000021d4, 0x000021d4, 0x000021f4, 
-0x000022ff, 0x00002308, 0x0000230b, 0x00002320, 0x00002321, 
-0x0000237c, 0x0000237c, 0x0000239b, 0x000023b3, 0x000025b7, 
-0x000025b7, 0x000025c1, 0x000025c1, 0x000025f8, 0x000025ff, 
-0x0000266f, 0x0000266f, 0x000027d0, 0x000027e5, 0x000027f0, 
-0x000027ff, 0x00002900, 0x00002982, 0x00002999, 0x000029d7, 
-0x000029dc, 0x000029fb, 0x000029fe, 0x00002aff, 0x0000fb29, 
-0x0000fb29, 0x0000fe62, 0x0000fe62, 0x0000fe64, 0x0000fe66, 
-0x0000ff0b, 0x0000ff0b, 0x0000ff1c, 0x0000ff1e, 0x0000ff5c, 
-0x0000ff5c, 0x0000ff5e, 0x0000ff5e, 0x0000ffe2, 0x0000ffe2, 
-0x0000ffe9, 0x0000ffec, 0x0001d6c1, 0x0001d6c1, 0x0001d6db, 
-0x0001d6db, 0x0001d6fb, 0x0001d6fb, 0x0001d715, 0x0001d715, 
-0x0001d735, 0x0001d735, 0x0001d74f, 0x0001d74f, 0x0001d76f, 
-0x0001d76f, 0x0001d789, 0x0001d789, 0x0001d7a9, 0x0001d7a9, 
-0x0001d7c3, 0x0001d7c3, 
-0x00000024, 0x00000024, 0x000000a2, 0x000000a5, 
-0x000009f2, 0x000009f3, 0x00000e3f, 0x00000e3f, 0x000017db, 
-0x000017db, 0x000020a0, 0x000020b1, 0x0000fdfc, 0x0000fdfc, 
-0x0000fe69, 0x0000fe69, 0x0000ff04, 0x0000ff04, 0x0000ffe0, 
-0x0000ffe1, 0x0000ffe5, 0x0000ffe6, 
-0x0000005e, 0x0000005e, 0x00000060, 0x00000060, 
-0x000000a8, 0x000000a8, 0x000000af, 0x000000af, 0x000000b4, 
-0x000000b4, 0x000000b8, 0x000000b8, 0x000002b9, 0x000002ba, 
-0x000002c2, 0x000002cf, 0x000002d2, 0x000002df, 0x000002e5, 
-0x000002ed, 0x00000374, 0x00000375, 0x00000384, 0x00000385, 
-0x00001fbd, 0x00001fbd, 0x00001fbf, 0x00001fc1, 0x00001fcd, 
-0x00001fcf, 0x00001fdd, 0x00001fdf, 0x00001fed, 0x00001fef, 
-0x00001ffd, 0x00001ffe, 0x0000309b, 0x0000309c, 0x0000ff3e, 
-0x0000ff3e, 0x0000ff40, 0x0000ff40, 0x0000ffe3, 0x0000ffe3, 
-0x000000a6, 0x000000a7, 0x000000a9, 0x000000a9, 
-0x000000ae, 0x000000ae, 0x000000b0, 0x000000b0, 0x000000b6, 
-0x000000b6, 0x00000482, 0x00000482, 0x000006e9, 0x000006e9, 
-0x000006fd, 0x000006fe, 0x000009fa, 0x000009fa, 0x00000b70, 
-0x00000b70, 0x00000f01, 0x00000f03, 0x00000f13, 0x00000f17, 
-0x00000f1a, 0x00000f1f, 0x00000f34, 0x00000f34, 0x00000f36, 
-0x00000f36, 0x00000f38, 0x00000f38, 0x00000fbe, 0x00000fc5, 
-0x00000fc7, 0x00000fcc, 0x00000fcf, 0x00000fcf, 0x00002100, 
-0x00002101, 0x00002103, 0x00002106, 0x00002108, 0x00002109, 
-0x00002114, 0x00002114, 0x00002116, 0x00002118, 0x0000211e, 
-0x00002123, 0x00002125, 0x00002125, 0x00002127, 0x00002127, 
-0x00002129, 0x00002129, 0x0000212e, 0x0000212e, 0x00002132, 
-0x00002132, 0x0000213a, 0x0000213a, 0x0000214a, 0x0000214a, 
-0x00002195, 0x00002199, 0x0000219c, 0x0000219f, 0x000021a1, 
-0x000021a2, 0x000021a4, 0x000021a5, 0x000021a7, 0x000021ad, 
-0x000021af, 0x000021cd, 0x000021d0, 0x000021d1, 0x000021d3, 
-0x000021d3, 0x000021d5, 0x000021f3, 0x00002300, 0x00002307, 
-0x0000230c, 0x0000231f, 0x00002322, 0x00002328, 0x0000232b, 
-0x0000237b, 0x0000237d, 0x0000239a, 0x000023b7, 0x000023ce, 
-0x00002400, 0x00002426, 0x00002440, 0x0000244a, 0x0000249c, 
-0x000024e9, 0x00002500, 0x000025b6, 0x000025b8, 0x000025c0, 
-0x000025c2, 0x000025f7, 0x00002600, 0x00002613, 0x00002616, 
-0x00002617, 0x00002619, 0x0000266e, 0x00002670, 0x0000267d, 
-0x00002680, 0x00002689, 0x00002701, 0x00002704, 0x00002706, 
-0x00002709, 0x0000270c, 0x00002727, 0x00002729, 0x0000274b, 
-0x0000274d, 0x0000274d, 0x0000274f, 0x00002752, 0x00002756, 
-0x00002756, 0x00002758, 0x0000275e, 0x00002761, 0x00002767, 
-0x00002794, 0x00002794, 0x00002798, 0x000027af, 0x000027b1, 
-0x000027be, 0x00002800, 0x000028ff, 0x00002e80, 0x00002e99, 
-0x00002e9b, 0x00002ef3, 0x00002f00, 0x00002fd5, 0x00002ff0, 
-0x00002ffb, 0x00003004, 0x00003004, 0x00003012, 0x00003013, 
-0x00003020, 0x00003020, 0x00003036, 0x00003037, 0x0000303e, 
-0x0000303f, 0x00003190, 0x00003191, 0x00003196, 0x0000319f, 
-0x00003200, 0x0000321c, 0x0000322a, 0x00003243, 0x00003260, 
-0x0000327b, 0x0000327f, 0x0000327f, 0x0000328a, 0x000032b0, 
-0x000032c0, 0x000032cb, 0x000032d0, 0x000032fe, 0x00003300, 
-0x00003376, 0x0000337b, 0x000033dd, 0x000033e0, 0x000033fe, 
-0x0000a490, 0x0000a4c6, 0x0000ffe4, 0x0000ffe4, 0x0000ffe8, 
-0x0000ffe8, 0x0000ffed, 0x0000ffee, 0x0000fffc, 0x0000fffd, 
-0x0001d000, 0x0001d0f5, 0x0001d100, 0x0001d126, 0x0001d12a, 
-0x0001d164, 0x0001d16a, 0x0001d16c, 0x0001d183, 0x0001d184, 
-0x0001d18c, 0x0001d1a9, 0x0001d1ae, 0x0001d1dd, 
-0x00000041, 0x0000005a, 0x00000061, 0x0000007a, 
-0x000000aa, 0x000000aa, 0x000000b5, 0x000000b5, 0x000000ba, 
-0x000000ba, 0x000000c0, 0x000000d6, 0x000000d8, 0x000000f6, 
-0x000000f8, 0x00000220, 0x00000222, 0x00000233, 0x00000250, 
-0x000002ad, 0x000002b0, 0x000002b8, 0x000002bb, 0x000002c1, 
-0x000002d0, 0x000002d1, 0x000002e0, 0x000002e4, 0x000002ee, 
-0x000002ee, 0x0000037a, 0x0000037a, 0x00000386, 0x00000386, 
-0x00000388, 0x0000038a, 0x0000038c, 0x0000038c, 0x0000038e, 
-0x000003a1, 0x000003a3, 0x000003ce, 0x000003d0, 0x000003f5, 
-0x00000400, 0x00000482, 0x0000048a, 0x000004ce, 0x000004d0, 
-0x000004f5, 0x000004f8, 0x000004f9, 0x00000500, 0x0000050f, 
-0x00000531, 0x00000556, 0x00000559, 0x0000055f, 0x00000561, 
-0x00000587, 0x00000589, 0x00000589, 0x00000903, 0x00000903, 
-0x00000905, 0x00000939, 0x0000093d, 0x00000940, 0x00000949, 
-0x0000094c, 0x00000950, 0x00000950, 0x00000958, 0x00000961, 
-0x00000964, 0x00000970, 0x00000982, 0x00000983, 0x00000985, 
-0x0000098c, 0x0000098f, 0x00000990, 0x00000993, 0x000009a8, 
-0x000009aa, 0x000009b0, 0x000009b2, 0x000009b2, 0x000009b6, 
-0x000009b9, 0x000009be, 0x000009c0, 0x000009c7, 0x000009c8, 
-0x000009cb, 0x000009cc, 0x000009d7, 0x000009d7, 0x000009dc, 
-0x000009dd, 0x000009df, 0x000009e1, 0x000009e6, 0x000009f1, 
-0x000009f4, 0x000009fa, 0x00000a05, 0x00000a0a, 0x00000a0f, 
-0x00000a10, 0x00000a13, 0x00000a28, 0x00000a2a, 0x00000a30, 
-0x00000a32, 0x00000a33, 0x00000a35, 0x00000a36, 0x00000a38, 
-0x00000a39, 0x00000a3e, 0x00000a40, 0x00000a59, 0x00000a5c, 
-0x00000a5e, 0x00000a5e, 0x00000a66, 0x00000a6f, 0x00000a72, 
-0x00000a74, 0x00000a83, 0x00000a83, 0x00000a85, 0x00000a8b, 
-0x00000a8d, 0x00000a8d, 0x00000a8f, 0x00000a91, 0x00000a93, 
-0x00000aa8, 0x00000aaa, 0x00000ab0, 0x00000ab2, 0x00000ab3, 
-0x00000ab5, 0x00000ab9, 0x00000abd, 0x00000ac0, 0x00000ac9, 
-0x00000ac9, 0x00000acb, 0x00000acc, 0x00000ad0, 0x00000ad0, 
-0x00000ae0, 0x00000ae0, 0x00000ae6, 0x00000aef, 0x00000b02, 
-0x00000b03, 0x00000b05, 0x00000b0c, 0x00000b0f, 0x00000b10, 
-0x00000b13, 0x00000b28, 0x00000b2a, 0x00000b30, 0x00000b32, 
-0x00000b33, 0x00000b36, 0x00000b39, 0x00000b3d, 0x00000b3e, 
-0x00000b40, 0x00000b40, 0x00000b47, 0x00000b48, 0x00000b4b, 
-0x00000b4c, 0x00000b57, 0x00000b57, 0x00000b5c, 0x00000b5d, 
-0x00000b5f, 0x00000b61, 0x00000b66, 0x00000b70, 0x00000b83, 
-0x00000b83, 0x00000b85, 0x00000b8a, 0x00000b8e, 0x00000b90, 
-0x00000b92, 0x00000b95, 0x00000b99, 0x00000b9a, 0x00000b9c, 
-0x00000b9c, 0x00000b9e, 0x00000b9f, 0x00000ba3, 0x00000ba4, 
-0x00000ba8, 0x00000baa, 0x00000bae, 0x00000bb5, 0x00000bb7, 
-0x00000bb9, 0x00000bbe, 0x00000bbf, 0x00000bc1, 0x00000bc2, 
-0x00000bc6, 0x00000bc8, 0x00000bca, 0x00000bcc, 0x00000bd7, 
-0x00000bd7, 0x00000be7, 0x00000bf2, 0x00000c01, 0x00000c03, 
-0x00000c05, 0x00000c0c, 0x00000c0e, 0x00000c10, 0x00000c12, 
-0x00000c28, 0x00000c2a, 0x00000c33, 0x00000c35, 0x00000c39, 
-0x00000c41, 0x00000c44, 0x00000c60, 0x00000c61, 0x00000c66, 
-0x00000c6f, 0x00000c82, 0x00000c83, 0x00000c85, 0x00000c8c, 
-0x00000c8e, 0x00000c90, 0x00000c92, 0x00000ca8, 0x00000caa, 
-0x00000cb3, 0x00000cb5, 0x00000cb9, 0x00000cbe, 0x00000cbe, 
-0x00000cc0, 0x00000cc4, 0x00000cc7, 0x00000cc8, 0x00000cca, 
-0x00000ccb, 0x00000cd5, 0x00000cd6, 0x00000cde, 0x00000cde, 
-0x00000ce0, 0x00000ce1, 0x00000ce6, 0x00000cef, 0x00000d02, 
-0x00000d03, 0x00000d05, 0x00000d0c, 0x00000d0e, 0x00000d10, 
-0x00000d12, 0x00000d28, 0x00000d2a, 0x00000d39, 0x00000d3e, 
-0x00000d40, 0x00000d46, 0x00000d48, 0x00000d4a, 0x00000d4c, 
-0x00000d57, 0x00000d57, 0x00000d60, 0x00000d61, 0x00000d66, 
-0x00000d6f, 0x00000d82, 0x00000d83, 0x00000d85, 0x00000d96, 
-0x00000d9a, 0x00000db1, 0x00000db3, 0x00000dbb, 0x00000dbd, 
-0x00000dbd, 0x00000dc0, 0x00000dc6, 0x00000dcf, 0x00000dd1, 
-0x00000dd8, 0x00000ddf, 0x00000df2, 0x00000df4, 0x00000e01, 
-0x00000e30, 0x00000e32, 0x00000e33, 0x00000e40, 0x00000e46, 
-0x00000e4f, 0x00000e5b, 0x00000e81, 0x00000e82, 0x00000e84, 
-0x00000e84, 0x00000e87, 0x00000e88, 0x00000e8a, 0x00000e8a, 
-0x00000e8d, 0x00000e8d, 0x00000e94, 0x00000e97, 0x00000e99, 
-0x00000e9f, 0x00000ea1, 0x00000ea3, 0x00000ea5, 0x00000ea5, 
-0x00000ea7, 0x00000ea7, 0x00000eaa, 0x00000eab, 0x00000ead, 
-0x00000eb0, 0x00000eb2, 0x00000eb3, 0x00000ebd, 0x00000ebd, 
-0x00000ec0, 0x00000ec4, 0x00000ec6, 0x00000ec6, 0x00000ed0, 
-0x00000ed9, 0x00000edc, 0x00000edd, 0x00000f00, 0x00000f17, 
-0x00000f1a, 0x00000f34, 0x00000f36, 0x00000f36, 0x00000f38, 
-0x00000f38, 0x00000f3e, 0x00000f47, 0x00000f49, 0x00000f6a, 
-0x00000f7f, 0x00000f7f, 0x00000f85, 0x00000f85, 0x00000f88, 
-0x00000f8b, 0x00000fbe, 0x00000fc5, 0x00000fc7, 0x00000fcc, 
-0x00000fcf, 0x00000fcf, 0x00001000, 0x00001021, 0x00001023, 
-0x00001027, 0x00001029, 0x0000102a, 0x0000102c, 0x0000102c, 
-0x00001031, 0x00001031, 0x00001038, 0x00001038, 0x00001040, 
-0x00001057, 0x000010a0, 0x000010c5, 0x000010d0, 0x000010f8, 
-0x000010fb, 0x000010fb, 0x00001100, 0x00001159, 0x0000115f, 
-0x000011a2, 0x000011a8, 0x000011f9, 0x00001200, 0x00001206, 
-0x00001208, 0x00001246, 0x00001248, 0x00001248, 0x0000124a, 
-0x0000124d, 0x00001250, 0x00001256, 0x00001258, 0x00001258, 
-0x0000125a, 0x0000125d, 0x00001260, 0x00001286, 0x00001288, 
-0x00001288, 0x0000128a, 0x0000128d, 0x00001290, 0x000012ae, 
-0x000012b0, 0x000012b0, 0x000012b2, 0x000012b5, 0x000012b8, 
-0x000012be, 0x000012c0, 0x000012c0, 0x000012c2, 0x000012c5, 
-0x000012c8, 0x000012ce, 0x000012d0, 0x000012d6, 0x000012d8, 
-0x000012ee, 0x000012f0, 0x0000130e, 0x00001310, 0x00001310, 
-0x00001312, 0x00001315, 0x00001318, 0x0000131e, 0x00001320, 
-0x00001346, 0x00001348, 0x0000135a, 0x00001361, 0x0000137c, 
-0x000013a0, 0x000013f4, 0x00001401, 0x00001676, 0x00001681, 
-0x0000169a, 0x000016a0, 0x000016f0, 0x00001700, 0x0000170c, 
-0x0000170e, 0x00001711, 0x00001720, 0x00001731, 0x00001735, 
-0x00001736, 0x00001740, 0x00001751, 0x00001760, 0x0000176c, 
-0x0000176e, 0x00001770, 0x00001780, 0x000017b6, 0x000017be, 
-0x000017c5, 0x000017c7, 0x000017c8, 0x000017d4, 0x000017da, 
-0x000017dc, 0x000017dc, 0x000017e0, 0x000017e9, 0x00001810, 
-0x00001819, 0x00001820, 0x00001877, 0x00001880, 0x000018a8, 
-0x00001e00, 0x00001e9b, 0x00001ea0, 0x00001ef9, 0x00001f00, 
-0x00001f15, 0x00001f18, 0x00001f1d, 0x00001f20, 0x00001f45, 
-0x00001f48, 0x00001f4d, 0x00001f50, 0x00001f57, 0x00001f59, 
-0x00001f59, 0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d, 
-0x00001f5f, 0x00001f7d, 0x00001f80, 0x00001fb4, 0x00001fb6, 
-0x00001fbc, 0x00001fbe, 0x00001fbe, 0x00001fc2, 0x00001fc4, 
-0x00001fc6, 0x00001fcc, 0x00001fd0, 0x00001fd3, 0x00001fd6, 
-0x00001fdb, 0x00001fe0, 0x00001fec, 0x00001ff2, 0x00001ff4, 
-0x00001ff6, 0x00001ffc, 0x0000200e, 0x0000200e, 0x00002071, 
-0x00002071, 0x0000207f, 0x0000207f, 0x00002102, 0x00002102, 
-0x00002107, 0x00002107, 0x0000210a, 0x00002113, 0x00002115, 
-0x00002115, 0x00002119, 0x0000211d, 0x00002124, 0x00002124, 
-0x00002126, 0x00002126, 0x00002128, 0x00002128, 0x0000212a, 
-0x0000212d, 0x0000212f, 0x00002131, 0x00002133, 0x00002139, 
-0x0000213d, 0x0000213f, 0x00002145, 0x00002149, 0x00002160, 
-0x00002183, 0x00002336, 0x0000237a, 0x00002395, 0x00002395, 
-0x0000249c, 0x000024e9, 0x00003005, 0x00003007, 0x00003021, 
-0x00003029, 0x00003031, 0x00003035, 0x00003038, 0x0000303c, 
-0x00003041, 0x00003096, 0x0000309d, 0x0000309f, 0x000030a1, 
-0x000030fa, 0x000030fc, 0x000030ff, 0x00003105, 0x0000312c, 
-0x00003131, 0x0000318e, 0x00003190, 0x000031b7, 0x000031f0, 
-0x0000321c, 0x00003220, 0x00003243, 0x00003260, 0x0000327b, 
-0x0000327f, 0x000032b0, 0x000032c0, 0x000032cb, 0x000032d0, 
-0x000032fe, 0x00003300, 0x00003376, 0x0000337b, 0x000033dd, 
-0x000033e0, 0x000033fe, 0x00003400, 0x00003400, 0x00004db5, 
-0x00004db5, 0x00004e00, 0x0000a48c, 0x0000ac00, 0x0000d7a3, 
-0x0000e000, 0x0000fb06, 0x0000fb13, 0x0000fb17, 0x0000ff21, 
-0x0000ff3a, 0x0000ff41, 0x0000ff5a, 0x0000ff66, 0x0000ffbe, 
-0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf, 0x0000ffd2, 
-0x0000ffd7, 0x0000ffda, 0x0000ffdc, 0x00010000, 0x0010ffff, 
-0x000005be, 0x000005be, 0x000005c0, 0x000005c0, 
-0x000005c3, 0x000005c3, 0x000005d0, 0x000005ea, 0x000005f0, 
-0x000005f4, 0x0000200f, 0x0000200f, 0x0000fb1d, 0x0000fb1d, 
-0x0000fb1f, 0x0000fb28, 0x0000fb2a, 0x0000fb36, 0x0000fb38, 
-0x0000fb3c, 0x0000fb3e, 0x0000fb3e, 0x0000fb40, 0x0000fb41, 
-0x0000fb43, 0x0000fb44, 0x0000fb46, 0x0000fb4f, 
-0x00000030, 0x00000039, 0x000000b2, 0x000000b3, 
-0x000000b9, 0x000000b9, 0x000006f0, 0x000006f9, 0x00002070, 
-0x00002070, 0x00002074, 0x00002079, 0x00002080, 0x00002089, 
-0x00002460, 0x0000249b, 0x000024ea, 0x000024ea, 0x0000ff10, 
-0x0000ff19, 0x0001d7ce, 0x0001d7ff, 
-0x0000002f, 0x0000002f, 0x0000ff0f, 0x0000ff0f, 
-0x00000023, 0x00000025, 0x0000002b, 0x0000002b, 
-0x0000002d, 0x0000002d, 0x000000a2, 0x000000a5, 0x000000b0, 
-0x000000b1, 0x0000066a, 0x0000066a, 0x000009f2, 0x000009f3, 
-0x00000e3f, 0x00000e3f, 0x000017db, 0x000017db, 0x00002030, 
-0x00002034, 0x0000207a, 0x0000207b, 0x0000208a, 0x0000208b, 
-0x000020a0, 0x000020b1, 0x0000212e, 0x0000212e, 0x00002212, 
-0x00002213, 0x0000fb29, 0x0000fb29, 0x0000fe5f, 0x0000fe5f, 
-0x0000fe62, 0x0000fe63, 0x0000fe69, 0x0000fe6a, 0x0000ff03, 
-0x0000ff05, 0x0000ff0b, 0x0000ff0b, 0x0000ff0d, 0x0000ff0d, 
-0x0000ffe0, 0x0000ffe1, 0x0000ffe5, 0x0000ffe6, 
-0x00000660, 0x00000669, 0x0000066b, 0x0000066c, 
-0x0000002c, 0x0000002c, 0x0000002e, 0x0000002e, 
-0x0000003a, 0x0000003a, 0x000000a0, 0x000000a0, 0x0000060c, 
-0x0000060c, 0x0000fe50, 0x0000fe50, 0x0000fe52, 0x0000fe52, 
-0x0000fe55, 0x0000fe55, 0x0000ff0c, 0x0000ff0c, 0x0000ff0e, 
-0x0000ff0e, 0x0000ff1a, 0x0000ff1a, 
-0x0000000a, 0x0000000a, 0x0000000d, 0x0000000d, 
-0x0000001c, 0x0000001e, 0x00000085, 0x00000085, 0x00002029, 
-0x00002029, 
-0x00000009, 0x00000009, 0x0000000b, 0x0000000b, 
-0x0000001f, 0x0000001f, 
-0x0000000c, 0x0000000c, 0x00000020, 0x00000020, 
-0x00001680, 0x00001680, 0x00002000, 0x0000200a, 0x00002028, 
-0x00002028, 0x0000202f, 0x0000202f, 0x0000205f, 0x0000205f, 
-0x00003000, 0x00003000, 
-0x00000000, 0x00000008, 0x0000000e, 0x0000001b, 
-0x00000021, 0x00000022, 0x00000026, 0x0000002a, 0x0000003b, 
-0x00000040, 0x0000005b, 0x00000060, 0x0000007b, 0x00000084, 
-0x00000086, 0x0000009f, 0x000000a1, 0x000000a1, 0x000000a6, 
-0x000000a9, 0x000000ab, 0x000000af, 0x000000b4, 0x000000b4, 
-0x000000b6, 0x000000b8, 0x000000bb, 0x000000bf, 0x000000d7, 
-0x000000d7, 0x000000f7, 0x000000f7, 0x000002b9, 0x000002ba, 
-0x000002c2, 0x000002cf, 0x000002d2, 0x000002df, 0x000002e5, 
-0x000002ed, 0x00000300, 0x0000034f, 0x00000360, 0x0000036f, 
-0x00000374, 0x00000375, 0x0000037e, 0x0000037e, 0x00000384, 
-0x00000385, 0x00000387, 0x00000387, 0x000003f6, 0x000003f6, 
-0x00000483, 0x00000486, 0x00000488, 0x00000489, 0x0000058a, 
-0x0000058a, 0x00000591, 0x000005a1, 0x000005a3, 0x000005b9, 
-0x000005bb, 0x000005bd, 0x000005bf, 0x000005bf, 0x000005c1, 
-0x000005c2, 0x000005c4, 0x000005c4, 0x0000064b, 0x00000655, 
-0x00000670, 0x00000670, 0x000006d6, 0x000006dc, 0x000006de, 
-0x000006e4, 0x000006e7, 0x000006ed, 0x0000070f, 0x0000070f, 
-0x00000711, 0x00000711, 0x00000730, 0x0000074a, 0x000007a6, 
-0x000007b0, 0x00000901, 0x00000902, 0x0000093c, 0x0000093c, 
-0x00000941, 0x00000948, 0x0000094d, 0x0000094d, 0x00000951, 
-0x00000954, 0x00000962, 0x00000963, 0x00000981, 0x00000981, 
-0x000009bc, 0x000009bc, 0x000009c1, 0x000009c4, 0x000009cd, 
-0x000009cd, 0x000009e2, 0x000009e3, 0x00000a02, 0x00000a02, 
-0x00000a3c, 0x00000a3c, 0x00000a41, 0x00000a42, 0x00000a47, 
-0x00000a48, 0x00000a4b, 0x00000a4d, 0x00000a70, 0x00000a71, 
-0x00000a81, 0x00000a82, 0x00000abc, 0x00000abc, 0x00000ac1, 
-0x00000ac5, 0x00000ac7, 0x00000ac8, 0x00000acd, 0x00000acd, 
-0x00000b01, 0x00000b01, 0x00000b3c, 0x00000b3c, 0x00000b3f, 
-0x00000b3f, 0x00000b41, 0x00000b43, 0x00000b4d, 0x00000b4d, 
-0x00000b56, 0x00000b56, 0x00000b82, 0x00000b82, 0x00000bc0, 
-0x00000bc0, 0x00000bcd, 0x00000bcd, 0x00000c3e, 0x00000c40, 
-0x00000c46, 0x00000c48, 0x00000c4a, 0x00000c4d, 0x00000c55, 
-0x00000c56, 0x00000cbf, 0x00000cbf, 0x00000cc6, 0x00000cc6, 
-0x00000ccc, 0x00000ccd, 0x00000d41, 0x00000d43, 0x00000d4d, 
-0x00000d4d, 0x00000dca, 0x00000dca, 0x00000dd2, 0x00000dd4, 
-0x00000dd6, 0x00000dd6, 0x00000e31, 0x00000e31, 0x00000e34, 
-0x00000e3a, 0x00000e47, 0x00000e4e, 0x00000eb1, 0x00000eb1, 
-0x00000eb4, 0x00000eb9, 0x00000ebb, 0x00000ebc, 0x00000ec8, 
-0x00000ecd, 0x00000f18, 0x00000f19, 0x00000f35, 0x00000f35, 
-0x00000f37, 0x00000f37, 0x00000f39, 0x00000f3d, 0x00000f71, 
-0x00000f7e, 0x00000f80, 0x00000f84, 0x00000f86, 0x00000f87, 
-0x00000f90, 0x00000f97, 0x00000f99, 0x00000fbc, 0x00000fc6, 
-0x00000fc6, 0x0000102d, 0x00001030, 0x00001032, 0x00001032, 
-0x00001036, 0x00001037, 0x00001039, 0x00001039, 0x00001058, 
-0x00001059, 0x0000169b, 0x0000169c, 0x00001712, 0x00001714, 
-0x00001732, 0x00001734, 0x00001752, 0x00001753, 0x00001772, 
-0x00001773, 0x000017b7, 0x000017bd, 0x000017c6, 0x000017c6, 
-0x000017c9, 0x000017d3, 0x00001800, 0x0000180e, 0x000018a9, 
-0x000018a9, 0x00001fbd, 0x00001fbd, 0x00001fbf, 0x00001fc1, 
-0x00001fcd, 0x00001fcf, 0x00001fdd, 0x00001fdf, 0x00001fed, 
-0x00001fef, 0x00001ffd, 0x00001ffe, 0x0000200b, 0x0000200d, 
-0x00002010, 0x00002027, 0x0000202a, 0x0000202e, 0x00002035, 
-0x00002052, 0x00002057, 0x00002057, 0x00002060, 0x00002063, 
-0x0000206a, 0x0000206f, 0x0000207c, 0x0000207e, 0x0000208c, 
-0x0000208e, 0x000020d0, 0x000020ea, 0x00002100, 0x00002101, 
-0x00002103, 0x00002106, 0x00002108, 0x00002109, 0x00002114, 
-0x00002114, 0x00002116, 0x00002118, 0x0000211e, 0x00002123, 
-0x00002125, 0x00002125, 0x00002127, 0x00002127, 0x00002129, 
-0x00002129, 0x00002132, 0x00002132, 0x0000213a, 0x0000213a, 
-0x00002140, 0x00002144, 0x0000214a, 0x0000214b, 0x00002153, 
-0x0000215f, 0x00002190, 0x00002211, 0x00002214, 0x00002335, 
-0x0000237b, 0x00002394, 0x00002396, 0x000023ce, 0x00002400, 
-0x00002426, 0x00002440, 0x0000244a, 0x000024eb, 0x000024fe, 
-0x00002500, 0x00002613, 0x00002616, 0x00002617, 0x00002619, 
-0x0000267d, 0x00002680, 0x00002689, 0x00002701, 0x00002704, 
-0x00002706, 0x00002709, 0x0000270c, 0x00002727, 0x00002729, 
-0x0000274b, 0x0000274d, 0x0000274d, 0x0000274f, 0x00002752, 
-0x00002756, 0x00002756, 0x00002758, 0x0000275e, 0x00002761, 
-0x00002794, 0x00002798, 0x000027af, 0x000027b1, 0x000027be, 
-0x000027d0, 0x000027eb, 0x000027f0, 0x00002aff, 0x00002e80, 
-0x00002e99, 0x00002e9b, 0x00002ef3, 0x00002f00, 0x00002fd5, 
-0x00002ff0, 0x00002ffb, 0x00003001, 0x00003004, 0x00003008, 
-0x00003020, 0x0000302a, 0x00003030, 0x00003036, 0x00003037, 
-0x0000303d, 0x0000303f, 0x00003099, 0x0000309c, 0x000030a0, 
-0x000030a0, 0x000030fb, 0x000030fb, 0x00003251, 0x0000325f, 
-0x000032b1, 0x000032bf, 0x0000a490, 0x0000a4c6, 0x0000fb1e, 
-0x0000fb1e, 0x0000fd3e, 0x0000fd3f, 0x0000fe00, 0x0000fe0f, 
-0x0000fe20, 0x0000fe23, 0x0000fe30, 0x0000fe46, 0x0000fe49, 
-0x0000fe4f, 0x0000fe51, 0x0000fe51, 0x0000fe54, 0x0000fe54, 
-0x0000fe56, 0x0000fe5e, 0x0000fe60, 0x0000fe61, 0x0000fe64, 
-0x0000fe66, 0x0000fe68, 0x0000fe68, 0x0000fe6b, 0x0000fe6b, 
-0x0000feff, 0x0000feff, 0x0000ff01, 0x0000ff02, 0x0000ff06, 
-0x0000ff0a, 0x0000ff1b, 0x0000ff20, 0x0000ff3b, 0x0000ff40, 
-0x0000ff5b, 0x0000ff65, 0x0000ffe2, 0x0000ffe4, 0x0000ffe8, 
-0x0000ffee, 0x0000fff9, 0x0000fffd, 0x0001d167, 0x0001d169, 
-0x0001d173, 0x0001d182, 0x0001d185, 0x0001d18b, 0x0001d1aa, 
-0x0001d1ad, 0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f, 
-0x000000c0, 0x000000c5, 0x000000c7, 0x000000cf, 
-0x000000d1, 0x000000d6, 0x000000d9, 0x000000dd, 0x000000e0, 
-0x000000e5, 0x000000e7, 0x000000ef, 0x000000f1, 0x000000f6, 
-0x000000f9, 0x000000fd, 0x000000ff, 0x0000010f, 0x00000112, 
-0x00000125, 0x00000128, 0x00000130, 0x00000134, 0x00000137, 
-0x00000139, 0x0000013e, 0x00000143, 0x00000148, 0x0000014c, 
-0x00000151, 0x00000154, 0x00000165, 0x00000168, 0x0000017e, 
-0x000001a0, 0x000001a1, 0x000001af, 0x000001b0, 0x000001cd, 
-0x000001dc, 0x000001de, 0x000001e3, 0x000001e6, 0x000001f0, 
-0x000001f4, 0x000001f5, 0x000001f8, 0x0000021b, 0x0000021e, 
-0x0000021f, 0x00000226, 0x00000233, 0x00000340, 0x00000341, 
-0x00000343, 0x00000344, 0x00000374, 0x00000374, 0x0000037e, 
-0x0000037e, 0x00000385, 0x0000038a, 0x0000038c, 0x0000038c, 
-0x0000038e, 0x00000390, 0x000003aa, 0x000003b0, 0x000003ca, 
-0x000003ce, 0x000003d3, 0x000003d4, 0x00000400, 0x00000401, 
-0x00000403, 0x00000403, 0x00000407, 0x00000407, 0x0000040c, 
-0x0000040e, 0x00000419, 0x00000419, 0x00000439, 0x00000439, 
-0x00000450, 0x00000451, 0x00000453, 0x00000453, 0x00000457, 
-0x00000457, 0x0000045c, 0x0000045e, 0x00000476, 0x00000477, 
-0x000004c1, 0x000004c2, 0x000004d0, 0x000004d3, 0x000004d6, 
-0x000004d7, 0x000004da, 0x000004df, 0x000004e2, 0x000004e7, 
-0x000004ea, 0x000004f5, 0x000004f8, 0x000004f9, 0x00000622, 
-0x00000626, 0x000006c0, 0x000006c0, 0x000006c2, 0x000006c2, 
-0x000006d3, 0x000006d3, 0x00000929, 0x00000929, 0x00000931, 
-0x00000931, 0x00000934, 0x00000934, 0x00000958, 0x0000095f, 
-0x000009cb, 0x000009cc, 0x000009dc, 0x000009dd, 0x000009df, 
-0x000009df, 0x00000a33, 0x00000a33, 0x00000a36, 0x00000a36, 
-0x00000a59, 0x00000a5b, 0x00000a5e, 0x00000a5e, 0x00000b48, 
-0x00000b48, 0x00000b4b, 0x00000b4c, 0x00000b5c, 0x00000b5d, 
-0x00000b94, 0x00000b94, 0x00000bca, 0x00000bcc, 0x00000c48, 
-0x00000c48, 0x00000cc0, 0x00000cc0, 0x00000cc7, 0x00000cc8, 
-0x00000cca, 0x00000ccb, 0x00000d4a, 0x00000d4c, 0x00000dda, 
-0x00000dda, 0x00000ddc, 0x00000dde, 0x00000f43, 0x00000f43, 
-0x00000f4d, 0x00000f4d, 0x00000f52, 0x00000f52, 0x00000f57, 
-0x00000f57, 0x00000f5c, 0x00000f5c, 0x00000f69, 0x00000f69, 
-0x00000f73, 0x00000f73, 0x00000f75, 0x00000f76, 0x00000f78, 
-0x00000f78, 0x00000f81, 0x00000f81, 0x00000f93, 0x00000f93, 
-0x00000f9d, 0x00000f9d, 0x00000fa2, 0x00000fa2, 0x00000fa7, 
-0x00000fa7, 0x00000fac, 0x00000fac, 0x00000fb9, 0x00000fb9, 
-0x00001026, 0x00001026, 0x00001e00, 0x00001e99, 0x00001e9b, 
-0x00001e9b, 0x00001ea0, 0x00001ef9, 0x00001f00, 0x00001f15, 
-0x00001f18, 0x00001f1d, 0x00001f20, 0x00001f45, 0x00001f48, 
-0x00001f4d, 0x00001f50, 0x00001f57, 0x00001f59, 0x00001f59, 
-0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d, 0x00001f5f, 
-0x00001f7d, 0x00001f80, 0x00001fb4, 0x00001fb6, 0x00001fbc, 
-0x00001fbe, 0x00001fbe, 0x00001fc1, 0x00001fc4, 0x00001fc6, 
-0x00001fd3, 0x00001fd6, 0x00001fdb, 0x00001fdd, 0x00001fef, 
-0x00001ff2, 0x00001ff4, 0x00001ff6, 0x00001ffd, 0x00002000, 
-0x00002001, 0x00002126, 0x00002126, 0x0000212a, 0x0000212b, 
-0x0000219a, 0x0000219b, 0x000021ae, 0x000021ae, 0x000021cd, 
-0x000021cf, 0x00002204, 0x00002204, 0x00002209, 0x00002209, 
-0x0000220c, 0x0000220c, 0x00002224, 0x00002224, 0x00002226, 
-0x00002226, 0x00002241, 0x00002241, 0x00002244, 0x00002244, 
-0x00002247, 0x00002247, 0x00002249, 0x00002249, 0x00002260, 
-0x00002260, 0x00002262, 0x00002262, 0x0000226d, 0x00002271, 
-0x00002274, 0x00002275, 0x00002278, 0x00002279, 0x00002280, 
-0x00002281, 0x00002284, 0x00002285, 0x00002288, 0x00002289, 
-0x000022ac, 0x000022af, 0x000022e0, 0x000022e3, 0x000022ea, 
-0x000022ed, 0x00002329, 0x0000232a, 0x00002adc, 0x00002adc, 
-0x0000304c, 0x0000304c, 0x0000304e, 0x0000304e, 0x00003050, 
-0x00003050, 0x00003052, 0x00003052, 0x00003054, 0x00003054, 
-0x00003056, 0x00003056, 0x00003058, 0x00003058, 0x0000305a, 
-0x0000305a, 0x0000305c, 0x0000305c, 0x0000305e, 0x0000305e, 
-0x00003060, 0x00003060, 0x00003062, 0x00003062, 0x00003065, 
-0x00003065, 0x00003067, 0x00003067, 0x00003069, 0x00003069, 
-0x00003070, 0x00003071, 0x00003073, 0x00003074, 0x00003076, 
-0x00003077, 0x00003079, 0x0000307a, 0x0000307c, 0x0000307d, 
-0x00003094, 0x00003094, 0x0000309e, 0x0000309e, 0x000030ac, 
-0x000030ac, 0x000030ae, 0x000030ae, 0x000030b0, 0x000030b0, 
-0x000030b2, 0x000030b2, 0x000030b4, 0x000030b4, 0x000030b6, 
-0x000030b6, 0x000030b8, 0x000030b8, 0x000030ba, 0x000030ba, 
-0x000030bc, 0x000030bc, 0x000030be, 0x000030be, 0x000030c0, 
-0x000030c0, 0x000030c2, 0x000030c2, 0x000030c5, 0x000030c5, 
-0x000030c7, 0x000030c7, 0x000030c9, 0x000030c9, 0x000030d0, 
-0x000030d1, 0x000030d3, 0x000030d4, 0x000030d6, 0x000030d7, 
-0x000030d9, 0x000030da, 0x000030dc, 0x000030dd, 0x000030f4, 
-0x000030f4, 0x000030f7, 0x000030fa, 0x000030fe, 0x000030fe, 
-0x0000f902, 0x0000fa0d, 0x0000fa10, 0x0000fa10, 0x0000fa12, 
-0x0000fa12, 0x0000fa15, 0x0000fa1e, 0x0000fa20, 0x0000fa20, 
-0x0000fa22, 0x0000fa22, 0x0000fa25, 0x0000fa26, 0x0000fa2a, 
-0x0000fa2d, 0x0000fa30, 0x0000fa6a, 0x0000fb1d, 0x0000fb1d, 
-0x0000fb1f, 0x0000fb1f, 0x0000fb2a, 0x0000fb36, 0x0000fb38, 
-0x0000fb3c, 0x0000fb3e, 0x0000fb3e, 0x0000fb40, 0x0000fb41, 
-0x0000fb43, 0x0000fb44, 0x0000fb46, 0x0000fb4e, 0x0001d15e, 
-0x0001d164, 0x0001d1bb, 0x0001d1c0, 0x0002f800, 0x0002fa1d, 
-0x00000000, 0x00000220, 0x00000222, 0x00000233, 
-0x00000250, 0x000002ad, 0x000002b0, 0x000002ee, 0x00000300, 
-0x0000034f, 0x00000360, 0x0000036f, 0x00000374, 0x00000375, 
-0x0000037a, 0x0000037a, 0x0000037e, 0x0000037e, 0x00000384, 
-0x0000038a, 0x0000038c, 0x0000038c, 0x0000038e, 0x000003a1, 
-0x000003a3, 0x000003ce, 0x000003d0, 0x000003f6, 0x00000400, 
-0x00000486, 0x00000488, 0x000004ce, 0x000004d0, 0x000004f5, 
-0x000004f8, 0x000004f9, 0x00000500, 0x0000050f, 0x00000531, 
-0x00000556, 0x00000559, 0x0000055f, 0x00000561, 0x00000587, 
-0x00000589, 0x0000058a, 0x00000591, 0x000005a1, 0x000005a3, 
-0x000005b9, 0x000005bb, 0x000005c4, 0x000005d0, 0x000005ea, 
-0x000005f0, 0x000005f4, 0x0000060c, 0x0000060c, 0x0000061b, 
-0x0000061b, 0x0000061f, 0x0000061f, 0x00000621, 0x0000063a, 
-0x00000640, 0x00000655, 0x00000660, 0x000006ed, 0x000006f0, 
-0x000006fe, 0x00000700, 0x0000070d, 0x0000070f, 0x0000072c, 
-0x00000730, 0x0000074a, 0x00000780, 0x000007b1, 0x00000901, 
-0x00000903, 0x00000905, 0x00000939, 0x0000093c, 0x0000094d, 
-0x00000950, 0x00000954, 0x00000958, 0x00000970, 0x00000981, 
-0x00000983, 0x00000985, 0x0000098c, 0x0000098f, 0x00000990, 
-0x00000993, 0x000009a8, 0x000009aa, 0x000009b0, 0x000009b2, 
-0x000009b2, 0x000009b6, 0x000009b9, 0x000009bc, 0x000009bc, 
-0x000009be, 0x000009c4, 0x000009c7, 0x000009c8, 0x000009cb, 
-0x000009cd, 0x000009d7, 0x000009d7, 0x000009dc, 0x000009dd, 
-0x000009df, 0x000009e3, 0x000009e6, 0x000009fa, 0x00000a02, 
-0x00000a02, 0x00000a05, 0x00000a0a, 0x00000a0f, 0x00000a10, 
-0x00000a13, 0x00000a28, 0x00000a2a, 0x00000a30, 0x00000a32, 
-0x00000a33, 0x00000a35, 0x00000a36, 0x00000a38, 0x00000a39, 
-0x00000a3c, 0x00000a3c, 0x00000a3e, 0x00000a42, 0x00000a47, 
-0x00000a48, 0x00000a4b, 0x00000a4d, 0x00000a59, 0x00000a5c, 
-0x00000a5e, 0x00000a5e, 0x00000a66, 0x00000a74, 0x00000a81, 
-0x00000a83, 0x00000a85, 0x00000a8b, 0x00000a8d, 0x00000a8d, 
-0x00000a8f, 0x00000a91, 0x00000a93, 0x00000aa8, 0x00000aaa, 
-0x00000ab0, 0x00000ab2, 0x00000ab3, 0x00000ab5, 0x00000ab9, 
-0x00000abc, 0x00000ac5, 0x00000ac7, 0x00000ac9, 0x00000acb, 
-0x00000acd, 0x00000ad0, 0x00000ad0, 0x00000ae0, 0x00000ae0, 
-0x00000ae6, 0x00000aef, 0x00000b01, 0x00000b03, 0x00000b05, 
-0x00000b0c, 0x00000b0f, 0x00000b10, 0x00000b13, 0x00000b28, 
-0x00000b2a, 0x00000b30, 0x00000b32, 0x00000b33, 0x00000b36, 
-0x00000b39, 0x00000b3c, 0x00000b43, 0x00000b47, 0x00000b48, 
-0x00000b4b, 0x00000b4d, 0x00000b56, 0x00000b57, 0x00000b5c, 
-0x00000b5d, 0x00000b5f, 0x00000b61, 0x00000b66, 0x00000b70, 
-0x00000b82, 0x00000b83, 0x00000b85, 0x00000b8a, 0x00000b8e, 
-0x00000b90, 0x00000b92, 0x00000b95, 0x00000b99, 0x00000b9a, 
-0x00000b9c, 0x00000b9c, 0x00000b9e, 0x00000b9f, 0x00000ba3, 
-0x00000ba4, 0x00000ba8, 0x00000baa, 0x00000bae, 0x00000bb5, 
-0x00000bb7, 0x00000bb9, 0x00000bbe, 0x00000bc2, 0x00000bc6, 
-0x00000bc8, 0x00000bca, 0x00000bcd, 0x00000bd7, 0x00000bd7, 
-0x00000be7, 0x00000bf2, 0x00000c01, 0x00000c03, 0x00000c05, 
-0x00000c0c, 0x00000c0e, 0x00000c10, 0x00000c12, 0x00000c28, 
-0x00000c2a, 0x00000c33, 0x00000c35, 0x00000c39, 0x00000c3e, 
-0x00000c44, 0x00000c46, 0x00000c48, 0x00000c4a, 0x00000c4d, 
-0x00000c55, 0x00000c56, 0x00000c60, 0x00000c61, 0x00000c66, 
-0x00000c6f, 0x00000c82, 0x00000c83, 0x00000c85, 0x00000c8c, 
-0x00000c8e, 0x00000c90, 0x00000c92, 0x00000ca8, 0x00000caa, 
-0x00000cb3, 0x00000cb5, 0x00000cb9, 0x00000cbe, 0x00000cc4, 
-0x00000cc6, 0x00000cc8, 0x00000cca, 0x00000ccd, 0x00000cd5, 
-0x00000cd6, 0x00000cde, 0x00000cde, 0x00000ce0, 0x00000ce1, 
-0x00000ce6, 0x00000cef, 0x00000d02, 0x00000d03, 0x00000d05, 
-0x00000d0c, 0x00000d0e, 0x00000d10, 0x00000d12, 0x00000d28, 
-0x00000d2a, 0x00000d39, 0x00000d3e, 0x00000d43, 0x00000d46, 
-0x00000d48, 0x00000d4a, 0x00000d4d, 0x00000d57, 0x00000d57, 
-0x00000d60, 0x00000d61, 0x00000d66, 0x00000d6f, 0x00000d82, 
-0x00000d83, 0x00000d85, 0x00000d96, 0x00000d9a, 0x00000db1, 
-0x00000db3, 0x00000dbb, 0x00000dbd, 0x00000dbd, 0x00000dc0, 
-0x00000dc6, 0x00000dca, 0x00000dca, 0x00000dcf, 0x00000dd4, 
-0x00000dd6, 0x00000dd6, 0x00000dd8, 0x00000ddf, 0x00000df2, 
-0x00000df4, 0x00000e01, 0x00000e3a, 0x00000e3f, 0x00000e5b, 
-0x00000e81, 0x00000e82, 0x00000e84, 0x00000e84, 0x00000e87, 
-0x00000e88, 0x00000e8a, 0x00000e8a, 0x00000e8d, 0x00000e8d, 
-0x00000e94, 0x00000e97, 0x00000e99, 0x00000e9f, 0x00000ea1, 
-0x00000ea3, 0x00000ea5, 0x00000ea5, 0x00000ea7, 0x00000ea7, 
-0x00000eaa, 0x00000eab, 0x00000ead, 0x00000eb9, 0x00000ebb, 
-0x00000ebd, 0x00000ec0, 0x00000ec4, 0x00000ec6, 0x00000ec6, 
-0x00000ec8, 0x00000ecd, 0x00000ed0, 0x00000ed9, 0x00000edc, 
-0x00000edd, 0x00000f00, 0x00000f47, 0x00000f49, 0x00000f6a, 
-0x00000f71, 0x00000f8b, 0x00000f90, 0x00000f97, 0x00000f99, 
-0x00000fbc, 0x00000fbe, 0x00000fcc, 0x00000fcf, 0x00000fcf, 
-0x00001000, 0x00001021, 0x00001023, 0x00001027, 0x00001029, 
-0x0000102a, 0x0000102c, 0x00001032, 0x00001036, 0x00001039, 
-0x00001040, 0x00001059, 0x000010a0, 0x000010c5, 0x000010d0, 
-0x000010f8, 0x000010fb, 0x000010fb, 0x00001100, 0x00001159, 
-0x0000115f, 0x000011a2, 0x000011a8, 0x000011f9, 0x00001200, 
-0x00001206, 0x00001208, 0x00001246, 0x00001248, 0x00001248, 
-0x0000124a, 0x0000124d, 0x00001250, 0x00001256, 0x00001258, 
-0x00001258, 0x0000125a, 0x0000125d, 0x00001260, 0x00001286, 
-0x00001288, 0x00001288, 0x0000128a, 0x0000128d, 0x00001290, 
-0x000012ae, 0x000012b0, 0x000012b0, 0x000012b2, 0x000012b5, 
-0x000012b8, 0x000012be, 0x000012c0, 0x000012c0, 0x000012c2, 
-0x000012c5, 0x000012c8, 0x000012ce, 0x000012d0, 0x000012d6, 
-0x000012d8, 0x000012ee, 0x000012f0, 0x0000130e, 0x00001310, 
-0x00001310, 0x00001312, 0x00001315, 0x00001318, 0x0000131e, 
-0x00001320, 0x00001346, 0x00001348, 0x0000135a, 0x00001361, 
-0x0000137c, 0x000013a0, 0x000013f4, 0x00001401, 0x00001676, 
-0x00001680, 0x0000169c, 0x000016a0, 0x000016f0, 0x00001700, 
-0x0000170c, 0x0000170e, 0x00001714, 0x00001720, 0x00001736, 
-0x00001740, 0x00001753, 0x00001760, 0x0000176c, 0x0000176e, 
-0x00001770, 0x00001772, 0x00001773, 0x00001780, 0x000017dc, 
-0x000017e0, 0x000017e9, 0x00001800, 0x0000180e, 0x00001810, 
-0x00001819, 0x00001820, 0x00001877, 0x00001880, 0x000018a9, 
-0x00001e00, 0x00001e9b, 0x00001ea0, 0x00001ef9, 0x00001f00, 
-0x00001f15, 0x00001f18, 0x00001f1d, 0x00001f20, 0x00001f45, 
-0x00001f48, 0x00001f4d, 0x00001f50, 0x00001f57, 0x00001f59, 
-0x00001f59, 0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d, 
-0x00001f5f, 0x00001f7d, 0x00001f80, 0x00001fb4, 0x00001fb6, 
-0x00001fc4, 0x00001fc6, 0x00001fd3, 0x00001fd6, 0x00001fdb, 
-0x00001fdd, 0x00001fef, 0x00001ff2, 0x00001ff4, 0x00001ff6, 
-0x00001ffe, 0x00002000, 0x00002052, 0x00002057, 0x00002057, 
-0x0000205f, 0x00002063, 0x0000206a, 0x00002071, 0x00002074, 
-0x0000208e, 0x000020a0, 0x000020b1, 0x000020d0, 0x000020ea, 
-0x00002100, 0x0000213a, 0x0000213d, 0x0000214b, 0x00002153, 
-0x00002183, 0x00002190, 0x000023ce, 0x00002400, 0x00002426, 
-0x00002440, 0x0000244a, 0x00002460, 0x000024fe, 0x00002500, 
-0x00002613, 0x00002616, 0x00002617, 0x00002619, 0x0000267d, 
-0x00002680, 0x00002689, 0x00002701, 0x00002704, 0x00002706, 
-0x00002709, 0x0000270c, 0x00002727, 0x00002729, 0x0000274b, 
-0x0000274d, 0x0000274d, 0x0000274f, 0x00002752, 0x00002756, 
-0x00002756, 0x00002758, 0x0000275e, 0x00002761, 0x00002794, 
-0x00002798, 0x000027af, 0x000027b1, 0x000027be, 0x000027d0, 
-0x000027eb, 0x000027f0, 0x00002aff, 0x00002e80, 0x00002e99, 
-0x00002e9b, 0x00002ef3, 0x00002f00, 0x00002fd5, 0x00002ff0, 
-0x00002ffb, 0x00003000, 0x0000303f, 0x00003041, 0x00003096, 
-0x00003099, 0x000030ff, 0x00003105, 0x0000312c, 0x00003131, 
-0x0000318e, 0x00003190, 0x000031b7, 0x000031f0, 0x0000321c, 
-0x00003220, 0x00003243, 0x00003251, 0x0000327b, 0x0000327f, 
-0x000032cb, 0x000032d0, 0x000032fe, 0x00003300, 0x00003376, 
-0x0000337b, 0x000033dd, 0x000033e0, 0x000033fe, 0x00003400, 
-0x00003400, 0x00004db5, 0x00004db5, 0x00004e00, 0x00009fa5, 
-0x0000a000, 0x0000a48c, 0x0000a490, 0x0000a4c6, 0x0000ac00, 
-0x0000d7a3, 0x0000f900, 0x0000fb06, 0x0000fb13, 0x0000fb17, 
-0x0000fb1d, 0x0000fb36, 0x0000fb38, 0x0000fb3c, 0x0000fb3e, 
-0x0000fb3e, 0x0000fb40, 0x0000fb41, 0x0000fb43, 0x0000fb44, 
-0x0000fb46, 0x0000fbb1, 0x0000fbd3, 0x0000fd3f, 0x0000fd50, 
-0x0000fd8f, 0x0000fd92, 0x0000fdc7, 0x0000fdf0, 0x0000fdfc, 
-0x0000fe00, 0x0000fe0f, 0x0000fe20, 0x0000fe23, 0x0000fe30, 
-0x0000fe46, 0x0000fe49, 0x0000fe52, 0x0000fe54, 0x0000fe66, 
-0x0000fe68, 0x0000fe6b, 0x0000fe70, 0x0000fe74, 0x0000fe76, 
-0x0000fefc, 0x0000feff, 0x0000feff, 0x0000ff01, 0x0000ffbe, 
-0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf, 0x0000ffd2, 
-0x0000ffd7, 0x0000ffda, 0x0000ffdc, 0x0000ffe0, 0x0000ffe6, 
-0x0000ffe8, 0x0000ffee, 0x0000fff9, 0x0000fffd, 0x00010300, 
-0x0001031e, 0x00010320, 0x00010323, 0x00010330, 0x0001034a, 
-0x00010400, 0x00010425, 0x00010428, 0x0001044d, 0x0001d000, 
-0x0001d0f5, 0x0001d100, 0x0001d126, 0x0001d12a, 0x0001d1dd, 
-0x0001d400, 0x0001d454, 0x0001d456, 0x0001d49c, 0x0001d49e, 
-0x0001d49f, 0x0001d4a2, 0x0001d4a2, 0x0001d4a5, 0x0001d4a6, 
-0x0001d4a9, 0x0001d4ac, 0x0001d4ae, 0x0001d4b9, 0x0001d4bb, 
-0x0001d4bb, 0x0001d4bd, 0x0001d4c0, 0x0001d4c2, 0x0001d4c3, 
-0x0001d4c5, 0x0001d505, 0x0001d507, 0x0001d50a, 0x0001d50d, 
-0x0001d514, 0x0001d516, 0x0001d51c, 0x0001d51e, 0x0001d539, 
-0x0001d53b, 0x0001d53e, 0x0001d540, 0x0001d544, 0x0001d546, 
-0x0001d546, 0x0001d54a, 0x0001d550, 0x0001d552, 0x0001d6a3, 
-0x0001d6a8, 0x0001d7c9, 0x0001d7ce, 0x0001d7ff, 0x00020000, 
-0x00020000, 0x0002a6d6, 0x0002a6d6, 0x0002f800, 0x0002fa1d, 
-0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f, 0x000f0000, 
-0x000f0000, 0x000ffffd, 0x000ffffd, 0x00100000, 0x00100000, 
-0x0010fffd, 0x0010fffd, 
-0x000000ab, 0x000000ab, 0x00002018, 0x00002018, 
-0x0000201b, 0x0000201c, 0x0000201f, 0x0000201f, 0x00002039, 
-0x00002039, 
-0x000000bb, 0x000000bb, 0x00002019, 0x00002019, 
-0x0000201d, 0x0000201d, 0x0000203a, 0x0000203a, 
-0x0000061b, 0x0000061b, 0x0000061f, 0x0000061f, 
-0x00000621, 0x0000063a, 0x00000640, 0x0000064a, 0x0000066d, 
-0x0000066f, 0x00000671, 0x000006d5, 0x000006dd, 0x000006dd, 
-0x000006e5, 0x000006e6, 0x000006fa, 0x000006fe, 0x00000700, 
-0x0000070d, 0x00000710, 0x00000710, 0x00000712, 0x0000072c, 
-0x00000780, 0x000007a5, 0x000007b1, 0x000007b1, 0x0000fb50, 
-0x0000fbb1, 0x0000fbd3, 0x0000fd3d, 0x0000fd50, 0x0000fd8f, 
-0x0000fd92, 0x0000fdc7, 0x0000fdf0, 0x0000fdfc, 0x0000fe70, 
-0x0000fe74, 0x0000fe76, 0x0000fefc, 
+static const unsigned short _ucprop_size = 50;
+
+static const unsigned short  _ucprop_offsets[] = {
+	0x0000, 0x0196, 0x0278, 0x0280, 0x02cc, 0x02e4, 0x0336, 0x0346,
+	0x0348, 0x034a, 0x034e, 0x036c, 0x036e, 0xffff, 0x0374, 0x082a,
+	0x0cec, 0x0d00, 0x0d62, 0x0fe6, 0x0ff2, 0x1010, 0x10a0, 0x112c,
+	0x122c, 0x12b0, 0x12d0, 0x1306, 0x144e, 0x17c0, 0x181e, 0x1834,
+	0x1846, 0x1870, 0x187c, 0x1896, 0x18a0, 0x18a6, 0x18b6, 0x1ba6,
+	0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x1d6a, 0x2152,
+	0x2168, 0x217c, 0x21a6, 0x0000
+};
+
+static const unsigned int _ucprop_ranges[] = {
+	0x00000300, 0x0000036f, 0x00000483, 0x00000487,
+	0x00000591, 0x000005bd, 0x000005bf, 0x000005bf,
+	0x000005c1, 0x000005c2, 0x000005c4, 0x000005c5,
+	0x000005c7, 0x000005c7, 0x00000610, 0x0000061a,
+	0x0000064b, 0x0000065f, 0x00000670, 0x00000670,
+	0x000006d6, 0x000006dc, 0x000006df, 0x000006e4,
+	0x000006e7, 0x000006e8, 0x000006ea, 0x000006ed,
+	0x00000711, 0x00000711, 0x00000730, 0x0000074a,
+	0x000007a6, 0x000007b0, 0x000007eb, 0x000007f3,
+	0x00000816, 0x00000819, 0x0000081b, 0x00000823,
+	0x00000825, 0x00000827, 0x00000829, 0x0000082d,
+	0x00000859, 0x0000085b, 0x00000900, 0x00000902,
+	0x0000093a, 0x0000093a, 0x0000093c, 0x0000093c,
+	0x00000941, 0x00000948, 0x0000094d, 0x0000094d,
+	0x00000951, 0x00000957, 0x00000962, 0x00000963,
+	0x00000981, 0x00000981, 0x000009bc, 0x000009bc,
+	0x000009c1, 0x000009c4, 0x000009cd, 0x000009cd,
+	0x000009e2, 0x000009e3, 0x00000a01, 0x00000a02,
+	0x00000a3c, 0x00000a3c, 0x00000a41, 0x00000a42,
+	0x00000a47, 0x00000a48, 0x00000a4b, 0x00000a4d,
+	0x00000a51, 0x00000a51, 0x00000a70, 0x00000a71,
+	0x00000a75, 0x00000a75, 0x00000a81, 0x00000a82,
+	0x00000abc, 0x00000abc, 0x00000ac1, 0x00000ac5,
+	0x00000ac7, 0x00000ac8, 0x00000acd, 0x00000acd,
+	0x00000ae2, 0x00000ae3, 0x00000b01, 0x00000b01,
+	0x00000b3c, 0x00000b3c, 0x00000b3f, 0x00000b3f,
+	0x00000b41, 0x00000b44, 0x00000b4d, 0x00000b4d,
+	0x00000b56, 0x00000b56, 0x00000b62, 0x00000b63,
+	0x00000b82, 0x00000b82, 0x00000bc0, 0x00000bc0,
+	0x00000bcd, 0x00000bcd, 0x00000c3e, 0x00000c40,
+	0x00000c46, 0x00000c48, 0x00000c4a, 0x00000c4d,
+	0x00000c55, 0x00000c56, 0x00000c62, 0x00000c63,
+	0x00000cbc, 0x00000cbc, 0x00000cbf, 0x00000cbf,
+	0x00000cc6, 0x00000cc6, 0x00000ccc, 0x00000ccd,
+	0x00000ce2, 0x00000ce3, 0x00000d41, 0x00000d44,
+	0x00000d4d, 0x00000d4d, 0x00000d62, 0x00000d63,
+	0x00000dca, 0x00000dca, 0x00000dd2, 0x00000dd4,
+	0x00000dd6, 0x00000dd6, 0x00000e31, 0x00000e31,
+	0x00000e34, 0x00000e3a, 0x00000e47, 0x00000e4e,
+	0x00000eb1, 0x00000eb1, 0x00000eb4, 0x00000eb9,
+	0x00000ebb, 0x00000ebc, 0x00000ec8, 0x00000ecd,
+	0x00000f18, 0x00000f19, 0x00000f35, 0x00000f35,
+	0x00000f37, 0x00000f37, 0x00000f39, 0x00000f39,
+	0x00000f71, 0x00000f7e, 0x00000f80, 0x00000f84,
+	0x00000f86, 0x00000f87, 0x00000f8d, 0x00000f97,
+	0x00000f99, 0x00000fbc, 0x00000fc6, 0x00000fc6,
+	0x0000102d, 0x00001030, 0x00001032, 0x00001037,
+	0x00001039, 0x0000103a, 0x0000103d, 0x0000103e,
+	0x00001058, 0x00001059, 0x0000105e, 0x00001060,
+	0x00001071, 0x00001074, 0x00001082, 0x00001082,
+	0x00001085, 0x00001086, 0x0000108d, 0x0000108d,
+	0x0000109d, 0x0000109d, 0x0000135d, 0x0000135f,
+	0x00001712, 0x00001714, 0x00001732, 0x00001734,
+	0x00001752, 0x00001753, 0x00001772, 0x00001773,
+	0x000017b7, 0x000017bd, 0x000017c6, 0x000017c6,
+	0x000017c9, 0x000017d3, 0x000017dd, 0x000017dd,
+	0x0000180b, 0x0000180d, 0x000018a9, 0x000018a9,
+	0x00001920, 0x00001922, 0x00001927, 0x00001928,
+	0x00001932, 0x00001932, 0x00001939, 0x0000193b,
+	0x00001a17, 0x00001a18, 0x00001a56, 0x00001a56,
+	0x00001a58, 0x00001a5e, 0x00001a60, 0x00001a60,
+	0x00001a62, 0x00001a62, 0x00001a65, 0x00001a6c,
+	0x00001a73, 0x00001a7c, 0x00001a7f, 0x00001a7f,
+	0x00001b00, 0x00001b03, 0x00001b34, 0x00001b34,
+	0x00001b36, 0x00001b3a, 0x00001b3c, 0x00001b3c,
+	0x00001b42, 0x00001b42, 0x00001b6b, 0x00001b73,
+	0x00001b80, 0x00001b81, 0x00001ba2, 0x00001ba5,
+	0x00001ba8, 0x00001ba9, 0x00001be6, 0x00001be6,
+	0x00001be8, 0x00001be9, 0x00001bed, 0x00001bed,
+	0x00001bef, 0x00001bf1, 0x00001c2c, 0x00001c33,
+	0x00001c36, 0x00001c37, 0x00001cd0, 0x00001cd2,
+	0x00001cd4, 0x00001ce0, 0x00001ce2, 0x00001ce8,
+	0x00001ced, 0x00001ced, 0x00001dc0, 0x00001de6,
+	0x00001dfc, 0x00001dff, 0x000020d0, 0x000020dc,
+	0x000020e1, 0x000020e1, 0x000020e5, 0x000020f0,
+	0x00002cef, 0x00002cf1, 0x00002d7f, 0x00002d7f,
+	0x00002de0, 0x00002dff, 0x0000302a, 0x0000302f,
+	0x00003099, 0x0000309a, 0x0000a66f, 0x0000a66f,
+	0x0000a67c, 0x0000a67d, 0x0000a6f0, 0x0000a6f1,
+	0x0000a802, 0x0000a802, 0x0000a806, 0x0000a806,
+	0x0000a80b, 0x0000a80b, 0x0000a825, 0x0000a826,
+	0x0000a8c4, 0x0000a8c4, 0x0000a8e0, 0x0000a8f1,
+	0x0000a926, 0x0000a92d, 0x0000a947, 0x0000a951,
+	0x0000a980, 0x0000a982, 0x0000a9b3, 0x0000a9b3,
+	0x0000a9b6, 0x0000a9b9, 0x0000a9bc, 0x0000a9bc,
+	0x0000aa29, 0x0000aa2e, 0x0000aa31, 0x0000aa32,
+	0x0000aa35, 0x0000aa36, 0x0000aa43, 0x0000aa43,
+	0x0000aa4c, 0x0000aa4c, 0x0000aab0, 0x0000aab0,
+	0x0000aab2, 0x0000aab4, 0x0000aab7, 0x0000aab8,
+	0x0000aabe, 0x0000aabf, 0x0000aac1, 0x0000aac1,
+	0x0000abe5, 0x0000abe5, 0x0000abe8, 0x0000abe8,
+	0x0000abed, 0x0000abed, 0x0000fb1e, 0x0000fb1e,
+	0x0000fe00, 0x0000fe0f, 0x0000fe20, 0x0000fe26,
+	0x000101fd, 0x000101fd, 0x00010a01, 0x00010a03,
+	0x00010a05, 0x00010a06, 0x00010a0c, 0x00010a0f,
+	0x00010a38, 0x00010a3a, 0x00010a3f, 0x00010a3f,
+	0x00011001, 0x00011001, 0x00011038, 0x00011046,
+	0x00011080, 0x00011081, 0x000110b3, 0x000110b6,
+	0x000110b9, 0x000110ba, 0x0001d167, 0x0001d169,
+	0x0001d17b, 0x0001d182, 0x0001d185, 0x0001d18b,
+	0x0001d1aa, 0x0001d1ad, 0x0001d242, 0x0001d244,
+	0x000e0100, 0x000e01ef, 0x00000903, 0x00000903,
+	0x0000093b, 0x0000093b, 0x0000093e, 0x00000940,
+	0x00000949, 0x0000094c, 0x0000094e, 0x0000094f,
+	0x00000982, 0x00000983, 0x000009be, 0x000009c0,
+	0x000009c7, 0x000009c8, 0x000009cb, 0x000009cc,
+	0x000009d7, 0x000009d7, 0x00000a03, 0x00000a03,
+	0x00000a3e, 0x00000a40, 0x00000a83, 0x00000a83,
+	0x00000abe, 0x00000ac0, 0x00000ac9, 0x00000ac9,
+	0x00000acb, 0x00000acc, 0x00000b02, 0x00000b03,
+	0x00000b3e, 0x00000b3e, 0x00000b40, 0x00000b40,
+	0x00000b47, 0x00000b48, 0x00000b4b, 0x00000b4c,
+	0x00000b57, 0x00000b57, 0x00000bbe, 0x00000bbf,
+	0x00000bc1, 0x00000bc2, 0x00000bc6, 0x00000bc8,
+	0x00000bca, 0x00000bcc, 0x00000bd7, 0x00000bd7,
+	0x00000c01, 0x00000c03, 0x00000c41, 0x00000c44,
+	0x00000c82, 0x00000c83, 0x00000cbe, 0x00000cbe,
+	0x00000cc0, 0x00000cc4, 0x00000cc7, 0x00000cc8,
+	0x00000cca, 0x00000ccb, 0x00000cd5, 0x00000cd6,
+	0x00000d02, 0x00000d03, 0x00000d3e, 0x00000d40,
+	0x00000d46, 0x00000d48, 0x00000d4a, 0x00000d4c,
+	0x00000d57, 0x00000d57, 0x00000d82, 0x00000d83,
+	0x00000dcf, 0x00000dd1, 0x00000dd8, 0x00000ddf,
+	0x00000df2, 0x00000df3, 0x00000f3e, 0x00000f3f,
+	0x00000f7f, 0x00000f7f, 0x0000102b, 0x0000102c,
+	0x00001031, 0x00001031, 0x00001038, 0x00001038,
+	0x0000103b, 0x0000103c, 0x00001056, 0x00001057,
+	0x00001062, 0x00001064, 0x00001067, 0x0000106d,
+	0x00001083, 0x00001084, 0x00001087, 0x0000108c,
+	0x0000108f, 0x0000108f, 0x0000109a, 0x0000109c,
+	0x000017b6, 0x000017b6, 0x000017be, 0x000017c5,
+	0x000017c7, 0x000017c8, 0x00001923, 0x00001926,
+	0x00001929, 0x0000192b, 0x00001930, 0x00001931,
+	0x00001933, 0x00001938, 0x000019b0, 0x000019c0,
+	0x000019c8, 0x000019c9, 0x00001a19, 0x00001a1b,
+	0x00001a55, 0x00001a55, 0x00001a57, 0x00001a57,
+	0x00001a61, 0x00001a61, 0x00001a63, 0x00001a64,
+	0x00001a6d, 0x00001a72, 0x00001b04, 0x00001b04,
+	0x00001b35, 0x00001b35, 0x00001b3b, 0x00001b3b,
+	0x00001b3d, 0x00001b41, 0x00001b43, 0x00001b44,
+	0x00001b82, 0x00001b82, 0x00001ba1, 0x00001ba1,
+	0x00001ba6, 0x00001ba7, 0x00001baa, 0x00001baa,
+	0x00001be7, 0x00001be7, 0x00001bea, 0x00001bec,
+	0x00001bee, 0x00001bee, 0x00001bf2, 0x00001bf3,
+	0x00001c24, 0x00001c2b, 0x00001c34, 0x00001c35,
+	0x00001ce1, 0x00001ce1, 0x00001cf2, 0x00001cf2,
+	0x0000a823, 0x0000a824, 0x0000a827, 0x0000a827,
+	0x0000a880, 0x0000a881, 0x0000a8b4, 0x0000a8c3,
+	0x0000a952, 0x0000a953, 0x0000a983, 0x0000a983,
+	0x0000a9b4, 0x0000a9b5, 0x0000a9ba, 0x0000a9bb,
+	0x0000a9bd, 0x0000a9c0, 0x0000aa2f, 0x0000aa30,
+	0x0000aa33, 0x0000aa34, 0x0000aa4d, 0x0000aa4d,
+	0x0000aa7b, 0x0000aa7b, 0x0000abe3, 0x0000abe4,
+	0x0000abe6, 0x0000abe7, 0x0000abe9, 0x0000abea,
+	0x0000abec, 0x0000abec, 0x00011000, 0x00011000,
+	0x00011002, 0x00011002, 0x00011082, 0x00011082,
+	0x000110b0, 0x000110b2, 0x000110b7, 0x000110b8,
+	0x0001d165, 0x0001d166, 0x0001d16d, 0x0001d172,
+	0x00000488, 0x00000489, 0x000020dd, 0x000020e0,
+	0x000020e2, 0x000020e4, 0x0000a670, 0x0000a672,
+	0x00000030, 0x00000039, 0x00000660, 0x00000669,
+	0x000006f0, 0x000006f9, 0x000007c0, 0x000007c9,
+	0x00000966, 0x0000096f, 0x000009e6, 0x000009ef,
+	0x00000a66, 0x00000a6f, 0x00000ae6, 0x00000aef,
+	0x00000b66, 0x00000b6f, 0x00000be6, 0x00000bef,
+	0x00000c66, 0x00000c6f, 0x00000ce6, 0x00000cef,
+	0x00000d66, 0x00000d6f, 0x00000e50, 0x00000e59,
+	0x00000ed0, 0x00000ed9, 0x00000f20, 0x00000f29,
+	0x00001040, 0x00001049, 0x00001090, 0x00001099,
+	0x000017e0, 0x000017e9, 0x00001810, 0x00001819,
+	0x00001946, 0x0000194f, 0x000019d0, 0x000019d9,
+	0x00001a80, 0x00001a89, 0x00001a90, 0x00001a99,
+	0x00001b50, 0x00001b59, 0x00001bb0, 0x00001bb9,
+	0x00001c40, 0x00001c49, 0x00001c50, 0x00001c59,
+	0x0000a620, 0x0000a629, 0x0000a8d0, 0x0000a8d9,
+	0x0000a900, 0x0000a909, 0x0000a9d0, 0x0000a9d9,
+	0x0000aa50, 0x0000aa59, 0x0000abf0, 0x0000abf9,
+	0x0000ff10, 0x0000ff19, 0x000104a0, 0x000104a9,
+	0x00011066, 0x0001106f, 0x0001d7ce, 0x0001d7ff,
+	0x000016ee, 0x000016f0, 0x00002160, 0x00002182,
+	0x00002185, 0x00002188, 0x00003007, 0x00003007,
+	0x00003021, 0x00003029, 0x00003038, 0x0000303a,
+	0x0000a6e6, 0x0000a6ef, 0x00010140, 0x00010174,
+	0x00010341, 0x00010341, 0x0001034a, 0x0001034a,
+	0x000103d1, 0x000103d5, 0x00012400, 0x00012462,
+	0x000000b2, 0x000000b3, 0x000000b9, 0x000000b9,
+	0x000000bc, 0x000000be, 0x000009f4, 0x000009f9,
+	0x00000b72, 0x00000b77, 0x00000bf0, 0x00000bf2,
+	0x00000c78, 0x00000c7e, 0x00000d70, 0x00000d75,
+	0x00000f2a, 0x00000f33, 0x00001369, 0x0000137c,
+	0x000017f0, 0x000017f9, 0x000019da, 0x000019da,
+	0x00002070, 0x00002070, 0x00002074, 0x00002079,
+	0x00002080, 0x00002089, 0x00002150, 0x0000215f,
+	0x00002189, 0x00002189, 0x00002460, 0x0000249b,
+	0x000024ea, 0x000024ff, 0x00002776, 0x00002793,
+	0x00002cfd, 0x00002cfd, 0x00003192, 0x00003195,
+	0x00003220, 0x00003229, 0x00003251, 0x0000325f,
+	0x00003280, 0x00003289, 0x000032b1, 0x000032bf,
+	0x0000a830, 0x0000a835, 0x00010107, 0x00010133,
+	0x00010175, 0x00010178, 0x0001018a, 0x0001018a,
+	0x00010320, 0x00010323, 0x00010858, 0x0001085f,
+	0x00010916, 0x0001091b, 0x00010a40, 0x00010a47,
+	0x00010a7d, 0x00010a7e, 0x00010b58, 0x00010b5f,
+	0x00010b78, 0x00010b7f, 0x00010e60, 0x00010e7e,
+	0x00011052, 0x00011065, 0x0001d360, 0x0001d371,
+	0x0001f100, 0x0001f10a, 0x00000020, 0x00000020,
+	0x000000a0, 0x000000a0, 0x00001680, 0x00001680,
+	0x0000180e, 0x0000180e, 0x00002000, 0x0000200a,
+	0x0000202f, 0x0000202f, 0x0000205f, 0x0000205f,
+	0x00003000, 0x00003000, 0x00002028, 0x00002028,
+	0x00002029, 0x00002029, 0x00000000, 0x0000001f,
+	0x0000007f, 0x0000009f, 0x000000ad, 0x000000ad,
+	0x00000600, 0x00000603, 0x000006dd, 0x000006dd,
+	0x0000070f, 0x0000070f, 0x000017b4, 0x000017b5,
+	0x0000200b, 0x0000200f, 0x0000202a, 0x0000202e,
+	0x00002060, 0x00002064, 0x0000206a, 0x0000206f,
+	0x0000feff, 0x0000feff, 0x0000fff9, 0x0000fffb,
+	0x000110bd, 0x000110bd, 0x0001d173, 0x0001d17a,
+	0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f,
+	0x00010000, 0x0010ffff, 0x0000e000, 0x0000f8ff,
+	0x000f0000, 0x000ffffd, 0x00100000, 0x0010fffd,
+	0x00000041, 0x0000005a, 0x000000c0, 0x000000d6,
+	0x000000d8, 0x000000de, 0x00000100, 0x00000100,
+	0x00000102, 0x00000102, 0x00000104, 0x00000104,
+	0x00000106, 0x00000106, 0x00000108, 0x00000108,
+	0x0000010a, 0x0000010a, 0x0000010c, 0x0000010c,
+	0x0000010e, 0x0000010e, 0x00000110, 0x00000110,
+	0x00000112, 0x00000112, 0x00000114, 0x00000114,
+	0x00000116, 0x00000116, 0x00000118, 0x00000118,
+	0x0000011a, 0x0000011a, 0x0000011c, 0x0000011c,
+	0x0000011e, 0x0000011e, 0x00000120, 0x00000120,
+	0x00000122, 0x00000122, 0x00000124, 0x00000124,
+	0x00000126, 0x00000126, 0x00000128, 0x00000128,
+	0x0000012a, 0x0000012a, 0x0000012c, 0x0000012c,
+	0x0000012e, 0x0000012e, 0x00000130, 0x00000130,
+	0x00000132, 0x00000132, 0x00000134, 0x00000134,
+	0x00000136, 0x00000136, 0x00000139, 0x00000139,
+	0x0000013b, 0x0000013b, 0x0000013d, 0x0000013d,
+	0x0000013f, 0x0000013f, 0x00000141, 0x00000141,
+	0x00000143, 0x00000143, 0x00000145, 0x00000145,
+	0x00000147, 0x00000147, 0x0000014a, 0x0000014a,
+	0x0000014c, 0x0000014c, 0x0000014e, 0x0000014e,
+	0x00000150, 0x00000150, 0x00000152, 0x00000152,
+	0x00000154, 0x00000154, 0x00000156, 0x00000156,
+	0x00000158, 0x00000158, 0x0000015a, 0x0000015a,
+	0x0000015c, 0x0000015c, 0x0000015e, 0x0000015e,
+	0x00000160, 0x00000160, 0x00000162, 0x00000162,
+	0x00000164, 0x00000164, 0x00000166, 0x00000166,
+	0x00000168, 0x00000168, 0x0000016a, 0x0000016a,
+	0x0000016c, 0x0000016c, 0x0000016e, 0x0000016e,
+	0x00000170, 0x00000170, 0x00000172, 0x00000172,
+	0x00000174, 0x00000174, 0x00000176, 0x00000176,
+	0x00000178, 0x00000179, 0x0000017b, 0x0000017b,
+	0x0000017d, 0x0000017d, 0x00000181, 0x00000182,
+	0x00000184, 0x00000184, 0x00000186, 0x00000187,
+	0x00000189, 0x0000018b, 0x0000018e, 0x00000191,
+	0x00000193, 0x00000194, 0x00000196, 0x00000198,
+	0x0000019c, 0x0000019d, 0x0000019f, 0x000001a0,
+	0x000001a2, 0x000001a2, 0x000001a4, 0x000001a4,
+	0x000001a6, 0x000001a7, 0x000001a9, 0x000001a9,
+	0x000001ac, 0x000001ac, 0x000001ae, 0x000001af,
+	0x000001b1, 0x000001b3, 0x000001b5, 0x000001b5,
+	0x000001b7, 0x000001b8, 0x000001bc, 0x000001bc,
+	0x000001c4, 0x000001c4, 0x000001c7, 0x000001c7,
+	0x000001ca, 0x000001ca, 0x000001cd, 0x000001cd,
+	0x000001cf, 0x000001cf, 0x000001d1, 0x000001d1,
+	0x000001d3, 0x000001d3, 0x000001d5, 0x000001d5,
+	0x000001d7, 0x000001d7, 0x000001d9, 0x000001d9,
+	0x000001db, 0x000001db, 0x000001de, 0x000001de,
+	0x000001e0, 0x000001e0, 0x000001e2, 0x000001e2,
+	0x000001e4, 0x000001e4, 0x000001e6, 0x000001e6,
+	0x000001e8, 0x000001e8, 0x000001ea, 0x000001ea,
+	0x000001ec, 0x000001ec, 0x000001ee, 0x000001ee,
+	0x000001f1, 0x000001f1, 0x000001f4, 0x000001f4,
+	0x000001f6, 0x000001f8, 0x000001fa, 0x000001fa,
+	0x000001fc, 0x000001fc, 0x000001fe, 0x000001fe,
+	0x00000200, 0x00000200, 0x00000202, 0x00000202,
+	0x00000204, 0x00000204, 0x00000206, 0x00000206,
+	0x00000208, 0x00000208, 0x0000020a, 0x0000020a,
+	0x0000020c, 0x0000020c, 0x0000020e, 0x0000020e,
+	0x00000210, 0x00000210, 0x00000212, 0x00000212,
+	0x00000214, 0x00000214, 0x00000216, 0x00000216,
+	0x00000218, 0x00000218, 0x0000021a, 0x0000021a,
+	0x0000021c, 0x0000021c, 0x0000021e, 0x0000021e,
+	0x00000220, 0x00000220, 0x00000222, 0x00000222,
+	0x00000224, 0x00000224, 0x00000226, 0x00000226,
+	0x00000228, 0x00000228, 0x0000022a, 0x0000022a,
+	0x0000022c, 0x0000022c, 0x0000022e, 0x0000022e,
+	0x00000230, 0x00000230, 0x00000232, 0x00000232,
+	0x0000023a, 0x0000023b, 0x0000023d, 0x0000023e,
+	0x00000241, 0x00000241, 0x00000243, 0x00000246,
+	0x00000248, 0x00000248, 0x0000024a, 0x0000024a,
+	0x0000024c, 0x0000024c, 0x0000024e, 0x0000024e,
+	0x00000370, 0x00000370, 0x00000372, 0x00000372,
+	0x00000376, 0x00000376, 0x00000386, 0x00000386,
+	0x00000388, 0x0000038a, 0x0000038c, 0x0000038c,
+	0x0000038e, 0x0000038f, 0x00000391, 0x000003a1,
+	0x000003a3, 0x000003ab, 0x000003cf, 0x000003cf,
+	0x000003d2, 0x000003d4, 0x000003d8, 0x000003d8,
+	0x000003da, 0x000003da, 0x000003dc, 0x000003dc,
+	0x000003de, 0x000003de, 0x000003e0, 0x000003e0,
+	0x000003e2, 0x000003e2, 0x000003e4, 0x000003e4,
+	0x000003e6, 0x000003e6, 0x000003e8, 0x000003e8,
+	0x000003ea, 0x000003ea, 0x000003ec, 0x000003ec,
+	0x000003ee, 0x000003ee, 0x000003f4, 0x000003f4,
+	0x000003f7, 0x000003f7, 0x000003f9, 0x000003fa,
+	0x000003fd, 0x0000042f, 0x00000460, 0x00000460,
+	0x00000462, 0x00000462, 0x00000464, 0x00000464,
+	0x00000466, 0x00000466, 0x00000468, 0x00000468,
+	0x0000046a, 0x0000046a, 0x0000046c, 0x0000046c,
+	0x0000046e, 0x0000046e, 0x00000470, 0x00000470,
+	0x00000472, 0x00000472, 0x00000474, 0x00000474,
+	0x00000476, 0x00000476, 0x00000478, 0x00000478,
+	0x0000047a, 0x0000047a, 0x0000047c, 0x0000047c,
+	0x0000047e, 0x0000047e, 0x00000480, 0x00000480,
+	0x0000048a, 0x0000048a, 0x0000048c, 0x0000048c,
+	0x0000048e, 0x0000048e, 0x00000490, 0x00000490,
+	0x00000492, 0x00000492, 0x00000494, 0x00000494,
+	0x00000496, 0x00000496, 0x00000498, 0x00000498,
+	0x0000049a, 0x0000049a, 0x0000049c, 0x0000049c,
+	0x0000049e, 0x0000049e, 0x000004a0, 0x000004a0,
+	0x000004a2, 0x000004a2, 0x000004a4, 0x000004a4,
+	0x000004a6, 0x000004a6, 0x000004a8, 0x000004a8,
+	0x000004aa, 0x000004aa, 0x000004ac, 0x000004ac,
+	0x000004ae, 0x000004ae, 0x000004b0, 0x000004b0,
+	0x000004b2, 0x000004b2, 0x000004b4, 0x000004b4,
+	0x000004b6, 0x000004b6, 0x000004b8, 0x000004b8,
+	0x000004ba, 0x000004ba, 0x000004bc, 0x000004bc,
+	0x000004be, 0x000004be, 0x000004c0, 0x000004c1,
+	0x000004c3, 0x000004c3, 0x000004c5, 0x000004c5,
+	0x000004c7, 0x000004c7, 0x000004c9, 0x000004c9,
+	0x000004cb, 0x000004cb, 0x000004cd, 0x000004cd,
+	0x000004d0, 0x000004d0, 0x000004d2, 0x000004d2,
+	0x000004d4, 0x000004d4, 0x000004d6, 0x000004d6,
+	0x000004d8, 0x000004d8, 0x000004da, 0x000004da,
+	0x000004dc, 0x000004dc, 0x000004de, 0x000004de,
+	0x000004e0, 0x000004e0, 0x000004e2, 0x000004e2,
+	0x000004e4, 0x000004e4, 0x000004e6, 0x000004e6,
+	0x000004e8, 0x000004e8, 0x000004ea, 0x000004ea,
+	0x000004ec, 0x000004ec, 0x000004ee, 0x000004ee,
+	0x000004f0, 0x000004f0, 0x000004f2, 0x000004f2,
+	0x000004f4, 0x000004f4, 0x000004f6, 0x000004f6,
+	0x000004f8, 0x000004f8, 0x000004fa, 0x000004fa,
+	0x000004fc, 0x000004fc, 0x000004fe, 0x000004fe,
+	0x00000500, 0x00000500, 0x00000502, 0x00000502,
+	0x00000504, 0x00000504, 0x00000506, 0x00000506,
+	0x00000508, 0x00000508, 0x0000050a, 0x0000050a,
+	0x0000050c, 0x0000050c, 0x0000050e, 0x0000050e,
+	0x00000510, 0x00000510, 0x00000512, 0x00000512,
+	0x00000514, 0x00000514, 0x00000516, 0x00000516,
+	0x00000518, 0x00000518, 0x0000051a, 0x0000051a,
+	0x0000051c, 0x0000051c, 0x0000051e, 0x0000051e,
+	0x00000520, 0x00000520, 0x00000522, 0x00000522,
+	0x00000524, 0x00000524, 0x00000526, 0x00000526,
+	0x00000531, 0x00000556, 0x000010a0, 0x000010c5,
+	0x00001e00, 0x00001e00, 0x00001e02, 0x00001e02,
+	0x00001e04, 0x00001e04, 0x00001e06, 0x00001e06,
+	0x00001e08, 0x00001e08, 0x00001e0a, 0x00001e0a,
+	0x00001e0c, 0x00001e0c, 0x00001e0e, 0x00001e0e,
+	0x00001e10, 0x00001e10, 0x00001e12, 0x00001e12,
+	0x00001e14, 0x00001e14, 0x00001e16, 0x00001e16,
+	0x00001e18, 0x00001e18, 0x00001e1a, 0x00001e1a,
+	0x00001e1c, 0x00001e1c, 0x00001e1e, 0x00001e1e,
+	0x00001e20, 0x00001e20, 0x00001e22, 0x00001e22,
+	0x00001e24, 0x00001e24, 0x00001e26, 0x00001e26,
+	0x00001e28, 0x00001e28, 0x00001e2a, 0x00001e2a,
+	0x00001e2c, 0x00001e2c, 0x00001e2e, 0x00001e2e,
+	0x00001e30, 0x00001e30, 0x00001e32, 0x00001e32,
+	0x00001e34, 0x00001e34, 0x00001e36, 0x00001e36,
+	0x00001e38, 0x00001e38, 0x00001e3a, 0x00001e3a,
+	0x00001e3c, 0x00001e3c, 0x00001e3e, 0x00001e3e,
+	0x00001e40, 0x00001e40, 0x00001e42, 0x00001e42,
+	0x00001e44, 0x00001e44, 0x00001e46, 0x00001e46,
+	0x00001e48, 0x00001e48, 0x00001e4a, 0x00001e4a,
+	0x00001e4c, 0x00001e4c, 0x00001e4e, 0x00001e4e,
+	0x00001e50, 0x00001e50, 0x00001e52, 0x00001e52,
+	0x00001e54, 0x00001e54, 0x00001e56, 0x00001e56,
+	0x00001e58, 0x00001e58, 0x00001e5a, 0x00001e5a,
+	0x00001e5c, 0x00001e5c, 0x00001e5e, 0x00001e5e,
+	0x00001e60, 0x00001e60, 0x00001e62, 0x00001e62,
+	0x00001e64, 0x00001e64, 0x00001e66, 0x00001e66,
+	0x00001e68, 0x00001e68, 0x00001e6a, 0x00001e6a,
+	0x00001e6c, 0x00001e6c, 0x00001e6e, 0x00001e6e,
+	0x00001e70, 0x00001e70, 0x00001e72, 0x00001e72,
+	0x00001e74, 0x00001e74, 0x00001e76, 0x00001e76,
+	0x00001e78, 0x00001e78, 0x00001e7a, 0x00001e7a,
+	0x00001e7c, 0x00001e7c, 0x00001e7e, 0x00001e7e,
+	0x00001e80, 0x00001e80, 0x00001e82, 0x00001e82,
+	0x00001e84, 0x00001e84, 0x00001e86, 0x00001e86,
+	0x00001e88, 0x00001e88, 0x00001e8a, 0x00001e8a,
+	0x00001e8c, 0x00001e8c, 0x00001e8e, 0x00001e8e,
+	0x00001e90, 0x00001e90, 0x00001e92, 0x00001e92,
+	0x00001e94, 0x00001e94, 0x00001e9e, 0x00001e9e,
+	0x00001ea0, 0x00001ea0, 0x00001ea2, 0x00001ea2,
+	0x00001ea4, 0x00001ea4, 0x00001ea6, 0x00001ea6,
+	0x00001ea8, 0x00001ea8, 0x00001eaa, 0x00001eaa,
+	0x00001eac, 0x00001eac, 0x00001eae, 0x00001eae,
+	0x00001eb0, 0x00001eb0, 0x00001eb2, 0x00001eb2,
+	0x00001eb4, 0x00001eb4, 0x00001eb6, 0x00001eb6,
+	0x00001eb8, 0x00001eb8, 0x00001eba, 0x00001eba,
+	0x00001ebc, 0x00001ebc, 0x00001ebe, 0x00001ebe,
+	0x00001ec0, 0x00001ec0, 0x00001ec2, 0x00001ec2,
+	0x00001ec4, 0x00001ec4, 0x00001ec6, 0x00001ec6,
+	0x00001ec8, 0x00001ec8, 0x00001eca, 0x00001eca,
+	0x00001ecc, 0x00001ecc, 0x00001ece, 0x00001ece,
+	0x00001ed0, 0x00001ed0, 0x00001ed2, 0x00001ed2,
+	0x00001ed4, 0x00001ed4, 0x00001ed6, 0x00001ed6,
+	0x00001ed8, 0x00001ed8, 0x00001eda, 0x00001eda,
+	0x00001edc, 0x00001edc, 0x00001ede, 0x00001ede,
+	0x00001ee0, 0x00001ee0, 0x00001ee2, 0x00001ee2,
+	0x00001ee4, 0x00001ee4, 0x00001ee6, 0x00001ee6,
+	0x00001ee8, 0x00001ee8, 0x00001eea, 0x00001eea,
+	0x00001eec, 0x00001eec, 0x00001eee, 0x00001eee,
+	0x00001ef0, 0x00001ef0, 0x00001ef2, 0x00001ef2,
+	0x00001ef4, 0x00001ef4, 0x00001ef6, 0x00001ef6,
+	0x00001ef8, 0x00001ef8, 0x00001efa, 0x00001efa,
+	0x00001efc, 0x00001efc, 0x00001efe, 0x00001efe,
+	0x00001f08, 0x00001f0f, 0x00001f18, 0x00001f1d,
+	0x00001f28, 0x00001f2f, 0x00001f38, 0x00001f3f,
+	0x00001f48, 0x00001f4d, 0x00001f59, 0x00001f59,
+	0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d,
+	0x00001f5f, 0x00001f5f, 0x00001f68, 0x00001f6f,
+	0x00001fb8, 0x00001fbb, 0x00001fc8, 0x00001fcb,
+	0x00001fd8, 0x00001fdb, 0x00001fe8, 0x00001fec,
+	0x00001ff8, 0x00001ffb, 0x00002102, 0x00002102,
+	0x00002107, 0x00002107, 0x0000210b, 0x0000210d,
+	0x00002110, 0x00002112, 0x00002115, 0x00002115,
+	0x00002119, 0x0000211d, 0x00002124, 0x00002124,
+	0x00002126, 0x00002126, 0x00002128, 0x00002128,
+	0x0000212a, 0x0000212d, 0x00002130, 0x00002133,
+	0x0000213e, 0x0000213f, 0x00002145, 0x00002145,
+	0x00002183, 0x00002183, 0x00002c00, 0x00002c2e,
+	0x00002c60, 0x00002c60, 0x00002c62, 0x00002c64,
+	0x00002c67, 0x00002c67, 0x00002c69, 0x00002c69,
+	0x00002c6b, 0x00002c6b, 0x00002c6d, 0x00002c70,
+	0x00002c72, 0x00002c72, 0x00002c75, 0x00002c75,
+	0x00002c7e, 0x00002c80, 0x00002c82, 0x00002c82,
+	0x00002c84, 0x00002c84, 0x00002c86, 0x00002c86,
+	0x00002c88, 0x00002c88, 0x00002c8a, 0x00002c8a,
+	0x00002c8c, 0x00002c8c, 0x00002c8e, 0x00002c8e,
+	0x00002c90, 0x00002c90, 0x00002c92, 0x00002c92,
+	0x00002c94, 0x00002c94, 0x00002c96, 0x00002c96,
+	0x00002c98, 0x00002c98, 0x00002c9a, 0x00002c9a,
+	0x00002c9c, 0x00002c9c, 0x00002c9e, 0x00002c9e,
+	0x00002ca0, 0x00002ca0, 0x00002ca2, 0x00002ca2,
+	0x00002ca4, 0x00002ca4, 0x00002ca6, 0x00002ca6,
+	0x00002ca8, 0x00002ca8, 0x00002caa, 0x00002caa,
+	0x00002cac, 0x00002cac, 0x00002cae, 0x00002cae,
+	0x00002cb0, 0x00002cb0, 0x00002cb2, 0x00002cb2,
+	0x00002cb4, 0x00002cb4, 0x00002cb6, 0x00002cb6,
+	0x00002cb8, 0x00002cb8, 0x00002cba, 0x00002cba,
+	0x00002cbc, 0x00002cbc, 0x00002cbe, 0x00002cbe,
+	0x00002cc0, 0x00002cc0, 0x00002cc2, 0x00002cc2,
+	0x00002cc4, 0x00002cc4, 0x00002cc6, 0x00002cc6,
+	0x00002cc8, 0x00002cc8, 0x00002cca, 0x00002cca,
+	0x00002ccc, 0x00002ccc, 0x00002cce, 0x00002cce,
+	0x00002cd0, 0x00002cd0, 0x00002cd2, 0x00002cd2,
+	0x00002cd4, 0x00002cd4, 0x00002cd6, 0x00002cd6,
+	0x00002cd8, 0x00002cd8, 0x00002cda, 0x00002cda,
+	0x00002cdc, 0x00002cdc, 0x00002cde, 0x00002cde,
+	0x00002ce0, 0x00002ce0, 0x00002ce2, 0x00002ce2,
+	0x00002ceb, 0x00002ceb, 0x00002ced, 0x00002ced,
+	0x0000a640, 0x0000a640, 0x0000a642, 0x0000a642,
+	0x0000a644, 0x0000a644, 0x0000a646, 0x0000a646,
+	0x0000a648, 0x0000a648, 0x0000a64a, 0x0000a64a,
+	0x0000a64c, 0x0000a64c, 0x0000a64e, 0x0000a64e,
+	0x0000a650, 0x0000a650, 0x0000a652, 0x0000a652,
+	0x0000a654, 0x0000a654, 0x0000a656, 0x0000a656,
+	0x0000a658, 0x0000a658, 0x0000a65a, 0x0000a65a,
+	0x0000a65c, 0x0000a65c, 0x0000a65e, 0x0000a65e,
+	0x0000a660, 0x0000a660, 0x0000a662, 0x0000a662,
+	0x0000a664, 0x0000a664, 0x0000a666, 0x0000a666,
+	0x0000a668, 0x0000a668, 0x0000a66a, 0x0000a66a,
+	0x0000a66c, 0x0000a66c, 0x0000a680, 0x0000a680,
+	0x0000a682, 0x0000a682, 0x0000a684, 0x0000a684,
+	0x0000a686, 0x0000a686, 0x0000a688, 0x0000a688,
+	0x0000a68a, 0x0000a68a, 0x0000a68c, 0x0000a68c,
+	0x0000a68e, 0x0000a68e, 0x0000a690, 0x0000a690,
+	0x0000a692, 0x0000a692, 0x0000a694, 0x0000a694,
+	0x0000a696, 0x0000a696, 0x0000a722, 0x0000a722,
+	0x0000a724, 0x0000a724, 0x0000a726, 0x0000a726,
+	0x0000a728, 0x0000a728, 0x0000a72a, 0x0000a72a,
+	0x0000a72c, 0x0000a72c, 0x0000a72e, 0x0000a72e,
+	0x0000a732, 0x0000a732, 0x0000a734, 0x0000a734,
+	0x0000a736, 0x0000a736, 0x0000a738, 0x0000a738,
+	0x0000a73a, 0x0000a73a, 0x0000a73c, 0x0000a73c,
+	0x0000a73e, 0x0000a73e, 0x0000a740, 0x0000a740,
+	0x0000a742, 0x0000a742, 0x0000a744, 0x0000a744,
+	0x0000a746, 0x0000a746, 0x0000a748, 0x0000a748,
+	0x0000a74a, 0x0000a74a, 0x0000a74c, 0x0000a74c,
+	0x0000a74e, 0x0000a74e, 0x0000a750, 0x0000a750,
+	0x0000a752, 0x0000a752, 0x0000a754, 0x0000a754,
+	0x0000a756, 0x0000a756, 0x0000a758, 0x0000a758,
+	0x0000a75a, 0x0000a75a, 0x0000a75c, 0x0000a75c,
+	0x0000a75e, 0x0000a75e, 0x0000a760, 0x0000a760,
+	0x0000a762, 0x0000a762, 0x0000a764, 0x0000a764,
+	0x0000a766, 0x0000a766, 0x0000a768, 0x0000a768,
+	0x0000a76a, 0x0000a76a, 0x0000a76c, 0x0000a76c,
+	0x0000a76e, 0x0000a76e, 0x0000a779, 0x0000a779,
+	0x0000a77b, 0x0000a77b, 0x0000a77d, 0x0000a77e,
+	0x0000a780, 0x0000a780, 0x0000a782, 0x0000a782,
+	0x0000a784, 0x0000a784, 0x0000a786, 0x0000a786,
+	0x0000a78b, 0x0000a78b, 0x0000a78d, 0x0000a78d,
+	0x0000a790, 0x0000a790, 0x0000a7a0, 0x0000a7a0,
+	0x0000a7a2, 0x0000a7a2, 0x0000a7a4, 0x0000a7a4,
+	0x0000a7a6, 0x0000a7a6, 0x0000a7a8, 0x0000a7a8,
+	0x0000ff21, 0x0000ff3a, 0x00010400, 0x00010427,
+	0x0001d400, 0x0001d419, 0x0001d434, 0x0001d44d,
+	0x0001d468, 0x0001d481, 0x0001d49c, 0x0001d49c,
+	0x0001d49e, 0x0001d49f, 0x0001d4a2, 0x0001d4a2,
+	0x0001d4a5, 0x0001d4a6, 0x0001d4a9, 0x0001d4ac,
+	0x0001d4ae, 0x0001d4b5, 0x0001d4d0, 0x0001d4e9,
+	0x0001d504, 0x0001d505, 0x0001d507, 0x0001d50a,
+	0x0001d50d, 0x0001d514, 0x0001d516, 0x0001d51c,
+	0x0001d538, 0x0001d539, 0x0001d53b, 0x0001d53e,
+	0x0001d540, 0x0001d544, 0x0001d546, 0x0001d546,
+	0x0001d54a, 0x0001d550, 0x0001d56c, 0x0001d585,
+	0x0001d5a0, 0x0001d5b9, 0x0001d5d4, 0x0001d5ed,
+	0x0001d608, 0x0001d621, 0x0001d63c, 0x0001d655,
+	0x0001d670, 0x0001d689, 0x0001d6a8, 0x0001d6c0,
+	0x0001d6e2, 0x0001d6fa, 0x0001d71c, 0x0001d734,
+	0x0001d756, 0x0001d76e, 0x0001d790, 0x0001d7a8,
+	0x0001d7ca, 0x0001d7ca, 0x00000061, 0x0000007a,
+	0x000000aa, 0x000000aa, 0x000000b5, 0x000000b5,
+	0x000000ba, 0x000000ba, 0x000000df, 0x000000f6,
+	0x000000f8, 0x000000ff, 0x00000101, 0x00000101,
+	0x00000103, 0x00000103, 0x00000105, 0x00000105,
+	0x00000107, 0x00000107, 0x00000109, 0x00000109,
+	0x0000010b, 0x0000010b, 0x0000010d, 0x0000010d,
+	0x0000010f, 0x0000010f, 0x00000111, 0x00000111,
+	0x00000113, 0x00000113, 0x00000115, 0x00000115,
+	0x00000117, 0x00000117, 0x00000119, 0x00000119,
+	0x0000011b, 0x0000011b, 0x0000011d, 0x0000011d,
+	0x0000011f, 0x0000011f, 0x00000121, 0x00000121,
+	0x00000123, 0x00000123, 0x00000125, 0x00000125,
+	0x00000127, 0x00000127, 0x00000129, 0x00000129,
+	0x0000012b, 0x0000012b, 0x0000012d, 0x0000012d,
+	0x0000012f, 0x0000012f, 0x00000131, 0x00000131,
+	0x00000133, 0x00000133, 0x00000135, 0x00000135,
+	0x00000137, 0x00000138, 0x0000013a, 0x0000013a,
+	0x0000013c, 0x0000013c, 0x0000013e, 0x0000013e,
+	0x00000140, 0x00000140, 0x00000142, 0x00000142,
+	0x00000144, 0x00000144, 0x00000146, 0x00000146,
+	0x00000148, 0x00000149, 0x0000014b, 0x0000014b,
+	0x0000014d, 0x0000014d, 0x0000014f, 0x0000014f,
+	0x00000151, 0x00000151, 0x00000153, 0x00000153,
+	0x00000155, 0x00000155, 0x00000157, 0x00000157,
+	0x00000159, 0x00000159, 0x0000015b, 0x0000015b,
+	0x0000015d, 0x0000015d, 0x0000015f, 0x0000015f,
+	0x00000161, 0x00000161, 0x00000163, 0x00000163,
+	0x00000165, 0x00000165, 0x00000167, 0x00000167,
+	0x00000169, 0x00000169, 0x0000016b, 0x0000016b,
+	0x0000016d, 0x0000016d, 0x0000016f, 0x0000016f,
+	0x00000171, 0x00000171, 0x00000173, 0x00000173,
+	0x00000175, 0x00000175, 0x00000177, 0x00000177,
+	0x0000017a, 0x0000017a, 0x0000017c, 0x0000017c,
+	0x0000017e, 0x00000180, 0x00000183, 0x00000183,
+	0x00000185, 0x00000185, 0x00000188, 0x00000188,
+	0x0000018c, 0x0000018d, 0x00000192, 0x00000192,
+	0x00000195, 0x00000195, 0x00000199, 0x0000019b,
+	0x0000019e, 0x0000019e, 0x000001a1, 0x000001a1,
+	0x000001a3, 0x000001a3, 0x000001a5, 0x000001a5,
+	0x000001a8, 0x000001a8, 0x000001aa, 0x000001ab,
+	0x000001ad, 0x000001ad, 0x000001b0, 0x000001b0,
+	0x000001b4, 0x000001b4, 0x000001b6, 0x000001b6,
+	0x000001b9, 0x000001ba, 0x000001bd, 0x000001bf,
+	0x000001c6, 0x000001c6, 0x000001c9, 0x000001c9,
+	0x000001cc, 0x000001cc, 0x000001ce, 0x000001ce,
+	0x000001d0, 0x000001d0, 0x000001d2, 0x000001d2,
+	0x000001d4, 0x000001d4, 0x000001d6, 0x000001d6,
+	0x000001d8, 0x000001d8, 0x000001da, 0x000001da,
+	0x000001dc, 0x000001dd, 0x000001df, 0x000001df,
+	0x000001e1, 0x000001e1, 0x000001e3, 0x000001e3,
+	0x000001e5, 0x000001e5, 0x000001e7, 0x000001e7,
+	0x000001e9, 0x000001e9, 0x000001eb, 0x000001eb,
+	0x000001ed, 0x000001ed, 0x000001ef, 0x000001f0,
+	0x000001f3, 0x000001f3, 0x000001f5, 0x000001f5,
+	0x000001f9, 0x000001f9, 0x000001fb, 0x000001fb,
+	0x000001fd, 0x000001fd, 0x000001ff, 0x000001ff,
+	0x00000201, 0x00000201, 0x00000203, 0x00000203,
+	0x00000205, 0x00000205, 0x00000207, 0x00000207,
+	0x00000209, 0x00000209, 0x0000020b, 0x0000020b,
+	0x0000020d, 0x0000020d, 0x0000020f, 0x0000020f,
+	0x00000211, 0x00000211, 0x00000213, 0x00000213,
+	0x00000215, 0x00000215, 0x00000217, 0x00000217,
+	0x00000219, 0x00000219, 0x0000021b, 0x0000021b,
+	0x0000021d, 0x0000021d, 0x0000021f, 0x0000021f,
+	0x00000221, 0x00000221, 0x00000223, 0x00000223,
+	0x00000225, 0x00000225, 0x00000227, 0x00000227,
+	0x00000229, 0x00000229, 0x0000022b, 0x0000022b,
+	0x0000022d, 0x0000022d, 0x0000022f, 0x0000022f,
+	0x00000231, 0x00000231, 0x00000233, 0x00000239,
+	0x0000023c, 0x0000023c, 0x0000023f, 0x00000240,
+	0x00000242, 0x00000242, 0x00000247, 0x00000247,
+	0x00000249, 0x00000249, 0x0000024b, 0x0000024b,
+	0x0000024d, 0x0000024d, 0x0000024f, 0x00000293,
+	0x00000295, 0x000002af, 0x00000371, 0x00000371,
+	0x00000373, 0x00000373, 0x00000377, 0x00000377,
+	0x0000037b, 0x0000037d, 0x00000390, 0x00000390,
+	0x000003ac, 0x000003ce, 0x000003d0, 0x000003d1,
+	0x000003d5, 0x000003d7, 0x000003d9, 0x000003d9,
+	0x000003db, 0x000003db, 0x000003dd, 0x000003dd,
+	0x000003df, 0x000003df, 0x000003e1, 0x000003e1,
+	0x000003e3, 0x000003e3, 0x000003e5, 0x000003e5,
+	0x000003e7, 0x000003e7, 0x000003e9, 0x000003e9,
+	0x000003eb, 0x000003eb, 0x000003ed, 0x000003ed,
+	0x000003ef, 0x000003f3, 0x000003f5, 0x000003f5,
+	0x000003f8, 0x000003f8, 0x000003fb, 0x000003fc,
+	0x00000430, 0x0000045f, 0x00000461, 0x00000461,
+	0x00000463, 0x00000463, 0x00000465, 0x00000465,
+	0x00000467, 0x00000467, 0x00000469, 0x00000469,
+	0x0000046b, 0x0000046b, 0x0000046d, 0x0000046d,
+	0x0000046f, 0x0000046f, 0x00000471, 0x00000471,
+	0x00000473, 0x00000473, 0x00000475, 0x00000475,
+	0x00000477, 0x00000477, 0x00000479, 0x00000479,
+	0x0000047b, 0x0000047b, 0x0000047d, 0x0000047d,
+	0x0000047f, 0x0000047f, 0x00000481, 0x00000481,
+	0x0000048b, 0x0000048b, 0x0000048d, 0x0000048d,
+	0x0000048f, 0x0000048f, 0x00000491, 0x00000491,
+	0x00000493, 0x00000493, 0x00000495, 0x00000495,
+	0x00000497, 0x00000497, 0x00000499, 0x00000499,
+	0x0000049b, 0x0000049b, 0x0000049d, 0x0000049d,
+	0x0000049f, 0x0000049f, 0x000004a1, 0x000004a1,
+	0x000004a3, 0x000004a3, 0x000004a5, 0x000004a5,
+	0x000004a7, 0x000004a7, 0x000004a9, 0x000004a9,
+	0x000004ab, 0x000004ab, 0x000004ad, 0x000004ad,
+	0x000004af, 0x000004af, 0x000004b1, 0x000004b1,
+	0x000004b3, 0x000004b3, 0x000004b5, 0x000004b5,
+	0x000004b7, 0x000004b7, 0x000004b9, 0x000004b9,
+	0x000004bb, 0x000004bb, 0x000004bd, 0x000004bd,
+	0x000004bf, 0x000004bf, 0x000004c2, 0x000004c2,
+	0x000004c4, 0x000004c4, 0x000004c6, 0x000004c6,
+	0x000004c8, 0x000004c8, 0x000004ca, 0x000004ca,
+	0x000004cc, 0x000004cc, 0x000004ce, 0x000004cf,
+	0x000004d1, 0x000004d1, 0x000004d3, 0x000004d3,
+	0x000004d5, 0x000004d5, 0x000004d7, 0x000004d7,
+	0x000004d9, 0x000004d9, 0x000004db, 0x000004db,
+	0x000004dd, 0x000004dd, 0x000004df, 0x000004df,
+	0x000004e1, 0x000004e1, 0x000004e3, 0x000004e3,
+	0x000004e5, 0x000004e5, 0x000004e7, 0x000004e7,
+	0x000004e9, 0x000004e9, 0x000004eb, 0x000004eb,
+	0x000004ed, 0x000004ed, 0x000004ef, 0x000004ef,
+	0x000004f1, 0x000004f1, 0x000004f3, 0x000004f3,
+	0x000004f5, 0x000004f5, 0x000004f7, 0x000004f7,
+	0x000004f9, 0x000004f9, 0x000004fb, 0x000004fb,
+	0x000004fd, 0x000004fd, 0x000004ff, 0x000004ff,
+	0x00000501, 0x00000501, 0x00000503, 0x00000503,
+	0x00000505, 0x00000505, 0x00000507, 0x00000507,
+	0x00000509, 0x00000509, 0x0000050b, 0x0000050b,
+	0x0000050d, 0x0000050d, 0x0000050f, 0x0000050f,
+	0x00000511, 0x00000511, 0x00000513, 0x00000513,
+	0x00000515, 0x00000515, 0x00000517, 0x00000517,
+	0x00000519, 0x00000519, 0x0000051b, 0x0000051b,
+	0x0000051d, 0x0000051d, 0x0000051f, 0x0000051f,
+	0x00000521, 0x00000521, 0x00000523, 0x00000523,
+	0x00000525, 0x00000525, 0x00000527, 0x00000527,
+	0x00000561, 0x00000587, 0x00001d00, 0x00001d2b,
+	0x00001d62, 0x00001d77, 0x00001d79, 0x00001d9a,
+	0x00001e01, 0x00001e01, 0x00001e03, 0x00001e03,
+	0x00001e05, 0x00001e05, 0x00001e07, 0x00001e07,
+	0x00001e09, 0x00001e09, 0x00001e0b, 0x00001e0b,
+	0x00001e0d, 0x00001e0d, 0x00001e0f, 0x00001e0f,
+	0x00001e11, 0x00001e11, 0x00001e13, 0x00001e13,
+	0x00001e15, 0x00001e15, 0x00001e17, 0x00001e17,
+	0x00001e19, 0x00001e19, 0x00001e1b, 0x00001e1b,
+	0x00001e1d, 0x00001e1d, 0x00001e1f, 0x00001e1f,
+	0x00001e21, 0x00001e21, 0x00001e23, 0x00001e23,
+	0x00001e25, 0x00001e25, 0x00001e27, 0x00001e27,
+	0x00001e29, 0x00001e29, 0x00001e2b, 0x00001e2b,
+	0x00001e2d, 0x00001e2d, 0x00001e2f, 0x00001e2f,
+	0x00001e31, 0x00001e31, 0x00001e33, 0x00001e33,
+	0x00001e35, 0x00001e35, 0x00001e37, 0x00001e37,
+	0x00001e39, 0x00001e39, 0x00001e3b, 0x00001e3b,
+	0x00001e3d, 0x00001e3d, 0x00001e3f, 0x00001e3f,
+	0x00001e41, 0x00001e41, 0x00001e43, 0x00001e43,
+	0x00001e45, 0x00001e45, 0x00001e47, 0x00001e47,
+	0x00001e49, 0x00001e49, 0x00001e4b, 0x00001e4b,
+	0x00001e4d, 0x00001e4d, 0x00001e4f, 0x00001e4f,
+	0x00001e51, 0x00001e51, 0x00001e53, 0x00001e53,
+	0x00001e55, 0x00001e55, 0x00001e57, 0x00001e57,
+	0x00001e59, 0x00001e59, 0x00001e5b, 0x00001e5b,
+	0x00001e5d, 0x00001e5d, 0x00001e5f, 0x00001e5f,
+	0x00001e61, 0x00001e61, 0x00001e63, 0x00001e63,
+	0x00001e65, 0x00001e65, 0x00001e67, 0x00001e67,
+	0x00001e69, 0x00001e69, 0x00001e6b, 0x00001e6b,
+	0x00001e6d, 0x00001e6d, 0x00001e6f, 0x00001e6f,
+	0x00001e71, 0x00001e71, 0x00001e73, 0x00001e73,
+	0x00001e75, 0x00001e75, 0x00001e77, 0x00001e77,
+	0x00001e79, 0x00001e79, 0x00001e7b, 0x00001e7b,
+	0x00001e7d, 0x00001e7d, 0x00001e7f, 0x00001e7f,
+	0x00001e81, 0x00001e81, 0x00001e83, 0x00001e83,
+	0x00001e85, 0x00001e85, 0x00001e87, 0x00001e87,
+	0x00001e89, 0x00001e89, 0x00001e8b, 0x00001e8b,
+	0x00001e8d, 0x00001e8d, 0x00001e8f, 0x00001e8f,
+	0x00001e91, 0x00001e91, 0x00001e93, 0x00001e93,
+	0x00001e95, 0x00001e9d, 0x00001e9f, 0x00001e9f,
+	0x00001ea1, 0x00001ea1, 0x00001ea3, 0x00001ea3,
+	0x00001ea5, 0x00001ea5, 0x00001ea7, 0x00001ea7,
+	0x00001ea9, 0x00001ea9, 0x00001eab, 0x00001eab,
+	0x00001ead, 0x00001ead, 0x00001eaf, 0x00001eaf,
+	0x00001eb1, 0x00001eb1, 0x00001eb3, 0x00001eb3,
+	0x00001eb5, 0x00001eb5, 0x00001eb7, 0x00001eb7,
+	0x00001eb9, 0x00001eb9, 0x00001ebb, 0x00001ebb,
+	0x00001ebd, 0x00001ebd, 0x00001ebf, 0x00001ebf,
+	0x00001ec1, 0x00001ec1, 0x00001ec3, 0x00001ec3,
+	0x00001ec5, 0x00001ec5, 0x00001ec7, 0x00001ec7,
+	0x00001ec9, 0x00001ec9, 0x00001ecb, 0x00001ecb,
+	0x00001ecd, 0x00001ecd, 0x00001ecf, 0x00001ecf,
+	0x00001ed1, 0x00001ed1, 0x00001ed3, 0x00001ed3,
+	0x00001ed5, 0x00001ed5, 0x00001ed7, 0x00001ed7,
+	0x00001ed9, 0x00001ed9, 0x00001edb, 0x00001edb,
+	0x00001edd, 0x00001edd, 0x00001edf, 0x00001edf,
+	0x00001ee1, 0x00001ee1, 0x00001ee3, 0x00001ee3,
+	0x00001ee5, 0x00001ee5, 0x00001ee7, 0x00001ee7,
+	0x00001ee9, 0x00001ee9, 0x00001eeb, 0x00001eeb,
+	0x00001eed, 0x00001eed, 0x00001eef, 0x00001eef,
+	0x00001ef1, 0x00001ef1, 0x00001ef3, 0x00001ef3,
+	0x00001ef5, 0x00001ef5, 0x00001ef7, 0x00001ef7,
+	0x00001ef9, 0x00001ef9, 0x00001efb, 0x00001efb,
+	0x00001efd, 0x00001efd, 0x00001eff, 0x00001f07,
+	0x00001f10, 0x00001f15, 0x00001f20, 0x00001f27,
+	0x00001f30, 0x00001f37, 0x00001f40, 0x00001f45,
+	0x00001f50, 0x00001f57, 0x00001f60, 0x00001f67,
+	0x00001f70, 0x00001f7d, 0x00001f80, 0x00001f87,
+	0x00001f90, 0x00001f97, 0x00001fa0, 0x00001fa7,
+	0x00001fb0, 0x00001fb4, 0x00001fb6, 0x00001fb7,
+	0x00001fbe, 0x00001fbe, 0x00001fc2, 0x00001fc4,
+	0x00001fc6, 0x00001fc7, 0x00001fd0, 0x00001fd3,
+	0x00001fd6, 0x00001fd7, 0x00001fe0, 0x00001fe7,
+	0x00001ff2, 0x00001ff4, 0x00001ff6, 0x00001ff7,
+	0x0000210a, 0x0000210a, 0x0000210e, 0x0000210f,
+	0x00002113, 0x00002113, 0x0000212f, 0x0000212f,
+	0x00002134, 0x00002134, 0x00002139, 0x00002139,
+	0x0000213c, 0x0000213d, 0x00002146, 0x00002149,
+	0x0000214e, 0x0000214e, 0x00002184, 0x00002184,
+	0x00002c30, 0x00002c5e, 0x00002c61, 0x00002c61,
+	0x00002c65, 0x00002c66, 0x00002c68, 0x00002c68,
+	0x00002c6a, 0x00002c6a, 0x00002c6c, 0x00002c6c,
+	0x00002c71, 0x00002c71, 0x00002c73, 0x00002c74,
+	0x00002c76, 0x00002c7c, 0x00002c81, 0x00002c81,
+	0x00002c83, 0x00002c83, 0x00002c85, 0x00002c85,
+	0x00002c87, 0x00002c87, 0x00002c89, 0x00002c89,
+	0x00002c8b, 0x00002c8b, 0x00002c8d, 0x00002c8d,
+	0x00002c8f, 0x00002c8f, 0x00002c91, 0x00002c91,
+	0x00002c93, 0x00002c93, 0x00002c95, 0x00002c95,
+	0x00002c97, 0x00002c97, 0x00002c99, 0x00002c99,
+	0x00002c9b, 0x00002c9b, 0x00002c9d, 0x00002c9d,
+	0x00002c9f, 0x00002c9f, 0x00002ca1, 0x00002ca1,
+	0x00002ca3, 0x00002ca3, 0x00002ca5, 0x00002ca5,
+	0x00002ca7, 0x00002ca7, 0x00002ca9, 0x00002ca9,
+	0x00002cab, 0x00002cab, 0x00002cad, 0x00002cad,
+	0x00002caf, 0x00002caf, 0x00002cb1, 0x00002cb1,
+	0x00002cb3, 0x00002cb3, 0x00002cb5, 0x00002cb5,
+	0x00002cb7, 0x00002cb7, 0x00002cb9, 0x00002cb9,
+	0x00002cbb, 0x00002cbb, 0x00002cbd, 0x00002cbd,
+	0x00002cbf, 0x00002cbf, 0x00002cc1, 0x00002cc1,
+	0x00002cc3, 0x00002cc3, 0x00002cc5, 0x00002cc5,
+	0x00002cc7, 0x00002cc7, 0x00002cc9, 0x00002cc9,
+	0x00002ccb, 0x00002ccb, 0x00002ccd, 0x00002ccd,
+	0x00002ccf, 0x00002ccf, 0x00002cd1, 0x00002cd1,
+	0x00002cd3, 0x00002cd3, 0x00002cd5, 0x00002cd5,
+	0x00002cd7, 0x00002cd7, 0x00002cd9, 0x00002cd9,
+	0x00002cdb, 0x00002cdb, 0x00002cdd, 0x00002cdd,
+	0x00002cdf, 0x00002cdf, 0x00002ce1, 0x00002ce1,
+	0x00002ce3, 0x00002ce4, 0x00002cec, 0x00002cec,
+	0x00002cee, 0x00002cee, 0x00002d00, 0x00002d25,
+	0x0000a641, 0x0000a641, 0x0000a643, 0x0000a643,
+	0x0000a645, 0x0000a645, 0x0000a647, 0x0000a647,
+	0x0000a649, 0x0000a649, 0x0000a64b, 0x0000a64b,
+	0x0000a64d, 0x0000a64d, 0x0000a64f, 0x0000a64f,
+	0x0000a651, 0x0000a651, 0x0000a653, 0x0000a653,
+	0x0000a655, 0x0000a655, 0x0000a657, 0x0000a657,
+	0x0000a659, 0x0000a659, 0x0000a65b, 0x0000a65b,
+	0x0000a65d, 0x0000a65d, 0x0000a65f, 0x0000a65f,
+	0x0000a661, 0x0000a661, 0x0000a663, 0x0000a663,
+	0x0000a665, 0x0000a665, 0x0000a667, 0x0000a667,
+	0x0000a669, 0x0000a669, 0x0000a66b, 0x0000a66b,
+	0x0000a66d, 0x0000a66d, 0x0000a681, 0x0000a681,
+	0x0000a683, 0x0000a683, 0x0000a685, 0x0000a685,
+	0x0000a687, 0x0000a687, 0x0000a689, 0x0000a689,
+	0x0000a68b, 0x0000a68b, 0x0000a68d, 0x0000a68d,
+	0x0000a68f, 0x0000a68f, 0x0000a691, 0x0000a691,
+	0x0000a693, 0x0000a693, 0x0000a695, 0x0000a695,
+	0x0000a697, 0x0000a697, 0x0000a723, 0x0000a723,
+	0x0000a725, 0x0000a725, 0x0000a727, 0x0000a727,
+	0x0000a729, 0x0000a729, 0x0000a72b, 0x0000a72b,
+	0x0000a72d, 0x0000a72d, 0x0000a72f, 0x0000a731,
+	0x0000a733, 0x0000a733, 0x0000a735, 0x0000a735,
+	0x0000a737, 0x0000a737, 0x0000a739, 0x0000a739,
+	0x0000a73b, 0x0000a73b, 0x0000a73d, 0x0000a73d,
+	0x0000a73f, 0x0000a73f, 0x0000a741, 0x0000a741,
+	0x0000a743, 0x0000a743, 0x0000a745, 0x0000a745,
+	0x0000a747, 0x0000a747, 0x0000a749, 0x0000a749,
+	0x0000a74b, 0x0000a74b, 0x0000a74d, 0x0000a74d,
+	0x0000a74f, 0x0000a74f, 0x0000a751, 0x0000a751,
+	0x0000a753, 0x0000a753, 0x0000a755, 0x0000a755,
+	0x0000a757, 0x0000a757, 0x0000a759, 0x0000a759,
+	0x0000a75b, 0x0000a75b, 0x0000a75d, 0x0000a75d,
+	0x0000a75f, 0x0000a75f, 0x0000a761, 0x0000a761,
+	0x0000a763, 0x0000a763, 0x0000a765, 0x0000a765,
+	0x0000a767, 0x0000a767, 0x0000a769, 0x0000a769,
+	0x0000a76b, 0x0000a76b, 0x0000a76d, 0x0000a76d,
+	0x0000a76f, 0x0000a76f, 0x0000a771, 0x0000a778,
+	0x0000a77a, 0x0000a77a, 0x0000a77c, 0x0000a77c,
+	0x0000a77f, 0x0000a77f, 0x0000a781, 0x0000a781,
+	0x0000a783, 0x0000a783, 0x0000a785, 0x0000a785,
+	0x0000a787, 0x0000a787, 0x0000a78c, 0x0000a78c,
+	0x0000a78e, 0x0000a78e, 0x0000a791, 0x0000a791,
+	0x0000a7a1, 0x0000a7a1, 0x0000a7a3, 0x0000a7a3,
+	0x0000a7a5, 0x0000a7a5, 0x0000a7a7, 0x0000a7a7,
+	0x0000a7a9, 0x0000a7a9, 0x0000a7fa, 0x0000a7fa,
+	0x0000fb00, 0x0000fb06, 0x0000fb13, 0x0000fb17,
+	0x0000ff41, 0x0000ff5a, 0x00010428, 0x0001044f,
+	0x0001d41a, 0x0001d433, 0x0001d44e, 0x0001d454,
+	0x0001d456, 0x0001d467, 0x0001d482, 0x0001d49b,
+	0x0001d4b6, 0x0001d4b9, 0x0001d4bb, 0x0001d4bb,
+	0x0001d4bd, 0x0001d4c3, 0x0001d4c5, 0x0001d4cf,
+	0x0001d4ea, 0x0001d503, 0x0001d51e, 0x0001d537,
+	0x0001d552, 0x0001d56b, 0x0001d586, 0x0001d59f,
+	0x0001d5ba, 0x0001d5d3, 0x0001d5ee, 0x0001d607,
+	0x0001d622, 0x0001d63b, 0x0001d656, 0x0001d66f,
+	0x0001d68a, 0x0001d6a5, 0x0001d6c2, 0x0001d6da,
+	0x0001d6dc, 0x0001d6e1, 0x0001d6fc, 0x0001d714,
+	0x0001d716, 0x0001d71b, 0x0001d736, 0x0001d74e,
+	0x0001d750, 0x0001d755, 0x0001d770, 0x0001d788,
+	0x0001d78a, 0x0001d78f, 0x0001d7aa, 0x0001d7c2,
+	0x0001d7c4, 0x0001d7c9, 0x0001d7cb, 0x0001d7cb,
+	0x000001c5, 0x000001c5, 0x000001c8, 0x000001c8,
+	0x000001cb, 0x000001cb, 0x000001f2, 0x000001f2,
+	0x00001f88, 0x00001f8f, 0x00001f98, 0x00001f9f,
+	0x00001fa8, 0x00001faf, 0x00001fbc, 0x00001fbc,
+	0x00001fcc, 0x00001fcc, 0x00001ffc, 0x00001ffc,
+	0x000002b0, 0x000002c1, 0x000002c6, 0x000002d1,
+	0x000002e0, 0x000002e4, 0x000002ec, 0x000002ec,
+	0x000002ee, 0x000002ee, 0x00000374, 0x00000374,
+	0x0000037a, 0x0000037a, 0x00000559, 0x00000559,
+	0x00000640, 0x00000640, 0x000006e5, 0x000006e6,
+	0x000007f4, 0x000007f5, 0x000007fa, 0x000007fa,
+	0x0000081a, 0x0000081a, 0x00000824, 0x00000824,
+	0x00000828, 0x00000828, 0x00000971, 0x00000971,
+	0x00000e46, 0x00000e46, 0x00000ec6, 0x00000ec6,
+	0x000010fc, 0x000010fc, 0x000017d7, 0x000017d7,
+	0x00001843, 0x00001843, 0x00001aa7, 0x00001aa7,
+	0x00001c78, 0x00001c7d, 0x00001d2c, 0x00001d61,
+	0x00001d78, 0x00001d78, 0x00001d9b, 0x00001dbf,
+	0x00002071, 0x00002071, 0x0000207f, 0x0000207f,
+	0x00002090, 0x0000209c, 0x00002c7d, 0x00002c7d,
+	0x00002d6f, 0x00002d6f, 0x00002e2f, 0x00002e2f,
+	0x00003005, 0x00003005, 0x00003031, 0x00003035,
+	0x0000303b, 0x0000303b, 0x0000309d, 0x0000309e,
+	0x000030fc, 0x000030fe, 0x0000a015, 0x0000a015,
+	0x0000a4f8, 0x0000a4fd, 0x0000a60c, 0x0000a60c,
+	0x0000a67f, 0x0000a67f, 0x0000a717, 0x0000a71f,
+	0x0000a770, 0x0000a770, 0x0000a788, 0x0000a788,
+	0x0000a9cf, 0x0000a9cf, 0x0000aa70, 0x0000aa70,
+	0x0000aadd, 0x0000aadd, 0x0000ff70, 0x0000ff70,
+	0x0000ff9e, 0x0000ff9f, 0x000001bb, 0x000001bb,
+	0x000001c0, 0x000001c3, 0x00000294, 0x00000294,
+	0x000005d0, 0x000005ea, 0x000005f0, 0x000005f2,
+	0x00000620, 0x0000063f, 0x00000641, 0x0000064a,
+	0x0000066e, 0x0000066f, 0x00000671, 0x000006d3,
+	0x000006d5, 0x000006d5, 0x000006ee, 0x000006ef,
+	0x000006fa, 0x000006fc, 0x000006ff, 0x000006ff,
+	0x00000710, 0x00000710, 0x00000712, 0x0000072f,
+	0x0000074d, 0x000007a5, 0x000007b1, 0x000007b1,
+	0x000007ca, 0x000007ea, 0x00000800, 0x00000815,
+	0x00000840, 0x00000858, 0x00000904, 0x00000939,
+	0x0000093d, 0x0000093d, 0x00000950, 0x00000950,
+	0x00000958, 0x00000961, 0x00000972, 0x00000977,
+	0x00000979, 0x0000097f, 0x00000985, 0x0000098c,
+	0x0000098f, 0x00000990, 0x00000993, 0x000009a8,
+	0x000009aa, 0x000009b0, 0x000009b2, 0x000009b2,
+	0x000009b6, 0x000009b9, 0x000009bd, 0x000009bd,
+	0x000009ce, 0x000009ce, 0x000009dc, 0x000009dd,
+	0x000009df, 0x000009e1, 0x000009f0, 0x000009f1,
+	0x00000a05, 0x00000a0a, 0x00000a0f, 0x00000a10,
+	0x00000a13, 0x00000a28, 0x00000a2a, 0x00000a30,
+	0x00000a32, 0x00000a33, 0x00000a35, 0x00000a36,
+	0x00000a38, 0x00000a39, 0x00000a59, 0x00000a5c,
+	0x00000a5e, 0x00000a5e, 0x00000a72, 0x00000a74,
+	0x00000a85, 0x00000a8d, 0x00000a8f, 0x00000a91,
+	0x00000a93, 0x00000aa8, 0x00000aaa, 0x00000ab0,
+	0x00000ab2, 0x00000ab3, 0x00000ab5, 0x00000ab9,
+	0x00000abd, 0x00000abd, 0x00000ad0, 0x00000ad0,
+	0x00000ae0, 0x00000ae1, 0x00000b05, 0x00000b0c,
+	0x00000b0f, 0x00000b10, 0x00000b13, 0x00000b28,
+	0x00000b2a, 0x00000b30, 0x00000b32, 0x00000b33,
+	0x00000b35, 0x00000b39, 0x00000b3d, 0x00000b3d,
+	0x00000b5c, 0x00000b5d, 0x00000b5f, 0x00000b61,
+	0x00000b71, 0x00000b71, 0x00000b83, 0x00000b83,
+	0x00000b85, 0x00000b8a, 0x00000b8e, 0x00000b90,
+	0x00000b92, 0x00000b95, 0x00000b99, 0x00000b9a,
+	0x00000b9c, 0x00000b9c, 0x00000b9e, 0x00000b9f,
+	0x00000ba3, 0x00000ba4, 0x00000ba8, 0x00000baa,
+	0x00000bae, 0x00000bb9, 0x00000bd0, 0x00000bd0,
+	0x00000c05, 0x00000c0c, 0x00000c0e, 0x00000c10,
+	0x00000c12, 0x00000c28, 0x00000c2a, 0x00000c33,
+	0x00000c35, 0x00000c39, 0x00000c3d, 0x00000c3d,
+	0x00000c58, 0x00000c59, 0x00000c60, 0x00000c61,
+	0x00000c85, 0x00000c8c, 0x00000c8e, 0x00000c90,
+	0x00000c92, 0x00000ca8, 0x00000caa, 0x00000cb3,
+	0x00000cb5, 0x00000cb9, 0x00000cbd, 0x00000cbd,
+	0x00000cde, 0x00000cde, 0x00000ce0, 0x00000ce1,
+	0x00000cf1, 0x00000cf2, 0x00000d05, 0x00000d0c,
+	0x00000d0e, 0x00000d10, 0x00000d12, 0x00000d3a,
+	0x00000d3d, 0x00000d3d, 0x00000d4e, 0x00000d4e,
+	0x00000d60, 0x00000d61, 0x00000d7a, 0x00000d7f,
+	0x00000d85, 0x00000d96, 0x00000d9a, 0x00000db1,
+	0x00000db3, 0x00000dbb, 0x00000dbd, 0x00000dbd,
+	0x00000dc0, 0x00000dc6, 0x00000e01, 0x00000e30,
+	0x00000e32, 0x00000e33, 0x00000e40, 0x00000e45,
+	0x00000e81, 0x00000e82, 0x00000e84, 0x00000e84,
+	0x00000e87, 0x00000e88, 0x00000e8a, 0x00000e8a,
+	0x00000e8d, 0x00000e8d, 0x00000e94, 0x00000e97,
+	0x00000e99, 0x00000e9f, 0x00000ea1, 0x00000ea3,
+	0x00000ea5, 0x00000ea5, 0x00000ea7, 0x00000ea7,
+	0x00000eaa, 0x00000eab, 0x00000ead, 0x00000eb0,
+	0x00000eb2, 0x00000eb3, 0x00000ebd, 0x00000ebd,
+	0x00000ec0, 0x00000ec4, 0x00000edc, 0x00000edd,
+	0x00000f00, 0x00000f00, 0x00000f40, 0x00000f47,
+	0x00000f49, 0x00000f6c, 0x00000f88, 0x00000f8c,
+	0x00001000, 0x0000102a, 0x0000103f, 0x0000103f,
+	0x00001050, 0x00001055, 0x0000105a, 0x0000105d,
+	0x00001061, 0x00001061, 0x00001065, 0x00001066,
+	0x0000106e, 0x00001070, 0x00001075, 0x00001081,
+	0x0000108e, 0x0000108e, 0x000010d0, 0x000010fa,
+	0x00001100, 0x00001248, 0x0000124a, 0x0000124d,
+	0x00001250, 0x00001256, 0x00001258, 0x00001258,
+	0x0000125a, 0x0000125d, 0x00001260, 0x00001288,
+	0x0000128a, 0x0000128d, 0x00001290, 0x000012b0,
+	0x000012b2, 0x000012b5, 0x000012b8, 0x000012be,
+	0x000012c0, 0x000012c0, 0x000012c2, 0x000012c5,
+	0x000012c8, 0x000012d6, 0x000012d8, 0x00001310,
+	0x00001312, 0x00001315, 0x00001318, 0x0000135a,
+	0x00001380, 0x0000138f, 0x000013a0, 0x000013f4,
+	0x00001401, 0x0000166c, 0x0000166f, 0x0000167f,
+	0x00001681, 0x0000169a, 0x000016a0, 0x000016ea,
+	0x00001700, 0x0000170c, 0x0000170e, 0x00001711,
+	0x00001720, 0x00001731, 0x00001740, 0x00001751,
+	0x00001760, 0x0000176c, 0x0000176e, 0x00001770,
+	0x00001780, 0x000017b3, 0x000017dc, 0x000017dc,
+	0x00001820, 0x00001842, 0x00001844, 0x00001877,
+	0x00001880, 0x000018a8, 0x000018aa, 0x000018aa,
+	0x000018b0, 0x000018f5, 0x00001900, 0x0000191c,
+	0x00001950, 0x0000196d, 0x00001970, 0x00001974,
+	0x00001980, 0x000019ab, 0x000019c1, 0x000019c7,
+	0x00001a00, 0x00001a16, 0x00001a20, 0x00001a54,
+	0x00001b05, 0x00001b33, 0x00001b45, 0x00001b4b,
+	0x00001b83, 0x00001ba0, 0x00001bae, 0x00001baf,
+	0x00001bc0, 0x00001be5, 0x00001c00, 0x00001c23,
+	0x00001c4d, 0x00001c4f, 0x00001c5a, 0x00001c77,
+	0x00001ce9, 0x00001cec, 0x00001cee, 0x00001cf1,
+	0x00002135, 0x00002138, 0x00002d30, 0x00002d65,
+	0x00002d80, 0x00002d96, 0x00002da0, 0x00002da6,
+	0x00002da8, 0x00002dae, 0x00002db0, 0x00002db6,
+	0x00002db8, 0x00002dbe, 0x00002dc0, 0x00002dc6,
+	0x00002dc8, 0x00002dce, 0x00002dd0, 0x00002dd6,
+	0x00002dd8, 0x00002dde, 0x00003006, 0x00003006,
+	0x0000303c, 0x0000303c, 0x00003041, 0x00003096,
+	0x0000309f, 0x0000309f, 0x000030a1, 0x000030fa,
+	0x000030ff, 0x000030ff, 0x00003105, 0x0000312d,
+	0x00003131, 0x0000318e, 0x000031a0, 0x000031ba,
+	0x000031f0, 0x000031ff, 0x00003400, 0x00004db5,
+	0x00004e00, 0x0000a014, 0x0000a016, 0x0000a48c,
+	0x0000a4d0, 0x0000a4f7, 0x0000a500, 0x0000a60b,
+	0x0000a610, 0x0000a61f, 0x0000a62a, 0x0000a62b,
+	0x0000a66e, 0x0000a66e, 0x0000a6a0, 0x0000a6e5,
+	0x0000a7fb, 0x0000a801, 0x0000a803, 0x0000a805,
+	0x0000a807, 0x0000a80a, 0x0000a80c, 0x0000a822,
+	0x0000a840, 0x0000a873, 0x0000a882, 0x0000a8b3,
+	0x0000a8f2, 0x0000a8f7, 0x0000a8fb, 0x0000a8fb,
+	0x0000a90a, 0x0000a925, 0x0000a930, 0x0000a946,
+	0x0000a960, 0x0000a97c, 0x0000a984, 0x0000a9b2,
+	0x0000aa00, 0x0000aa28, 0x0000aa40, 0x0000aa42,
+	0x0000aa44, 0x0000aa4b, 0x0000aa60, 0x0000aa6f,
+	0x0000aa71, 0x0000aa76, 0x0000aa7a, 0x0000aa7a,
+	0x0000aa80, 0x0000aaaf, 0x0000aab1, 0x0000aab1,
+	0x0000aab5, 0x0000aab6, 0x0000aab9, 0x0000aabd,
+	0x0000aac0, 0x0000aac0, 0x0000aac2, 0x0000aac2,
+	0x0000aadb, 0x0000aadc, 0x0000ab01, 0x0000ab06,
+	0x0000ab09, 0x0000ab0e, 0x0000ab11, 0x0000ab16,
+	0x0000ab20, 0x0000ab26, 0x0000ab28, 0x0000ab2e,
+	0x0000abc0, 0x0000abe2, 0x0000ac00, 0x0000d7a3,
+	0x0000d7b0, 0x0000d7c6, 0x0000d7cb, 0x0000d7fb,
+	0x0000f900, 0x0000faff, 0x0000fb1d, 0x0000fb1d,
+	0x0000fb1f, 0x0000fb28, 0x0000fb2a, 0x0000fb36,
+	0x0000fb38, 0x0000fb3c, 0x0000fb3e, 0x0000fb3e,
+	0x0000fb40, 0x0000fb41, 0x0000fb43, 0x0000fb44,
+	0x0000fb46, 0x0000fbb1, 0x0000fbd3, 0x0000fd3d,
+	0x0000fd50, 0x0000fd8f, 0x0000fd92, 0x0000fdc7,
+	0x0000fdf0, 0x0000fdfb, 0x0000fe70, 0x0000fe74,
+	0x0000fe76, 0x0000fefc, 0x0000ff66, 0x0000ff6f,
+	0x0000ff71, 0x0000ff9d, 0x0000ffa0, 0x0000ffbe,
+	0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf,
+	0x0000ffd2, 0x0000ffd7, 0x0000ffda, 0x0000ffdc,
+	0x00010000, 0x0001000b, 0x0001000d, 0x00010026,
+	0x00010028, 0x0001003a, 0x0001003c, 0x0001003d,
+	0x0001003f, 0x0001004d, 0x00010050, 0x0001005d,
+	0x00010080, 0x000100fa, 0x00010280, 0x0001029c,
+	0x000102a0, 0x000102d0, 0x00010300, 0x0001031e,
+	0x00010330, 0x00010340, 0x00010342, 0x00010349,
+	0x00010380, 0x0001039d, 0x000103a0, 0x000103c3,
+	0x000103c8, 0x000103cf, 0x00010450, 0x0001049d,
+	0x00010800, 0x00010805, 0x00010808, 0x00010808,
+	0x0001080a, 0x00010835, 0x00010837, 0x00010838,
+	0x0001083c, 0x0001083c, 0x0001083f, 0x00010855,
+	0x00010900, 0x00010915, 0x00010920, 0x00010939,
+	0x00010a00, 0x00010a00, 0x00010a10, 0x00010a13,
+	0x00010a15, 0x00010a17, 0x00010a19, 0x00010a33,
+	0x00010a60, 0x00010a7c, 0x00010b00, 0x00010b35,
+	0x00010b40, 0x00010b55, 0x00010b60, 0x00010b72,
+	0x00010c00, 0x00010c48, 0x00011003, 0x00011037,
+	0x00011083, 0x000110af, 0x00012000, 0x0001236e,
+	0x00013000, 0x0001342e, 0x00016800, 0x00016a38,
+	0x0001b000, 0x0001b001, 0x00020000, 0x0002a6d6,
+	0x0002a700, 0x0002a700, 0x0002b734, 0x0002b734,
+	0x0002b740, 0x0002b740, 0x0002b81d, 0x0002b81d,
+	0x0002f800, 0x0002fa1d, 0x0000005f, 0x0000005f,
+	0x0000203f, 0x00002040, 0x00002054, 0x00002054,
+	0x0000fe33, 0x0000fe34, 0x0000fe4d, 0x0000fe4f,
+	0x0000ff3f, 0x0000ff3f, 0x0000002d, 0x0000002d,
+	0x0000058a, 0x0000058a, 0x000005be, 0x000005be,
+	0x00001400, 0x00001400, 0x00001806, 0x00001806,
+	0x00002010, 0x00002015, 0x00002e17, 0x00002e17,
+	0x00002e1a, 0x00002e1a, 0x0000301c, 0x0000301c,
+	0x00003030, 0x00003030, 0x000030a0, 0x000030a0,
+	0x0000fe31, 0x0000fe32, 0x0000fe58, 0x0000fe58,
+	0x0000fe63, 0x0000fe63, 0x0000ff0d, 0x0000ff0d,
+	0x00000028, 0x00000028, 0x0000005b, 0x0000005b,
+	0x0000007b, 0x0000007b, 0x00000f3a, 0x00000f3a,
+	0x00000f3c, 0x00000f3c, 0x0000169b, 0x0000169b,
+	0x0000201a, 0x0000201a, 0x0000201e, 0x0000201e,
+	0x00002045, 0x00002045, 0x0000207d, 0x0000207d,
+	0x0000208d, 0x0000208d, 0x00002329, 0x00002329,
+	0x00002768, 0x00002768, 0x0000276a, 0x0000276a,
+	0x0000276c, 0x0000276c, 0x0000276e, 0x0000276e,
+	0x00002770, 0x00002770, 0x00002772, 0x00002772,
+	0x00002774, 0x00002774, 0x000027c5, 0x000027c5,
+	0x000027e6, 0x000027e6, 0x000027e8, 0x000027e8,
+	0x000027ea, 0x000027ea, 0x000027ec, 0x000027ec,
+	0x000027ee, 0x000027ee, 0x00002983, 0x00002983,
+	0x00002985, 0x00002985, 0x00002987, 0x00002987,
+	0x00002989, 0x00002989, 0x0000298b, 0x0000298b,
+	0x0000298d, 0x0000298d, 0x0000298f, 0x0000298f,
+	0x00002991, 0x00002991, 0x00002993, 0x00002993,
+	0x00002995, 0x00002995, 0x00002997, 0x00002997,
+	0x000029d8, 0x000029d8, 0x000029da, 0x000029da,
+	0x000029fc, 0x000029fc, 0x00002e22, 0x00002e22,
+	0x00002e24, 0x00002e24, 0x00002e26, 0x00002e26,
+	0x00002e28, 0x00002e28, 0x00003008, 0x00003008,
+	0x0000300a, 0x0000300a, 0x0000300c, 0x0000300c,
+	0x0000300e, 0x0000300e, 0x00003010, 0x00003010,
+	0x00003014, 0x00003014, 0x00003016, 0x00003016,
+	0x00003018, 0x00003018, 0x0000301a, 0x0000301a,
+	0x0000301d, 0x0000301d, 0x0000fd3e, 0x0000fd3e,
+	0x0000fe17, 0x0000fe17, 0x0000fe35, 0x0000fe35,
+	0x0000fe37, 0x0000fe37, 0x0000fe39, 0x0000fe39,
+	0x0000fe3b, 0x0000fe3b, 0x0000fe3d, 0x0000fe3d,
+	0x0000fe3f, 0x0000fe3f, 0x0000fe41, 0x0000fe41,
+	0x0000fe43, 0x0000fe43, 0x0000fe47, 0x0000fe47,
+	0x0000fe59, 0x0000fe59, 0x0000fe5b, 0x0000fe5b,
+	0x0000fe5d, 0x0000fe5d, 0x0000ff08, 0x0000ff08,
+	0x0000ff3b, 0x0000ff3b, 0x0000ff5b, 0x0000ff5b,
+	0x0000ff5f, 0x0000ff5f, 0x0000ff62, 0x0000ff62,
+	0x00000029, 0x00000029, 0x0000005d, 0x0000005d,
+	0x0000007d, 0x0000007d, 0x00000f3b, 0x00000f3b,
+	0x00000f3d, 0x00000f3d, 0x0000169c, 0x0000169c,
+	0x00002046, 0x00002046, 0x0000207e, 0x0000207e,
+	0x0000208e, 0x0000208e, 0x0000232a, 0x0000232a,
+	0x00002769, 0x00002769, 0x0000276b, 0x0000276b,
+	0x0000276d, 0x0000276d, 0x0000276f, 0x0000276f,
+	0x00002771, 0x00002771, 0x00002773, 0x00002773,
+	0x00002775, 0x00002775, 0x000027c6, 0x000027c6,
+	0x000027e7, 0x000027e7, 0x000027e9, 0x000027e9,
+	0x000027eb, 0x000027eb, 0x000027ed, 0x000027ed,
+	0x000027ef, 0x000027ef, 0x00002984, 0x00002984,
+	0x00002986, 0x00002986, 0x00002988, 0x00002988,
+	0x0000298a, 0x0000298a, 0x0000298c, 0x0000298c,
+	0x0000298e, 0x0000298e, 0x00002990, 0x00002990,
+	0x00002992, 0x00002992, 0x00002994, 0x00002994,
+	0x00002996, 0x00002996, 0x00002998, 0x00002998,
+	0x000029d9, 0x000029d9, 0x000029db, 0x000029db,
+	0x000029fd, 0x000029fd, 0x00002e23, 0x00002e23,
+	0x00002e25, 0x00002e25, 0x00002e27, 0x00002e27,
+	0x00002e29, 0x00002e29, 0x00003009, 0x00003009,
+	0x0000300b, 0x0000300b, 0x0000300d, 0x0000300d,
+	0x0000300f, 0x0000300f, 0x00003011, 0x00003011,
+	0x00003015, 0x00003015, 0x00003017, 0x00003017,
+	0x00003019, 0x00003019, 0x0000301b, 0x0000301b,
+	0x0000301e, 0x0000301f, 0x0000fd3f, 0x0000fd3f,
+	0x0000fe18, 0x0000fe18, 0x0000fe36, 0x0000fe36,
+	0x0000fe38, 0x0000fe38, 0x0000fe3a, 0x0000fe3a,
+	0x0000fe3c, 0x0000fe3c, 0x0000fe3e, 0x0000fe3e,
+	0x0000fe40, 0x0000fe40, 0x0000fe42, 0x0000fe42,
+	0x0000fe44, 0x0000fe44, 0x0000fe48, 0x0000fe48,
+	0x0000fe5a, 0x0000fe5a, 0x0000fe5c, 0x0000fe5c,
+	0x0000fe5e, 0x0000fe5e, 0x0000ff09, 0x0000ff09,
+	0x0000ff3d, 0x0000ff3d, 0x0000ff5d, 0x0000ff5d,
+	0x0000ff60, 0x0000ff60, 0x0000ff63, 0x0000ff63,
+	0x00000021, 0x00000023, 0x00000025, 0x00000027,
+	0x0000002a, 0x0000002a, 0x0000002c, 0x0000002c,
+	0x0000002e, 0x0000002f, 0x0000003a, 0x0000003b,
+	0x0000003f, 0x00000040, 0x0000005c, 0x0000005c,
+	0x000000a1, 0x000000a1, 0x000000b7, 0x000000b7,
+	0x000000bf, 0x000000bf, 0x0000037e, 0x0000037e,
+	0x00000387, 0x00000387, 0x0000055a, 0x0000055f,
+	0x00000589, 0x00000589, 0x000005c0, 0x000005c0,
+	0x000005c3, 0x000005c3, 0x000005c6, 0x000005c6,
+	0x000005f3, 0x000005f4, 0x00000609, 0x0000060a,
+	0x0000060c, 0x0000060d, 0x0000061b, 0x0000061b,
+	0x0000061e, 0x0000061f, 0x0000066a, 0x0000066d,
+	0x000006d4, 0x000006d4, 0x00000700, 0x0000070d,
+	0x000007f7, 0x000007f9, 0x00000830, 0x0000083e,
+	0x0000085e, 0x0000085e, 0x00000964, 0x00000965,
+	0x00000970, 0x00000970, 0x00000df4, 0x00000df4,
+	0x00000e4f, 0x00000e4f, 0x00000e5a, 0x00000e5b,
+	0x00000f04, 0x00000f12, 0x00000f85, 0x00000f85,
+	0x00000fd0, 0x00000fd4, 0x00000fd9, 0x00000fda,
+	0x0000104a, 0x0000104f, 0x000010fb, 0x000010fb,
+	0x00001361, 0x00001368, 0x0000166d, 0x0000166e,
+	0x000016eb, 0x000016ed, 0x00001735, 0x00001736,
+	0x000017d4, 0x000017d6, 0x000017d8, 0x000017da,
+	0x00001800, 0x00001805, 0x00001807, 0x0000180a,
+	0x00001944, 0x00001945, 0x00001a1e, 0x00001a1f,
+	0x00001aa0, 0x00001aa6, 0x00001aa8, 0x00001aad,
+	0x00001b5a, 0x00001b60, 0x00001bfc, 0x00001bff,
+	0x00001c3b, 0x00001c3f, 0x00001c7e, 0x00001c7f,
+	0x00001cd3, 0x00001cd3, 0x00002016, 0x00002017,
+	0x00002020, 0x00002027, 0x00002030, 0x00002038,
+	0x0000203b, 0x0000203e, 0x00002041, 0x00002043,
+	0x00002047, 0x00002051, 0x00002053, 0x00002053,
+	0x00002055, 0x0000205e, 0x00002cf9, 0x00002cfc,
+	0x00002cfe, 0x00002cff, 0x00002d70, 0x00002d70,
+	0x00002e00, 0x00002e01, 0x00002e06, 0x00002e08,
+	0x00002e0b, 0x00002e0b, 0x00002e0e, 0x00002e16,
+	0x00002e18, 0x00002e19, 0x00002e1b, 0x00002e1b,
+	0x00002e1e, 0x00002e1f, 0x00002e2a, 0x00002e2e,
+	0x00002e30, 0x00002e31, 0x00003001, 0x00003003,
+	0x0000303d, 0x0000303d, 0x000030fb, 0x000030fb,
+	0x0000a4fe, 0x0000a4ff, 0x0000a60d, 0x0000a60f,
+	0x0000a673, 0x0000a673, 0x0000a67e, 0x0000a67e,
+	0x0000a6f2, 0x0000a6f7, 0x0000a874, 0x0000a877,
+	0x0000a8ce, 0x0000a8cf, 0x0000a8f8, 0x0000a8fa,
+	0x0000a92e, 0x0000a92f, 0x0000a95f, 0x0000a95f,
+	0x0000a9c1, 0x0000a9cd, 0x0000a9de, 0x0000a9df,
+	0x0000aa5c, 0x0000aa5f, 0x0000aade, 0x0000aadf,
+	0x0000abeb, 0x0000abeb, 0x0000fe10, 0x0000fe16,
+	0x0000fe19, 0x0000fe19, 0x0000fe30, 0x0000fe30,
+	0x0000fe45, 0x0000fe46, 0x0000fe49, 0x0000fe4c,
+	0x0000fe50, 0x0000fe52, 0x0000fe54, 0x0000fe57,
+	0x0000fe5f, 0x0000fe61, 0x0000fe68, 0x0000fe68,
+	0x0000fe6a, 0x0000fe6b, 0x0000ff01, 0x0000ff03,
+	0x0000ff05, 0x0000ff07, 0x0000ff0a, 0x0000ff0a,
+	0x0000ff0c, 0x0000ff0c, 0x0000ff0e, 0x0000ff0f,
+	0x0000ff1a, 0x0000ff1b, 0x0000ff1f, 0x0000ff20,
+	0x0000ff3c, 0x0000ff3c, 0x0000ff61, 0x0000ff61,
+	0x0000ff64, 0x0000ff65, 0x00010100, 0x00010101,
+	0x0001039f, 0x0001039f, 0x000103d0, 0x000103d0,
+	0x00010857, 0x00010857, 0x0001091f, 0x0001091f,
+	0x0001093f, 0x0001093f, 0x00010a50, 0x00010a58,
+	0x00010a7f, 0x00010a7f, 0x00010b39, 0x00010b3f,
+	0x00011047, 0x0001104d, 0x000110bb, 0x000110bc,
+	0x000110be, 0x000110c1, 0x00012470, 0x00012473,
+	0x0000002b, 0x0000002b, 0x0000003c, 0x0000003e,
+	0x0000007c, 0x0000007c, 0x0000007e, 0x0000007e,
+	0x000000ac, 0x000000ac, 0x000000b1, 0x000000b1,
+	0x000000d7, 0x000000d7, 0x000000f7, 0x000000f7,
+	0x000003f6, 0x000003f6, 0x00000606, 0x00000608,
+	0x00002044, 0x00002044, 0x00002052, 0x00002052,
+	0x0000207a, 0x0000207c, 0x0000208a, 0x0000208c,
+	0x00002118, 0x00002118, 0x00002140, 0x00002144,
+	0x0000214b, 0x0000214b, 0x00002190, 0x00002194,
+	0x0000219a, 0x0000219b, 0x000021a0, 0x000021a0,
+	0x000021a3, 0x000021a3, 0x000021a6, 0x000021a6,
+	0x000021ae, 0x000021ae, 0x000021ce, 0x000021cf,
+	0x000021d2, 0x000021d2, 0x000021d4, 0x000021d4,
+	0x000021f4, 0x000022ff, 0x00002308, 0x0000230b,
+	0x00002320, 0x00002321, 0x0000237c, 0x0000237c,
+	0x0000239b, 0x000023b3, 0x000023dc, 0x000023e1,
+	0x000025b7, 0x000025b7, 0x000025c1, 0x000025c1,
+	0x000025f8, 0x000025ff, 0x0000266f, 0x0000266f,
+	0x000027c0, 0x000027c4, 0x000027c7, 0x000027ca,
+	0x000027cc, 0x000027cc, 0x000027ce, 0x000027e5,
+	0x000027f0, 0x000027ff, 0x00002900, 0x00002982,
+	0x00002999, 0x000029d7, 0x000029dc, 0x000029fb,
+	0x000029fe, 0x00002aff, 0x00002b30, 0x00002b44,
+	0x00002b47, 0x00002b4c, 0x0000fb29, 0x0000fb29,
+	0x0000fe62, 0x0000fe62, 0x0000fe64, 0x0000fe66,
+	0x0000ff0b, 0x0000ff0b, 0x0000ff1c, 0x0000ff1e,
+	0x0000ff5c, 0x0000ff5c, 0x0000ff5e, 0x0000ff5e,
+	0x0000ffe2, 0x0000ffe2, 0x0000ffe9, 0x0000ffec,
+	0x0001d6c1, 0x0001d6c1, 0x0001d6db, 0x0001d6db,
+	0x0001d6fb, 0x0001d6fb, 0x0001d715, 0x0001d715,
+	0x0001d735, 0x0001d735, 0x0001d74f, 0x0001d74f,
+	0x0001d76f, 0x0001d76f, 0x0001d789, 0x0001d789,
+	0x0001d7a9, 0x0001d7a9, 0x0001d7c3, 0x0001d7c3,
+	0x00000024, 0x00000024, 0x000000a2, 0x000000a5,
+	0x0000060b, 0x0000060b, 0x000009f2, 0x000009f3,
+	0x000009fb, 0x000009fb, 0x00000af1, 0x00000af1,
+	0x00000bf9, 0x00000bf9, 0x00000e3f, 0x00000e3f,
+	0x000017db, 0x000017db, 0x000020a0, 0x000020b9,
+	0x0000a838, 0x0000a838, 0x0000fdfc, 0x0000fdfc,
+	0x0000fe69, 0x0000fe69, 0x0000ff04, 0x0000ff04,
+	0x0000ffe0, 0x0000ffe1, 0x0000ffe5, 0x0000ffe6,
+	0x0000005e, 0x0000005e, 0x00000060, 0x00000060,
+	0x000000a8, 0x000000a8, 0x000000af, 0x000000af,
+	0x000000b4, 0x000000b4, 0x000000b8, 0x000000b8,
+	0x000002c2, 0x000002c5, 0x000002d2, 0x000002df,
+	0x000002e5, 0x000002eb, 0x000002ed, 0x000002ed,
+	0x000002ef, 0x000002ff, 0x00000375, 0x00000375,
+	0x00000384, 0x00000385, 0x00001fbd, 0x00001fbd,
+	0x00001fbf, 0x00001fc1, 0x00001fcd, 0x00001fcf,
+	0x00001fdd, 0x00001fdf, 0x00001fed, 0x00001fef,
+	0x00001ffd, 0x00001ffe, 0x0000309b, 0x0000309c,
+	0x0000a700, 0x0000a716, 0x0000a720, 0x0000a721,
+	0x0000a789, 0x0000a78a, 0x0000fbb2, 0x0000fbc1,
+	0x0000ff3e, 0x0000ff3e, 0x0000ff40, 0x0000ff40,
+	0x0000ffe3, 0x0000ffe3, 0x000000a6, 0x000000a7,
+	0x000000a9, 0x000000a9, 0x000000ae, 0x000000ae,
+	0x000000b0, 0x000000b0, 0x000000b6, 0x000000b6,
+	0x00000482, 0x00000482, 0x0000060e, 0x0000060f,
+	0x000006de, 0x000006de, 0x000006e9, 0x000006e9,
+	0x000006fd, 0x000006fe, 0x000007f6, 0x000007f6,
+	0x000009fa, 0x000009fa, 0x00000b70, 0x00000b70,
+	0x00000bf3, 0x00000bf8, 0x00000bfa, 0x00000bfa,
+	0x00000c7f, 0x00000c7f, 0x00000d79, 0x00000d79,
+	0x00000f01, 0x00000f03, 0x00000f13, 0x00000f17,
+	0x00000f1a, 0x00000f1f, 0x00000f34, 0x00000f34,
+	0x00000f36, 0x00000f36, 0x00000f38, 0x00000f38,
+	0x00000fbe, 0x00000fc5, 0x00000fc7, 0x00000fcc,
+	0x00000fce, 0x00000fcf, 0x00000fd5, 0x00000fd8,
+	0x0000109e, 0x0000109f, 0x00001360, 0x00001360,
+	0x00001390, 0x00001399, 0x00001940, 0x00001940,
+	0x000019de, 0x000019ff, 0x00001b61, 0x00001b6a,
+	0x00001b74, 0x00001b7c, 0x00002100, 0x00002101,
+	0x00002103, 0x00002106, 0x00002108, 0x00002109,
+	0x00002114, 0x00002114, 0x00002116, 0x00002117,
+	0x0000211e, 0x00002123, 0x00002125, 0x00002125,
+	0x00002127, 0x00002127, 0x00002129, 0x00002129,
+	0x0000212e, 0x0000212e, 0x0000213a, 0x0000213b,
+	0x0000214a, 0x0000214a, 0x0000214c, 0x0000214d,
+	0x0000214f, 0x0000214f, 0x00002195, 0x00002199,
+	0x0000219c, 0x0000219f, 0x000021a1, 0x000021a2,
+	0x000021a4, 0x000021a5, 0x000021a7, 0x000021ad,
+	0x000021af, 0x000021cd, 0x000021d0, 0x000021d1,
+	0x000021d3, 0x000021d3, 0x000021d5, 0x000021f3,
+	0x00002300, 0x00002307, 0x0000230c, 0x0000231f,
+	0x00002322, 0x00002328, 0x0000232b, 0x0000237b,
+	0x0000237d, 0x0000239a, 0x000023b4, 0x000023db,
+	0x000023e2, 0x000023f3, 0x00002400, 0x00002426,
+	0x00002440, 0x0000244a, 0x0000249c, 0x000024e9,
+	0x00002500, 0x000025b6, 0x000025b8, 0x000025c0,
+	0x000025c2, 0x000025f7, 0x00002600, 0x0000266e,
+	0x00002670, 0x000026ff, 0x00002701, 0x00002767,
+	0x00002794, 0x000027bf, 0x00002800, 0x000028ff,
+	0x00002b00, 0x00002b2f, 0x00002b45, 0x00002b46,
+	0x00002b50, 0x00002b59, 0x00002ce5, 0x00002cea,
+	0x00002e80, 0x00002e99, 0x00002e9b, 0x00002ef3,
+	0x00002f00, 0x00002fd5, 0x00002ff0, 0x00002ffb,
+	0x00003004, 0x00003004, 0x00003012, 0x00003013,
+	0x00003020, 0x00003020, 0x00003036, 0x00003037,
+	0x0000303e, 0x0000303f, 0x00003190, 0x00003191,
+	0x00003196, 0x0000319f, 0x000031c0, 0x000031e3,
+	0x00003200, 0x0000321e, 0x0000322a, 0x00003250,
+	0x00003260, 0x0000327f, 0x0000328a, 0x000032b0,
+	0x000032c0, 0x000032fe, 0x00003300, 0x000033ff,
+	0x00004dc0, 0x00004dff, 0x0000a490, 0x0000a4c6,
+	0x0000a828, 0x0000a82b, 0x0000a836, 0x0000a837,
+	0x0000a839, 0x0000a839, 0x0000aa77, 0x0000aa79,
+	0x0000fdfd, 0x0000fdfd, 0x0000ffe4, 0x0000ffe4,
+	0x0000ffe8, 0x0000ffe8, 0x0000ffed, 0x0000ffee,
+	0x0000fffc, 0x0000fffd, 0x00010102, 0x00010102,
+	0x00010137, 0x0001013f, 0x00010179, 0x00010189,
+	0x00010190, 0x0001019b, 0x000101d0, 0x000101fc,
+	0x0001d000, 0x0001d0f5, 0x0001d100, 0x0001d126,
+	0x0001d129, 0x0001d164, 0x0001d16a, 0x0001d16c,
+	0x0001d183, 0x0001d184, 0x0001d18c, 0x0001d1a9,
+	0x0001d1ae, 0x0001d1dd, 0x0001d200, 0x0001d241,
+	0x0001d245, 0x0001d245, 0x0001d300, 0x0001d356,
+	0x0001f000, 0x0001f02b, 0x0001f030, 0x0001f093,
+	0x0001f0a0, 0x0001f0ae, 0x0001f0b1, 0x0001f0be,
+	0x0001f0c1, 0x0001f0cf, 0x0001f0d1, 0x0001f0df,
+	0x0001f110, 0x0001f12e, 0x0001f130, 0x0001f169,
+	0x0001f170, 0x0001f19a, 0x0001f1e6, 0x0001f202,
+	0x0001f210, 0x0001f23a, 0x0001f240, 0x0001f248,
+	0x0001f250, 0x0001f251, 0x0001f300, 0x0001f320,
+	0x0001f330, 0x0001f335, 0x0001f337, 0x0001f37c,
+	0x0001f380, 0x0001f393, 0x0001f3a0, 0x0001f3c4,
+	0x0001f3c6, 0x0001f3ca, 0x0001f3e0, 0x0001f3f0,
+	0x0001f400, 0x0001f43e, 0x0001f440, 0x0001f440,
+	0x0001f442, 0x0001f4f7, 0x0001f4f9, 0x0001f4fc,
+	0x0001f500, 0x0001f53d, 0x0001f550, 0x0001f567,
+	0x0001f5fb, 0x0001f5ff, 0x0001f601, 0x0001f610,
+	0x0001f612, 0x0001f614, 0x0001f616, 0x0001f616,
+	0x0001f618, 0x0001f618, 0x0001f61a, 0x0001f61a,
+	0x0001f61c, 0x0001f61e, 0x0001f620, 0x0001f625,
+	0x0001f628, 0x0001f62b, 0x0001f62d, 0x0001f62d,
+	0x0001f630, 0x0001f633, 0x0001f635, 0x0001f640,
+	0x0001f645, 0x0001f64f, 0x0001f680, 0x0001f6c5,
+	0x0001f700, 0x0001f773, 0x00000041, 0x0000005a,
+	0x00000061, 0x0000007a, 0x000000aa, 0x000000aa,
+	0x000000b5, 0x000000b5, 0x000000ba, 0x000000ba,
+	0x000000c0, 0x000000d6, 0x000000d8, 0x000000f6,
+	0x000000f8, 0x000002b8, 0x000002bb, 0x000002c1,
+	0x000002d0, 0x000002d1, 0x000002e0, 0x000002e4,
+	0x000002ee, 0x000002ee, 0x00000370, 0x00000373,
+	0x00000376, 0x00000377, 0x0000037a, 0x0000037d,
+	0x00000386, 0x00000386, 0x00000388, 0x0000038a,
+	0x0000038c, 0x0000038c, 0x0000038e, 0x000003a1,
+	0x000003a3, 0x000003f5, 0x000003f7, 0x00000482,
+	0x0000048a, 0x00000527, 0x00000531, 0x00000556,
+	0x00000559, 0x0000055f, 0x00000561, 0x00000587,
+	0x00000589, 0x00000589, 0x00000903, 0x00000939,
+	0x0000093b, 0x0000093b, 0x0000093d, 0x00000940,
+	0x00000949, 0x0000094c, 0x0000094e, 0x00000950,
+	0x00000958, 0x00000961, 0x00000964, 0x00000977,
+	0x00000979, 0x0000097f, 0x00000982, 0x00000983,
+	0x00000985, 0x0000098c, 0x0000098f, 0x00000990,
+	0x00000993, 0x000009a8, 0x000009aa, 0x000009b0,
+	0x000009b2, 0x000009b2, 0x000009b6, 0x000009b9,
+	0x000009bd, 0x000009c0, 0x000009c7, 0x000009c8,
+	0x000009cb, 0x000009cc, 0x000009ce, 0x000009ce,
+	0x000009d7, 0x000009d7, 0x000009dc, 0x000009dd,
+	0x000009df, 0x000009e1, 0x000009e6, 0x000009f1,
+	0x000009f4, 0x000009fa, 0x00000a03, 0x00000a03,
+	0x00000a05, 0x00000a0a, 0x00000a0f, 0x00000a10,
+	0x00000a13, 0x00000a28, 0x00000a2a, 0x00000a30,
+	0x00000a32, 0x00000a33, 0x00000a35, 0x00000a36,
+	0x00000a38, 0x00000a39, 0x00000a3e, 0x00000a40,
+	0x00000a59, 0x00000a5c, 0x00000a5e, 0x00000a5e,
+	0x00000a66, 0x00000a6f, 0x00000a72, 0x00000a74,
+	0x00000a83, 0x00000a83, 0x00000a85, 0x00000a8d,
+	0x00000a8f, 0x00000a91, 0x00000a93, 0x00000aa8,
+	0x00000aaa, 0x00000ab0, 0x00000ab2, 0x00000ab3,
+	0x00000ab5, 0x00000ab9, 0x00000abd, 0x00000ac0,
+	0x00000ac9, 0x00000ac9, 0x00000acb, 0x00000acc,
+	0x00000ad0, 0x00000ad0, 0x00000ae0, 0x00000ae1,
+	0x00000ae6, 0x00000aef, 0x00000b02, 0x00000b03,
+	0x00000b05, 0x00000b0c, 0x00000b0f, 0x00000b10,
+	0x00000b13, 0x00000b28, 0x00000b2a, 0x00000b30,
+	0x00000b32, 0x00000b33, 0x00000b35, 0x00000b39,
+	0x00000b3d, 0x00000b3e, 0x00000b40, 0x00000b40,
+	0x00000b47, 0x00000b48, 0x00000b4b, 0x00000b4c,
+	0x00000b57, 0x00000b57, 0x00000b5c, 0x00000b5d,
+	0x00000b5f, 0x00000b61, 0x00000b66, 0x00000b77,
+	0x00000b83, 0x00000b83, 0x00000b85, 0x00000b8a,
+	0x00000b8e, 0x00000b90, 0x00000b92, 0x00000b95,
+	0x00000b99, 0x00000b9a, 0x00000b9c, 0x00000b9c,
+	0x00000b9e, 0x00000b9f, 0x00000ba3, 0x00000ba4,
+	0x00000ba8, 0x00000baa, 0x00000bae, 0x00000bb9,
+	0x00000bbe, 0x00000bbf, 0x00000bc1, 0x00000bc2,
+	0x00000bc6, 0x00000bc8, 0x00000bca, 0x00000bcc,
+	0x00000bd0, 0x00000bd0, 0x00000bd7, 0x00000bd7,
+	0x00000be6, 0x00000bf2, 0x00000c01, 0x00000c03,
+	0x00000c05, 0x00000c0c, 0x00000c0e, 0x00000c10,
+	0x00000c12, 0x00000c28, 0x00000c2a, 0x00000c33,
+	0x00000c35, 0x00000c39, 0x00000c3d, 0x00000c3d,
+	0x00000c41, 0x00000c44, 0x00000c58, 0x00000c59,
+	0x00000c60, 0x00000c61, 0x00000c66, 0x00000c6f,
+	0x00000c7f, 0x00000c7f, 0x00000c82, 0x00000c83,
+	0x00000c85, 0x00000c8c, 0x00000c8e, 0x00000c90,
+	0x00000c92, 0x00000ca8, 0x00000caa, 0x00000cb3,
+	0x00000cb5, 0x00000cb9, 0x00000cbd, 0x00000cc4,
+	0x00000cc6, 0x00000cc8, 0x00000cca, 0x00000ccb,
+	0x00000cd5, 0x00000cd6, 0x00000cde, 0x00000cde,
+	0x00000ce0, 0x00000ce1, 0x00000ce6, 0x00000cef,
+	0x00000cf1, 0x00000cf2, 0x00000d02, 0x00000d03,
+	0x00000d05, 0x00000d0c, 0x00000d0e, 0x00000d10,
+	0x00000d12, 0x00000d3a, 0x00000d3d, 0x00000d40,
+	0x00000d46, 0x00000d48, 0x00000d4a, 0x00000d4c,
+	0x00000d4e, 0x00000d4e, 0x00000d57, 0x00000d57,
+	0x00000d60, 0x00000d61, 0x00000d66, 0x00000d75,
+	0x00000d79, 0x00000d7f, 0x00000d82, 0x00000d83,
+	0x00000d85, 0x00000d96, 0x00000d9a, 0x00000db1,
+	0x00000db3, 0x00000dbb, 0x00000dbd, 0x00000dbd,
+	0x00000dc0, 0x00000dc6, 0x00000dcf, 0x00000dd1,
+	0x00000dd8, 0x00000ddf, 0x00000df2, 0x00000df4,
+	0x00000e01, 0x00000e30, 0x00000e32, 0x00000e33,
+	0x00000e40, 0x00000e46, 0x00000e4f, 0x00000e5b,
+	0x00000e81, 0x00000e82, 0x00000e84, 0x00000e84,
+	0x00000e87, 0x00000e88, 0x00000e8a, 0x00000e8a,
+	0x00000e8d, 0x00000e8d, 0x00000e94, 0x00000e97,
+	0x00000e99, 0x00000e9f, 0x00000ea1, 0x00000ea3,
+	0x00000ea5, 0x00000ea5, 0x00000ea7, 0x00000ea7,
+	0x00000eaa, 0x00000eab, 0x00000ead, 0x00000eb0,
+	0x00000eb2, 0x00000eb3, 0x00000ebd, 0x00000ebd,
+	0x00000ec0, 0x00000ec4, 0x00000ec6, 0x00000ec6,
+	0x00000ed0, 0x00000ed9, 0x00000edc, 0x00000edd,
+	0x00000f00, 0x00000f17, 0x00000f1a, 0x00000f34,
+	0x00000f36, 0x00000f36, 0x00000f38, 0x00000f38,
+	0x00000f3e, 0x00000f47, 0x00000f49, 0x00000f6c,
+	0x00000f7f, 0x00000f7f, 0x00000f85, 0x00000f85,
+	0x00000f88, 0x00000f8c, 0x00000fbe, 0x00000fc5,
+	0x00000fc7, 0x00000fcc, 0x00000fce, 0x00000fda,
+	0x00001000, 0x0000102c, 0x00001031, 0x00001031,
+	0x00001038, 0x00001038, 0x0000103b, 0x0000103c,
+	0x0000103f, 0x00001057, 0x0000105a, 0x0000105d,
+	0x00001061, 0x00001070, 0x00001075, 0x00001081,
+	0x00001083, 0x00001084, 0x00001087, 0x0000108c,
+	0x0000108e, 0x0000109c, 0x0000109e, 0x000010c5,
+	0x000010d0, 0x000010fc, 0x00001100, 0x00001248,
+	0x0000124a, 0x0000124d, 0x00001250, 0x00001256,
+	0x00001258, 0x00001258, 0x0000125a, 0x0000125d,
+	0x00001260, 0x00001288, 0x0000128a, 0x0000128d,
+	0x00001290, 0x000012b0, 0x000012b2, 0x000012b5,
+	0x000012b8, 0x000012be, 0x000012c0, 0x000012c0,
+	0x000012c2, 0x000012c5, 0x000012c8, 0x000012d6,
+	0x000012d8, 0x00001310, 0x00001312, 0x00001315,
+	0x00001318, 0x0000135a, 0x00001360, 0x0000137c,
+	0x00001380, 0x0000138f, 0x000013a0, 0x000013f4,
+	0x00001401, 0x0000167f, 0x00001681, 0x0000169a,
+	0x000016a0, 0x000016f0, 0x00001700, 0x0000170c,
+	0x0000170e, 0x00001711, 0x00001720, 0x00001731,
+	0x00001735, 0x00001736, 0x00001740, 0x00001751,
+	0x00001760, 0x0000176c, 0x0000176e, 0x00001770,
+	0x00001780, 0x000017b6, 0x000017be, 0x000017c5,
+	0x000017c7, 0x000017c8, 0x000017d4, 0x000017da,
+	0x000017dc, 0x000017dc, 0x000017e0, 0x000017e9,
+	0x00001810, 0x00001819, 0x00001820, 0x00001877,
+	0x00001880, 0x000018a8, 0x000018aa, 0x000018aa,
+	0x000018b0, 0x000018f5, 0x00001900, 0x0000191c,
+	0x00001923, 0x00001926, 0x00001929, 0x0000192b,
+	0x00001930, 0x00001931, 0x00001933, 0x00001938,
+	0x00001946, 0x0000196d, 0x00001970, 0x00001974,
+	0x00001980, 0x000019ab, 0x000019b0, 0x000019c9,
+	0x000019d0, 0x000019da, 0x00001a00, 0x00001a16,
+	0x00001a19, 0x00001a1b, 0x00001a1e, 0x00001a55,
+	0x00001a57, 0x00001a57, 0x00001a61, 0x00001a61,
+	0x00001a63, 0x00001a64, 0x00001a6d, 0x00001a72,
+	0x00001a80, 0x00001a89, 0x00001a90, 0x00001a99,
+	0x00001aa0, 0x00001aad, 0x00001b04, 0x00001b33,
+	0x00001b35, 0x00001b35, 0x00001b3b, 0x00001b3b,
+	0x00001b3d, 0x00001b41, 0x00001b43, 0x00001b4b,
+	0x00001b50, 0x00001b6a, 0x00001b74, 0x00001b7c,
+	0x00001b82, 0x00001ba1, 0x00001ba6, 0x00001ba7,
+	0x00001baa, 0x00001baa, 0x00001bae, 0x00001bb9,
+	0x00001bc0, 0x00001be5, 0x00001be7, 0x00001be7,
+	0x00001bea, 0x00001bec, 0x00001bee, 0x00001bee,
+	0x00001bf2, 0x00001bf3, 0x00001bfc, 0x00001c2b,
+	0x00001c34, 0x00001c35, 0x00001c3b, 0x00001c49,
+	0x00001c4d, 0x00001c7f, 0x00001cd3, 0x00001cd3,
+	0x00001ce1, 0x00001ce1, 0x00001ce9, 0x00001cec,
+	0x00001cee, 0x00001cf2, 0x00001d00, 0x00001dbf,
+	0x00001e00, 0x00001f15, 0x00001f18, 0x00001f1d,
+	0x00001f20, 0x00001f45, 0x00001f48, 0x00001f4d,
+	0x00001f50, 0x00001f57, 0x00001f59, 0x00001f59,
+	0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d,
+	0x00001f5f, 0x00001f7d, 0x00001f80, 0x00001fb4,
+	0x00001fb6, 0x00001fbc, 0x00001fbe, 0x00001fbe,
+	0x00001fc2, 0x00001fc4, 0x00001fc6, 0x00001fcc,
+	0x00001fd0, 0x00001fd3, 0x00001fd6, 0x00001fdb,
+	0x00001fe0, 0x00001fec, 0x00001ff2, 0x00001ff4,
+	0x00001ff6, 0x00001ffc, 0x0000200e, 0x0000200e,
+	0x00002071, 0x00002071, 0x0000207f, 0x0000207f,
+	0x00002090, 0x0000209c, 0x00002102, 0x00002102,
+	0x00002107, 0x00002107, 0x0000210a, 0x00002113,
+	0x00002115, 0x00002115, 0x00002119, 0x0000211d,
+	0x00002124, 0x00002124, 0x00002126, 0x00002126,
+	0x00002128, 0x00002128, 0x0000212a, 0x0000212d,
+	0x0000212f, 0x00002139, 0x0000213c, 0x0000213f,
+	0x00002145, 0x00002149, 0x0000214e, 0x0000214f,
+	0x00002160, 0x00002188, 0x00002336, 0x0000237a,
+	0x00002395, 0x00002395, 0x0000249c, 0x000024e9,
+	0x000026ac, 0x000026ac, 0x00002800, 0x000028ff,
+	0x00002c00, 0x00002c2e, 0x00002c30, 0x00002c5e,
+	0x00002c60, 0x00002ce4, 0x00002ceb, 0x00002cee,
+	0x00002d00, 0x00002d25, 0x00002d30, 0x00002d65,
+	0x00002d6f, 0x00002d70, 0x00002d80, 0x00002d96,
+	0x00002da0, 0x00002da6, 0x00002da8, 0x00002dae,
+	0x00002db0, 0x00002db6, 0x00002db8, 0x00002dbe,
+	0x00002dc0, 0x00002dc6, 0x00002dc8, 0x00002dce,
+	0x00002dd0, 0x00002dd6, 0x00002dd8, 0x00002dde,
+	0x00003005, 0x00003007, 0x00003021, 0x00003029,
+	0x00003031, 0x00003035, 0x00003038, 0x0000303c,
+	0x00003041, 0x00003096, 0x0000309d, 0x0000309f,
+	0x000030a1, 0x000030fa, 0x000030fc, 0x000030ff,
+	0x00003105, 0x0000312d, 0x00003131, 0x0000318e,
+	0x00003190, 0x000031ba, 0x000031f0, 0x0000321c,
+	0x00003220, 0x0000324f, 0x00003260, 0x0000327b,
+	0x0000327f, 0x000032b0, 0x000032c0, 0x000032cb,
+	0x000032d0, 0x000032fe, 0x00003300, 0x00003376,
+	0x0000337b, 0x000033dd, 0x000033e0, 0x000033fe,
+	0x00003400, 0x00004db5, 0x00004e00, 0x0000a48c,
+	0x0000a4d0, 0x0000a60c, 0x0000a610, 0x0000a62b,
+	0x0000a640, 0x0000a66e, 0x0000a680, 0x0000a697,
+	0x0000a6a0, 0x0000a6ef, 0x0000a6f2, 0x0000a6f7,
+	0x0000a722, 0x0000a787, 0x0000a789, 0x0000a78e,
+	0x0000a790, 0x0000a791, 0x0000a7a0, 0x0000a7a9,
+	0x0000a7fa, 0x0000a801, 0x0000a803, 0x0000a805,
+	0x0000a807, 0x0000a80a, 0x0000a80c, 0x0000a824,
+	0x0000a827, 0x0000a827, 0x0000a830, 0x0000a837,
+	0x0000a840, 0x0000a873, 0x0000a880, 0x0000a8c3,
+	0x0000a8ce, 0x0000a8d9, 0x0000a8f2, 0x0000a8fb,
+	0x0000a900, 0x0000a925, 0x0000a92e, 0x0000a946,
+	0x0000a952, 0x0000a953, 0x0000a95f, 0x0000a97c,
+	0x0000a983, 0x0000a9b2, 0x0000a9b4, 0x0000a9b5,
+	0x0000a9ba, 0x0000a9bb, 0x0000a9bd, 0x0000a9cd,
+	0x0000a9cf, 0x0000a9d9, 0x0000a9de, 0x0000a9df,
+	0x0000aa00, 0x0000aa28, 0x0000aa2f, 0x0000aa30,
+	0x0000aa33, 0x0000aa34, 0x0000aa40, 0x0000aa42,
+	0x0000aa44, 0x0000aa4b, 0x0000aa4d, 0x0000aa4d,
+	0x0000aa50, 0x0000aa59, 0x0000aa5c, 0x0000aa7b,
+	0x0000aa80, 0x0000aaaf, 0x0000aab1, 0x0000aab1,
+	0x0000aab5, 0x0000aab6, 0x0000aab9, 0x0000aabd,
+	0x0000aac0, 0x0000aac0, 0x0000aac2, 0x0000aac2,
+	0x0000aadb, 0x0000aadf, 0x0000ab01, 0x0000ab06,
+	0x0000ab09, 0x0000ab0e, 0x0000ab11, 0x0000ab16,
+	0x0000ab20, 0x0000ab26, 0x0000ab28, 0x0000ab2e,
+	0x0000abc0, 0x0000abe4, 0x0000abe6, 0x0000abe7,
+	0x0000abe9, 0x0000abec, 0x0000abf0, 0x0000abf9,
+	0x0000ac00, 0x0000d7a3, 0x0000d7b0, 0x0000d7c6,
+	0x0000d7cb, 0x0000d7fb, 0x0000e000, 0x0000fb06,
+	0x0000fb13, 0x0000fb17, 0x0000ff21, 0x0000ff3a,
+	0x0000ff41, 0x0000ff5a, 0x0000ff66, 0x0000ffbe,
+	0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf,
+	0x0000ffd2, 0x0000ffd7, 0x0000ffda, 0x0000ffdc,
+	0x00010000, 0x0002a6d6, 0x0002a700, 0x0002a700,
+	0x0002b734, 0x0002b734, 0x0002b740, 0x0002b740,
+	0x0002b81d, 0x0002b81d, 0x0002f800, 0x0002fa1d,
+	0x000f0000, 0x000ffffd, 0x00100000, 0x0010fffd,
+	0x000005be, 0x000005be, 0x000005c0, 0x000005c0,
+	0x000005c3, 0x000005c3, 0x000005c6, 0x000005c6,
+	0x000005d0, 0x000005ea, 0x000005f0, 0x000005f4,
+	0x000007c0, 0x000007ea, 0x000007f4, 0x000007f5,
+	0x000007fa, 0x000007fa, 0x00000800, 0x00000815,
+	0x0000081a, 0x0000081a, 0x00000824, 0x00000824,
+	0x00000828, 0x00000828, 0x00000830, 0x0000083e,
+	0x00000840, 0x00000858, 0x0000085e, 0x0000085e,
+	0x0000200f, 0x0000200f, 0x0000fb1d, 0x0000fb1d,
+	0x0000fb1f, 0x0000fb28, 0x0000fb2a, 0x0000fb36,
+	0x0000fb38, 0x0000fb3c, 0x0000fb3e, 0x0000fb3e,
+	0x0000fb40, 0x0000fb41, 0x0000fb43, 0x0000fb44,
+	0x0000fb46, 0x0000fb4f, 0x00010800, 0x00010805,
+	0x00010808, 0x00010808, 0x0001080a, 0x00010835,
+	0x00010837, 0x00010838, 0x0001083c, 0x0001083c,
+	0x0001083f, 0x00010855, 0x00010857, 0x0001085f,
+	0x00010900, 0x0001091b, 0x00010920, 0x00010939,
+	0x0001093f, 0x0001093f, 0x00010a00, 0x00010a00,
+	0x00010a10, 0x00010a13, 0x00010a15, 0x00010a17,
+	0x00010a19, 0x00010a33, 0x00010a40, 0x00010a47,
+	0x00010a50, 0x00010a58, 0x00010a60, 0x00010a7f,
+	0x00010b00, 0x00010b35, 0x00010b40, 0x00010b55,
+	0x00010b58, 0x00010b72, 0x00010b78, 0x00010b7f,
+	0x00010c00, 0x00010c48, 0x00000030, 0x00000039,
+	0x000000b2, 0x000000b3, 0x000000b9, 0x000000b9,
+	0x000006f0, 0x000006f9, 0x00002070, 0x00002070,
+	0x00002074, 0x00002079, 0x00002080, 0x00002089,
+	0x00002488, 0x0000249b, 0x0000ff10, 0x0000ff19,
+	0x0001d7ce, 0x0001d7ff, 0x0001f100, 0x0001f10a,
+	0x0000002b, 0x0000002b, 0x0000002d, 0x0000002d,
+	0x0000207a, 0x0000207b, 0x0000208a, 0x0000208b,
+	0x00002212, 0x00002212, 0x0000fb29, 0x0000fb29,
+	0x0000fe62, 0x0000fe63, 0x0000ff0b, 0x0000ff0b,
+	0x0000ff0d, 0x0000ff0d, 0x00000023, 0x00000025,
+	0x000000a2, 0x000000a5, 0x000000b0, 0x000000b1,
+	0x00000609, 0x0000060a, 0x0000066a, 0x0000066a,
+	0x000009f2, 0x000009f3, 0x000009fb, 0x000009fb,
+	0x00000af1, 0x00000af1, 0x00000bf9, 0x00000bf9,
+	0x00000e3f, 0x00000e3f, 0x000017db, 0x000017db,
+	0x00002030, 0x00002034, 0x000020a0, 0x000020b9,
+	0x0000212e, 0x0000212e, 0x00002213, 0x00002213,
+	0x0000a838, 0x0000a839, 0x0000fe5f, 0x0000fe5f,
+	0x0000fe69, 0x0000fe6a, 0x0000ff03, 0x0000ff05,
+	0x0000ffe0, 0x0000ffe1, 0x0000ffe5, 0x0000ffe6,
+	0x00000600, 0x00000603, 0x00000660, 0x00000669,
+	0x0000066b, 0x0000066c, 0x000006dd, 0x000006dd,
+	0x0000070f, 0x0000070f, 0x00010e60, 0x00010e7e,
+	0x0000002c, 0x0000002c, 0x0000002e, 0x0000002f,
+	0x0000003a, 0x0000003a, 0x000000a0, 0x000000a0,
+	0x0000060c, 0x0000060c, 0x0000202f, 0x0000202f,
+	0x00002044, 0x00002044, 0x0000fe50, 0x0000fe50,
+	0x0000fe52, 0x0000fe52, 0x0000fe55, 0x0000fe55,
+	0x0000ff0c, 0x0000ff0c, 0x0000ff0e, 0x0000ff0f,
+	0x0000ff1a, 0x0000ff1a, 0x0000000a, 0x0000000a,
+	0x0000000d, 0x0000000d, 0x0000001c, 0x0000001e,
+	0x00000085, 0x00000085, 0x00002029, 0x00002029,
+	0x00000009, 0x00000009, 0x0000000b, 0x0000000b,
+	0x0000001f, 0x0000001f, 0x0000000c, 0x0000000c,
+	0x00000020, 0x00000020, 0x00001680, 0x00001680,
+	0x0000180e, 0x0000180e, 0x00002000, 0x0000200a,
+	0x00002028, 0x00002028, 0x0000205f, 0x0000205f,
+	0x00003000, 0x00003000, 0x00000000, 0x00000008,
+	0x0000000e, 0x0000001b, 0x00000021, 0x00000022,
+	0x00000026, 0x0000002a, 0x0000003b, 0x00000040,
+	0x0000005b, 0x00000060, 0x0000007b, 0x00000084,
+	0x00000086, 0x0000009f, 0x000000a1, 0x000000a1,
+	0x000000a6, 0x000000a9, 0x000000ab, 0x000000af,
+	0x000000b4, 0x000000b4, 0x000000b6, 0x000000b8,
+	0x000000bb, 0x000000bf, 0x000000d7, 0x000000d7,
+	0x000000f7, 0x000000f7, 0x000002b9, 0x000002ba,
+	0x000002c2, 0x000002cf, 0x000002d2, 0x000002df,
+	0x000002e5, 0x000002ed, 0x000002ef, 0x0000036f,
+	0x00000374, 0x00000375, 0x0000037e, 0x0000037e,
+	0x00000384, 0x00000385, 0x00000387, 0x00000387,
+	0x000003f6, 0x000003f6, 0x00000483, 0x00000489,
+	0x0000058a, 0x0000058a, 0x00000591, 0x000005bd,
+	0x000005bf, 0x000005bf, 0x000005c1, 0x000005c2,
+	0x000005c4, 0x000005c5, 0x000005c7, 0x000005c7,
+	0x00000606, 0x00000607, 0x0000060e, 0x0000061a,
+	0x0000064b, 0x0000065f, 0x00000670, 0x00000670,
+	0x000006d6, 0x000006dc, 0x000006de, 0x000006e4,
+	0x000006e7, 0x000006ed, 0x00000711, 0x00000711,
+	0x00000730, 0x0000074a, 0x000007a6, 0x000007b0,
+	0x000007eb, 0x000007f3, 0x000007f6, 0x000007f9,
+	0x00000816, 0x00000819, 0x0000081b, 0x00000823,
+	0x00000825, 0x00000827, 0x00000829, 0x0000082d,
+	0x00000859, 0x0000085b, 0x00000900, 0x00000902,
+	0x0000093a, 0x0000093a, 0x0000093c, 0x0000093c,
+	0x00000941, 0x00000948, 0x0000094d, 0x0000094d,
+	0x00000951, 0x00000957, 0x00000962, 0x00000963,
+	0x00000981, 0x00000981, 0x000009bc, 0x000009bc,
+	0x000009c1, 0x000009c4, 0x000009cd, 0x000009cd,
+	0x000009e2, 0x000009e3, 0x00000a01, 0x00000a02,
+	0x00000a3c, 0x00000a3c, 0x00000a41, 0x00000a42,
+	0x00000a47, 0x00000a48, 0x00000a4b, 0x00000a4d,
+	0x00000a51, 0x00000a51, 0x00000a70, 0x00000a71,
+	0x00000a75, 0x00000a75, 0x00000a81, 0x00000a82,
+	0x00000abc, 0x00000abc, 0x00000ac1, 0x00000ac5,
+	0x00000ac7, 0x00000ac8, 0x00000acd, 0x00000acd,
+	0x00000ae2, 0x00000ae3, 0x00000b01, 0x00000b01,
+	0x00000b3c, 0x00000b3c, 0x00000b3f, 0x00000b3f,
+	0x00000b41, 0x00000b44, 0x00000b4d, 0x00000b4d,
+	0x00000b56, 0x00000b56, 0x00000b62, 0x00000b63,
+	0x00000b82, 0x00000b82, 0x00000bc0, 0x00000bc0,
+	0x00000bcd, 0x00000bcd, 0x00000bf3, 0x00000bf8,
+	0x00000bfa, 0x00000bfa, 0x00000c3e, 0x00000c40,
+	0x00000c46, 0x00000c48, 0x00000c4a, 0x00000c4d,
+	0x00000c55, 0x00000c56, 0x00000c62, 0x00000c63,
+	0x00000c78, 0x00000c7e, 0x00000cbc, 0x00000cbc,
+	0x00000ccc, 0x00000ccd, 0x00000ce2, 0x00000ce3,
+	0x00000d41, 0x00000d44, 0x00000d4d, 0x00000d4d,
+	0x00000d62, 0x00000d63, 0x00000dca, 0x00000dca,
+	0x00000dd2, 0x00000dd4, 0x00000dd6, 0x00000dd6,
+	0x00000e31, 0x00000e31, 0x00000e34, 0x00000e3a,
+	0x00000e47, 0x00000e4e, 0x00000eb1, 0x00000eb1,
+	0x00000eb4, 0x00000eb9, 0x00000ebb, 0x00000ebc,
+	0x00000ec8, 0x00000ecd, 0x00000f18, 0x00000f19,
+	0x00000f35, 0x00000f35, 0x00000f37, 0x00000f37,
+	0x00000f39, 0x00000f3d, 0x00000f71, 0x00000f7e,
+	0x00000f80, 0x00000f84, 0x00000f86, 0x00000f87,
+	0x00000f8d, 0x00000f97, 0x00000f99, 0x00000fbc,
+	0x00000fc6, 0x00000fc6, 0x0000102d, 0x00001030,
+	0x00001032, 0x00001037, 0x00001039, 0x0000103a,
+	0x0000103d, 0x0000103e, 0x00001058, 0x00001059,
+	0x0000105e, 0x00001060, 0x00001071, 0x00001074,
+	0x00001082, 0x00001082, 0x00001085, 0x00001086,
+	0x0000108d, 0x0000108d, 0x0000109d, 0x0000109d,
+	0x0000135d, 0x0000135f, 0x00001390, 0x00001399,
+	0x00001400, 0x00001400, 0x0000169b, 0x0000169c,
+	0x00001712, 0x00001714, 0x00001732, 0x00001734,
+	0x00001752, 0x00001753, 0x00001772, 0x00001773,
+	0x000017b7, 0x000017bd, 0x000017c6, 0x000017c6,
+	0x000017c9, 0x000017d3, 0x000017dd, 0x000017dd,
+	0x000017f0, 0x000017f9, 0x00001800, 0x0000180d,
+	0x000018a9, 0x000018a9, 0x00001920, 0x00001922,
+	0x00001927, 0x00001928, 0x00001932, 0x00001932,
+	0x00001939, 0x0000193b, 0x00001940, 0x00001940,
+	0x00001944, 0x00001945, 0x000019de, 0x000019ff,
+	0x00001a17, 0x00001a18, 0x00001a56, 0x00001a56,
+	0x00001a58, 0x00001a5e, 0x00001a60, 0x00001a60,
+	0x00001a62, 0x00001a62, 0x00001a65, 0x00001a6c,
+	0x00001a73, 0x00001a7c, 0x00001a7f, 0x00001a7f,
+	0x00001b00, 0x00001b03, 0x00001b34, 0x00001b34,
+	0x00001b36, 0x00001b3a, 0x00001b3c, 0x00001b3c,
+	0x00001b42, 0x00001b42, 0x00001b6b, 0x00001b73,
+	0x00001b80, 0x00001b81, 0x00001ba2, 0x00001ba5,
+	0x00001ba8, 0x00001ba9, 0x00001be6, 0x00001be6,
+	0x00001be8, 0x00001be9, 0x00001bed, 0x00001bed,
+	0x00001bef, 0x00001bf1, 0x00001c2c, 0x00001c33,
+	0x00001c36, 0x00001c37, 0x00001cd0, 0x00001cd2,
+	0x00001cd4, 0x00001ce0, 0x00001ce2, 0x00001ce8,
+	0x00001ced, 0x00001ced, 0x00001dc0, 0x00001de6,
+	0x00001dfc, 0x00001dff, 0x00001fbd, 0x00001fbd,
+	0x00001fbf, 0x00001fc1, 0x00001fcd, 0x00001fcf,
+	0x00001fdd, 0x00001fdf, 0x00001fed, 0x00001fef,
+	0x00001ffd, 0x00001ffe, 0x0000200b, 0x0000200d,
+	0x00002010, 0x00002027, 0x0000202a, 0x0000202e,
+	0x00002035, 0x00002043, 0x00002045, 0x0000205e,
+	0x00002060, 0x00002064, 0x0000206a, 0x0000206f,
+	0x0000207c, 0x0000207e, 0x0000208c, 0x0000208e,
+	0x000020d0, 0x000020f0, 0x00002100, 0x00002101,
+	0x00002103, 0x00002106, 0x00002108, 0x00002109,
+	0x00002114, 0x00002114, 0x00002116, 0x00002118,
+	0x0000211e, 0x00002123, 0x00002125, 0x00002125,
+	0x00002127, 0x00002127, 0x00002129, 0x00002129,
+	0x0000213a, 0x0000213b, 0x00002140, 0x00002144,
+	0x0000214a, 0x0000214d, 0x00002150, 0x0000215f,
+	0x00002189, 0x00002189, 0x00002190, 0x00002211,
+	0x00002214, 0x00002335, 0x0000237b, 0x00002394,
+	0x00002396, 0x000023f3, 0x00002400, 0x00002426,
+	0x00002440, 0x0000244a, 0x00002460, 0x00002487,
+	0x000024ea, 0x000026ab, 0x000026ad, 0x000026ff,
+	0x00002701, 0x000027ca, 0x000027cc, 0x000027cc,
+	0x000027ce, 0x000027ff, 0x00002900, 0x00002b4c,
+	0x00002b50, 0x00002b59, 0x00002ce5, 0x00002cea,
+	0x00002cef, 0x00002cf1, 0x00002cf9, 0x00002cff,
+	0x00002d7f, 0x00002d7f, 0x00002de0, 0x00002e31,
+	0x00002e80, 0x00002e99, 0x00002e9b, 0x00002ef3,
+	0x00002f00, 0x00002fd5, 0x00002ff0, 0x00002ffb,
+	0x00003001, 0x00003004, 0x00003008, 0x00003020,
+	0x0000302a, 0x00003030, 0x00003036, 0x00003037,
+	0x0000303d, 0x0000303f, 0x00003099, 0x0000309c,
+	0x000030a0, 0x000030a0, 0x000030fb, 0x000030fb,
+	0x000031c0, 0x000031e3, 0x0000321d, 0x0000321e,
+	0x00003250, 0x0000325f, 0x0000327c, 0x0000327e,
+	0x000032b1, 0x000032bf, 0x000032cc, 0x000032cf,
+	0x00003377, 0x0000337a, 0x000033de, 0x000033df,
+	0x000033ff, 0x000033ff, 0x00004dc0, 0x00004dff,
+	0x0000a490, 0x0000a4c6, 0x0000a60d, 0x0000a60f,
+	0x0000a66f, 0x0000a673, 0x0000a67c, 0x0000a67f,
+	0x0000a6f0, 0x0000a6f1, 0x0000a700, 0x0000a721,
+	0x0000a788, 0x0000a788, 0x0000a802, 0x0000a802,
+	0x0000a806, 0x0000a806, 0x0000a80b, 0x0000a80b,
+	0x0000a825, 0x0000a826, 0x0000a828, 0x0000a82b,
+	0x0000a874, 0x0000a877, 0x0000a8c4, 0x0000a8c4,
+	0x0000a8e0, 0x0000a8f1, 0x0000a926, 0x0000a92d,
+	0x0000a947, 0x0000a951, 0x0000a980, 0x0000a982,
+	0x0000a9b3, 0x0000a9b3, 0x0000a9b6, 0x0000a9b9,
+	0x0000a9bc, 0x0000a9bc, 0x0000aa29, 0x0000aa2e,
+	0x0000aa31, 0x0000aa32, 0x0000aa35, 0x0000aa36,
+	0x0000aa43, 0x0000aa43, 0x0000aa4c, 0x0000aa4c,
+	0x0000aab0, 0x0000aab0, 0x0000aab2, 0x0000aab4,
+	0x0000aab7, 0x0000aab8, 0x0000aabe, 0x0000aabf,
+	0x0000aac1, 0x0000aac1, 0x0000abe5, 0x0000abe5,
+	0x0000abe8, 0x0000abe8, 0x0000abed, 0x0000abed,
+	0x0000fb1e, 0x0000fb1e, 0x0000fd3e, 0x0000fd3f,
+	0x0000fdfd, 0x0000fdfd, 0x0000fe00, 0x0000fe19,
+	0x0000fe20, 0x0000fe26, 0x0000fe30, 0x0000fe4f,
+	0x0000fe51, 0x0000fe51, 0x0000fe54, 0x0000fe54,
+	0x0000fe56, 0x0000fe5e, 0x0000fe60, 0x0000fe61,
+	0x0000fe64, 0x0000fe66, 0x0000fe68, 0x0000fe68,
+	0x0000fe6b, 0x0000fe6b, 0x0000feff, 0x0000feff,
+	0x0000ff01, 0x0000ff02, 0x0000ff06, 0x0000ff0a,
+	0x0000ff1b, 0x0000ff20, 0x0000ff3b, 0x0000ff40,
+	0x0000ff5b, 0x0000ff65, 0x0000ffe2, 0x0000ffe4,
+	0x0000ffe8, 0x0000ffee, 0x0000fff9, 0x0000fffd,
+	0x00010101, 0x00010101, 0x00010140, 0x0001018a,
+	0x00010190, 0x0001019b, 0x000101fd, 0x000101fd,
+	0x0001091f, 0x0001091f, 0x00010a01, 0x00010a03,
+	0x00010a05, 0x00010a06, 0x00010a0c, 0x00010a0f,
+	0x00010a38, 0x00010a3a, 0x00010a3f, 0x00010a3f,
+	0x00010b39, 0x00010b3f, 0x00011001, 0x00011001,
+	0x00011038, 0x00011046, 0x00011052, 0x00011065,
+	0x00011080, 0x00011081, 0x000110b3, 0x000110b6,
+	0x000110b9, 0x000110ba, 0x0001d167, 0x0001d169,
+	0x0001d173, 0x0001d182, 0x0001d185, 0x0001d18b,
+	0x0001d1aa, 0x0001d1ad, 0x0001d200, 0x0001d245,
+	0x0001d300, 0x0001d356, 0x0001d6db, 0x0001d6db,
+	0x0001d715, 0x0001d715, 0x0001d74f, 0x0001d74f,
+	0x0001d789, 0x0001d789, 0x0001d7c3, 0x0001d7c3,
+	0x0001f000, 0x0001f02b, 0x0001f030, 0x0001f093,
+	0x0001f0a0, 0x0001f0ae, 0x0001f0b1, 0x0001f0be,
+	0x0001f0c1, 0x0001f0cf, 0x0001f0d1, 0x0001f0df,
+	0x0001f300, 0x0001f320, 0x0001f330, 0x0001f335,
+	0x0001f337, 0x0001f37c, 0x0001f380, 0x0001f393,
+	0x0001f3a0, 0x0001f3c4, 0x0001f3c6, 0x0001f3ca,
+	0x0001f3e0, 0x0001f3f0, 0x0001f400, 0x0001f43e,
+	0x0001f440, 0x0001f440, 0x0001f442, 0x0001f48b,
+	0x0001f48d, 0x0001f4f7, 0x0001f4f9, 0x0001f4fc,
+	0x0001f500, 0x0001f523, 0x0001f525, 0x0001f53d,
+	0x0001f550, 0x0001f567, 0x0001f5fb, 0x0001f5ff,
+	0x0001f601, 0x0001f610, 0x0001f612, 0x0001f614,
+	0x0001f616, 0x0001f616, 0x0001f618, 0x0001f618,
+	0x0001f61a, 0x0001f61a, 0x0001f61c, 0x0001f61e,
+	0x0001f620, 0x0001f625, 0x0001f628, 0x0001f62b,
+	0x0001f62d, 0x0001f62d, 0x0001f630, 0x0001f633,
+	0x0001f635, 0x0001f640, 0x0001f645, 0x0001f64f,
+	0x0001f680, 0x0001f6c5, 0x0001f700, 0x0001f773,
+	0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f,
+	0x000e0100, 0x000e01ef, 0x000000c0, 0x000000c5,
+	0x000000c7, 0x000000cf, 0x000000d1, 0x000000d6,
+	0x000000d9, 0x000000dd, 0x000000e0, 0x000000e5,
+	0x000000e7, 0x000000ef, 0x000000f1, 0x000000f6,
+	0x000000f9, 0x000000fd, 0x000000ff, 0x0000010f,
+	0x00000112, 0x00000125, 0x00000128, 0x00000130,
+	0x00000134, 0x00000137, 0x00000139, 0x0000013e,
+	0x00000143, 0x00000148, 0x0000014c, 0x00000151,
+	0x00000154, 0x00000165, 0x00000168, 0x0000017e,
+	0x000001a0, 0x000001a1, 0x000001af, 0x000001b0,
+	0x000001cd, 0x000001dc, 0x000001de, 0x000001e3,
+	0x000001e6, 0x000001f0, 0x000001f4, 0x000001f5,
+	0x000001f8, 0x0000021b, 0x0000021e, 0x0000021f,
+	0x00000226, 0x00000233, 0x00000340, 0x00000341,
+	0x00000343, 0x00000344, 0x00000374, 0x00000374,
+	0x0000037e, 0x0000037e, 0x00000385, 0x0000038a,
+	0x0000038c, 0x0000038c, 0x0000038e, 0x00000390,
+	0x000003aa, 0x000003b0, 0x000003ca, 0x000003ce,
+	0x000003d3, 0x000003d4, 0x00000400, 0x00000401,
+	0x00000403, 0x00000403, 0x00000407, 0x00000407,
+	0x0000040c, 0x0000040e, 0x00000419, 0x00000419,
+	0x00000439, 0x00000439, 0x00000450, 0x00000451,
+	0x00000453, 0x00000453, 0x00000457, 0x00000457,
+	0x0000045c, 0x0000045e, 0x00000476, 0x00000477,
+	0x000004c1, 0x000004c2, 0x000004d0, 0x000004d3,
+	0x000004d6, 0x000004d7, 0x000004da, 0x000004df,
+	0x000004e2, 0x000004e7, 0x000004ea, 0x000004f5,
+	0x000004f8, 0x000004f9, 0x00000622, 0x00000626,
+	0x000006c0, 0x000006c0, 0x000006c2, 0x000006c2,
+	0x000006d3, 0x000006d3, 0x00000929, 0x00000929,
+	0x00000931, 0x00000931, 0x00000934, 0x00000934,
+	0x00000958, 0x0000095f, 0x000009cb, 0x000009cc,
+	0x000009dc, 0x000009dd, 0x000009df, 0x000009df,
+	0x00000a33, 0x00000a33, 0x00000a36, 0x00000a36,
+	0x00000a59, 0x00000a5b, 0x00000a5e, 0x00000a5e,
+	0x00000b48, 0x00000b48, 0x00000b4b, 0x00000b4c,
+	0x00000b5c, 0x00000b5d, 0x00000b94, 0x00000b94,
+	0x00000bca, 0x00000bcc, 0x00000c48, 0x00000c48,
+	0x00000cc0, 0x00000cc0, 0x00000cc7, 0x00000cc8,
+	0x00000cca, 0x00000ccb, 0x00000d4a, 0x00000d4c,
+	0x00000dda, 0x00000dda, 0x00000ddc, 0x00000dde,
+	0x00000f43, 0x00000f43, 0x00000f4d, 0x00000f4d,
+	0x00000f52, 0x00000f52, 0x00000f57, 0x00000f57,
+	0x00000f5c, 0x00000f5c, 0x00000f69, 0x00000f69,
+	0x00000f73, 0x00000f73, 0x00000f75, 0x00000f76,
+	0x00000f78, 0x00000f78, 0x00000f81, 0x00000f81,
+	0x00000f93, 0x00000f93, 0x00000f9d, 0x00000f9d,
+	0x00000fa2, 0x00000fa2, 0x00000fa7, 0x00000fa7,
+	0x00000fac, 0x00000fac, 0x00000fb9, 0x00000fb9,
+	0x00001026, 0x00001026, 0x00001b06, 0x00001b06,
+	0x00001b08, 0x00001b08, 0x00001b0a, 0x00001b0a,
+	0x00001b0c, 0x00001b0c, 0x00001b0e, 0x00001b0e,
+	0x00001b12, 0x00001b12, 0x00001b3b, 0x00001b3b,
+	0x00001b3d, 0x00001b3d, 0x00001b40, 0x00001b41,
+	0x00001b43, 0x00001b43, 0x00001e00, 0x00001e99,
+	0x00001e9b, 0x00001e9b, 0x00001ea0, 0x00001ef9,
+	0x00001f00, 0x00001f15, 0x00001f18, 0x00001f1d,
+	0x00001f20, 0x00001f45, 0x00001f48, 0x00001f4d,
+	0x00001f50, 0x00001f57, 0x00001f59, 0x00001f59,
+	0x00001f5b, 0x00001f5b, 0x00001f5d, 0x00001f5d,
+	0x00001f5f, 0x00001f7d, 0x00001f80, 0x00001fb4,
+	0x00001fb6, 0x00001fbc, 0x00001fbe, 0x00001fbe,
+	0x00001fc1, 0x00001fc4, 0x00001fc6, 0x00001fd3,
+	0x00001fd6, 0x00001fdb, 0x00001fdd, 0x00001fef,
+	0x00001ff2, 0x00001ff4, 0x00001ff6, 0x00001ffd,
+	0x00002000, 0x00002001, 0x00002126, 0x00002126,
+	0x0000212a, 0x0000212b, 0x0000219a, 0x0000219b,
+	0x000021ae, 0x000021ae, 0x000021cd, 0x000021cf,
+	0x00002204, 0x00002204, 0x00002209, 0x00002209,
+	0x0000220c, 0x0000220c, 0x00002224, 0x00002224,
+	0x00002226, 0x00002226, 0x00002241, 0x00002241,
+	0x00002244, 0x00002244, 0x00002247, 0x00002247,
+	0x00002249, 0x00002249, 0x00002260, 0x00002260,
+	0x00002262, 0x00002262, 0x0000226d, 0x00002271,
+	0x00002274, 0x00002275, 0x00002278, 0x00002279,
+	0x00002280, 0x00002281, 0x00002284, 0x00002285,
+	0x00002288, 0x00002289, 0x000022ac, 0x000022af,
+	0x000022e0, 0x000022e3, 0x000022ea, 0x000022ed,
+	0x00002329, 0x0000232a, 0x00002adc, 0x00002adc,
+	0x0000304c, 0x0000304c, 0x0000304e, 0x0000304e,
+	0x00003050, 0x00003050, 0x00003052, 0x00003052,
+	0x00003054, 0x00003054, 0x00003056, 0x00003056,
+	0x00003058, 0x00003058, 0x0000305a, 0x0000305a,
+	0x0000305c, 0x0000305c, 0x0000305e, 0x0000305e,
+	0x00003060, 0x00003060, 0x00003062, 0x00003062,
+	0x00003065, 0x00003065, 0x00003067, 0x00003067,
+	0x00003069, 0x00003069, 0x00003070, 0x00003071,
+	0x00003073, 0x00003074, 0x00003076, 0x00003077,
+	0x00003079, 0x0000307a, 0x0000307c, 0x0000307d,
+	0x00003094, 0x00003094, 0x0000309e, 0x0000309e,
+	0x000030ac, 0x000030ac, 0x000030ae, 0x000030ae,
+	0x000030b0, 0x000030b0, 0x000030b2, 0x000030b2,
+	0x000030b4, 0x000030b4, 0x000030b6, 0x000030b6,
+	0x000030b8, 0x000030b8, 0x000030ba, 0x000030ba,
+	0x000030bc, 0x000030bc, 0x000030be, 0x000030be,
+	0x000030c0, 0x000030c0, 0x000030c2, 0x000030c2,
+	0x000030c5, 0x000030c5, 0x000030c7, 0x000030c7,
+	0x000030c9, 0x000030c9, 0x000030d0, 0x000030d1,
+	0x000030d3, 0x000030d4, 0x000030d6, 0x000030d7,
+	0x000030d9, 0x000030da, 0x000030dc, 0x000030dd,
+	0x000030f4, 0x000030f4, 0x000030f7, 0x000030fa,
+	0x000030fe, 0x000030fe, 0x0000f902, 0x0000fa0d,
+	0x0000fa10, 0x0000fa10, 0x0000fa12, 0x0000fa12,
+	0x0000fa15, 0x0000fa1e, 0x0000fa20, 0x0000fa20,
+	0x0000fa22, 0x0000fa22, 0x0000fa25, 0x0000fa26,
+	0x0000fa2a, 0x0000fa2d, 0x0000fa30, 0x0000fa6d,
+	0x0000fa70, 0x0000fad9, 0x0000fb1d, 0x0000fb1d,
+	0x0000fb1f, 0x0000fb1f, 0x0000fb2a, 0x0000fb36,
+	0x0000fb38, 0x0000fb3c, 0x0000fb3e, 0x0000fb3e,
+	0x0000fb40, 0x0000fb41, 0x0000fb43, 0x0000fb44,
+	0x0000fb46, 0x0000fb4e, 0x0001109a, 0x0001109a,
+	0x0001109c, 0x0001109c, 0x000110ab, 0x000110ab,
+	0x0001d15e, 0x0001d164, 0x0001d1bb, 0x0001d1c0,
+	0x0002f800, 0x0002fa1d, 0x00000000, 0x00000377,
+	0x0000037a, 0x0000037e, 0x00000384, 0x0000038a,
+	0x0000038c, 0x0000038c, 0x0000038e, 0x000003a1,
+	0x000003a3, 0x00000527, 0x00000531, 0x00000556,
+	0x00000559, 0x0000055f, 0x00000561, 0x00000587,
+	0x00000589, 0x0000058a, 0x00000591, 0x000005c7,
+	0x000005d0, 0x000005ea, 0x000005f0, 0x000005f4,
+	0x00000600, 0x00000603, 0x00000606, 0x0000061b,
+	0x0000061e, 0x0000070d, 0x0000070f, 0x0000074a,
+	0x0000074d, 0x000007b1, 0x000007c0, 0x000007fa,
+	0x00000800, 0x0000082d, 0x00000830, 0x0000083e,
+	0x00000840, 0x0000085b, 0x0000085e, 0x0000085e,
+	0x00000900, 0x00000977, 0x00000979, 0x0000097f,
+	0x00000981, 0x00000983, 0x00000985, 0x0000098c,
+	0x0000098f, 0x00000990, 0x00000993, 0x000009a8,
+	0x000009aa, 0x000009b0, 0x000009b2, 0x000009b2,
+	0x000009b6, 0x000009b9, 0x000009bc, 0x000009c4,
+	0x000009c7, 0x000009c8, 0x000009cb, 0x000009ce,
+	0x000009d7, 0x000009d7, 0x000009dc, 0x000009dd,
+	0x000009df, 0x000009e3, 0x000009e6, 0x000009fb,
+	0x00000a01, 0x00000a03, 0x00000a05, 0x00000a0a,
+	0x00000a0f, 0x00000a10, 0x00000a13, 0x00000a28,
+	0x00000a2a, 0x00000a30, 0x00000a32, 0x00000a33,
+	0x00000a35, 0x00000a36, 0x00000a38, 0x00000a39,
+	0x00000a3c, 0x00000a3c, 0x00000a3e, 0x00000a42,
+	0x00000a47, 0x00000a48, 0x00000a4b, 0x00000a4d,
+	0x00000a51, 0x00000a51, 0x00000a59, 0x00000a5c,
+	0x00000a5e, 0x00000a5e, 0x00000a66, 0x00000a75,
+	0x00000a81, 0x00000a83, 0x00000a85, 0x00000a8d,
+	0x00000a8f, 0x00000a91, 0x00000a93, 0x00000aa8,
+	0x00000aaa, 0x00000ab0, 0x00000ab2, 0x00000ab3,
+	0x00000ab5, 0x00000ab9, 0x00000abc, 0x00000ac5,
+	0x00000ac7, 0x00000ac9, 0x00000acb, 0x00000acd,
+	0x00000ad0, 0x00000ad0, 0x00000ae0, 0x00000ae3,
+	0x00000ae6, 0x00000aef, 0x00000af1, 0x00000af1,
+	0x00000b01, 0x00000b03, 0x00000b05, 0x00000b0c,
+	0x00000b0f, 0x00000b10, 0x00000b13, 0x00000b28,
+	0x00000b2a, 0x00000b30, 0x00000b32, 0x00000b33,
+	0x00000b35, 0x00000b39, 0x00000b3c, 0x00000b44,
+	0x00000b47, 0x00000b48, 0x00000b4b, 0x00000b4d,
+	0x00000b56, 0x00000b57, 0x00000b5c, 0x00000b5d,
+	0x00000b5f, 0x00000b63, 0x00000b66, 0x00000b77,
+	0x00000b82, 0x00000b83, 0x00000b85, 0x00000b8a,
+	0x00000b8e, 0x00000b90, 0x00000b92, 0x00000b95,
+	0x00000b99, 0x00000b9a, 0x00000b9c, 0x00000b9c,
+	0x00000b9e, 0x00000b9f, 0x00000ba3, 0x00000ba4,
+	0x00000ba8, 0x00000baa, 0x00000bae, 0x00000bb9,
+	0x00000bbe, 0x00000bc2, 0x00000bc6, 0x00000bc8,
+	0x00000bca, 0x00000bcd, 0x00000bd0, 0x00000bd0,
+	0x00000bd7, 0x00000bd7, 0x00000be6, 0x00000bfa,
+	0x00000c01, 0x00000c03, 0x00000c05, 0x00000c0c,
+	0x00000c0e, 0x00000c10, 0x00000c12, 0x00000c28,
+	0x00000c2a, 0x00000c33, 0x00000c35, 0x00000c39,
+	0x00000c3d, 0x00000c44, 0x00000c46, 0x00000c48,
+	0x00000c4a, 0x00000c4d, 0x00000c55, 0x00000c56,
+	0x00000c58, 0x00000c59, 0x00000c60, 0x00000c63,
+	0x00000c66, 0x00000c6f, 0x00000c78, 0x00000c7f,
+	0x00000c82, 0x00000c83, 0x00000c85, 0x00000c8c,
+	0x00000c8e, 0x00000c90, 0x00000c92, 0x00000ca8,
+	0x00000caa, 0x00000cb3, 0x00000cb5, 0x00000cb9,
+	0x00000cbc, 0x00000cc4, 0x00000cc6, 0x00000cc8,
+	0x00000cca, 0x00000ccd, 0x00000cd5, 0x00000cd6,
+	0x00000cde, 0x00000cde, 0x00000ce0, 0x00000ce3,
+	0x00000ce6, 0x00000cef, 0x00000cf1, 0x00000cf2,
+	0x00000d02, 0x00000d03, 0x00000d05, 0x00000d0c,
+	0x00000d0e, 0x00000d10, 0x00000d12, 0x00000d3a,
+	0x00000d3d, 0x00000d44, 0x00000d46, 0x00000d48,
+	0x00000d4a, 0x00000d4e, 0x00000d57, 0x00000d57,
+	0x00000d60, 0x00000d63, 0x00000d66, 0x00000d75,
+	0x00000d79, 0x00000d7f, 0x00000d82, 0x00000d83,
+	0x00000d85, 0x00000d96, 0x00000d9a, 0x00000db1,
+	0x00000db3, 0x00000dbb, 0x00000dbd, 0x00000dbd,
+	0x00000dc0, 0x00000dc6, 0x00000dca, 0x00000dca,
+	0x00000dcf, 0x00000dd4, 0x00000dd6, 0x00000dd6,
+	0x00000dd8, 0x00000ddf, 0x00000df2, 0x00000df4,
+	0x00000e01, 0x00000e3a, 0x00000e3f, 0x00000e5b,
+	0x00000e81, 0x00000e82, 0x00000e84, 0x00000e84,
+	0x00000e87, 0x00000e88, 0x00000e8a, 0x00000e8a,
+	0x00000e8d, 0x00000e8d, 0x00000e94, 0x00000e97,
+	0x00000e99, 0x00000e9f, 0x00000ea1, 0x00000ea3,
+	0x00000ea5, 0x00000ea5, 0x00000ea7, 0x00000ea7,
+	0x00000eaa, 0x00000eab, 0x00000ead, 0x00000eb9,
+	0x00000ebb, 0x00000ebd, 0x00000ec0, 0x00000ec4,
+	0x00000ec6, 0x00000ec6, 0x00000ec8, 0x00000ecd,
+	0x00000ed0, 0x00000ed9, 0x00000edc, 0x00000edd,
+	0x00000f00, 0x00000f47, 0x00000f49, 0x00000f6c,
+	0x00000f71, 0x00000f97, 0x00000f99, 0x00000fbc,
+	0x00000fbe, 0x00000fcc, 0x00000fce, 0x00000fda,
+	0x00001000, 0x000010c5, 0x000010d0, 0x000010fc,
+	0x00001100, 0x00001248, 0x0000124a, 0x0000124d,
+	0x00001250, 0x00001256, 0x00001258, 0x00001258,
+	0x0000125a, 0x0000125d, 0x00001260, 0x00001288,
+	0x0000128a, 0x0000128d, 0x00001290, 0x000012b0,
+	0x000012b2, 0x000012b5, 0x000012b8, 0x000012be,
+	0x000012c0, 0x000012c0, 0x000012c2, 0x000012c5,
+	0x000012c8, 0x000012d6, 0x000012d8, 0x00001310,
+	0x00001312, 0x00001315, 0x00001318, 0x0000135a,
+	0x0000135d, 0x0000137c, 0x00001380, 0x00001399,
+	0x000013a0, 0x000013f4, 0x00001400, 0x0000169c,
+	0x000016a0, 0x000016f0, 0x00001700, 0x0000170c,
+	0x0000170e, 0x00001714, 0x00001720, 0x00001736,
+	0x00001740, 0x00001753, 0x00001760, 0x0000176c,
+	0x0000176e, 0x00001770, 0x00001772, 0x00001773,
+	0x00001780, 0x000017dd, 0x000017e0, 0x000017e9,
+	0x000017f0, 0x000017f9, 0x00001800, 0x0000180e,
+	0x00001810, 0x00001819, 0x00001820, 0x00001877,
+	0x00001880, 0x000018aa, 0x000018b0, 0x000018f5,
+	0x00001900, 0x0000191c, 0x00001920, 0x0000192b,
+	0x00001930, 0x0000193b, 0x00001940, 0x00001940,
+	0x00001944, 0x0000196d, 0x00001970, 0x00001974,
+	0x00001980, 0x000019ab, 0x000019b0, 0x000019c9,
+	0x000019d0, 0x000019da, 0x000019de, 0x00001a1b,
+	0x00001a1e, 0x00001a5e, 0x00001a60, 0x00001a7c,
+	0x00001a7f, 0x00001a89, 0x00001a90, 0x00001a99,
+	0x00001aa0, 0x00001aad, 0x00001b00, 0x00001b4b,
+	0x00001b50, 0x00001b7c, 0x00001b80, 0x00001baa,
+	0x00001bae, 0x00001bb9, 0x00001bc0, 0x00001bf3,
+	0x00001bfc, 0x00001c37, 0x00001c3b, 0x00001c49,
+	0x00001c4d, 0x00001c7f, 0x00001cd0, 0x00001cf2,
+	0x00001d00, 0x00001de6, 0x00001dfc, 0x00001f15,
+	0x00001f18, 0x00001f1d, 0x00001f20, 0x00001f45,
+	0x00001f48, 0x00001f4d, 0x00001f50, 0x00001f57,
+	0x00001f59, 0x00001f59, 0x00001f5b, 0x00001f5b,
+	0x00001f5d, 0x00001f5d, 0x00001f5f, 0x00001f7d,
+	0x00001f80, 0x00001fb4, 0x00001fb6, 0x00001fc4,
+	0x00001fc6, 0x00001fd3, 0x00001fd6, 0x00001fdb,
+	0x00001fdd, 0x00001fef, 0x00001ff2, 0x00001ff4,
+	0x00001ff6, 0x00001ffe, 0x00002000, 0x00002064,
+	0x0000206a, 0x00002071, 0x00002074, 0x0000208e,
+	0x00002090, 0x0000209c, 0x000020a0, 0x000020b9,
+	0x000020d0, 0x000020f0, 0x00002100, 0x00002189,
+	0x00002190, 0x000023f3, 0x00002400, 0x00002426,
+	0x00002440, 0x0000244a, 0x00002460, 0x000026ff,
+	0x00002701, 0x000027ca, 0x000027cc, 0x000027cc,
+	0x000027ce, 0x00002b4c, 0x00002b50, 0x00002b59,
+	0x00002c00, 0x00002c2e, 0x00002c30, 0x00002c5e,
+	0x00002c60, 0x00002cf1, 0x00002cf9, 0x00002d25,
+	0x00002d30, 0x00002d65, 0x00002d6f, 0x00002d70,
+	0x00002d7f, 0x00002d96, 0x00002da0, 0x00002da6,
+	0x00002da8, 0x00002dae, 0x00002db0, 0x00002db6,
+	0x00002db8, 0x00002dbe, 0x00002dc0, 0x00002dc6,
+	0x00002dc8, 0x00002dce, 0x00002dd0, 0x00002dd6,
+	0x00002dd8, 0x00002dde, 0x00002de0, 0x00002e31,
+	0x00002e80, 0x00002e99, 0x00002e9b, 0x00002ef3,
+	0x00002f00, 0x00002fd5, 0x00002ff0, 0x00002ffb,
+	0x00003000, 0x0000303f, 0x00003041, 0x00003096,
+	0x00003099, 0x000030ff, 0x00003105, 0x0000312d,
+	0x00003131, 0x0000318e, 0x00003190, 0x000031ba,
+	0x000031c0, 0x000031e3, 0x000031f0, 0x0000321e,
+	0x00003220, 0x000032fe, 0x00003300, 0x000033ff,
+	0x00003400, 0x00004db5, 0x00004dc0, 0x00004dff,
+	0x00004e00, 0x00009fa5, 0x0000a000, 0x0000a48c,
+	0x0000a490, 0x0000a4c6, 0x0000a4d0, 0x0000a62b,
+	0x0000a640, 0x0000a673, 0x0000a67c, 0x0000a697,
+	0x0000a6a0, 0x0000a6f7, 0x0000a700, 0x0000a78e,
+	0x0000a790, 0x0000a791, 0x0000a7a0, 0x0000a7a9,
+	0x0000a7fa, 0x0000a82b, 0x0000a830, 0x0000a839,
+	0x0000a840, 0x0000a877, 0x0000a880, 0x0000a8c4,
+	0x0000a8ce, 0x0000a8d9, 0x0000a8e0, 0x0000a8fb,
+	0x0000a900, 0x0000a953, 0x0000a95f, 0x0000a97c,
+	0x0000a980, 0x0000a9cd, 0x0000a9cf, 0x0000a9d9,
+	0x0000a9de, 0x0000a9df, 0x0000aa00, 0x0000aa36,
+	0x0000aa40, 0x0000aa4d, 0x0000aa50, 0x0000aa59,
+	0x0000aa5c, 0x0000aa7b, 0x0000aa80, 0x0000aac2,
+	0x0000aadb, 0x0000aadf, 0x0000ab01, 0x0000ab06,
+	0x0000ab09, 0x0000ab0e, 0x0000ab11, 0x0000ab16,
+	0x0000ab20, 0x0000ab26, 0x0000ab28, 0x0000ab2e,
+	0x0000abc0, 0x0000abed, 0x0000abf0, 0x0000abf9,
+	0x0000ac00, 0x0000d7a3, 0x0000d7b0, 0x0000d7c6,
+	0x0000d7cb, 0x0000d7fb, 0x0000f900, 0x0000fb06,
+	0x0000fb13, 0x0000fb17, 0x0000fb1d, 0x0000fb36,
+	0x0000fb38, 0x0000fb3c, 0x0000fb3e, 0x0000fb3e,
+	0x0000fb40, 0x0000fb41, 0x0000fb43, 0x0000fb44,
+	0x0000fb46, 0x0000fbc1, 0x0000fbd3, 0x0000fd3f,
+	0x0000fd50, 0x0000fd8f, 0x0000fd92, 0x0000fdc7,
+	0x0000fdf0, 0x0000fdfd, 0x0000fe00, 0x0000fe19,
+	0x0000fe20, 0x0000fe26, 0x0000fe30, 0x0000fe52,
+	0x0000fe54, 0x0000fe66, 0x0000fe68, 0x0000fe6b,
+	0x0000fe70, 0x0000fe74, 0x0000fe76, 0x0000fefc,
+	0x0000feff, 0x0000feff, 0x0000ff01, 0x0000ffbe,
+	0x0000ffc2, 0x0000ffc7, 0x0000ffca, 0x0000ffcf,
+	0x0000ffd2, 0x0000ffd7, 0x0000ffda, 0x0000ffdc,
+	0x0000ffe0, 0x0000ffe6, 0x0000ffe8, 0x0000ffee,
+	0x0000fff9, 0x0000fffd, 0x00010000, 0x0001000b,
+	0x0001000d, 0x00010026, 0x00010028, 0x0001003a,
+	0x0001003c, 0x0001003d, 0x0001003f, 0x0001004d,
+	0x00010050, 0x0001005d, 0x00010080, 0x000100fa,
+	0x00010100, 0x00010102, 0x00010107, 0x00010133,
+	0x00010137, 0x0001018a, 0x00010190, 0x0001019b,
+	0x000101d0, 0x000101fd, 0x00010280, 0x0001029c,
+	0x000102a0, 0x000102d0, 0x00010300, 0x0001031e,
+	0x00010320, 0x00010323, 0x00010330, 0x0001034a,
+	0x00010380, 0x0001039d, 0x0001039f, 0x000103c3,
+	0x000103c8, 0x000103d5, 0x00010400, 0x0001049d,
+	0x000104a0, 0x000104a9, 0x00010800, 0x00010805,
+	0x00010808, 0x00010808, 0x0001080a, 0x00010835,
+	0x00010837, 0x00010838, 0x0001083c, 0x0001083c,
+	0x0001083f, 0x00010855, 0x00010857, 0x0001085f,
+	0x00010900, 0x0001091b, 0x0001091f, 0x00010939,
+	0x0001093f, 0x0001093f, 0x00010a00, 0x00010a03,
+	0x00010a05, 0x00010a06, 0x00010a0c, 0x00010a13,
+	0x00010a15, 0x00010a17, 0x00010a19, 0x00010a33,
+	0x00010a38, 0x00010a3a, 0x00010a3f, 0x00010a47,
+	0x00010a50, 0x00010a58, 0x00010a60, 0x00010a7f,
+	0x00010b00, 0x00010b35, 0x00010b39, 0x00010b55,
+	0x00010b58, 0x00010b72, 0x00010b78, 0x00010b7f,
+	0x00010c00, 0x00010c48, 0x00010e60, 0x00010e7e,
+	0x00011000, 0x0001104d, 0x00011052, 0x0001106f,
+	0x00011080, 0x000110c1, 0x00012000, 0x0001236e,
+	0x00012400, 0x00012462, 0x00012470, 0x00012473,
+	0x00013000, 0x0001342e, 0x00016800, 0x00016a38,
+	0x0001b000, 0x0001b001, 0x0001d000, 0x0001d0f5,
+	0x0001d100, 0x0001d126, 0x0001d129, 0x0001d1dd,
+	0x0001d200, 0x0001d245, 0x0001d300, 0x0001d356,
+	0x0001d360, 0x0001d371, 0x0001d400, 0x0001d454,
+	0x0001d456, 0x0001d49c, 0x0001d49e, 0x0001d49f,
+	0x0001d4a2, 0x0001d4a2, 0x0001d4a5, 0x0001d4a6,
+	0x0001d4a9, 0x0001d4ac, 0x0001d4ae, 0x0001d4b9,
+	0x0001d4bb, 0x0001d4bb, 0x0001d4bd, 0x0001d4c3,
+	0x0001d4c5, 0x0001d505, 0x0001d507, 0x0001d50a,
+	0x0001d50d, 0x0001d514, 0x0001d516, 0x0001d51c,
+	0x0001d51e, 0x0001d539, 0x0001d53b, 0x0001d53e,
+	0x0001d540, 0x0001d544, 0x0001d546, 0x0001d546,
+	0x0001d54a, 0x0001d550, 0x0001d552, 0x0001d6a5,
+	0x0001d6a8, 0x0001d7cb, 0x0001d7ce, 0x0001d7ff,
+	0x0001f000, 0x0001f02b, 0x0001f030, 0x0001f093,
+	0x0001f0a0, 0x0001f0ae, 0x0001f0b1, 0x0001f0be,
+	0x0001f0c1, 0x0001f0cf, 0x0001f0d1, 0x0001f0df,
+	0x0001f100, 0x0001f10a, 0x0001f110, 0x0001f12e,
+	0x0001f130, 0x0001f169, 0x0001f170, 0x0001f19a,
+	0x0001f1e6, 0x0001f202, 0x0001f210, 0x0001f23a,
+	0x0001f240, 0x0001f248, 0x0001f250, 0x0001f251,
+	0x0001f300, 0x0001f320, 0x0001f330, 0x0001f335,
+	0x0001f337, 0x0001f37c, 0x0001f380, 0x0001f393,
+	0x0001f3a0, 0x0001f3c4, 0x0001f3c6, 0x0001f3ca,
+	0x0001f3e0, 0x0001f3f0, 0x0001f400, 0x0001f43e,
+	0x0001f440, 0x0001f440, 0x0001f442, 0x0001f4f7,
+	0x0001f4f9, 0x0001f4fc, 0x0001f500, 0x0001f53d,
+	0x0001f550, 0x0001f567, 0x0001f5fb, 0x0001f5ff,
+	0x0001f601, 0x0001f610, 0x0001f612, 0x0001f614,
+	0x0001f616, 0x0001f616, 0x0001f618, 0x0001f618,
+	0x0001f61a, 0x0001f61a, 0x0001f61c, 0x0001f61e,
+	0x0001f620, 0x0001f625, 0x0001f628, 0x0001f62b,
+	0x0001f62d, 0x0001f62d, 0x0001f630, 0x0001f633,
+	0x0001f635, 0x0001f640, 0x0001f645, 0x0001f64f,
+	0x0001f680, 0x0001f6c5, 0x0001f700, 0x0001f773,
+	0x00020000, 0x0002a6d6, 0x0002a700, 0x0002a700,
+	0x0002b734, 0x0002b734, 0x0002b740, 0x0002b740,
+	0x0002b81d, 0x0002b81d, 0x0002f800, 0x0002fa1d,
+	0x000e0001, 0x000e0001, 0x000e0020, 0x000e007f,
+	0x000e0100, 0x000e01ef, 0x000000ab, 0x000000ab,
+	0x00002018, 0x00002018, 0x0000201b, 0x0000201c,
+	0x0000201f, 0x0000201f, 0x00002039, 0x00002039,
+	0x00002e02, 0x00002e02, 0x00002e04, 0x00002e04,
+	0x00002e09, 0x00002e09, 0x00002e0c, 0x00002e0c,
+	0x00002e1c, 0x00002e1c, 0x00002e20, 0x00002e20,
+	0x000000bb, 0x000000bb, 0x00002019, 0x00002019,
+	0x0000201d, 0x0000201d, 0x0000203a, 0x0000203a,
+	0x00002e03, 0x00002e03, 0x00002e05, 0x00002e05,
+	0x00002e0a, 0x00002e0a, 0x00002e0d, 0x00002e0d,
+	0x00002e1d, 0x00002e1d, 0x00002e21, 0x00002e21,
+	0x00000608, 0x00000608, 0x0000060b, 0x0000060b,
+	0x0000060d, 0x0000060d, 0x0000061b, 0x0000061b,
+	0x0000061e, 0x0000064a, 0x0000066d, 0x0000066f,
+	0x00000671, 0x000006d5, 0x000006e5, 0x000006e6,
+	0x000006ee, 0x000006ef, 0x000006fa, 0x0000070d,
+	0x00000710, 0x00000710, 0x00000712, 0x0000072f,
+	0x0000074d, 0x000007a5, 0x000007b1, 0x000007b1,
+	0x0000fb50, 0x0000fbc1, 0x0000fbd3, 0x0000fd3d,
+	0x0000fd50, 0x0000fd8f, 0x0000fd92, 0x0000fdc7,
+	0x0000fdf0, 0x0000fdfc, 0x0000fe70, 0x0000fe74,
+	0x0000fe76, 0x0000fefc
 };
-/* }}} */
-/* {{{ case data */
-static unsigned short _uccase_size = 0x05e0;
-static unsigned short _uccase_len[2] = { 0x08bb, 0x08d9 };
-static unsigned long _uccase_map[] = {
-/* upper */
-0x00000041, 0x00000061, 0x00000041,
-0x00000042, 0x00000062, 0x00000042,
-0x00000043, 0x00000063, 0x00000043,
-0x00000044, 0x00000064, 0x00000044,
-0x00000045, 0x00000065, 0x00000045,
-0x00000046, 0x00000066, 0x00000046,
-0x00000047, 0x00000067, 0x00000047,
-0x00000048, 0x00000068, 0x00000048,
-0x00000049, 0x00000069, 0x00000049,
-0x0000004a, 0x0000006a, 0x0000004a,
-0x0000004b, 0x0000006b, 0x0000004b,
-0x0000004c, 0x0000006c, 0x0000004c,
-0x0000004d, 0x0000006d, 0x0000004d,
-0x0000004e, 0x0000006e, 0x0000004e,
-0x0000004f, 0x0000006f, 0x0000004f,
-0x00000050, 0x00000070, 0x00000050,
-0x00000051, 0x00000071, 0x00000051,
-0x00000052, 0x00000072, 0x00000052,
-0x00000053, 0x00000073, 0x00000053,
-0x00000054, 0x00000074, 0x00000054,
-0x00000055, 0x00000075, 0x00000055,
-0x00000056, 0x00000076, 0x00000056,
-0x00000057, 0x00000077, 0x00000057,
-0x00000058, 0x00000078, 0x00000058,
-0x00000059, 0x00000079, 0x00000059,
-0x0000005a, 0x0000007a, 0x0000005a,
-0x000000c0, 0x000000e0, 0x000000c0,
-0x000000c1, 0x000000e1, 0x000000c1,
-0x000000c2, 0x000000e2, 0x000000c2,
-0x000000c3, 0x000000e3, 0x000000c3,
-0x000000c4, 0x000000e4, 0x000000c4,
-0x000000c5, 0x000000e5, 0x000000c5,
-0x000000c6, 0x000000e6, 0x000000c6,
-0x000000c7, 0x000000e7, 0x000000c7,
-0x000000c8, 0x000000e8, 0x000000c8,
-0x000000c9, 0x000000e9, 0x000000c9,
-0x000000ca, 0x000000ea, 0x000000ca,
-0x000000cb, 0x000000eb, 0x000000cb,
-0x000000cc, 0x000000ec, 0x000000cc,
-0x000000cd, 0x000000ed, 0x000000cd,
-0x000000ce, 0x000000ee, 0x000000ce,
-0x000000cf, 0x000000ef, 0x000000cf,
-0x000000d0, 0x000000f0, 0x000000d0,
-0x000000d1, 0x000000f1, 0x000000d1,
-0x000000d2, 0x000000f2, 0x000000d2,
-0x000000d3, 0x000000f3, 0x000000d3,
-0x000000d4, 0x000000f4, 0x000000d4,
-0x000000d5, 0x000000f5, 0x000000d5,
-0x000000d6, 0x000000f6, 0x000000d6,
-0x000000d8, 0x000000f8, 0x000000d8,
-0x000000d9, 0x000000f9, 0x000000d9,
-0x000000da, 0x000000fa, 0x000000da,
-0x000000db, 0x000000fb, 0x000000db,
-0x000000dc, 0x000000fc, 0x000000dc,
-0x000000dd, 0x000000fd, 0x000000dd,
-0x000000de, 0x000000fe, 0x000000de,
-0x00000100, 0x00000101, 0x00000100,
-0x00000102, 0x00000103, 0x00000102,
-0x00000104, 0x00000105, 0x00000104,
-0x00000106, 0x00000107, 0x00000106,
-0x00000108, 0x00000109, 0x00000108,
-0x0000010a, 0x0000010b, 0x0000010a,
-0x0000010c, 0x0000010d, 0x0000010c,
-0x0000010e, 0x0000010f, 0x0000010e,
-0x00000110, 0x00000111, 0x00000110,
-0x00000112, 0x00000113, 0x00000112,
-0x00000114, 0x00000115, 0x00000114,
-0x00000116, 0x00000117, 0x00000116,
-0x00000118, 0x00000119, 0x00000118,
-0x0000011a, 0x0000011b, 0x0000011a,
-0x0000011c, 0x0000011d, 0x0000011c,
-0x0000011e, 0x0000011f, 0x0000011e,
-0x00000120, 0x00000121, 0x00000120,
-0x00000122, 0x00000123, 0x00000122,
-0x00000124, 0x00000125, 0x00000124,
-0x00000126, 0x00000127, 0x00000126,
-0x00000128, 0x00000129, 0x00000128,
-0x0000012a, 0x0000012b, 0x0000012a,
-0x0000012c, 0x0000012d, 0x0000012c,
-0x0000012e, 0x0000012f, 0x0000012e,
-0x00000130, 0x00000069, 0x00000130,
-0x00000132, 0x00000133, 0x00000132,
-0x00000134, 0x00000135, 0x00000134,
-0x00000136, 0x00000137, 0x00000136,
-0x00000139, 0x0000013a, 0x00000139,
-0x0000013b, 0x0000013c, 0x0000013b,
-0x0000013d, 0x0000013e, 0x0000013d,
-0x0000013f, 0x00000140, 0x0000013f,
-0x00000141, 0x00000142, 0x00000141,
-0x00000143, 0x00000144, 0x00000143,
-0x00000145, 0x00000146, 0x00000145,
-0x00000147, 0x00000148, 0x00000147,
-0x0000014a, 0x0000014b, 0x0000014a,
-0x0000014c, 0x0000014d, 0x0000014c,
-0x0000014e, 0x0000014f, 0x0000014e,
-0x00000150, 0x00000151, 0x00000150,
-0x00000152, 0x00000153, 0x00000152,
-0x00000154, 0x00000155, 0x00000154,
-0x00000156, 0x00000157, 0x00000156,
-0x00000158, 0x00000159, 0x00000158,
-0x0000015a, 0x0000015b, 0x0000015a,
-0x0000015c, 0x0000015d, 0x0000015c,
-0x0000015e, 0x0000015f, 0x0000015e,
-0x00000160, 0x00000161, 0x00000160,
-0x00000162, 0x00000163, 0x00000162,
-0x00000164, 0x00000165, 0x00000164,
-0x00000166, 0x00000167, 0x00000166,
-0x00000168, 0x00000169, 0x00000168,
-0x0000016a, 0x0000016b, 0x0000016a,
-0x0000016c, 0x0000016d, 0x0000016c,
-0x0000016e, 0x0000016f, 0x0000016e,
-0x00000170, 0x00000171, 0x00000170,
-0x00000172, 0x00000173, 0x00000172,
-0x00000174, 0x00000175, 0x00000174,
-0x00000176, 0x00000177, 0x00000176,
-0x00000178, 0x000000ff, 0x00000178,
-0x00000179, 0x0000017a, 0x00000179,
-0x0000017b, 0x0000017c, 0x0000017b,
-0x0000017d, 0x0000017e, 0x0000017d,
-0x00000181, 0x00000253, 0x00000181,
-0x00000182, 0x00000183, 0x00000182,
-0x00000184, 0x00000185, 0x00000184,
-0x00000186, 0x00000254, 0x00000186,
-0x00000187, 0x00000188, 0x00000187,
-0x00000189, 0x00000256, 0x00000189,
-0x0000018a, 0x00000257, 0x0000018a,
-0x0000018b, 0x0000018c, 0x0000018b,
-0x0000018e, 0x000001dd, 0x0000018e,
-0x0000018f, 0x00000259, 0x0000018f,
-0x00000190, 0x0000025b, 0x00000190,
-0x00000191, 0x00000192, 0x00000191,
-0x00000193, 0x00000260, 0x00000193,
-0x00000194, 0x00000263, 0x00000194,
-0x00000196, 0x00000269, 0x00000196,
-0x00000197, 0x00000268, 0x00000197,
-0x00000198, 0x00000199, 0x00000198,
-0x0000019c, 0x0000026f, 0x0000019c,
-0x0000019d, 0x00000272, 0x0000019d,
-0x0000019f, 0x00000275, 0x0000019f,
-0x000001a0, 0x000001a1, 0x000001a0,
-0x000001a2, 0x000001a3, 0x000001a2,
-0x000001a4, 0x000001a5, 0x000001a4,
-0x000001a6, 0x00000280, 0x000001a6,
-0x000001a7, 0x000001a8, 0x000001a7,
-0x000001a9, 0x00000283, 0x000001a9,
-0x000001ac, 0x000001ad, 0x000001ac,
-0x000001ae, 0x00000288, 0x000001ae,
-0x000001af, 0x000001b0, 0x000001af,
-0x000001b1, 0x0000028a, 0x000001b1,
-0x000001b2, 0x0000028b, 0x000001b2,
-0x000001b3, 0x000001b4, 0x000001b3,
-0x000001b5, 0x000001b6, 0x000001b5,
-0x000001b7, 0x00000292, 0x000001b7,
-0x000001b8, 0x000001b9, 0x000001b8,
-0x000001bc, 0x000001bd, 0x000001bc,
-0x000001c4, 0x000001c6, 0x000001c5,
-0x000001c7, 0x000001c9, 0x000001c8,
-0x000001ca, 0x000001cc, 0x000001cb,
-0x000001cd, 0x000001ce, 0x000001cd,
-0x000001cf, 0x000001d0, 0x000001cf,
-0x000001d1, 0x000001d2, 0x000001d1,
-0x000001d3, 0x000001d4, 0x000001d3,
-0x000001d5, 0x000001d6, 0x000001d5,
-0x000001d7, 0x000001d8, 0x000001d7,
-0x000001d9, 0x000001da, 0x000001d9,
-0x000001db, 0x000001dc, 0x000001db,
-0x000001de, 0x000001df, 0x000001de,
-0x000001e0, 0x000001e1, 0x000001e0,
-0x000001e2, 0x000001e3, 0x000001e2,
-0x000001e4, 0x000001e5, 0x000001e4,
-0x000001e6, 0x000001e7, 0x000001e6,
-0x000001e8, 0x000001e9, 0x000001e8,
-0x000001ea, 0x000001eb, 0x000001ea,
-0x000001ec, 0x000001ed, 0x000001ec,
-0x000001ee, 0x000001ef, 0x000001ee,
-0x000001f1, 0x000001f3, 0x000001f2,
-0x000001f4, 0x000001f5, 0x000001f4,
-0x000001f6, 0x00000195, 0x000001f6,
-0x000001f7, 0x000001bf, 0x000001f7,
-0x000001f8, 0x000001f9, 0x000001f8,
-0x000001fa, 0x000001fb, 0x000001fa,
-0x000001fc, 0x000001fd, 0x000001fc,
-0x000001fe, 0x000001ff, 0x000001fe,
-0x00000200, 0x00000201, 0x00000200,
-0x00000202, 0x00000203, 0x00000202,
-0x00000204, 0x00000205, 0x00000204,
-0x00000206, 0x00000207, 0x00000206,
-0x00000208, 0x00000209, 0x00000208,
-0x0000020a, 0x0000020b, 0x0000020a,
-0x0000020c, 0x0000020d, 0x0000020c,
-0x0000020e, 0x0000020f, 0x0000020e,
-0x00000210, 0x00000211, 0x00000210,
-0x00000212, 0x00000213, 0x00000212,
-0x00000214, 0x00000215, 0x00000214,
-0x00000216, 0x00000217, 0x00000216,
-0x00000218, 0x00000219, 0x00000218,
-0x0000021a, 0x0000021b, 0x0000021a,
-0x0000021c, 0x0000021d, 0x0000021c,
-0x0000021e, 0x0000021f, 0x0000021e,
-0x00000220, 0x0000019e, 0x00000220,
-0x00000222, 0x00000223, 0x00000222,
-0x00000224, 0x00000225, 0x00000224,
-0x00000226, 0x00000227, 0x00000226,
-0x00000228, 0x00000229, 0x00000228,
-0x0000022a, 0x0000022b, 0x0000022a,
-0x0000022c, 0x0000022d, 0x0000022c,
-0x0000022e, 0x0000022f, 0x0000022e,
-0x00000230, 0x00000231, 0x00000230,
-0x00000232, 0x00000233, 0x00000232,
-0x00000386, 0x000003ac, 0x00000386,
-0x00000388, 0x000003ad, 0x00000388,
-0x00000389, 0x000003ae, 0x00000389,
-0x0000038a, 0x000003af, 0x0000038a,
-0x0000038c, 0x000003cc, 0x0000038c,
-0x0000038e, 0x000003cd, 0x0000038e,
-0x0000038f, 0x000003ce, 0x0000038f,
-0x00000391, 0x000003b1, 0x00000391,
-0x00000392, 0x000003b2, 0x00000392,
-0x00000393, 0x000003b3, 0x00000393,
-0x00000394, 0x000003b4, 0x00000394,
-0x00000395, 0x000003b5, 0x00000395,
-0x00000396, 0x000003b6, 0x00000396,
-0x00000397, 0x000003b7, 0x00000397,
-0x00000398, 0x000003b8, 0x00000398,
-0x00000399, 0x000003b9, 0x00000399,
-0x0000039a, 0x000003ba, 0x0000039a,
-0x0000039b, 0x000003bb, 0x0000039b,
-0x0000039c, 0x000003bc, 0x0000039c,
-0x0000039d, 0x000003bd, 0x0000039d,
-0x0000039e, 0x000003be, 0x0000039e,
-0x0000039f, 0x000003bf, 0x0000039f,
-0x000003a0, 0x000003c0, 0x000003a0,
-0x000003a1, 0x000003c1, 0x000003a1,
-0x000003a3, 0x000003c3, 0x000003a3,
-0x000003a4, 0x000003c4, 0x000003a4,
-0x000003a5, 0x000003c5, 0x000003a5,
-0x000003a6, 0x000003c6, 0x000003a6,
-0x000003a7, 0x000003c7, 0x000003a7,
-0x000003a8, 0x000003c8, 0x000003a8,
-0x000003a9, 0x000003c9, 0x000003a9,
-0x000003aa, 0x000003ca, 0x000003aa,
-0x000003ab, 0x000003cb, 0x000003ab,
-0x000003d8, 0x000003d9, 0x000003d8,
-0x000003da, 0x000003db, 0x000003da,
-0x000003dc, 0x000003dd, 0x000003dc,
-0x000003de, 0x000003df, 0x000003de,
-0x000003e0, 0x000003e1, 0x000003e0,
-0x000003e2, 0x000003e3, 0x000003e2,
-0x000003e4, 0x000003e5, 0x000003e4,
-0x000003e6, 0x000003e7, 0x000003e6,
-0x000003e8, 0x000003e9, 0x000003e8,
-0x000003ea, 0x000003eb, 0x000003ea,
-0x000003ec, 0x000003ed, 0x000003ec,
-0x000003ee, 0x000003ef, 0x000003ee,
-0x000003f4, 0x000003b8, 0x000003f4,
-0x00000400, 0x00000450, 0x00000400,
-0x00000401, 0x00000451, 0x00000401,
-0x00000402, 0x00000452, 0x00000402,
-0x00000403, 0x00000453, 0x00000403,
-0x00000404, 0x00000454, 0x00000404,
-0x00000405, 0x00000455, 0x00000405,
-0x00000406, 0x00000456, 0x00000406,
-0x00000407, 0x00000457, 0x00000407,
-0x00000408, 0x00000458, 0x00000408,
-0x00000409, 0x00000459, 0x00000409,
-0x0000040a, 0x0000045a, 0x0000040a,
-0x0000040b, 0x0000045b, 0x0000040b,
-0x0000040c, 0x0000045c, 0x0000040c,
-0x0000040d, 0x0000045d, 0x0000040d,
-0x0000040e, 0x0000045e, 0x0000040e,
-0x0000040f, 0x0000045f, 0x0000040f,
-0x00000410, 0x00000430, 0x00000410,
-0x00000411, 0x00000431, 0x00000411,
-0x00000412, 0x00000432, 0x00000412,
-0x00000413, 0x00000433, 0x00000413,
-0x00000414, 0x00000434, 0x00000414,
-0x00000415, 0x00000435, 0x00000415,
-0x00000416, 0x00000436, 0x00000416,
-0x00000417, 0x00000437, 0x00000417,
-0x00000418, 0x00000438, 0x00000418,
-0x00000419, 0x00000439, 0x00000419,
-0x0000041a, 0x0000043a, 0x0000041a,
-0x0000041b, 0x0000043b, 0x0000041b,
-0x0000041c, 0x0000043c, 0x0000041c,
-0x0000041d, 0x0000043d, 0x0000041d,
-0x0000041e, 0x0000043e, 0x0000041e,
-0x0000041f, 0x0000043f, 0x0000041f,
-0x00000420, 0x00000440, 0x00000420,
-0x00000421, 0x00000441, 0x00000421,
-0x00000422, 0x00000442, 0x00000422,
-0x00000423, 0x00000443, 0x00000423,
-0x00000424, 0x00000444, 0x00000424,
-0x00000425, 0x00000445, 0x00000425,
-0x00000426, 0x00000446, 0x00000426,
-0x00000427, 0x00000447, 0x00000427,
-0x00000428, 0x00000448, 0x00000428,
-0x00000429, 0x00000449, 0x00000429,
-0x0000042a, 0x0000044a, 0x0000042a,
-0x0000042b, 0x0000044b, 0x0000042b,
-0x0000042c, 0x0000044c, 0x0000042c,
-0x0000042d, 0x0000044d, 0x0000042d,
-0x0000042e, 0x0000044e, 0x0000042e,
-0x0000042f, 0x0000044f, 0x0000042f,
-0x00000460, 0x00000461, 0x00000460,
-0x00000462, 0x00000463, 0x00000462,
-0x00000464, 0x00000465, 0x00000464,
-0x00000466, 0x00000467, 0x00000466,
-0x00000468, 0x00000469, 0x00000468,
-0x0000046a, 0x0000046b, 0x0000046a,
-0x0000046c, 0x0000046d, 0x0000046c,
-0x0000046e, 0x0000046f, 0x0000046e,
-0x00000470, 0x00000471, 0x00000470,
-0x00000472, 0x00000473, 0x00000472,
-0x00000474, 0x00000475, 0x00000474,
-0x00000476, 0x00000477, 0x00000476,
-0x00000478, 0x00000479, 0x00000478,
-0x0000047a, 0x0000047b, 0x0000047a,
-0x0000047c, 0x0000047d, 0x0000047c,
-0x0000047e, 0x0000047f, 0x0000047e,
-0x00000480, 0x00000481, 0x00000480,
-0x0000048a, 0x0000048b, 0x0000048a,
-0x0000048c, 0x0000048d, 0x0000048c,
-0x0000048e, 0x0000048f, 0x0000048e,
-0x00000490, 0x00000491, 0x00000490,
-0x00000492, 0x00000493, 0x00000492,
-0x00000494, 0x00000495, 0x00000494,
-0x00000496, 0x00000497, 0x00000496,
-0x00000498, 0x00000499, 0x00000498,
-0x0000049a, 0x0000049b, 0x0000049a,
-0x0000049c, 0x0000049d, 0x0000049c,
-0x0000049e, 0x0000049f, 0x0000049e,
-0x000004a0, 0x000004a1, 0x000004a0,
-0x000004a2, 0x000004a3, 0x000004a2,
-0x000004a4, 0x000004a5, 0x000004a4,
-0x000004a6, 0x000004a7, 0x000004a6,
-0x000004a8, 0x000004a9, 0x000004a8,
-0x000004aa, 0x000004ab, 0x000004aa,
-0x000004ac, 0x000004ad, 0x000004ac,
-0x000004ae, 0x000004af, 0x000004ae,
-0x000004b0, 0x000004b1, 0x000004b0,
-0x000004b2, 0x000004b3, 0x000004b2,
-0x000004b4, 0x000004b5, 0x000004b4,
-0x000004b6, 0x000004b7, 0x000004b6,
-0x000004b8, 0x000004b9, 0x000004b8,
-0x000004ba, 0x000004bb, 0x000004ba,
-0x000004bc, 0x000004bd, 0x000004bc,
-0x000004be, 0x000004bf, 0x000004be,
-0x000004c1, 0x000004c2, 0x000004c1,
-0x000004c3, 0x000004c4, 0x000004c3,
-0x000004c5, 0x000004c6, 0x000004c5,
-0x000004c7, 0x000004c8, 0x000004c7,
-0x000004c9, 0x000004ca, 0x000004c9,
-0x000004cb, 0x000004cc, 0x000004cb,
-0x000004cd, 0x000004ce, 0x000004cd,
-0x000004d0, 0x000004d1, 0x000004d0,
-0x000004d2, 0x000004d3, 0x000004d2,
-0x000004d4, 0x000004d5, 0x000004d4,
-0x000004d6, 0x000004d7, 0x000004d6,
-0x000004d8, 0x000004d9, 0x000004d8,
-0x000004da, 0x000004db, 0x000004da,
-0x000004dc, 0x000004dd, 0x000004dc,
-0x000004de, 0x000004df, 0x000004de,
-0x000004e0, 0x000004e1, 0x000004e0,
-0x000004e2, 0x000004e3, 0x000004e2,
-0x000004e4, 0x000004e5, 0x000004e4,
-0x000004e6, 0x000004e7, 0x000004e6,
-0x000004e8, 0x000004e9, 0x000004e8,
-0x000004ea, 0x000004eb, 0x000004ea,
-0x000004ec, 0x000004ed, 0x000004ec,
-0x000004ee, 0x000004ef, 0x000004ee,
-0x000004f0, 0x000004f1, 0x000004f0,
-0x000004f2, 0x000004f3, 0x000004f2,
-0x000004f4, 0x000004f5, 0x000004f4,
-0x000004f8, 0x000004f9, 0x000004f8,
-0x00000500, 0x00000501, 0x00000500,
-0x00000502, 0x00000503, 0x00000502,
-0x00000504, 0x00000505, 0x00000504,
-0x00000506, 0x00000507, 0x00000506,
-0x00000508, 0x00000509, 0x00000508,
-0x0000050a, 0x0000050b, 0x0000050a,
-0x0000050c, 0x0000050d, 0x0000050c,
-0x0000050e, 0x0000050f, 0x0000050e,
-0x00000531, 0x00000561, 0x00000531,
-0x00000532, 0x00000562, 0x00000532,
-0x00000533, 0x00000563, 0x00000533,
-0x00000534, 0x00000564, 0x00000534,
-0x00000535, 0x00000565, 0x00000535,
-0x00000536, 0x00000566, 0x00000536,
-0x00000537, 0x00000567, 0x00000537,
-0x00000538, 0x00000568, 0x00000538,
-0x00000539, 0x00000569, 0x00000539,
-0x0000053a, 0x0000056a, 0x0000053a,
-0x0000053b, 0x0000056b, 0x0000053b,
-0x0000053c, 0x0000056c, 0x0000053c,
-0x0000053d, 0x0000056d, 0x0000053d,
-0x0000053e, 0x0000056e, 0x0000053e,
-0x0000053f, 0x0000056f, 0x0000053f,
-0x00000540, 0x00000570, 0x00000540,
-0x00000541, 0x00000571, 0x00000541,
-0x00000542, 0x00000572, 0x00000542,
-0x00000543, 0x00000573, 0x00000543,
-0x00000544, 0x00000574, 0x00000544,
-0x00000545, 0x00000575, 0x00000545,
-0x00000546, 0x00000576, 0x00000546,
-0x00000547, 0x00000577, 0x00000547,
-0x00000548, 0x00000578, 0x00000548,
-0x00000549, 0x00000579, 0x00000549,
-0x0000054a, 0x0000057a, 0x0000054a,
-0x0000054b, 0x0000057b, 0x0000054b,
-0x0000054c, 0x0000057c, 0x0000054c,
-0x0000054d, 0x0000057d, 0x0000054d,
-0x0000054e, 0x0000057e, 0x0000054e,
-0x0000054f, 0x0000057f, 0x0000054f,
-0x00000550, 0x00000580, 0x00000550,
-0x00000551, 0x00000581, 0x00000551,
-0x00000552, 0x00000582, 0x00000552,
-0x00000553, 0x00000583, 0x00000553,
-0x00000554, 0x00000584, 0x00000554,
-0x00000555, 0x00000585, 0x00000555,
-0x00000556, 0x00000586, 0x00000556,
-0x00001e00, 0x00001e01, 0x00001e00,
-0x00001e02, 0x00001e03, 0x00001e02,
-0x00001e04, 0x00001e05, 0x00001e04,
-0x00001e06, 0x00001e07, 0x00001e06,
-0x00001e08, 0x00001e09, 0x00001e08,
-0x00001e0a, 0x00001e0b, 0x00001e0a,
-0x00001e0c, 0x00001e0d, 0x00001e0c,
-0x00001e0e, 0x00001e0f, 0x00001e0e,
-0x00001e10, 0x00001e11, 0x00001e10,
-0x00001e12, 0x00001e13, 0x00001e12,
-0x00001e14, 0x00001e15, 0x00001e14,
-0x00001e16, 0x00001e17, 0x00001e16,
-0x00001e18, 0x00001e19, 0x00001e18,
-0x00001e1a, 0x00001e1b, 0x00001e1a,
-0x00001e1c, 0x00001e1d, 0x00001e1c,
-0x00001e1e, 0x00001e1f, 0x00001e1e,
-0x00001e20, 0x00001e21, 0x00001e20,
-0x00001e22, 0x00001e23, 0x00001e22,
-0x00001e24, 0x00001e25, 0x00001e24,
-0x00001e26, 0x00001e27, 0x00001e26,
-0x00001e28, 0x00001e29, 0x00001e28,
-0x00001e2a, 0x00001e2b, 0x00001e2a,
-0x00001e2c, 0x00001e2d, 0x00001e2c,
-0x00001e2e, 0x00001e2f, 0x00001e2e,
-0x00001e30, 0x00001e31, 0x00001e30,
-0x00001e32, 0x00001e33, 0x00001e32,
-0x00001e34, 0x00001e35, 0x00001e34,
-0x00001e36, 0x00001e37, 0x00001e36,
-0x00001e38, 0x00001e39, 0x00001e38,
-0x00001e3a, 0x00001e3b, 0x00001e3a,
-0x00001e3c, 0x00001e3d, 0x00001e3c,
-0x00001e3e, 0x00001e3f, 0x00001e3e,
-0x00001e40, 0x00001e41, 0x00001e40,
-0x00001e42, 0x00001e43, 0x00001e42,
-0x00001e44, 0x00001e45, 0x00001e44,
-0x00001e46, 0x00001e47, 0x00001e46,
-0x00001e48, 0x00001e49, 0x00001e48,
-0x00001e4a, 0x00001e4b, 0x00001e4a,
-0x00001e4c, 0x00001e4d, 0x00001e4c,
-0x00001e4e, 0x00001e4f, 0x00001e4e,
-0x00001e50, 0x00001e51, 0x00001e50,
-0x00001e52, 0x00001e53, 0x00001e52,
-0x00001e54, 0x00001e55, 0x00001e54,
-0x00001e56, 0x00001e57, 0x00001e56,
-0x00001e58, 0x00001e59, 0x00001e58,
-0x00001e5a, 0x00001e5b, 0x00001e5a,
-0x00001e5c, 0x00001e5d, 0x00001e5c,
-0x00001e5e, 0x00001e5f, 0x00001e5e,
-0x00001e60, 0x00001e61, 0x00001e60,
-0x00001e62, 0x00001e63, 0x00001e62,
-0x00001e64, 0x00001e65, 0x00001e64,
-0x00001e66, 0x00001e67, 0x00001e66,
-0x00001e68, 0x00001e69, 0x00001e68,
-0x00001e6a, 0x00001e6b, 0x00001e6a,
-0x00001e6c, 0x00001e6d, 0x00001e6c,
-0x00001e6e, 0x00001e6f, 0x00001e6e,
-0x00001e70, 0x00001e71, 0x00001e70,
-0x00001e72, 0x00001e73, 0x00001e72,
-0x00001e74, 0x00001e75, 0x00001e74,
-0x00001e76, 0x00001e77, 0x00001e76,
-0x00001e78, 0x00001e79, 0x00001e78,
-0x00001e7a, 0x00001e7b, 0x00001e7a,
-0x00001e7c, 0x00001e7d, 0x00001e7c,
-0x00001e7e, 0x00001e7f, 0x00001e7e,
-0x00001e80, 0x00001e81, 0x00001e80,
-0x00001e82, 0x00001e83, 0x00001e82,
-0x00001e84, 0x00001e85, 0x00001e84,
-0x00001e86, 0x00001e87, 0x00001e86,
-0x00001e88, 0x00001e89, 0x00001e88,
-0x00001e8a, 0x00001e8b, 0x00001e8a,
-0x00001e8c, 0x00001e8d, 0x00001e8c,
-0x00001e8e, 0x00001e8f, 0x00001e8e,
-0x00001e90, 0x00001e91, 0x00001e90,
-0x00001e92, 0x00001e93, 0x00001e92,
-0x00001e94, 0x00001e95, 0x00001e94,
-0x00001ea0, 0x00001ea1, 0x00001ea0,
-0x00001ea2, 0x00001ea3, 0x00001ea2,
-0x00001ea4, 0x00001ea5, 0x00001ea4,
-0x00001ea6, 0x00001ea7, 0x00001ea6,
-0x00001ea8, 0x00001ea9, 0x00001ea8,
-0x00001eaa, 0x00001eab, 0x00001eaa,
-0x00001eac, 0x00001ead, 0x00001eac,
-0x00001eae, 0x00001eaf, 0x00001eae,
-0x00001eb0, 0x00001eb1, 0x00001eb0,
-0x00001eb2, 0x00001eb3, 0x00001eb2,
-0x00001eb4, 0x00001eb5, 0x00001eb4,
-0x00001eb6, 0x00001eb7, 0x00001eb6,
-0x00001eb8, 0x00001eb9, 0x00001eb8,
-0x00001eba, 0x00001ebb, 0x00001eba,
-0x00001ebc, 0x00001ebd, 0x00001ebc,
-0x00001ebe, 0x00001ebf, 0x00001ebe,
-0x00001ec0, 0x00001ec1, 0x00001ec0,
-0x00001ec2, 0x00001ec3, 0x00001ec2,
-0x00001ec4, 0x00001ec5, 0x00001ec4,
-0x00001ec6, 0x00001ec7, 0x00001ec6,
-0x00001ec8, 0x00001ec9, 0x00001ec8,
-0x00001eca, 0x00001ecb, 0x00001eca,
-0x00001ecc, 0x00001ecd, 0x00001ecc,
-0x00001ece, 0x00001ecf, 0x00001ece,
-0x00001ed0, 0x00001ed1, 0x00001ed0,
-0x00001ed2, 0x00001ed3, 0x00001ed2,
-0x00001ed4, 0x00001ed5, 0x00001ed4,
-0x00001ed6, 0x00001ed7, 0x00001ed6,
-0x00001ed8, 0x00001ed9, 0x00001ed8,
-0x00001eda, 0x00001edb, 0x00001eda,
-0x00001edc, 0x00001edd, 0x00001edc,
-0x00001ede, 0x00001edf, 0x00001ede,
-0x00001ee0, 0x00001ee1, 0x00001ee0,
-0x00001ee2, 0x00001ee3, 0x00001ee2,
-0x00001ee4, 0x00001ee5, 0x00001ee4,
-0x00001ee6, 0x00001ee7, 0x00001ee6,
-0x00001ee8, 0x00001ee9, 0x00001ee8,
-0x00001eea, 0x00001eeb, 0x00001eea,
-0x00001eec, 0x00001eed, 0x00001eec,
-0x00001eee, 0x00001eef, 0x00001eee,
-0x00001ef0, 0x00001ef1, 0x00001ef0,
-0x00001ef2, 0x00001ef3, 0x00001ef2,
-0x00001ef4, 0x00001ef5, 0x00001ef4,
-0x00001ef6, 0x00001ef7, 0x00001ef6,
-0x00001ef8, 0x00001ef9, 0x00001ef8,
-0x00001f08, 0x00001f00, 0x00001f08,
-0x00001f09, 0x00001f01, 0x00001f09,
-0x00001f0a, 0x00001f02, 0x00001f0a,
-0x00001f0b, 0x00001f03, 0x00001f0b,
-0x00001f0c, 0x00001f04, 0x00001f0c,
-0x00001f0d, 0x00001f05, 0x00001f0d,
-0x00001f0e, 0x00001f06, 0x00001f0e,
-0x00001f0f, 0x00001f07, 0x00001f0f,
-0x00001f18, 0x00001f10, 0x00001f18,
-0x00001f19, 0x00001f11, 0x00001f19,
-0x00001f1a, 0x00001f12, 0x00001f1a,
-0x00001f1b, 0x00001f13, 0x00001f1b,
-0x00001f1c, 0x00001f14, 0x00001f1c,
-0x00001f1d, 0x00001f15, 0x00001f1d,
-0x00001f28, 0x00001f20, 0x00001f28,
-0x00001f29, 0x00001f21, 0x00001f29,
-0x00001f2a, 0x00001f22, 0x00001f2a,
-0x00001f2b, 0x00001f23, 0x00001f2b,
-0x00001f2c, 0x00001f24, 0x00001f2c,
-0x00001f2d, 0x00001f25, 0x00001f2d,
-0x00001f2e, 0x00001f26, 0x00001f2e,
-0x00001f2f, 0x00001f27, 0x00001f2f,
-0x00001f38, 0x00001f30, 0x00001f38,
-0x00001f39, 0x00001f31, 0x00001f39,
-0x00001f3a, 0x00001f32, 0x00001f3a,
-0x00001f3b, 0x00001f33, 0x00001f3b,
-0x00001f3c, 0x00001f34, 0x00001f3c,
-0x00001f3d, 0x00001f35, 0x00001f3d,
-0x00001f3e, 0x00001f36, 0x00001f3e,
-0x00001f3f, 0x00001f37, 0x00001f3f,
-0x00001f48, 0x00001f40, 0x00001f48,
-0x00001f49, 0x00001f41, 0x00001f49,
-0x00001f4a, 0x00001f42, 0x00001f4a,
-0x00001f4b, 0x00001f43, 0x00001f4b,
-0x00001f4c, 0x00001f44, 0x00001f4c,
-0x00001f4d, 0x00001f45, 0x00001f4d,
-0x00001f59, 0x00001f51, 0x00001f59,
-0x00001f5b, 0x00001f53, 0x00001f5b,
-0x00001f5d, 0x00001f55, 0x00001f5d,
-0x00001f5f, 0x00001f57, 0x00001f5f,
-0x00001f68, 0x00001f60, 0x00001f68,
-0x00001f69, 0x00001f61, 0x00001f69,
-0x00001f6a, 0x00001f62, 0x00001f6a,
-0x00001f6b, 0x00001f63, 0x00001f6b,
-0x00001f6c, 0x00001f64, 0x00001f6c,
-0x00001f6d, 0x00001f65, 0x00001f6d,
-0x00001f6e, 0x00001f66, 0x00001f6e,
-0x00001f6f, 0x00001f67, 0x00001f6f,
-0x00001f88, 0x00001f80, 0x00001f88,
-0x00001f89, 0x00001f81, 0x00001f89,
-0x00001f8a, 0x00001f82, 0x00001f8a,
-0x00001f8b, 0x00001f83, 0x00001f8b,
-0x00001f8c, 0x00001f84, 0x00001f8c,
-0x00001f8d, 0x00001f85, 0x00001f8d,
-0x00001f8e, 0x00001f86, 0x00001f8e,
-0x00001f8f, 0x00001f87, 0x00001f8f,
-0x00001f98, 0x00001f90, 0x00001f98,
-0x00001f99, 0x00001f91, 0x00001f99,
-0x00001f9a, 0x00001f92, 0x00001f9a,
-0x00001f9b, 0x00001f93, 0x00001f9b,
-0x00001f9c, 0x00001f94, 0x00001f9c,
-0x00001f9d, 0x00001f95, 0x00001f9d,
-0x00001f9e, 0x00001f96, 0x00001f9e,
-0x00001f9f, 0x00001f97, 0x00001f9f,
-0x00001fa8, 0x00001fa0, 0x00001fa8,
-0x00001fa9, 0x00001fa1, 0x00001fa9,
-0x00001faa, 0x00001fa2, 0x00001faa,
-0x00001fab, 0x00001fa3, 0x00001fab,
-0x00001fac, 0x00001fa4, 0x00001fac,
-0x00001fad, 0x00001fa5, 0x00001fad,
-0x00001fae, 0x00001fa6, 0x00001fae,
-0x00001faf, 0x00001fa7, 0x00001faf,
-0x00001fb8, 0x00001fb0, 0x00001fb8,
-0x00001fb9, 0x00001fb1, 0x00001fb9,
-0x00001fba, 0x00001f70, 0x00001fba,
-0x00001fbb, 0x00001f71, 0x00001fbb,
-0x00001fbc, 0x00001fb3, 0x00001fbc,
-0x00001fc8, 0x00001f72, 0x00001fc8,
-0x00001fc9, 0x00001f73, 0x00001fc9,
-0x00001fca, 0x00001f74, 0x00001fca,
-0x00001fcb, 0x00001f75, 0x00001fcb,
-0x00001fcc, 0x00001fc3, 0x00001fcc,
-0x00001fd8, 0x00001fd0, 0x00001fd8,
-0x00001fd9, 0x00001fd1, 0x00001fd9,
-0x00001fda, 0x00001f76, 0x00001fda,
-0x00001fdb, 0x00001f77, 0x00001fdb,
-0x00001fe8, 0x00001fe0, 0x00001fe8,
-0x00001fe9, 0x00001fe1, 0x00001fe9,
-0x00001fea, 0x00001f7a, 0x00001fea,
-0x00001feb, 0x00001f7b, 0x00001feb,
-0x00001fec, 0x00001fe5, 0x00001fec,
-0x00001ff8, 0x00001f78, 0x00001ff8,
-0x00001ff9, 0x00001f79, 0x00001ff9,
-0x00001ffa, 0x00001f7c, 0x00001ffa,
-0x00001ffb, 0x00001f7d, 0x00001ffb,
-0x00001ffc, 0x00001ff3, 0x00001ffc,
-0x00002126, 0x000003c9, 0x00002126,
-0x0000212a, 0x0000006b, 0x0000212a,
-0x0000212b, 0x000000e5, 0x0000212b,
-0x00002160, 0x00002170, 0x00002160,
-0x00002161, 0x00002171, 0x00002161,
-0x00002162, 0x00002172, 0x00002162,
-0x00002163, 0x00002173, 0x00002163,
-0x00002164, 0x00002174, 0x00002164,
-0x00002165, 0x00002175, 0x00002165,
-0x00002166, 0x00002176, 0x00002166,
-0x00002167, 0x00002177, 0x00002167,
-0x00002168, 0x00002178, 0x00002168,
-0x00002169, 0x00002179, 0x00002169,
-0x0000216a, 0x0000217a, 0x0000216a,
-0x0000216b, 0x0000217b, 0x0000216b,
-0x0000216c, 0x0000217c, 0x0000216c,
-0x0000216d, 0x0000217d, 0x0000216d,
-0x0000216e, 0x0000217e, 0x0000216e,
-0x0000216f, 0x0000217f, 0x0000216f,
-0x000024b6, 0x000024d0, 0x000024b6,
-0x000024b7, 0x000024d1, 0x000024b7,
-0x000024b8, 0x000024d2, 0x000024b8,
-0x000024b9, 0x000024d3, 0x000024b9,
-0x000024ba, 0x000024d4, 0x000024ba,
-0x000024bb, 0x000024d5, 0x000024bb,
-0x000024bc, 0x000024d6, 0x000024bc,
-0x000024bd, 0x000024d7, 0x000024bd,
-0x000024be, 0x000024d8, 0x000024be,
-0x000024bf, 0x000024d9, 0x000024bf,
-0x000024c0, 0x000024da, 0x000024c0,
-0x000024c1, 0x000024db, 0x000024c1,
-0x000024c2, 0x000024dc, 0x000024c2,
-0x000024c3, 0x000024dd, 0x000024c3,
-0x000024c4, 0x000024de, 0x000024c4,
-0x000024c5, 0x000024df, 0x000024c5,
-0x000024c6, 0x000024e0, 0x000024c6,
-0x000024c7, 0x000024e1, 0x000024c7,
-0x000024c8, 0x000024e2, 0x000024c8,
-0x000024c9, 0x000024e3, 0x000024c9,
-0x000024ca, 0x000024e4, 0x000024ca,
-0x000024cb, 0x000024e5, 0x000024cb,
-0x000024cc, 0x000024e6, 0x000024cc,
-0x000024cd, 0x000024e7, 0x000024cd,
-0x000024ce, 0x000024e8, 0x000024ce,
-0x000024cf, 0x000024e9, 0x000024cf,
-0x0000ff21, 0x0000ff41, 0x0000ff21,
-0x0000ff22, 0x0000ff42, 0x0000ff22,
-0x0000ff23, 0x0000ff43, 0x0000ff23,
-0x0000ff24, 0x0000ff44, 0x0000ff24,
-0x0000ff25, 0x0000ff45, 0x0000ff25,
-0x0000ff26, 0x0000ff46, 0x0000ff26,
-0x0000ff27, 0x0000ff47, 0x0000ff27,
-0x0000ff28, 0x0000ff48, 0x0000ff28,
-0x0000ff29, 0x0000ff49, 0x0000ff29,
-0x0000ff2a, 0x0000ff4a, 0x0000ff2a,
-0x0000ff2b, 0x0000ff4b, 0x0000ff2b,
-0x0000ff2c, 0x0000ff4c, 0x0000ff2c,
-0x0000ff2d, 0x0000ff4d, 0x0000ff2d,
-0x0000ff2e, 0x0000ff4e, 0x0000ff2e,
-0x0000ff2f, 0x0000ff4f, 0x0000ff2f,
-0x0000ff30, 0x0000ff50, 0x0000ff30,
-0x0000ff31, 0x0000ff51, 0x0000ff31,
-0x0000ff32, 0x0000ff52, 0x0000ff32,
-0x0000ff33, 0x0000ff53, 0x0000ff33,
-0x0000ff34, 0x0000ff54, 0x0000ff34,
-0x0000ff35, 0x0000ff55, 0x0000ff35,
-0x0000ff36, 0x0000ff56, 0x0000ff36,
-0x0000ff37, 0x0000ff57, 0x0000ff37,
-0x0000ff38, 0x0000ff58, 0x0000ff38,
-0x0000ff39, 0x0000ff59, 0x0000ff39,
-0x0000ff3a, 0x0000ff5a, 0x0000ff3a,
-0x00010400, 0x00010428, 0x00010400,
-0x00010401, 0x00010429, 0x00010401,
-0x00010402, 0x0001042a, 0x00010402,
-0x00010403, 0x0001042b, 0x00010403,
-0x00010404, 0x0001042c, 0x00010404,
-0x00010405, 0x0001042d, 0x00010405,
-0x00010406, 0x0001042e, 0x00010406,
-0x00010407, 0x0001042f, 0x00010407,
-0x00010408, 0x00010430, 0x00010408,
-0x00010409, 0x00010431, 0x00010409,
-0x0001040a, 0x00010432, 0x0001040a,
-0x0001040b, 0x00010433, 0x0001040b,
-0x0001040c, 0x00010434, 0x0001040c,
-0x0001040d, 0x00010435, 0x0001040d,
-0x0001040e, 0x00010436, 0x0001040e,
-0x0001040f, 0x00010437, 0x0001040f,
-0x00010410, 0x00010438, 0x00010410,
-0x00010411, 0x00010439, 0x00010411,
-0x00010412, 0x0001043a, 0x00010412,
-0x00010413, 0x0001043b, 0x00010413,
-0x00010414, 0x0001043c, 0x00010414,
-0x00010415, 0x0001043d, 0x00010415,
-0x00010416, 0x0001043e, 0x00010416,
-0x00010417, 0x0001043f, 0x00010417,
-0x00010418, 0x00010440, 0x00010418,
-0x00010419, 0x00010441, 0x00010419,
-0x0001041a, 0x00010442, 0x0001041a,
-0x0001041b, 0x00010443, 0x0001041b,
-0x0001041c, 0x00010444, 0x0001041c,
-0x0001041d, 0x00010445, 0x0001041d,
-0x0001041e, 0x00010446, 0x0001041e,
-0x0001041f, 0x00010447, 0x0001041f,
-0x00010420, 0x00010448, 0x00010420,
-0x00010421, 0x00010449, 0x00010421,
-0x00010422, 0x0001044a, 0x00010422,
-0x00010423, 0x0001044b, 0x00010423,
-0x00010424, 0x0001044c, 0x00010424,
-0x00010425, 0x0001044d, 0x00010425,
-/* lower */
-0x00000061, 0x00000041, 0x00000041,
-0x00000062, 0x00000042, 0x00000042,
-0x00000063, 0x00000043, 0x00000043,
-0x00000064, 0x00000044, 0x00000044,
-0x00000065, 0x00000045, 0x00000045,
-0x00000066, 0x00000046, 0x00000046,
-0x00000067, 0x00000047, 0x00000047,
-0x00000068, 0x00000048, 0x00000048,
-0x00000069, 0x00000049, 0x00000049,
-0x0000006a, 0x0000004a, 0x0000004a,
-0x0000006b, 0x0000004b, 0x0000004b,
-0x0000006c, 0x0000004c, 0x0000004c,
-0x0000006d, 0x0000004d, 0x0000004d,
-0x0000006e, 0x0000004e, 0x0000004e,
-0x0000006f, 0x0000004f, 0x0000004f,
-0x00000070, 0x00000050, 0x00000050,
-0x00000071, 0x00000051, 0x00000051,
-0x00000072, 0x00000052, 0x00000052,
-0x00000073, 0x00000053, 0x00000053,
-0x00000074, 0x00000054, 0x00000054,
-0x00000075, 0x00000055, 0x00000055,
-0x00000076, 0x00000056, 0x00000056,
-0x00000077, 0x00000057, 0x00000057,
-0x00000078, 0x00000058, 0x00000058,
-0x00000079, 0x00000059, 0x00000059,
-0x0000007a, 0x0000005a, 0x0000005a,
-0x000000b5, 0x0000039c, 0x0000039c,
-0x000000e0, 0x000000c0, 0x000000c0,
-0x000000e1, 0x000000c1, 0x000000c1,
-0x000000e2, 0x000000c2, 0x000000c2,
-0x000000e3, 0x000000c3, 0x000000c3,
-0x000000e4, 0x000000c4, 0x000000c4,
-0x000000e5, 0x000000c5, 0x000000c5,
-0x000000e6, 0x000000c6, 0x000000c6,
-0x000000e7, 0x000000c7, 0x000000c7,
-0x000000e8, 0x000000c8, 0x000000c8,
-0x000000e9, 0x000000c9, 0x000000c9,
-0x000000ea, 0x000000ca, 0x000000ca,
-0x000000eb, 0x000000cb, 0x000000cb,
-0x000000ec, 0x000000cc, 0x000000cc,
-0x000000ed, 0x000000cd, 0x000000cd,
-0x000000ee, 0x000000ce, 0x000000ce,
-0x000000ef, 0x000000cf, 0x000000cf,
-0x000000f0, 0x000000d0, 0x000000d0,
-0x000000f1, 0x000000d1, 0x000000d1,
-0x000000f2, 0x000000d2, 0x000000d2,
-0x000000f3, 0x000000d3, 0x000000d3,
-0x000000f4, 0x000000d4, 0x000000d4,
-0x000000f5, 0x000000d5, 0x000000d5,
-0x000000f6, 0x000000d6, 0x000000d6,
-0x000000f8, 0x000000d8, 0x000000d8,
-0x000000f9, 0x000000d9, 0x000000d9,
-0x000000fa, 0x000000da, 0x000000da,
-0x000000fb, 0x000000db, 0x000000db,
-0x000000fc, 0x000000dc, 0x000000dc,
-0x000000fd, 0x000000dd, 0x000000dd,
-0x000000fe, 0x000000de, 0x000000de,
-0x000000ff, 0x00000178, 0x00000178,
-0x00000101, 0x00000100, 0x00000100,
-0x00000103, 0x00000102, 0x00000102,
-0x00000105, 0x00000104, 0x00000104,
-0x00000107, 0x00000106, 0x00000106,
-0x00000109, 0x00000108, 0x00000108,
-0x0000010b, 0x0000010a, 0x0000010a,
-0x0000010d, 0x0000010c, 0x0000010c,
-0x0000010f, 0x0000010e, 0x0000010e,
-0x00000111, 0x00000110, 0x00000110,
-0x00000113, 0x00000112, 0x00000112,
-0x00000115, 0x00000114, 0x00000114,
-0x00000117, 0x00000116, 0x00000116,
-0x00000119, 0x00000118, 0x00000118,
-0x0000011b, 0x0000011a, 0x0000011a,
-0x0000011d, 0x0000011c, 0x0000011c,
-0x0000011f, 0x0000011e, 0x0000011e,
-0x00000121, 0x00000120, 0x00000120,
-0x00000123, 0x00000122, 0x00000122,
-0x00000125, 0x00000124, 0x00000124,
-0x00000127, 0x00000126, 0x00000126,
-0x00000129, 0x00000128, 0x00000128,
-0x0000012b, 0x0000012a, 0x0000012a,
-0x0000012d, 0x0000012c, 0x0000012c,
-0x0000012f, 0x0000012e, 0x0000012e,
-0x00000131, 0x00000049, 0x00000049,
-0x00000133, 0x00000132, 0x00000132,
-0x00000135, 0x00000134, 0x00000134,
-0x00000137, 0x00000136, 0x00000136,
-0x0000013a, 0x00000139, 0x00000139,
-0x0000013c, 0x0000013b, 0x0000013b,
-0x0000013e, 0x0000013d, 0x0000013d,
-0x00000140, 0x0000013f, 0x0000013f,
-0x00000142, 0x00000141, 0x00000141,
-0x00000144, 0x00000143, 0x00000143,
-0x00000146, 0x00000145, 0x00000145,
-0x00000148, 0x00000147, 0x00000147,
-0x0000014b, 0x0000014a, 0x0000014a,
-0x0000014d, 0x0000014c, 0x0000014c,
-0x0000014f, 0x0000014e, 0x0000014e,
-0x00000151, 0x00000150, 0x00000150,
-0x00000153, 0x00000152, 0x00000152,
-0x00000155, 0x00000154, 0x00000154,
-0x00000157, 0x00000156, 0x00000156,
-0x00000159, 0x00000158, 0x00000158,
-0x0000015b, 0x0000015a, 0x0000015a,
-0x0000015d, 0x0000015c, 0x0000015c,
-0x0000015f, 0x0000015e, 0x0000015e,
-0x00000161, 0x00000160, 0x00000160,
-0x00000163, 0x00000162, 0x00000162,
-0x00000165, 0x00000164, 0x00000164,
-0x00000167, 0x00000166, 0x00000166,
-0x00000169, 0x00000168, 0x00000168,
-0x0000016b, 0x0000016a, 0x0000016a,
-0x0000016d, 0x0000016c, 0x0000016c,
-0x0000016f, 0x0000016e, 0x0000016e,
-0x00000171, 0x00000170, 0x00000170,
-0x00000173, 0x00000172, 0x00000172,
-0x00000175, 0x00000174, 0x00000174,
-0x00000177, 0x00000176, 0x00000176,
-0x0000017a, 0x00000179, 0x00000179,
-0x0000017c, 0x0000017b, 0x0000017b,
-0x0000017e, 0x0000017d, 0x0000017d,
-0x0000017f, 0x00000053, 0x00000053,
-0x00000183, 0x00000182, 0x00000182,
-0x00000185, 0x00000184, 0x00000184,
-0x00000188, 0x00000187, 0x00000187,
-0x0000018c, 0x0000018b, 0x0000018b,
-0x00000192, 0x00000191, 0x00000191,
-0x00000195, 0x000001f6, 0x000001f6,
-0x00000199, 0x00000198, 0x00000198,
-0x0000019e, 0x00000220, 0x00000220,
-0x000001a1, 0x000001a0, 0x000001a0,
-0x000001a3, 0x000001a2, 0x000001a2,
-0x000001a5, 0x000001a4, 0x000001a4,
-0x000001a8, 0x000001a7, 0x000001a7,
-0x000001ad, 0x000001ac, 0x000001ac,
-0x000001b0, 0x000001af, 0x000001af,
-0x000001b4, 0x000001b3, 0x000001b3,
-0x000001b6, 0x000001b5, 0x000001b5,
-0x000001b9, 0x000001b8, 0x000001b8,
-0x000001bd, 0x000001bc, 0x000001bc,
-0x000001bf, 0x000001f7, 0x000001f7,
-0x000001c6, 0x000001c4, 0x000001c5,
-0x000001c9, 0x000001c7, 0x000001c8,
-0x000001cc, 0x000001ca, 0x000001cb,
-0x000001ce, 0x000001cd, 0x000001cd,
-0x000001d0, 0x000001cf, 0x000001cf,
-0x000001d2, 0x000001d1, 0x000001d1,
-0x000001d4, 0x000001d3, 0x000001d3,
-0x000001d6, 0x000001d5, 0x000001d5,
-0x000001d8, 0x000001d7, 0x000001d7,
-0x000001da, 0x000001d9, 0x000001d9,
-0x000001dc, 0x000001db, 0x000001db,
-0x000001dd, 0x0000018e, 0x0000018e,
-0x000001df, 0x000001de, 0x000001de,
-0x000001e1, 0x000001e0, 0x000001e0,
-0x000001e3, 0x000001e2, 0x000001e2,
-0x000001e5, 0x000001e4, 0x000001e4,
-0x000001e7, 0x000001e6, 0x000001e6,
-0x000001e9, 0x000001e8, 0x000001e8,
-0x000001eb, 0x000001ea, 0x000001ea,
-0x000001ed, 0x000001ec, 0x000001ec,
-0x000001ef, 0x000001ee, 0x000001ee,
-0x000001f3, 0x000001f1, 0x000001f2,
-0x000001f5, 0x000001f4, 0x000001f4,
-0x000001f9, 0x000001f8, 0x000001f8,
-0x000001fb, 0x000001fa, 0x000001fa,
-0x000001fd, 0x000001fc, 0x000001fc,
-0x000001ff, 0x000001fe, 0x000001fe,
-0x00000201, 0x00000200, 0x00000200,
-0x00000203, 0x00000202, 0x00000202,
-0x00000205, 0x00000204, 0x00000204,
-0x00000207, 0x00000206, 0x00000206,
-0x00000209, 0x00000208, 0x00000208,
-0x0000020b, 0x0000020a, 0x0000020a,
-0x0000020d, 0x0000020c, 0x0000020c,
-0x0000020f, 0x0000020e, 0x0000020e,
-0x00000211, 0x00000210, 0x00000210,
-0x00000213, 0x00000212, 0x00000212,
-0x00000215, 0x00000214, 0x00000214,
-0x00000217, 0x00000216, 0x00000216,
-0x00000219, 0x00000218, 0x00000218,
-0x0000021b, 0x0000021a, 0x0000021a,
-0x0000021d, 0x0000021c, 0x0000021c,
-0x0000021f, 0x0000021e, 0x0000021e,
-0x00000223, 0x00000222, 0x00000222,
-0x00000225, 0x00000224, 0x00000224,
-0x00000227, 0x00000226, 0x00000226,
-0x00000229, 0x00000228, 0x00000228,
-0x0000022b, 0x0000022a, 0x0000022a,
-0x0000022d, 0x0000022c, 0x0000022c,
-0x0000022f, 0x0000022e, 0x0000022e,
-0x00000231, 0x00000230, 0x00000230,
-0x00000233, 0x00000232, 0x00000232,
-0x00000253, 0x00000181, 0x00000181,
-0x00000254, 0x00000186, 0x00000186,
-0x00000256, 0x00000189, 0x00000189,
-0x00000257, 0x0000018a, 0x0000018a,
-0x00000259, 0x0000018f, 0x0000018f,
-0x0000025b, 0x00000190, 0x00000190,
-0x00000260, 0x00000193, 0x00000193,
-0x00000263, 0x00000194, 0x00000194,
-0x00000268, 0x00000197, 0x00000197,
-0x00000269, 0x00000196, 0x00000196,
-0x0000026f, 0x0000019c, 0x0000019c,
-0x00000272, 0x0000019d, 0x0000019d,
-0x00000275, 0x0000019f, 0x0000019f,
-0x00000280, 0x000001a6, 0x000001a6,
-0x00000283, 0x000001a9, 0x000001a9,
-0x00000288, 0x000001ae, 0x000001ae,
-0x0000028a, 0x000001b1, 0x000001b1,
-0x0000028b, 0x000001b2, 0x000001b2,
-0x00000292, 0x000001b7, 0x000001b7,
-0x00000345, 0x00000399, 0x00000399,
-0x000003ac, 0x00000386, 0x00000386,
-0x000003ad, 0x00000388, 0x00000388,
-0x000003ae, 0x00000389, 0x00000389,
-0x000003af, 0x0000038a, 0x0000038a,
-0x000003b1, 0x00000391, 0x00000391,
-0x000003b2, 0x00000392, 0x00000392,
-0x000003b3, 0x00000393, 0x00000393,
-0x000003b4, 0x00000394, 0x00000394,
-0x000003b5, 0x00000395, 0x00000395,
-0x000003b6, 0x00000396, 0x00000396,
-0x000003b7, 0x00000397, 0x00000397,
-0x000003b8, 0x00000398, 0x00000398,
-0x000003b9, 0x00000399, 0x00000399,
-0x000003ba, 0x0000039a, 0x0000039a,
-0x000003bb, 0x0000039b, 0x0000039b,
-0x000003bc, 0x0000039c, 0x0000039c,
-0x000003bd, 0x0000039d, 0x0000039d,
-0x000003be, 0x0000039e, 0x0000039e,
-0x000003bf, 0x0000039f, 0x0000039f,
-0x000003c0, 0x000003a0, 0x000003a0,
-0x000003c1, 0x000003a1, 0x000003a1,
-0x000003c2, 0x000003a3, 0x000003a3,
-0x000003c3, 0x000003a3, 0x000003a3,
-0x000003c4, 0x000003a4, 0x000003a4,
-0x000003c5, 0x000003a5, 0x000003a5,
-0x000003c6, 0x000003a6, 0x000003a6,
-0x000003c7, 0x000003a7, 0x000003a7,
-0x000003c8, 0x000003a8, 0x000003a8,
-0x000003c9, 0x000003a9, 0x000003a9,
-0x000003ca, 0x000003aa, 0x000003aa,
-0x000003cb, 0x000003ab, 0x000003ab,
-0x000003cc, 0x0000038c, 0x0000038c,
-0x000003cd, 0x0000038e, 0x0000038e,
-0x000003ce, 0x0000038f, 0x0000038f,
-0x000003d0, 0x00000392, 0x00000392,
-0x000003d1, 0x00000398, 0x00000398,
-0x000003d5, 0x000003a6, 0x000003a6,
-0x000003d6, 0x000003a0, 0x000003a0,
-0x000003d9, 0x000003d8, 0x000003d8,
-0x000003db, 0x000003da, 0x000003da,
-0x000003dd, 0x000003dc, 0x000003dc,
-0x000003df, 0x000003de, 0x000003de,
-0x000003e1, 0x000003e0, 0x000003e0,
-0x000003e3, 0x000003e2, 0x000003e2,
-0x000003e5, 0x000003e4, 0x000003e4,
-0x000003e7, 0x000003e6, 0x000003e6,
-0x000003e9, 0x000003e8, 0x000003e8,
-0x000003eb, 0x000003ea, 0x000003ea,
-0x000003ed, 0x000003ec, 0x000003ec,
-0x000003ef, 0x000003ee, 0x000003ee,
-0x000003f0, 0x0000039a, 0x0000039a,
-0x000003f1, 0x000003a1, 0x000003a1,
-0x000003f2, 0x000003a3, 0x000003a3,
-0x000003f5, 0x00000395, 0x00000395,
-0x00000430, 0x00000410, 0x00000410,
-0x00000431, 0x00000411, 0x00000411,
-0x00000432, 0x00000412, 0x00000412,
-0x00000433, 0x00000413, 0x00000413,
-0x00000434, 0x00000414, 0x00000414,
-0x00000435, 0x00000415, 0x00000415,
-0x00000436, 0x00000416, 0x00000416,
-0x00000437, 0x00000417, 0x00000417,
-0x00000438, 0x00000418, 0x00000418,
-0x00000439, 0x00000419, 0x00000419,
-0x0000043a, 0x0000041a, 0x0000041a,
-0x0000043b, 0x0000041b, 0x0000041b,
-0x0000043c, 0x0000041c, 0x0000041c,
-0x0000043d, 0x0000041d, 0x0000041d,
-0x0000043e, 0x0000041e, 0x0000041e,
-0x0000043f, 0x0000041f, 0x0000041f,
-0x00000440, 0x00000420, 0x00000420,
-0x00000441, 0x00000421, 0x00000421,
-0x00000442, 0x00000422, 0x00000422,
-0x00000443, 0x00000423, 0x00000423,
-0x00000444, 0x00000424, 0x00000424,
-0x00000445, 0x00000425, 0x00000425,
-0x00000446, 0x00000426, 0x00000426,
-0x00000447, 0x00000427, 0x00000427,
-0x00000448, 0x00000428, 0x00000428,
-0x00000449, 0x00000429, 0x00000429,
-0x0000044a, 0x0000042a, 0x0000042a,
-0x0000044b, 0x0000042b, 0x0000042b,
-0x0000044c, 0x0000042c, 0x0000042c,
-0x0000044d, 0x0000042d, 0x0000042d,
-0x0000044e, 0x0000042e, 0x0000042e,
-0x0000044f, 0x0000042f, 0x0000042f,
-0x00000450, 0x00000400, 0x00000400,
-0x00000451, 0x00000401, 0x00000401,
-0x00000452, 0x00000402, 0x00000402,
-0x00000453, 0x00000403, 0x00000403,
-0x00000454, 0x00000404, 0x00000404,
-0x00000455, 0x00000405, 0x00000405,
-0x00000456, 0x00000406, 0x00000406,
-0x00000457, 0x00000407, 0x00000407,
-0x00000458, 0x00000408, 0x00000408,
-0x00000459, 0x00000409, 0x00000409,
-0x0000045a, 0x0000040a, 0x0000040a,
-0x0000045b, 0x0000040b, 0x0000040b,
-0x0000045c, 0x0000040c, 0x0000040c,
-0x0000045d, 0x0000040d, 0x0000040d,
-0x0000045e, 0x0000040e, 0x0000040e,
-0x0000045f, 0x0000040f, 0x0000040f,
-0x00000461, 0x00000460, 0x00000460,
-0x00000463, 0x00000462, 0x00000462,
-0x00000465, 0x00000464, 0x00000464,
-0x00000467, 0x00000466, 0x00000466,
-0x00000469, 0x00000468, 0x00000468,
-0x0000046b, 0x0000046a, 0x0000046a,
-0x0000046d, 0x0000046c, 0x0000046c,
-0x0000046f, 0x0000046e, 0x0000046e,
-0x00000471, 0x00000470, 0x00000470,
-0x00000473, 0x00000472, 0x00000472,
-0x00000475, 0x00000474, 0x00000474,
-0x00000477, 0x00000476, 0x00000476,
-0x00000479, 0x00000478, 0x00000478,
-0x0000047b, 0x0000047a, 0x0000047a,
-0x0000047d, 0x0000047c, 0x0000047c,
-0x0000047f, 0x0000047e, 0x0000047e,
-0x00000481, 0x00000480, 0x00000480,
-0x0000048b, 0x0000048a, 0x0000048a,
-0x0000048d, 0x0000048c, 0x0000048c,
-0x0000048f, 0x0000048e, 0x0000048e,
-0x00000491, 0x00000490, 0x00000490,
-0x00000493, 0x00000492, 0x00000492,
-0x00000495, 0x00000494, 0x00000494,
-0x00000497, 0x00000496, 0x00000496,
-0x00000499, 0x00000498, 0x00000498,
-0x0000049b, 0x0000049a, 0x0000049a,
-0x0000049d, 0x0000049c, 0x0000049c,
-0x0000049f, 0x0000049e, 0x0000049e,
-0x000004a1, 0x000004a0, 0x000004a0,
-0x000004a3, 0x000004a2, 0x000004a2,
-0x000004a5, 0x000004a4, 0x000004a4,
-0x000004a7, 0x000004a6, 0x000004a6,
-0x000004a9, 0x000004a8, 0x000004a8,
-0x000004ab, 0x000004aa, 0x000004aa,
-0x000004ad, 0x000004ac, 0x000004ac,
-0x000004af, 0x000004ae, 0x000004ae,
-0x000004b1, 0x000004b0, 0x000004b0,
-0x000004b3, 0x000004b2, 0x000004b2,
-0x000004b5, 0x000004b4, 0x000004b4,
-0x000004b7, 0x000004b6, 0x000004b6,
-0x000004b9, 0x000004b8, 0x000004b8,
-0x000004bb, 0x000004ba, 0x000004ba,
-0x000004bd, 0x000004bc, 0x000004bc,
-0x000004bf, 0x000004be, 0x000004be,
-0x000004c2, 0x000004c1, 0x000004c1,
-0x000004c4, 0x000004c3, 0x000004c3,
-0x000004c6, 0x000004c5, 0x000004c5,
-0x000004c8, 0x000004c7, 0x000004c7,
-0x000004ca, 0x000004c9, 0x000004c9,
-0x000004cc, 0x000004cb, 0x000004cb,
-0x000004ce, 0x000004cd, 0x000004cd,
-0x000004d1, 0x000004d0, 0x000004d0,
-0x000004d3, 0x000004d2, 0x000004d2,
-0x000004d5, 0x000004d4, 0x000004d4,
-0x000004d7, 0x000004d6, 0x000004d6,
-0x000004d9, 0x000004d8, 0x000004d8,
-0x000004db, 0x000004da, 0x000004da,
-0x000004dd, 0x000004dc, 0x000004dc,
-0x000004df, 0x000004de, 0x000004de,
-0x000004e1, 0x000004e0, 0x000004e0,
-0x000004e3, 0x000004e2, 0x000004e2,
-0x000004e5, 0x000004e4, 0x000004e4,
-0x000004e7, 0x000004e6, 0x000004e6,
-0x000004e9, 0x000004e8, 0x000004e8,
-0x000004eb, 0x000004ea, 0x000004ea,
-0x000004ed, 0x000004ec, 0x000004ec,
-0x000004ef, 0x000004ee, 0x000004ee,
-0x000004f1, 0x000004f0, 0x000004f0,
-0x000004f3, 0x000004f2, 0x000004f2,
-0x000004f5, 0x000004f4, 0x000004f4,
-0x000004f9, 0x000004f8, 0x000004f8,
-0x00000501, 0x00000500, 0x00000500,
-0x00000503, 0x00000502, 0x00000502,
-0x00000505, 0x00000504, 0x00000504,
-0x00000507, 0x00000506, 0x00000506,
-0x00000509, 0x00000508, 0x00000508,
-0x0000050b, 0x0000050a, 0x0000050a,
-0x0000050d, 0x0000050c, 0x0000050c,
-0x0000050f, 0x0000050e, 0x0000050e,
-0x00000561, 0x00000531, 0x00000531,
-0x00000562, 0x00000532, 0x00000532,
-0x00000563, 0x00000533, 0x00000533,
-0x00000564, 0x00000534, 0x00000534,
-0x00000565, 0x00000535, 0x00000535,
-0x00000566, 0x00000536, 0x00000536,
-0x00000567, 0x00000537, 0x00000537,
-0x00000568, 0x00000538, 0x00000538,
-0x00000569, 0x00000539, 0x00000539,
-0x0000056a, 0x0000053a, 0x0000053a,
-0x0000056b, 0x0000053b, 0x0000053b,
-0x0000056c, 0x0000053c, 0x0000053c,
-0x0000056d, 0x0000053d, 0x0000053d,
-0x0000056e, 0x0000053e, 0x0000053e,
-0x0000056f, 0x0000053f, 0x0000053f,
-0x00000570, 0x00000540, 0x00000540,
-0x00000571, 0x00000541, 0x00000541,
-0x00000572, 0x00000542, 0x00000542,
-0x00000573, 0x00000543, 0x00000543,
-0x00000574, 0x00000544, 0x00000544,
-0x00000575, 0x00000545, 0x00000545,
-0x00000576, 0x00000546, 0x00000546,
-0x00000577, 0x00000547, 0x00000547,
-0x00000578, 0x00000548, 0x00000548,
-0x00000579, 0x00000549, 0x00000549,
-0x0000057a, 0x0000054a, 0x0000054a,
-0x0000057b, 0x0000054b, 0x0000054b,
-0x0000057c, 0x0000054c, 0x0000054c,
-0x0000057d, 0x0000054d, 0x0000054d,
-0x0000057e, 0x0000054e, 0x0000054e,
-0x0000057f, 0x0000054f, 0x0000054f,
-0x00000580, 0x00000550, 0x00000550,
-0x00000581, 0x00000551, 0x00000551,
-0x00000582, 0x00000552, 0x00000552,
-0x00000583, 0x00000553, 0x00000553,
-0x00000584, 0x00000554, 0x00000554,
-0x00000585, 0x00000555, 0x00000555,
-0x00000586, 0x00000556, 0x00000556,
-0x00001e01, 0x00001e00, 0x00001e00,
-0x00001e03, 0x00001e02, 0x00001e02,
-0x00001e05, 0x00001e04, 0x00001e04,
-0x00001e07, 0x00001e06, 0x00001e06,
-0x00001e09, 0x00001e08, 0x00001e08,
-0x00001e0b, 0x00001e0a, 0x00001e0a,
-0x00001e0d, 0x00001e0c, 0x00001e0c,
-0x00001e0f, 0x00001e0e, 0x00001e0e,
-0x00001e11, 0x00001e10, 0x00001e10,
-0x00001e13, 0x00001e12, 0x00001e12,
-0x00001e15, 0x00001e14, 0x00001e14,
-0x00001e17, 0x00001e16, 0x00001e16,
-0x00001e19, 0x00001e18, 0x00001e18,
-0x00001e1b, 0x00001e1a, 0x00001e1a,
-0x00001e1d, 0x00001e1c, 0x00001e1c,
-0x00001e1f, 0x00001e1e, 0x00001e1e,
-0x00001e21, 0x00001e20, 0x00001e20,
-0x00001e23, 0x00001e22, 0x00001e22,
-0x00001e25, 0x00001e24, 0x00001e24,
-0x00001e27, 0x00001e26, 0x00001e26,
-0x00001e29, 0x00001e28, 0x00001e28,
-0x00001e2b, 0x00001e2a, 0x00001e2a,
-0x00001e2d, 0x00001e2c, 0x00001e2c,
-0x00001e2f, 0x00001e2e, 0x00001e2e,
-0x00001e31, 0x00001e30, 0x00001e30,
-0x00001e33, 0x00001e32, 0x00001e32,
-0x00001e35, 0x00001e34, 0x00001e34,
-0x00001e37, 0x00001e36, 0x00001e36,
-0x00001e39, 0x00001e38, 0x00001e38,
-0x00001e3b, 0x00001e3a, 0x00001e3a,
-0x00001e3d, 0x00001e3c, 0x00001e3c,
-0x00001e3f, 0x00001e3e, 0x00001e3e,
-0x00001e41, 0x00001e40, 0x00001e40,
-0x00001e43, 0x00001e42, 0x00001e42,
-0x00001e45, 0x00001e44, 0x00001e44,
-0x00001e47, 0x00001e46, 0x00001e46,
-0x00001e49, 0x00001e48, 0x00001e48,
-0x00001e4b, 0x00001e4a, 0x00001e4a,
-0x00001e4d, 0x00001e4c, 0x00001e4c,
-0x00001e4f, 0x00001e4e, 0x00001e4e,
-0x00001e51, 0x00001e50, 0x00001e50,
-0x00001e53, 0x00001e52, 0x00001e52,
-0x00001e55, 0x00001e54, 0x00001e54,
-0x00001e57, 0x00001e56, 0x00001e56,
-0x00001e59, 0x00001e58, 0x00001e58,
-0x00001e5b, 0x00001e5a, 0x00001e5a,
-0x00001e5d, 0x00001e5c, 0x00001e5c,
-0x00001e5f, 0x00001e5e, 0x00001e5e,
-0x00001e61, 0x00001e60, 0x00001e60,
-0x00001e63, 0x00001e62, 0x00001e62,
-0x00001e65, 0x00001e64, 0x00001e64,
-0x00001e67, 0x00001e66, 0x00001e66,
-0x00001e69, 0x00001e68, 0x00001e68,
-0x00001e6b, 0x00001e6a, 0x00001e6a,
-0x00001e6d, 0x00001e6c, 0x00001e6c,
-0x00001e6f, 0x00001e6e, 0x00001e6e,
-0x00001e71, 0x00001e70, 0x00001e70,
-0x00001e73, 0x00001e72, 0x00001e72,
-0x00001e75, 0x00001e74, 0x00001e74,
-0x00001e77, 0x00001e76, 0x00001e76,
-0x00001e79, 0x00001e78, 0x00001e78,
-0x00001e7b, 0x00001e7a, 0x00001e7a,
-0x00001e7d, 0x00001e7c, 0x00001e7c,
-0x00001e7f, 0x00001e7e, 0x00001e7e,
-0x00001e81, 0x00001e80, 0x00001e80,
-0x00001e83, 0x00001e82, 0x00001e82,
-0x00001e85, 0x00001e84, 0x00001e84,
-0x00001e87, 0x00001e86, 0x00001e86,
-0x00001e89, 0x00001e88, 0x00001e88,
-0x00001e8b, 0x00001e8a, 0x00001e8a,
-0x00001e8d, 0x00001e8c, 0x00001e8c,
-0x00001e8f, 0x00001e8e, 0x00001e8e,
-0x00001e91, 0x00001e90, 0x00001e90,
-0x00001e93, 0x00001e92, 0x00001e92,
-0x00001e95, 0x00001e94, 0x00001e94,
-0x00001e9b, 0x00001e60, 0x00001e60,
-0x00001ea1, 0x00001ea0, 0x00001ea0,
-0x00001ea3, 0x00001ea2, 0x00001ea2,
-0x00001ea5, 0x00001ea4, 0x00001ea4,
-0x00001ea7, 0x00001ea6, 0x00001ea6,
-0x00001ea9, 0x00001ea8, 0x00001ea8,
-0x00001eab, 0x00001eaa, 0x00001eaa,
-0x00001ead, 0x00001eac, 0x00001eac,
-0x00001eaf, 0x00001eae, 0x00001eae,
-0x00001eb1, 0x00001eb0, 0x00001eb0,
-0x00001eb3, 0x00001eb2, 0x00001eb2,
-0x00001eb5, 0x00001eb4, 0x00001eb4,
-0x00001eb7, 0x00001eb6, 0x00001eb6,
-0x00001eb9, 0x00001eb8, 0x00001eb8,
-0x00001ebb, 0x00001eba, 0x00001eba,
-0x00001ebd, 0x00001ebc, 0x00001ebc,
-0x00001ebf, 0x00001ebe, 0x00001ebe,
-0x00001ec1, 0x00001ec0, 0x00001ec0,
-0x00001ec3, 0x00001ec2, 0x00001ec2,
-0x00001ec5, 0x00001ec4, 0x00001ec4,
-0x00001ec7, 0x00001ec6, 0x00001ec6,
-0x00001ec9, 0x00001ec8, 0x00001ec8,
-0x00001ecb, 0x00001eca, 0x00001eca,
-0x00001ecd, 0x00001ecc, 0x00001ecc,
-0x00001ecf, 0x00001ece, 0x00001ece,
-0x00001ed1, 0x00001ed0, 0x00001ed0,
-0x00001ed3, 0x00001ed2, 0x00001ed2,
-0x00001ed5, 0x00001ed4, 0x00001ed4,
-0x00001ed7, 0x00001ed6, 0x00001ed6,
-0x00001ed9, 0x00001ed8, 0x00001ed8,
-0x00001edb, 0x00001eda, 0x00001eda,
-0x00001edd, 0x00001edc, 0x00001edc,
-0x00001edf, 0x00001ede, 0x00001ede,
-0x00001ee1, 0x00001ee0, 0x00001ee0,
-0x00001ee3, 0x00001ee2, 0x00001ee2,
-0x00001ee5, 0x00001ee4, 0x00001ee4,
-0x00001ee7, 0x00001ee6, 0x00001ee6,
-0x00001ee9, 0x00001ee8, 0x00001ee8,
-0x00001eeb, 0x00001eea, 0x00001eea,
-0x00001eed, 0x00001eec, 0x00001eec,
-0x00001eef, 0x00001eee, 0x00001eee,
-0x00001ef1, 0x00001ef0, 0x00001ef0,
-0x00001ef3, 0x00001ef2, 0x00001ef2,
-0x00001ef5, 0x00001ef4, 0x00001ef4,
-0x00001ef7, 0x00001ef6, 0x00001ef6,
-0x00001ef9, 0x00001ef8, 0x00001ef8,
-0x00001f00, 0x00001f08, 0x00001f08,
-0x00001f01, 0x00001f09, 0x00001f09,
-0x00001f02, 0x00001f0a, 0x00001f0a,
-0x00001f03, 0x00001f0b, 0x00001f0b,
-0x00001f04, 0x00001f0c, 0x00001f0c,
-0x00001f05, 0x00001f0d, 0x00001f0d,
-0x00001f06, 0x00001f0e, 0x00001f0e,
-0x00001f07, 0x00001f0f, 0x00001f0f,
-0x00001f10, 0x00001f18, 0x00001f18,
-0x00001f11, 0x00001f19, 0x00001f19,
-0x00001f12, 0x00001f1a, 0x00001f1a,
-0x00001f13, 0x00001f1b, 0x00001f1b,
-0x00001f14, 0x00001f1c, 0x00001f1c,
-0x00001f15, 0x00001f1d, 0x00001f1d,
-0x00001f20, 0x00001f28, 0x00001f28,
-0x00001f21, 0x00001f29, 0x00001f29,
-0x00001f22, 0x00001f2a, 0x00001f2a,
-0x00001f23, 0x00001f2b, 0x00001f2b,
-0x00001f24, 0x00001f2c, 0x00001f2c,
-0x00001f25, 0x00001f2d, 0x00001f2d,
-0x00001f26, 0x00001f2e, 0x00001f2e,
-0x00001f27, 0x00001f2f, 0x00001f2f,
-0x00001f30, 0x00001f38, 0x00001f38,
-0x00001f31, 0x00001f39, 0x00001f39,
-0x00001f32, 0x00001f3a, 0x00001f3a,
-0x00001f33, 0x00001f3b, 0x00001f3b,
-0x00001f34, 0x00001f3c, 0x00001f3c,
-0x00001f35, 0x00001f3d, 0x00001f3d,
-0x00001f36, 0x00001f3e, 0x00001f3e,
-0x00001f37, 0x00001f3f, 0x00001f3f,
-0x00001f40, 0x00001f48, 0x00001f48,
-0x00001f41, 0x00001f49, 0x00001f49,
-0x00001f42, 0x00001f4a, 0x00001f4a,
-0x00001f43, 0x00001f4b, 0x00001f4b,
-0x00001f44, 0x00001f4c, 0x00001f4c,
-0x00001f45, 0x00001f4d, 0x00001f4d,
-0x00001f51, 0x00001f59, 0x00001f59,
-0x00001f53, 0x00001f5b, 0x00001f5b,
-0x00001f55, 0x00001f5d, 0x00001f5d,
-0x00001f57, 0x00001f5f, 0x00001f5f,
-0x00001f60, 0x00001f68, 0x00001f68,
-0x00001f61, 0x00001f69, 0x00001f69,
-0x00001f62, 0x00001f6a, 0x00001f6a,
-0x00001f63, 0x00001f6b, 0x00001f6b,
-0x00001f64, 0x00001f6c, 0x00001f6c,
-0x00001f65, 0x00001f6d, 0x00001f6d,
-0x00001f66, 0x00001f6e, 0x00001f6e,
-0x00001f67, 0x00001f6f, 0x00001f6f,
-0x00001f70, 0x00001fba, 0x00001fba,
-0x00001f71, 0x00001fbb, 0x00001fbb,
-0x00001f72, 0x00001fc8, 0x00001fc8,
-0x00001f73, 0x00001fc9, 0x00001fc9,
-0x00001f74, 0x00001fca, 0x00001fca,
-0x00001f75, 0x00001fcb, 0x00001fcb,
-0x00001f76, 0x00001fda, 0x00001fda,
-0x00001f77, 0x00001fdb, 0x00001fdb,
-0x00001f78, 0x00001ff8, 0x00001ff8,
-0x00001f79, 0x00001ff9, 0x00001ff9,
-0x00001f7a, 0x00001fea, 0x00001fea,
-0x00001f7b, 0x00001feb, 0x00001feb,
-0x00001f7c, 0x00001ffa, 0x00001ffa,
-0x00001f7d, 0x00001ffb, 0x00001ffb,
-0x00001f80, 0x00001f88, 0x00001f88,
-0x00001f81, 0x00001f89, 0x00001f89,
-0x00001f82, 0x00001f8a, 0x00001f8a,
-0x00001f83, 0x00001f8b, 0x00001f8b,
-0x00001f84, 0x00001f8c, 0x00001f8c,
-0x00001f85, 0x00001f8d, 0x00001f8d,
-0x00001f86, 0x00001f8e, 0x00001f8e,
-0x00001f87, 0x00001f8f, 0x00001f8f,
-0x00001f90, 0x00001f98, 0x00001f98,
-0x00001f91, 0x00001f99, 0x00001f99,
-0x00001f92, 0x00001f9a, 0x00001f9a,
-0x00001f93, 0x00001f9b, 0x00001f9b,
-0x00001f94, 0x00001f9c, 0x00001f9c,
-0x00001f95, 0x00001f9d, 0x00001f9d,
-0x00001f96, 0x00001f9e, 0x00001f9e,
-0x00001f97, 0x00001f9f, 0x00001f9f,
-0x00001fa0, 0x00001fa8, 0x00001fa8,
-0x00001fa1, 0x00001fa9, 0x00001fa9,
-0x00001fa2, 0x00001faa, 0x00001faa,
-0x00001fa3, 0x00001fab, 0x00001fab,
-0x00001fa4, 0x00001fac, 0x00001fac,
-0x00001fa5, 0x00001fad, 0x00001fad,
-0x00001fa6, 0x00001fae, 0x00001fae,
-0x00001fa7, 0x00001faf, 0x00001faf,
-0x00001fb0, 0x00001fb8, 0x00001fb8,
-0x00001fb1, 0x00001fb9, 0x00001fb9,
-0x00001fb3, 0x00001fbc, 0x00001fbc,
-0x00001fbe, 0x00000399, 0x00000399,
-0x00001fc3, 0x00001fcc, 0x00001fcc,
-0x00001fd0, 0x00001fd8, 0x00001fd8,
-0x00001fd1, 0x00001fd9, 0x00001fd9,
-0x00001fe0, 0x00001fe8, 0x00001fe8,
-0x00001fe1, 0x00001fe9, 0x00001fe9,
-0x00001fe5, 0x00001fec, 0x00001fec,
-0x00001ff3, 0x00001ffc, 0x00001ffc,
-0x00002170, 0x00002160, 0x00002160,
-0x00002171, 0x00002161, 0x00002161,
-0x00002172, 0x00002162, 0x00002162,
-0x00002173, 0x00002163, 0x00002163,
-0x00002174, 0x00002164, 0x00002164,
-0x00002175, 0x00002165, 0x00002165,
-0x00002176, 0x00002166, 0x00002166,
-0x00002177, 0x00002167, 0x00002167,
-0x00002178, 0x00002168, 0x00002168,
-0x00002179, 0x00002169, 0x00002169,
-0x0000217a, 0x0000216a, 0x0000216a,
-0x0000217b, 0x0000216b, 0x0000216b,
-0x0000217c, 0x0000216c, 0x0000216c,
-0x0000217d, 0x0000216d, 0x0000216d,
-0x0000217e, 0x0000216e, 0x0000216e,
-0x0000217f, 0x0000216f, 0x0000216f,
-0x000024d0, 0x000024b6, 0x000024b6,
-0x000024d1, 0x000024b7, 0x000024b7,
-0x000024d2, 0x000024b8, 0x000024b8,
-0x000024d3, 0x000024b9, 0x000024b9,
-0x000024d4, 0x000024ba, 0x000024ba,
-0x000024d5, 0x000024bb, 0x000024bb,
-0x000024d6, 0x000024bc, 0x000024bc,
-0x000024d7, 0x000024bd, 0x000024bd,
-0x000024d8, 0x000024be, 0x000024be,
-0x000024d9, 0x000024bf, 0x000024bf,
-0x000024da, 0x000024c0, 0x000024c0,
-0x000024db, 0x000024c1, 0x000024c1,
-0x000024dc, 0x000024c2, 0x000024c2,
-0x000024dd, 0x000024c3, 0x000024c3,
-0x000024de, 0x000024c4, 0x000024c4,
-0x000024df, 0x000024c5, 0x000024c5,
-0x000024e0, 0x000024c6, 0x000024c6,
-0x000024e1, 0x000024c7, 0x000024c7,
-0x000024e2, 0x000024c8, 0x000024c8,
-0x000024e3, 0x000024c9, 0x000024c9,
-0x000024e4, 0x000024ca, 0x000024ca,
-0x000024e5, 0x000024cb, 0x000024cb,
-0x000024e6, 0x000024cc, 0x000024cc,
-0x000024e7, 0x000024cd, 0x000024cd,
-0x000024e8, 0x000024ce, 0x000024ce,
-0x000024e9, 0x000024cf, 0x000024cf,
-0x0000ff41, 0x0000ff21, 0x0000ff21,
-0x0000ff42, 0x0000ff22, 0x0000ff22,
-0x0000ff43, 0x0000ff23, 0x0000ff23,
-0x0000ff44, 0x0000ff24, 0x0000ff24,
-0x0000ff45, 0x0000ff25, 0x0000ff25,
-0x0000ff46, 0x0000ff26, 0x0000ff26,
-0x0000ff47, 0x0000ff27, 0x0000ff27,
-0x0000ff48, 0x0000ff28, 0x0000ff28,
-0x0000ff49, 0x0000ff29, 0x0000ff29,
-0x0000ff4a, 0x0000ff2a, 0x0000ff2a,
-0x0000ff4b, 0x0000ff2b, 0x0000ff2b,
-0x0000ff4c, 0x0000ff2c, 0x0000ff2c,
-0x0000ff4d, 0x0000ff2d, 0x0000ff2d,
-0x0000ff4e, 0x0000ff2e, 0x0000ff2e,
-0x0000ff4f, 0x0000ff2f, 0x0000ff2f,
-0x0000ff50, 0x0000ff30, 0x0000ff30,
-0x0000ff51, 0x0000ff31, 0x0000ff31,
-0x0000ff52, 0x0000ff32, 0x0000ff32,
-0x0000ff53, 0x0000ff33, 0x0000ff33,
-0x0000ff54, 0x0000ff34, 0x0000ff34,
-0x0000ff55, 0x0000ff35, 0x0000ff35,
-0x0000ff56, 0x0000ff36, 0x0000ff36,
-0x0000ff57, 0x0000ff37, 0x0000ff37,
-0x0000ff58, 0x0000ff38, 0x0000ff38,
-0x0000ff59, 0x0000ff39, 0x0000ff39,
-0x0000ff5a, 0x0000ff3a, 0x0000ff3a,
-0x00010428, 0x00010400, 0x00010400,
-0x00010429, 0x00010401, 0x00010401,
-0x0001042a, 0x00010402, 0x00010402,
-0x0001042b, 0x00010403, 0x00010403,
-0x0001042c, 0x00010404, 0x00010404,
-0x0001042d, 0x00010405, 0x00010405,
-0x0001042e, 0x00010406, 0x00010406,
-0x0001042f, 0x00010407, 0x00010407,
-0x00010430, 0x00010408, 0x00010408,
-0x00010431, 0x00010409, 0x00010409,
-0x00010432, 0x0001040a, 0x0001040a,
-0x00010433, 0x0001040b, 0x0001040b,
-0x00010434, 0x0001040c, 0x0001040c,
-0x00010435, 0x0001040d, 0x0001040d,
-0x00010436, 0x0001040e, 0x0001040e,
-0x00010437, 0x0001040f, 0x0001040f,
-0x00010438, 0x00010410, 0x00010410,
-0x00010439, 0x00010411, 0x00010411,
-0x0001043a, 0x00010412, 0x00010412,
-0x0001043b, 0x00010413, 0x00010413,
-0x0001043c, 0x00010414, 0x00010414,
-0x0001043d, 0x00010415, 0x00010415,
-0x0001043e, 0x00010416, 0x00010416,
-0x0001043f, 0x00010417, 0x00010417,
-0x00010440, 0x00010418, 0x00010418,
-0x00010441, 0x00010419, 0x00010419,
-0x00010442, 0x0001041a, 0x0001041a,
-0x00010443, 0x0001041b, 0x0001041b,
-0x00010444, 0x0001041c, 0x0001041c,
-0x00010445, 0x0001041d, 0x0001041d,
-0x00010446, 0x0001041e, 0x0001041e,
-0x00010447, 0x0001041f, 0x0001041f,
-0x00010448, 0x00010420, 0x00010420,
-0x00010449, 0x00010421, 0x00010421,
-0x0001044a, 0x00010422, 0x00010422,
-0x0001044b, 0x00010423, 0x00010423,
-0x0001044c, 0x00010424, 0x00010424,
-0x0001044d, 0x00010425, 0x00010425,
-/* title */
-0x000001c5, 0x000001c4, 0x000001c6,
-0x000001c8, 0x000001c7, 0x000001c9,
-0x000001cb, 0x000001ca, 0x000001cc,
-0x000001f2, 0x000001f1, 0x000001f3,
+
+static const unsigned int _uccase_size = 2080;
+
+/* Starting indexes of the case tables
+ * UpperIndex = 0
+ * LowerIndex = _uccase_len[0]
+ * TitleIndex = LowerIndex + _uccase_len[1] */
+
+static const unsigned short _uccase_len[2] = {3102, 3126};
+
+static const unsigned int _uccase_map[] = {
+	0x00000041, 0x00000061, 0x00000041,
+	0x00000042, 0x00000062, 0x00000042,
+	0x00000043, 0x00000063, 0x00000043,
+	0x00000044, 0x00000064, 0x00000044,
+	0x00000045, 0x00000065, 0x00000045,
+	0x00000046, 0x00000066, 0x00000046,
+	0x00000047, 0x00000067, 0x00000047,
+	0x00000048, 0x00000068, 0x00000048,
+	0x00000049, 0x00000069, 0x00000049,
+	0x0000004a, 0x0000006a, 0x0000004a,
+	0x0000004b, 0x0000006b, 0x0000004b,
+	0x0000004c, 0x0000006c, 0x0000004c,
+	0x0000004d, 0x0000006d, 0x0000004d,
+	0x0000004e, 0x0000006e, 0x0000004e,
+	0x0000004f, 0x0000006f, 0x0000004f,
+	0x00000050, 0x00000070, 0x00000050,
+	0x00000051, 0x00000071, 0x00000051,
+	0x00000052, 0x00000072, 0x00000052,
+	0x00000053, 0x00000073, 0x00000053,
+	0x00000054, 0x00000074, 0x00000054,
+	0x00000055, 0x00000075, 0x00000055,
+	0x00000056, 0x00000076, 0x00000056,
+	0x00000057, 0x00000077, 0x00000057,
+	0x00000058, 0x00000078, 0x00000058,
+	0x00000059, 0x00000079, 0x00000059,
+	0x0000005a, 0x0000007a, 0x0000005a,
+	0x000000c0, 0x000000e0, 0x000000c0,
+	0x000000c1, 0x000000e1, 0x000000c1,
+	0x000000c2, 0x000000e2, 0x000000c2,
+	0x000000c3, 0x000000e3, 0x000000c3,
+	0x000000c4, 0x000000e4, 0x000000c4,
+	0x000000c5, 0x000000e5, 0x000000c5,
+	0x000000c6, 0x000000e6, 0x000000c6,
+	0x000000c7, 0x000000e7, 0x000000c7,
+	0x000000c8, 0x000000e8, 0x000000c8,
+	0x000000c9, 0x000000e9, 0x000000c9,
+	0x000000ca, 0x000000ea, 0x000000ca,
+	0x000000cb, 0x000000eb, 0x000000cb,
+	0x000000cc, 0x000000ec, 0x000000cc,
+	0x000000cd, 0x000000ed, 0x000000cd,
+	0x000000ce, 0x000000ee, 0x000000ce,
+	0x000000cf, 0x000000ef, 0x000000cf,
+	0x000000d0, 0x000000f0, 0x000000d0,
+	0x000000d1, 0x000000f1, 0x000000d1,
+	0x000000d2, 0x000000f2, 0x000000d2,
+	0x000000d3, 0x000000f3, 0x000000d3,
+	0x000000d4, 0x000000f4, 0x000000d4,
+	0x000000d5, 0x000000f5, 0x000000d5,
+	0x000000d6, 0x000000f6, 0x000000d6,
+	0x000000d8, 0x000000f8, 0x000000d8,
+	0x000000d9, 0x000000f9, 0x000000d9,
+	0x000000da, 0x000000fa, 0x000000da,
+	0x000000db, 0x000000fb, 0x000000db,
+	0x000000dc, 0x000000fc, 0x000000dc,
+	0x000000dd, 0x000000fd, 0x000000dd,
+	0x000000de, 0x000000fe, 0x000000de,
+	0x00000100, 0x00000101, 0x00000100,
+	0x00000102, 0x00000103, 0x00000102,
+	0x00000104, 0x00000105, 0x00000104,
+	0x00000106, 0x00000107, 0x00000106,
+	0x00000108, 0x00000109, 0x00000108,
+	0x0000010a, 0x0000010b, 0x0000010a,
+	0x0000010c, 0x0000010d, 0x0000010c,
+	0x0000010e, 0x0000010f, 0x0000010e,
+	0x00000110, 0x00000111, 0x00000110,
+	0x00000112, 0x00000113, 0x00000112,
+	0x00000114, 0x00000115, 0x00000114,
+	0x00000116, 0x00000117, 0x00000116,
+	0x00000118, 0x00000119, 0x00000118,
+	0x0000011a, 0x0000011b, 0x0000011a,
+	0x0000011c, 0x0000011d, 0x0000011c,
+	0x0000011e, 0x0000011f, 0x0000011e,
+	0x00000120, 0x00000121, 0x00000120,
+	0x00000122, 0x00000123, 0x00000122,
+	0x00000124, 0x00000125, 0x00000124,
+	0x00000126, 0x00000127, 0x00000126,
+	0x00000128, 0x00000129, 0x00000128,
+	0x0000012a, 0x0000012b, 0x0000012a,
+	0x0000012c, 0x0000012d, 0x0000012c,
+	0x0000012e, 0x0000012f, 0x0000012e,
+	0x00000130, 0x00000069, 0x00000130,
+	0x00000132, 0x00000133, 0x00000132,
+	0x00000134, 0x00000135, 0x00000134,
+	0x00000136, 0x00000137, 0x00000136,
+	0x00000139, 0x0000013a, 0x00000139,
+	0x0000013b, 0x0000013c, 0x0000013b,
+	0x0000013d, 0x0000013e, 0x0000013d,
+	0x0000013f, 0x00000140, 0x0000013f,
+	0x00000141, 0x00000142, 0x00000141,
+	0x00000143, 0x00000144, 0x00000143,
+	0x00000145, 0x00000146, 0x00000145,
+	0x00000147, 0x00000148, 0x00000147,
+	0x0000014a, 0x0000014b, 0x0000014a,
+	0x0000014c, 0x0000014d, 0x0000014c,
+	0x0000014e, 0x0000014f, 0x0000014e,
+	0x00000150, 0x00000151, 0x00000150,
+	0x00000152, 0x00000153, 0x00000152,
+	0x00000154, 0x00000155, 0x00000154,
+	0x00000156, 0x00000157, 0x00000156,
+	0x00000158, 0x00000159, 0x00000158,
+	0x0000015a, 0x0000015b, 0x0000015a,
+	0x0000015c, 0x0000015d, 0x0000015c,
+	0x0000015e, 0x0000015f, 0x0000015e,
+	0x00000160, 0x00000161, 0x00000160,
+	0x00000162, 0x00000163, 0x00000162,
+	0x00000164, 0x00000165, 0x00000164,
+	0x00000166, 0x00000167, 0x00000166,
+	0x00000168, 0x00000169, 0x00000168,
+	0x0000016a, 0x0000016b, 0x0000016a,
+	0x0000016c, 0x0000016d, 0x0000016c,
+	0x0000016e, 0x0000016f, 0x0000016e,
+	0x00000170, 0x00000171, 0x00000170,
+	0x00000172, 0x00000173, 0x00000172,
+	0x00000174, 0x00000175, 0x00000174,
+	0x00000176, 0x00000177, 0x00000176,
+	0x00000178, 0x000000ff, 0x00000178,
+	0x00000179, 0x0000017a, 0x00000179,
+	0x0000017b, 0x0000017c, 0x0000017b,
+	0x0000017d, 0x0000017e, 0x0000017d,
+	0x00000181, 0x00000253, 0x00000181,
+	0x00000182, 0x00000183, 0x00000182,
+	0x00000184, 0x00000185, 0x00000184,
+	0x00000186, 0x00000254, 0x00000186,
+	0x00000187, 0x00000188, 0x00000187,
+	0x00000189, 0x00000256, 0x00000189,
+	0x0000018a, 0x00000257, 0x0000018a,
+	0x0000018b, 0x0000018c, 0x0000018b,
+	0x0000018e, 0x000001dd, 0x0000018e,
+	0x0000018f, 0x00000259, 0x0000018f,
+	0x00000190, 0x0000025b, 0x00000190,
+	0x00000191, 0x00000192, 0x00000191,
+	0x00000193, 0x00000260, 0x00000193,
+	0x00000194, 0x00000263, 0x00000194,
+	0x00000196, 0x00000269, 0x00000196,
+	0x00000197, 0x00000268, 0x00000197,
+	0x00000198, 0x00000199, 0x00000198,
+	0x0000019c, 0x0000026f, 0x0000019c,
+	0x0000019d, 0x00000272, 0x0000019d,
+	0x0000019f, 0x00000275, 0x0000019f,
+	0x000001a0, 0x000001a1, 0x000001a0,
+	0x000001a2, 0x000001a3, 0x000001a2,
+	0x000001a4, 0x000001a5, 0x000001a4,
+	0x000001a6, 0x00000280, 0x000001a6,
+	0x000001a7, 0x000001a8, 0x000001a7,
+	0x000001a9, 0x00000283, 0x000001a9,
+	0x000001ac, 0x000001ad, 0x000001ac,
+	0x000001ae, 0x00000288, 0x000001ae,
+	0x000001af, 0x000001b0, 0x000001af,
+	0x000001b1, 0x0000028a, 0x000001b1,
+	0x000001b2, 0x0000028b, 0x000001b2,
+	0x000001b3, 0x000001b4, 0x000001b3,
+	0x000001b5, 0x000001b6, 0x000001b5,
+	0x000001b7, 0x00000292, 0x000001b7,
+	0x000001b8, 0x000001b9, 0x000001b8,
+	0x000001bc, 0x000001bd, 0x000001bc,
+	0x000001c4, 0x000001c6, 0x000001c5,
+	0x000001c7, 0x000001c9, 0x000001c8,
+	0x000001ca, 0x000001cc, 0x000001cb,
+	0x000001cd, 0x000001ce, 0x000001cd,
+	0x000001cf, 0x000001d0, 0x000001cf,
+	0x000001d1, 0x000001d2, 0x000001d1,
+	0x000001d3, 0x000001d4, 0x000001d3,
+	0x000001d5, 0x000001d6, 0x000001d5,
+	0x000001d7, 0x000001d8, 0x000001d7,
+	0x000001d9, 0x000001da, 0x000001d9,
+	0x000001db, 0x000001dc, 0x000001db,
+	0x000001de, 0x000001df, 0x000001de,
+	0x000001e0, 0x000001e1, 0x000001e0,
+	0x000001e2, 0x000001e3, 0x000001e2,
+	0x000001e4, 0x000001e5, 0x000001e4,
+	0x000001e6, 0x000001e7, 0x000001e6,
+	0x000001e8, 0x000001e9, 0x000001e8,
+	0x000001ea, 0x000001eb, 0x000001ea,
+	0x000001ec, 0x000001ed, 0x000001ec,
+	0x000001ee, 0x000001ef, 0x000001ee,
+	0x000001f1, 0x000001f3, 0x000001f2,
+	0x000001f4, 0x000001f5, 0x000001f4,
+	0x000001f6, 0x00000195, 0x000001f6,
+	0x000001f7, 0x000001bf, 0x000001f7,
+	0x000001f8, 0x000001f9, 0x000001f8,
+	0x000001fa, 0x000001fb, 0x000001fa,
+	0x000001fc, 0x000001fd, 0x000001fc,
+	0x000001fe, 0x000001ff, 0x000001fe,
+	0x00000200, 0x00000201, 0x00000200,
+	0x00000202, 0x00000203, 0x00000202,
+	0x00000204, 0x00000205, 0x00000204,
+	0x00000206, 0x00000207, 0x00000206,
+	0x00000208, 0x00000209, 0x00000208,
+	0x0000020a, 0x0000020b, 0x0000020a,
+	0x0000020c, 0x0000020d, 0x0000020c,
+	0x0000020e, 0x0000020f, 0x0000020e,
+	0x00000210, 0x00000211, 0x00000210,
+	0x00000212, 0x00000213, 0x00000212,
+	0x00000214, 0x00000215, 0x00000214,
+	0x00000216, 0x00000217, 0x00000216,
+	0x00000218, 0x00000219, 0x00000218,
+	0x0000021a, 0x0000021b, 0x0000021a,
+	0x0000021c, 0x0000021d, 0x0000021c,
+	0x0000021e, 0x0000021f, 0x0000021e,
+	0x00000220, 0x0000019e, 0x00000220,
+	0x00000222, 0x00000223, 0x00000222,
+	0x00000224, 0x00000225, 0x00000224,
+	0x00000226, 0x00000227, 0x00000226,
+	0x00000228, 0x00000229, 0x00000228,
+	0x0000022a, 0x0000022b, 0x0000022a,
+	0x0000022c, 0x0000022d, 0x0000022c,
+	0x0000022e, 0x0000022f, 0x0000022e,
+	0x00000230, 0x00000231, 0x00000230,
+	0x00000232, 0x00000233, 0x00000232,
+	0x0000023a, 0x00002c65, 0x0000023a,
+	0x0000023b, 0x0000023c, 0x0000023b,
+	0x0000023d, 0x0000019a, 0x0000023d,
+	0x0000023e, 0x00002c66, 0x0000023e,
+	0x00000241, 0x00000242, 0x00000241,
+	0x00000243, 0x00000180, 0x00000243,
+	0x00000244, 0x00000289, 0x00000244,
+	0x00000245, 0x0000028c, 0x00000245,
+	0x00000246, 0x00000247, 0x00000246,
+	0x00000248, 0x00000249, 0x00000248,
+	0x0000024a, 0x0000024b, 0x0000024a,
+	0x0000024c, 0x0000024d, 0x0000024c,
+	0x0000024e, 0x0000024f, 0x0000024e,
+	0x00000370, 0x00000371, 0x00000370,
+	0x00000372, 0x00000373, 0x00000372,
+	0x00000376, 0x00000377, 0x00000376,
+	0x00000386, 0x000003ac, 0x00000386,
+	0x00000388, 0x000003ad, 0x00000388,
+	0x00000389, 0x000003ae, 0x00000389,
+	0x0000038a, 0x000003af, 0x0000038a,
+	0x0000038c, 0x000003cc, 0x0000038c,
+	0x0000038e, 0x000003cd, 0x0000038e,
+	0x0000038f, 0x000003ce, 0x0000038f,
+	0x00000391, 0x000003b1, 0x00000391,
+	0x00000392, 0x000003b2, 0x00000392,
+	0x00000393, 0x000003b3, 0x00000393,
+	0x00000394, 0x000003b4, 0x00000394,
+	0x00000395, 0x000003b5, 0x00000395,
+	0x00000396, 0x000003b6, 0x00000396,
+	0x00000397, 0x000003b7, 0x00000397,
+	0x00000398, 0x000003b8, 0x00000398,
+	0x00000399, 0x000003b9, 0x00000399,
+	0x0000039a, 0x000003ba, 0x0000039a,
+	0x0000039b, 0x000003bb, 0x0000039b,
+	0x0000039c, 0x000003bc, 0x0000039c,
+	0x0000039d, 0x000003bd, 0x0000039d,
+	0x0000039e, 0x000003be, 0x0000039e,
+	0x0000039f, 0x000003bf, 0x0000039f,
+	0x000003a0, 0x000003c0, 0x000003a0,
+	0x000003a1, 0x000003c1, 0x000003a1,
+	0x000003a3, 0x000003c3, 0x000003a3,
+	0x000003a4, 0x000003c4, 0x000003a4,
+	0x000003a5, 0x000003c5, 0x000003a5,
+	0x000003a6, 0x000003c6, 0x000003a6,
+	0x000003a7, 0x000003c7, 0x000003a7,
+	0x000003a8, 0x000003c8, 0x000003a8,
+	0x000003a9, 0x000003c9, 0x000003a9,
+	0x000003aa, 0x000003ca, 0x000003aa,
+	0x000003ab, 0x000003cb, 0x000003ab,
+	0x000003cf, 0x000003d7, 0x000003cf,
+	0x000003d8, 0x000003d9, 0x000003d8,
+	0x000003da, 0x000003db, 0x000003da,
+	0x000003dc, 0x000003dd, 0x000003dc,
+	0x000003de, 0x000003df, 0x000003de,
+	0x000003e0, 0x000003e1, 0x000003e0,
+	0x000003e2, 0x000003e3, 0x000003e2,
+	0x000003e4, 0x000003e5, 0x000003e4,
+	0x000003e6, 0x000003e7, 0x000003e6,
+	0x000003e8, 0x000003e9, 0x000003e8,
+	0x000003ea, 0x000003eb, 0x000003ea,
+	0x000003ec, 0x000003ed, 0x000003ec,
+	0x000003ee, 0x000003ef, 0x000003ee,
+	0x000003f4, 0x000003b8, 0x000003f4,
+	0x000003f7, 0x000003f8, 0x000003f7,
+	0x000003f9, 0x000003f2, 0x000003f9,
+	0x000003fa, 0x000003fb, 0x000003fa,
+	0x000003fd, 0x0000037b, 0x000003fd,
+	0x000003fe, 0x0000037c, 0x000003fe,
+	0x000003ff, 0x0000037d, 0x000003ff,
+	0x00000400, 0x00000450, 0x00000400,
+	0x00000401, 0x00000451, 0x00000401,
+	0x00000402, 0x00000452, 0x00000402,
+	0x00000403, 0x00000453, 0x00000403,
+	0x00000404, 0x00000454, 0x00000404,
+	0x00000405, 0x00000455, 0x00000405,
+	0x00000406, 0x00000456, 0x00000406,
+	0x00000407, 0x00000457, 0x00000407,
+	0x00000408, 0x00000458, 0x00000408,
+	0x00000409, 0x00000459, 0x00000409,
+	0x0000040a, 0x0000045a, 0x0000040a,
+	0x0000040b, 0x0000045b, 0x0000040b,
+	0x0000040c, 0x0000045c, 0x0000040c,
+	0x0000040d, 0x0000045d, 0x0000040d,
+	0x0000040e, 0x0000045e, 0x0000040e,
+	0x0000040f, 0x0000045f, 0x0000040f,
+	0x00000410, 0x00000430, 0x00000410,
+	0x00000411, 0x00000431, 0x00000411,
+	0x00000412, 0x00000432, 0x00000412,
+	0x00000413, 0x00000433, 0x00000413,
+	0x00000414, 0x00000434, 0x00000414,
+	0x00000415, 0x00000435, 0x00000415,
+	0x00000416, 0x00000436, 0x00000416,
+	0x00000417, 0x00000437, 0x00000417,
+	0x00000418, 0x00000438, 0x00000418,
+	0x00000419, 0x00000439, 0x00000419,
+	0x0000041a, 0x0000043a, 0x0000041a,
+	0x0000041b, 0x0000043b, 0x0000041b,
+	0x0000041c, 0x0000043c, 0x0000041c,
+	0x0000041d, 0x0000043d, 0x0000041d,
+	0x0000041e, 0x0000043e, 0x0000041e,
+	0x0000041f, 0x0000043f, 0x0000041f,
+	0x00000420, 0x00000440, 0x00000420,
+	0x00000421, 0x00000441, 0x00000421,
+	0x00000422, 0x00000442, 0x00000422,
+	0x00000423, 0x00000443, 0x00000423,
+	0x00000424, 0x00000444, 0x00000424,
+	0x00000425, 0x00000445, 0x00000425,
+	0x00000426, 0x00000446, 0x00000426,
+	0x00000427, 0x00000447, 0x00000427,
+	0x00000428, 0x00000448, 0x00000428,
+	0x00000429, 0x00000449, 0x00000429,
+	0x0000042a, 0x0000044a, 0x0000042a,
+	0x0000042b, 0x0000044b, 0x0000042b,
+	0x0000042c, 0x0000044c, 0x0000042c,
+	0x0000042d, 0x0000044d, 0x0000042d,
+	0x0000042e, 0x0000044e, 0x0000042e,
+	0x0000042f, 0x0000044f, 0x0000042f,
+	0x00000460, 0x00000461, 0x00000460,
+	0x00000462, 0x00000463, 0x00000462,
+	0x00000464, 0x00000465, 0x00000464,
+	0x00000466, 0x00000467, 0x00000466,
+	0x00000468, 0x00000469, 0x00000468,
+	0x0000046a, 0x0000046b, 0x0000046a,
+	0x0000046c, 0x0000046d, 0x0000046c,
+	0x0000046e, 0x0000046f, 0x0000046e,
+	0x00000470, 0x00000471, 0x00000470,
+	0x00000472, 0x00000473, 0x00000472,
+	0x00000474, 0x00000475, 0x00000474,
+	0x00000476, 0x00000477, 0x00000476,
+	0x00000478, 0x00000479, 0x00000478,
+	0x0000047a, 0x0000047b, 0x0000047a,
+	0x0000047c, 0x0000047d, 0x0000047c,
+	0x0000047e, 0x0000047f, 0x0000047e,
+	0x00000480, 0x00000481, 0x00000480,
+	0x0000048a, 0x0000048b, 0x0000048a,
+	0x0000048c, 0x0000048d, 0x0000048c,
+	0x0000048e, 0x0000048f, 0x0000048e,
+	0x00000490, 0x00000491, 0x00000490,
+	0x00000492, 0x00000493, 0x00000492,
+	0x00000494, 0x00000495, 0x00000494,
+	0x00000496, 0x00000497, 0x00000496,
+	0x00000498, 0x00000499, 0x00000498,
+	0x0000049a, 0x0000049b, 0x0000049a,
+	0x0000049c, 0x0000049d, 0x0000049c,
+	0x0000049e, 0x0000049f, 0x0000049e,
+	0x000004a0, 0x000004a1, 0x000004a0,
+	0x000004a2, 0x000004a3, 0x000004a2,
+	0x000004a4, 0x000004a5, 0x000004a4,
+	0x000004a6, 0x000004a7, 0x000004a6,
+	0x000004a8, 0x000004a9, 0x000004a8,
+	0x000004aa, 0x000004ab, 0x000004aa,
+	0x000004ac, 0x000004ad, 0x000004ac,
+	0x000004ae, 0x000004af, 0x000004ae,
+	0x000004b0, 0x000004b1, 0x000004b0,
+	0x000004b2, 0x000004b3, 0x000004b2,
+	0x000004b4, 0x000004b5, 0x000004b4,
+	0x000004b6, 0x000004b7, 0x000004b6,
+	0x000004b8, 0x000004b9, 0x000004b8,
+	0x000004ba, 0x000004bb, 0x000004ba,
+	0x000004bc, 0x000004bd, 0x000004bc,
+	0x000004be, 0x000004bf, 0x000004be,
+	0x000004c0, 0x000004cf, 0x000004c0,
+	0x000004c1, 0x000004c2, 0x000004c1,
+	0x000004c3, 0x000004c4, 0x000004c3,
+	0x000004c5, 0x000004c6, 0x000004c5,
+	0x000004c7, 0x000004c8, 0x000004c7,
+	0x000004c9, 0x000004ca, 0x000004c9,
+	0x000004cb, 0x000004cc, 0x000004cb,
+	0x000004cd, 0x000004ce, 0x000004cd,
+	0x000004d0, 0x000004d1, 0x000004d0,
+	0x000004d2, 0x000004d3, 0x000004d2,
+	0x000004d4, 0x000004d5, 0x000004d4,
+	0x000004d6, 0x000004d7, 0x000004d6,
+	0x000004d8, 0x000004d9, 0x000004d8,
+	0x000004da, 0x000004db, 0x000004da,
+	0x000004dc, 0x000004dd, 0x000004dc,
+	0x000004de, 0x000004df, 0x000004de,
+	0x000004e0, 0x000004e1, 0x000004e0,
+	0x000004e2, 0x000004e3, 0x000004e2,
+	0x000004e4, 0x000004e5, 0x000004e4,
+	0x000004e6, 0x000004e7, 0x000004e6,
+	0x000004e8, 0x000004e9, 0x000004e8,
+	0x000004ea, 0x000004eb, 0x000004ea,
+	0x000004ec, 0x000004ed, 0x000004ec,
+	0x000004ee, 0x000004ef, 0x000004ee,
+	0x000004f0, 0x000004f1, 0x000004f0,
+	0x000004f2, 0x000004f3, 0x000004f2,
+	0x000004f4, 0x000004f5, 0x000004f4,
+	0x000004f6, 0x000004f7, 0x000004f6,
+	0x000004f8, 0x000004f9, 0x000004f8,
+	0x000004fa, 0x000004fb, 0x000004fa,
+	0x000004fc, 0x000004fd, 0x000004fc,
+	0x000004fe, 0x000004ff, 0x000004fe,
+	0x00000500, 0x00000501, 0x00000500,
+	0x00000502, 0x00000503, 0x00000502,
+	0x00000504, 0x00000505, 0x00000504,
+	0x00000506, 0x00000507, 0x00000506,
+	0x00000508, 0x00000509, 0x00000508,
+	0x0000050a, 0x0000050b, 0x0000050a,
+	0x0000050c, 0x0000050d, 0x0000050c,
+	0x0000050e, 0x0000050f, 0x0000050e,
+	0x00000510, 0x00000511, 0x00000510,
+	0x00000512, 0x00000513, 0x00000512,
+	0x00000514, 0x00000515, 0x00000514,
+	0x00000516, 0x00000517, 0x00000516,
+	0x00000518, 0x00000519, 0x00000518,
+	0x0000051a, 0x0000051b, 0x0000051a,
+	0x0000051c, 0x0000051d, 0x0000051c,
+	0x0000051e, 0x0000051f, 0x0000051e,
+	0x00000520, 0x00000521, 0x00000520,
+	0x00000522, 0x00000523, 0x00000522,
+	0x00000524, 0x00000525, 0x00000524,
+	0x00000526, 0x00000527, 0x00000526,
+	0x00000531, 0x00000561, 0x00000531,
+	0x00000532, 0x00000562, 0x00000532,
+	0x00000533, 0x00000563, 0x00000533,
+	0x00000534, 0x00000564, 0x00000534,
+	0x00000535, 0x00000565, 0x00000535,
+	0x00000536, 0x00000566, 0x00000536,
+	0x00000537, 0x00000567, 0x00000537,
+	0x00000538, 0x00000568, 0x00000538,
+	0x00000539, 0x00000569, 0x00000539,
+	0x0000053a, 0x0000056a, 0x0000053a,
+	0x0000053b, 0x0000056b, 0x0000053b,
+	0x0000053c, 0x0000056c, 0x0000053c,
+	0x0000053d, 0x0000056d, 0x0000053d,
+	0x0000053e, 0x0000056e, 0x0000053e,
+	0x0000053f, 0x0000056f, 0x0000053f,
+	0x00000540, 0x00000570, 0x00000540,
+	0x00000541, 0x00000571, 0x00000541,
+	0x00000542, 0x00000572, 0x00000542,
+	0x00000543, 0x00000573, 0x00000543,
+	0x00000544, 0x00000574, 0x00000544,
+	0x00000545, 0x00000575, 0x00000545,
+	0x00000546, 0x00000576, 0x00000546,
+	0x00000547, 0x00000577, 0x00000547,
+	0x00000548, 0x00000578, 0x00000548,
+	0x00000549, 0x00000579, 0x00000549,
+	0x0000054a, 0x0000057a, 0x0000054a,
+	0x0000054b, 0x0000057b, 0x0000054b,
+	0x0000054c, 0x0000057c, 0x0000054c,
+	0x0000054d, 0x0000057d, 0x0000054d,
+	0x0000054e, 0x0000057e, 0x0000054e,
+	0x0000054f, 0x0000057f, 0x0000054f,
+	0x00000550, 0x00000580, 0x00000550,
+	0x00000551, 0x00000581, 0x00000551,
+	0x00000552, 0x00000582, 0x00000552,
+	0x00000553, 0x00000583, 0x00000553,
+	0x00000554, 0x00000584, 0x00000554,
+	0x00000555, 0x00000585, 0x00000555,
+	0x00000556, 0x00000586, 0x00000556,
+	0x000010a0, 0x00002d00, 0x000010a0,
+	0x000010a1, 0x00002d01, 0x000010a1,
+	0x000010a2, 0x00002d02, 0x000010a2,
+	0x000010a3, 0x00002d03, 0x000010a3,
+	0x000010a4, 0x00002d04, 0x000010a4,
+	0x000010a5, 0x00002d05, 0x000010a5,
+	0x000010a6, 0x00002d06, 0x000010a6,
+	0x000010a7, 0x00002d07, 0x000010a7,
+	0x000010a8, 0x00002d08, 0x000010a8,
+	0x000010a9, 0x00002d09, 0x000010a9,
+	0x000010aa, 0x00002d0a, 0x000010aa,
+	0x000010ab, 0x00002d0b, 0x000010ab,
+	0x000010ac, 0x00002d0c, 0x000010ac,
+	0x000010ad, 0x00002d0d, 0x000010ad,
+	0x000010ae, 0x00002d0e, 0x000010ae,
+	0x000010af, 0x00002d0f, 0x000010af,
+	0x000010b0, 0x00002d10, 0x000010b0,
+	0x000010b1, 0x00002d11, 0x000010b1,
+	0x000010b2, 0x00002d12, 0x000010b2,
+	0x000010b3, 0x00002d13, 0x000010b3,
+	0x000010b4, 0x00002d14, 0x000010b4,
+	0x000010b5, 0x00002d15, 0x000010b5,
+	0x000010b6, 0x00002d16, 0x000010b6,
+	0x000010b7, 0x00002d17, 0x000010b7,
+	0x000010b8, 0x00002d18, 0x000010b8,
+	0x000010b9, 0x00002d19, 0x000010b9,
+	0x000010ba, 0x00002d1a, 0x000010ba,
+	0x000010bb, 0x00002d1b, 0x000010bb,
+	0x000010bc, 0x00002d1c, 0x000010bc,
+	0x000010bd, 0x00002d1d, 0x000010bd,
+	0x000010be, 0x00002d1e, 0x000010be,
+	0x000010bf, 0x00002d1f, 0x000010bf,
+	0x000010c0, 0x00002d20, 0x000010c0,
+	0x000010c1, 0x00002d21, 0x000010c1,
+	0x000010c2, 0x00002d22, 0x000010c2,
+	0x000010c3, 0x00002d23, 0x000010c3,
+	0x000010c4, 0x00002d24, 0x000010c4,
+	0x000010c5, 0x00002d25, 0x000010c5,
+	0x00001e00, 0x00001e01, 0x00001e00,
+	0x00001e02, 0x00001e03, 0x00001e02,
+	0x00001e04, 0x00001e05, 0x00001e04,
+	0x00001e06, 0x00001e07, 0x00001e06,
+	0x00001e08, 0x00001e09, 0x00001e08,
+	0x00001e0a, 0x00001e0b, 0x00001e0a,
+	0x00001e0c, 0x00001e0d, 0x00001e0c,
+	0x00001e0e, 0x00001e0f, 0x00001e0e,
+	0x00001e10, 0x00001e11, 0x00001e10,
+	0x00001e12, 0x00001e13, 0x00001e12,
+	0x00001e14, 0x00001e15, 0x00001e14,
+	0x00001e16, 0x00001e17, 0x00001e16,
+	0x00001e18, 0x00001e19, 0x00001e18,
+	0x00001e1a, 0x00001e1b, 0x00001e1a,
+	0x00001e1c, 0x00001e1d, 0x00001e1c,
+	0x00001e1e, 0x00001e1f, 0x00001e1e,
+	0x00001e20, 0x00001e21, 0x00001e20,
+	0x00001e22, 0x00001e23, 0x00001e22,
+	0x00001e24, 0x00001e25, 0x00001e24,
+	0x00001e26, 0x00001e27, 0x00001e26,
+	0x00001e28, 0x00001e29, 0x00001e28,
+	0x00001e2a, 0x00001e2b, 0x00001e2a,
+	0x00001e2c, 0x00001e2d, 0x00001e2c,
+	0x00001e2e, 0x00001e2f, 0x00001e2e,
+	0x00001e30, 0x00001e31, 0x00001e30,
+	0x00001e32, 0x00001e33, 0x00001e32,
+	0x00001e34, 0x00001e35, 0x00001e34,
+	0x00001e36, 0x00001e37, 0x00001e36,
+	0x00001e38, 0x00001e39, 0x00001e38,
+	0x00001e3a, 0x00001e3b, 0x00001e3a,
+	0x00001e3c, 0x00001e3d, 0x00001e3c,
+	0x00001e3e, 0x00001e3f, 0x00001e3e,
+	0x00001e40, 0x00001e41, 0x00001e40,
+	0x00001e42, 0x00001e43, 0x00001e42,
+	0x00001e44, 0x00001e45, 0x00001e44,
+	0x00001e46, 0x00001e47, 0x00001e46,
+	0x00001e48, 0x00001e49, 0x00001e48,
+	0x00001e4a, 0x00001e4b, 0x00001e4a,
+	0x00001e4c, 0x00001e4d, 0x00001e4c,
+	0x00001e4e, 0x00001e4f, 0x00001e4e,
+	0x00001e50, 0x00001e51, 0x00001e50,
+	0x00001e52, 0x00001e53, 0x00001e52,
+	0x00001e54, 0x00001e55, 0x00001e54,
+	0x00001e56, 0x00001e57, 0x00001e56,
+	0x00001e58, 0x00001e59, 0x00001e58,
+	0x00001e5a, 0x00001e5b, 0x00001e5a,
+	0x00001e5c, 0x00001e5d, 0x00001e5c,
+	0x00001e5e, 0x00001e5f, 0x00001e5e,
+	0x00001e60, 0x00001e61, 0x00001e60,
+	0x00001e62, 0x00001e63, 0x00001e62,
+	0x00001e64, 0x00001e65, 0x00001e64,
+	0x00001e66, 0x00001e67, 0x00001e66,
+	0x00001e68, 0x00001e69, 0x00001e68,
+	0x00001e6a, 0x00001e6b, 0x00001e6a,
+	0x00001e6c, 0x00001e6d, 0x00001e6c,
+	0x00001e6e, 0x00001e6f, 0x00001e6e,
+	0x00001e70, 0x00001e71, 0x00001e70,
+	0x00001e72, 0x00001e73, 0x00001e72,
+	0x00001e74, 0x00001e75, 0x00001e74,
+	0x00001e76, 0x00001e77, 0x00001e76,
+	0x00001e78, 0x00001e79, 0x00001e78,
+	0x00001e7a, 0x00001e7b, 0x00001e7a,
+	0x00001e7c, 0x00001e7d, 0x00001e7c,
+	0x00001e7e, 0x00001e7f, 0x00001e7e,
+	0x00001e80, 0x00001e81, 0x00001e80,
+	0x00001e82, 0x00001e83, 0x00001e82,
+	0x00001e84, 0x00001e85, 0x00001e84,
+	0x00001e86, 0x00001e87, 0x00001e86,
+	0x00001e88, 0x00001e89, 0x00001e88,
+	0x00001e8a, 0x00001e8b, 0x00001e8a,
+	0x00001e8c, 0x00001e8d, 0x00001e8c,
+	0x00001e8e, 0x00001e8f, 0x00001e8e,
+	0x00001e90, 0x00001e91, 0x00001e90,
+	0x00001e92, 0x00001e93, 0x00001e92,
+	0x00001e94, 0x00001e95, 0x00001e94,
+	0x00001e9e, 0x000000df, 0x00001e9e,
+	0x00001ea0, 0x00001ea1, 0x00001ea0,
+	0x00001ea2, 0x00001ea3, 0x00001ea2,
+	0x00001ea4, 0x00001ea5, 0x00001ea4,
+	0x00001ea6, 0x00001ea7, 0x00001ea6,
+	0x00001ea8, 0x00001ea9, 0x00001ea8,
+	0x00001eaa, 0x00001eab, 0x00001eaa,
+	0x00001eac, 0x00001ead, 0x00001eac,
+	0x00001eae, 0x00001eaf, 0x00001eae,
+	0x00001eb0, 0x00001eb1, 0x00001eb0,
+	0x00001eb2, 0x00001eb3, 0x00001eb2,
+	0x00001eb4, 0x00001eb5, 0x00001eb4,
+	0x00001eb6, 0x00001eb7, 0x00001eb6,
+	0x00001eb8, 0x00001eb9, 0x00001eb8,
+	0x00001eba, 0x00001ebb, 0x00001eba,
+	0x00001ebc, 0x00001ebd, 0x00001ebc,
+	0x00001ebe, 0x00001ebf, 0x00001ebe,
+	0x00001ec0, 0x00001ec1, 0x00001ec0,
+	0x00001ec2, 0x00001ec3, 0x00001ec2,
+	0x00001ec4, 0x00001ec5, 0x00001ec4,
+	0x00001ec6, 0x00001ec7, 0x00001ec6,
+	0x00001ec8, 0x00001ec9, 0x00001ec8,
+	0x00001eca, 0x00001ecb, 0x00001eca,
+	0x00001ecc, 0x00001ecd, 0x00001ecc,
+	0x00001ece, 0x00001ecf, 0x00001ece,
+	0x00001ed0, 0x00001ed1, 0x00001ed0,
+	0x00001ed2, 0x00001ed3, 0x00001ed2,
+	0x00001ed4, 0x00001ed5, 0x00001ed4,
+	0x00001ed6, 0x00001ed7, 0x00001ed6,
+	0x00001ed8, 0x00001ed9, 0x00001ed8,
+	0x00001eda, 0x00001edb, 0x00001eda,
+	0x00001edc, 0x00001edd, 0x00001edc,
+	0x00001ede, 0x00001edf, 0x00001ede,
+	0x00001ee0, 0x00001ee1, 0x00001ee0,
+	0x00001ee2, 0x00001ee3, 0x00001ee2,
+	0x00001ee4, 0x00001ee5, 0x00001ee4,
+	0x00001ee6, 0x00001ee7, 0x00001ee6,
+	0x00001ee8, 0x00001ee9, 0x00001ee8,
+	0x00001eea, 0x00001eeb, 0x00001eea,
+	0x00001eec, 0x00001eed, 0x00001eec,
+	0x00001eee, 0x00001eef, 0x00001eee,
+	0x00001ef0, 0x00001ef1, 0x00001ef0,
+	0x00001ef2, 0x00001ef3, 0x00001ef2,
+	0x00001ef4, 0x00001ef5, 0x00001ef4,
+	0x00001ef6, 0x00001ef7, 0x00001ef6,
+	0x00001ef8, 0x00001ef9, 0x00001ef8,
+	0x00001efa, 0x00001efb, 0x00001efa,
+	0x00001efc, 0x00001efd, 0x00001efc,
+	0x00001efe, 0x00001eff, 0x00001efe,
+	0x00001f08, 0x00001f00, 0x00001f08,
+	0x00001f09, 0x00001f01, 0x00001f09,
+	0x00001f0a, 0x00001f02, 0x00001f0a,
+	0x00001f0b, 0x00001f03, 0x00001f0b,
+	0x00001f0c, 0x00001f04, 0x00001f0c,
+	0x00001f0d, 0x00001f05, 0x00001f0d,
+	0x00001f0e, 0x00001f06, 0x00001f0e,
+	0x00001f0f, 0x00001f07, 0x00001f0f,
+	0x00001f18, 0x00001f10, 0x00001f18,
+	0x00001f19, 0x00001f11, 0x00001f19,
+	0x00001f1a, 0x00001f12, 0x00001f1a,
+	0x00001f1b, 0x00001f13, 0x00001f1b,
+	0x00001f1c, 0x00001f14, 0x00001f1c,
+	0x00001f1d, 0x00001f15, 0x00001f1d,
+	0x00001f28, 0x00001f20, 0x00001f28,
+	0x00001f29, 0x00001f21, 0x00001f29,
+	0x00001f2a, 0x00001f22, 0x00001f2a,
+	0x00001f2b, 0x00001f23, 0x00001f2b,
+	0x00001f2c, 0x00001f24, 0x00001f2c,
+	0x00001f2d, 0x00001f25, 0x00001f2d,
+	0x00001f2e, 0x00001f26, 0x00001f2e,
+	0x00001f2f, 0x00001f27, 0x00001f2f,
+	0x00001f38, 0x00001f30, 0x00001f38,
+	0x00001f39, 0x00001f31, 0x00001f39,
+	0x00001f3a, 0x00001f32, 0x00001f3a,
+	0x00001f3b, 0x00001f33, 0x00001f3b,
+	0x00001f3c, 0x00001f34, 0x00001f3c,
+	0x00001f3d, 0x00001f35, 0x00001f3d,
+	0x00001f3e, 0x00001f36, 0x00001f3e,
+	0x00001f3f, 0x00001f37, 0x00001f3f,
+	0x00001f48, 0x00001f40, 0x00001f48,
+	0x00001f49, 0x00001f41, 0x00001f49,
+	0x00001f4a, 0x00001f42, 0x00001f4a,
+	0x00001f4b, 0x00001f43, 0x00001f4b,
+	0x00001f4c, 0x00001f44, 0x00001f4c,
+	0x00001f4d, 0x00001f45, 0x00001f4d,
+	0x00001f59, 0x00001f51, 0x00001f59,
+	0x00001f5b, 0x00001f53, 0x00001f5b,
+	0x00001f5d, 0x00001f55, 0x00001f5d,
+	0x00001f5f, 0x00001f57, 0x00001f5f,
+	0x00001f68, 0x00001f60, 0x00001f68,
+	0x00001f69, 0x00001f61, 0x00001f69,
+	0x00001f6a, 0x00001f62, 0x00001f6a,
+	0x00001f6b, 0x00001f63, 0x00001f6b,
+	0x00001f6c, 0x00001f64, 0x00001f6c,
+	0x00001f6d, 0x00001f65, 0x00001f6d,
+	0x00001f6e, 0x00001f66, 0x00001f6e,
+	0x00001f6f, 0x00001f67, 0x00001f6f,
+	0x00001f88, 0x00001f80, 0x00001f88,
+	0x00001f89, 0x00001f81, 0x00001f89,
+	0x00001f8a, 0x00001f82, 0x00001f8a,
+	0x00001f8b, 0x00001f83, 0x00001f8b,
+	0x00001f8c, 0x00001f84, 0x00001f8c,
+	0x00001f8d, 0x00001f85, 0x00001f8d,
+	0x00001f8e, 0x00001f86, 0x00001f8e,
+	0x00001f8f, 0x00001f87, 0x00001f8f,
+	0x00001f98, 0x00001f90, 0x00001f98,
+	0x00001f99, 0x00001f91, 0x00001f99,
+	0x00001f9a, 0x00001f92, 0x00001f9a,
+	0x00001f9b, 0x00001f93, 0x00001f9b,
+	0x00001f9c, 0x00001f94, 0x00001f9c,
+	0x00001f9d, 0x00001f95, 0x00001f9d,
+	0x00001f9e, 0x00001f96, 0x00001f9e,
+	0x00001f9f, 0x00001f97, 0x00001f9f,
+	0x00001fa8, 0x00001fa0, 0x00001fa8,
+	0x00001fa9, 0x00001fa1, 0x00001fa9,
+	0x00001faa, 0x00001fa2, 0x00001faa,
+	0x00001fab, 0x00001fa3, 0x00001fab,
+	0x00001fac, 0x00001fa4, 0x00001fac,
+	0x00001fad, 0x00001fa5, 0x00001fad,
+	0x00001fae, 0x00001fa6, 0x00001fae,
+	0x00001faf, 0x00001fa7, 0x00001faf,
+	0x00001fb8, 0x00001fb0, 0x00001fb8,
+	0x00001fb9, 0x00001fb1, 0x00001fb9,
+	0x00001fba, 0x00001f70, 0x00001fba,
+	0x00001fbb, 0x00001f71, 0x00001fbb,
+	0x00001fbc, 0x00001fb3, 0x00001fbc,
+	0x00001fc8, 0x00001f72, 0x00001fc8,
+	0x00001fc9, 0x00001f73, 0x00001fc9,
+	0x00001fca, 0x00001f74, 0x00001fca,
+	0x00001fcb, 0x00001f75, 0x00001fcb,
+	0x00001fcc, 0x00001fc3, 0x00001fcc,
+	0x00001fd8, 0x00001fd0, 0x00001fd8,
+	0x00001fd9, 0x00001fd1, 0x00001fd9,
+	0x00001fda, 0x00001f76, 0x00001fda,
+	0x00001fdb, 0x00001f77, 0x00001fdb,
+	0x00001fe8, 0x00001fe0, 0x00001fe8,
+	0x00001fe9, 0x00001fe1, 0x00001fe9,
+	0x00001fea, 0x00001f7a, 0x00001fea,
+	0x00001feb, 0x00001f7b, 0x00001feb,
+	0x00001fec, 0x00001fe5, 0x00001fec,
+	0x00001ff8, 0x00001f78, 0x00001ff8,
+	0x00001ff9, 0x00001f79, 0x00001ff9,
+	0x00001ffa, 0x00001f7c, 0x00001ffa,
+	0x00001ffb, 0x00001f7d, 0x00001ffb,
+	0x00001ffc, 0x00001ff3, 0x00001ffc,
+	0x00002126, 0x000003c9, 0x00002126,
+	0x0000212a, 0x0000006b, 0x0000212a,
+	0x0000212b, 0x000000e5, 0x0000212b,
+	0x00002132, 0x0000214e, 0x00002132,
+	0x00002160, 0x00002170, 0x00002160,
+	0x00002161, 0x00002171, 0x00002161,
+	0x00002162, 0x00002172, 0x00002162,
+	0x00002163, 0x00002173, 0x00002163,
+	0x00002164, 0x00002174, 0x00002164,
+	0x00002165, 0x00002175, 0x00002165,
+	0x00002166, 0x00002176, 0x00002166,
+	0x00002167, 0x00002177, 0x00002167,
+	0x00002168, 0x00002178, 0x00002168,
+	0x00002169, 0x00002179, 0x00002169,
+	0x0000216a, 0x0000217a, 0x0000216a,
+	0x0000216b, 0x0000217b, 0x0000216b,
+	0x0000216c, 0x0000217c, 0x0000216c,
+	0x0000216d, 0x0000217d, 0x0000216d,
+	0x0000216e, 0x0000217e, 0x0000216e,
+	0x0000216f, 0x0000217f, 0x0000216f,
+	0x00002183, 0x00002184, 0x00002183,
+	0x000024b6, 0x000024d0, 0x000024b6,
+	0x000024b7, 0x000024d1, 0x000024b7,
+	0x000024b8, 0x000024d2, 0x000024b8,
+	0x000024b9, 0x000024d3, 0x000024b9,
+	0x000024ba, 0x000024d4, 0x000024ba,
+	0x000024bb, 0x000024d5, 0x000024bb,
+	0x000024bc, 0x000024d6, 0x000024bc,
+	0x000024bd, 0x000024d7, 0x000024bd,
+	0x000024be, 0x000024d8, 0x000024be,
+	0x000024bf, 0x000024d9, 0x000024bf,
+	0x000024c0, 0x000024da, 0x000024c0,
+	0x000024c1, 0x000024db, 0x000024c1,
+	0x000024c2, 0x000024dc, 0x000024c2,
+	0x000024c3, 0x000024dd, 0x000024c3,
+	0x000024c4, 0x000024de, 0x000024c4,
+	0x000024c5, 0x000024df, 0x000024c5,
+	0x000024c6, 0x000024e0, 0x000024c6,
+	0x000024c7, 0x000024e1, 0x000024c7,
+	0x000024c8, 0x000024e2, 0x000024c8,
+	0x000024c9, 0x000024e3, 0x000024c9,
+	0x000024ca, 0x000024e4, 0x000024ca,
+	0x000024cb, 0x000024e5, 0x000024cb,
+	0x000024cc, 0x000024e6, 0x000024cc,
+	0x000024cd, 0x000024e7, 0x000024cd,
+	0x000024ce, 0x000024e8, 0x000024ce,
+	0x000024cf, 0x000024e9, 0x000024cf,
+	0x00002c00, 0x00002c30, 0x00002c00,
+	0x00002c01, 0x00002c31, 0x00002c01,
+	0x00002c02, 0x00002c32, 0x00002c02,
+	0x00002c03, 0x00002c33, 0x00002c03,
+	0x00002c04, 0x00002c34, 0x00002c04,
+	0x00002c05, 0x00002c35, 0x00002c05,
+	0x00002c06, 0x00002c36, 0x00002c06,
+	0x00002c07, 0x00002c37, 0x00002c07,
+	0x00002c08, 0x00002c38, 0x00002c08,
+	0x00002c09, 0x00002c39, 0x00002c09,
+	0x00002c0a, 0x00002c3a, 0x00002c0a,
+	0x00002c0b, 0x00002c3b, 0x00002c0b,
+	0x00002c0c, 0x00002c3c, 0x00002c0c,
+	0x00002c0d, 0x00002c3d, 0x00002c0d,
+	0x00002c0e, 0x00002c3e, 0x00002c0e,
+	0x00002c0f, 0x00002c3f, 0x00002c0f,
+	0x00002c10, 0x00002c40, 0x00002c10,
+	0x00002c11, 0x00002c41, 0x00002c11,
+	0x00002c12, 0x00002c42, 0x00002c12,
+	0x00002c13, 0x00002c43, 0x00002c13,
+	0x00002c14, 0x00002c44, 0x00002c14,
+	0x00002c15, 0x00002c45, 0x00002c15,
+	0x00002c16, 0x00002c46, 0x00002c16,
+	0x00002c17, 0x00002c47, 0x00002c17,
+	0x00002c18, 0x00002c48, 0x00002c18,
+	0x00002c19, 0x00002c49, 0x00002c19,
+	0x00002c1a, 0x00002c4a, 0x00002c1a,
+	0x00002c1b, 0x00002c4b, 0x00002c1b,
+	0x00002c1c, 0x00002c4c, 0x00002c1c,
+	0x00002c1d, 0x00002c4d, 0x00002c1d,
+	0x00002c1e, 0x00002c4e, 0x00002c1e,
+	0x00002c1f, 0x00002c4f, 0x00002c1f,
+	0x00002c20, 0x00002c50, 0x00002c20,
+	0x00002c21, 0x00002c51, 0x00002c21,
+	0x00002c22, 0x00002c52, 0x00002c22,
+	0x00002c23, 0x00002c53, 0x00002c23,
+	0x00002c24, 0x00002c54, 0x00002c24,
+	0x00002c25, 0x00002c55, 0x00002c25,
+	0x00002c26, 0x00002c56, 0x00002c26,
+	0x00002c27, 0x00002c57, 0x00002c27,
+	0x00002c28, 0x00002c58, 0x00002c28,
+	0x00002c29, 0x00002c59, 0x00002c29,
+	0x00002c2a, 0x00002c5a, 0x00002c2a,
+	0x00002c2b, 0x00002c5b, 0x00002c2b,
+	0x00002c2c, 0x00002c5c, 0x00002c2c,
+	0x00002c2d, 0x00002c5d, 0x00002c2d,
+	0x00002c2e, 0x00002c5e, 0x00002c2e,
+	0x00002c60, 0x00002c61, 0x00002c60,
+	0x00002c62, 0x0000026b, 0x00002c62,
+	0x00002c63, 0x00001d7d, 0x00002c63,
+	0x00002c64, 0x0000027d, 0x00002c64,
+	0x00002c67, 0x00002c68, 0x00002c67,
+	0x00002c69, 0x00002c6a, 0x00002c69,
+	0x00002c6b, 0x00002c6c, 0x00002c6b,
+	0x00002c6d, 0x00000251, 0x00002c6d,
+	0x00002c6e, 0x00000271, 0x00002c6e,
+	0x00002c6f, 0x00000250, 0x00002c6f,
+	0x00002c70, 0x00000252, 0x00002c70,
+	0x00002c72, 0x00002c73, 0x00002c72,
+	0x00002c75, 0x00002c76, 0x00002c75,
+	0x00002c7e, 0x0000023f, 0x00002c7e,
+	0x00002c7f, 0x00000240, 0x00002c7f,
+	0x00002c80, 0x00002c81, 0x00002c80,
+	0x00002c82, 0x00002c83, 0x00002c82,
+	0x00002c84, 0x00002c85, 0x00002c84,
+	0x00002c86, 0x00002c87, 0x00002c86,
+	0x00002c88, 0x00002c89, 0x00002c88,
+	0x00002c8a, 0x00002c8b, 0x00002c8a,
+	0x00002c8c, 0x00002c8d, 0x00002c8c,
+	0x00002c8e, 0x00002c8f, 0x00002c8e,
+	0x00002c90, 0x00002c91, 0x00002c90,
+	0x00002c92, 0x00002c93, 0x00002c92,
+	0x00002c94, 0x00002c95, 0x00002c94,
+	0x00002c96, 0x00002c97, 0x00002c96,
+	0x00002c98, 0x00002c99, 0x00002c98,
+	0x00002c9a, 0x00002c9b, 0x00002c9a,
+	0x00002c9c, 0x00002c9d, 0x00002c9c,
+	0x00002c9e, 0x00002c9f, 0x00002c9e,
+	0x00002ca0, 0x00002ca1, 0x00002ca0,
+	0x00002ca2, 0x00002ca3, 0x00002ca2,
+	0x00002ca4, 0x00002ca5, 0x00002ca4,
+	0x00002ca6, 0x00002ca7, 0x00002ca6,
+	0x00002ca8, 0x00002ca9, 0x00002ca8,
+	0x00002caa, 0x00002cab, 0x00002caa,
+	0x00002cac, 0x00002cad, 0x00002cac,
+	0x00002cae, 0x00002caf, 0x00002cae,
+	0x00002cb0, 0x00002cb1, 0x00002cb0,
+	0x00002cb2, 0x00002cb3, 0x00002cb2,
+	0x00002cb4, 0x00002cb5, 0x00002cb4,
+	0x00002cb6, 0x00002cb7, 0x00002cb6,
+	0x00002cb8, 0x00002cb9, 0x00002cb8,
+	0x00002cba, 0x00002cbb, 0x00002cba,
+	0x00002cbc, 0x00002cbd, 0x00002cbc,
+	0x00002cbe, 0x00002cbf, 0x00002cbe,
+	0x00002cc0, 0x00002cc1, 0x00002cc0,
+	0x00002cc2, 0x00002cc3, 0x00002cc2,
+	0x00002cc4, 0x00002cc5, 0x00002cc4,
+	0x00002cc6, 0x00002cc7, 0x00002cc6,
+	0x00002cc8, 0x00002cc9, 0x00002cc8,
+	0x00002cca, 0x00002ccb, 0x00002cca,
+	0x00002ccc, 0x00002ccd, 0x00002ccc,
+	0x00002cce, 0x00002ccf, 0x00002cce,
+	0x00002cd0, 0x00002cd1, 0x00002cd0,
+	0x00002cd2, 0x00002cd3, 0x00002cd2,
+	0x00002cd4, 0x00002cd5, 0x00002cd4,
+	0x00002cd6, 0x00002cd7, 0x00002cd6,
+	0x00002cd8, 0x00002cd9, 0x00002cd8,
+	0x00002cda, 0x00002cdb, 0x00002cda,
+	0x00002cdc, 0x00002cdd, 0x00002cdc,
+	0x00002cde, 0x00002cdf, 0x00002cde,
+	0x00002ce0, 0x00002ce1, 0x00002ce0,
+	0x00002ce2, 0x00002ce3, 0x00002ce2,
+	0x00002ceb, 0x00002cec, 0x00002ceb,
+	0x00002ced, 0x00002cee, 0x00002ced,
+	0x0000a640, 0x0000a641, 0x0000a640,
+	0x0000a642, 0x0000a643, 0x0000a642,
+	0x0000a644, 0x0000a645, 0x0000a644,
+	0x0000a646, 0x0000a647, 0x0000a646,
+	0x0000a648, 0x0000a649, 0x0000a648,
+	0x0000a64a, 0x0000a64b, 0x0000a64a,
+	0x0000a64c, 0x0000a64d, 0x0000a64c,
+	0x0000a64e, 0x0000a64f, 0x0000a64e,
+	0x0000a650, 0x0000a651, 0x0000a650,
+	0x0000a652, 0x0000a653, 0x0000a652,
+	0x0000a654, 0x0000a655, 0x0000a654,
+	0x0000a656, 0x0000a657, 0x0000a656,
+	0x0000a658, 0x0000a659, 0x0000a658,
+	0x0000a65a, 0x0000a65b, 0x0000a65a,
+	0x0000a65c, 0x0000a65d, 0x0000a65c,
+	0x0000a65e, 0x0000a65f, 0x0000a65e,
+	0x0000a660, 0x0000a661, 0x0000a660,
+	0x0000a662, 0x0000a663, 0x0000a662,
+	0x0000a664, 0x0000a665, 0x0000a664,
+	0x0000a666, 0x0000a667, 0x0000a666,
+	0x0000a668, 0x0000a669, 0x0000a668,
+	0x0000a66a, 0x0000a66b, 0x0000a66a,
+	0x0000a66c, 0x0000a66d, 0x0000a66c,
+	0x0000a680, 0x0000a681, 0x0000a680,
+	0x0000a682, 0x0000a683, 0x0000a682,
+	0x0000a684, 0x0000a685, 0x0000a684,
+	0x0000a686, 0x0000a687, 0x0000a686,
+	0x0000a688, 0x0000a689, 0x0000a688,
+	0x0000a68a, 0x0000a68b, 0x0000a68a,
+	0x0000a68c, 0x0000a68d, 0x0000a68c,
+	0x0000a68e, 0x0000a68f, 0x0000a68e,
+	0x0000a690, 0x0000a691, 0x0000a690,
+	0x0000a692, 0x0000a693, 0x0000a692,
+	0x0000a694, 0x0000a695, 0x0000a694,
+	0x0000a696, 0x0000a697, 0x0000a696,
+	0x0000a722, 0x0000a723, 0x0000a722,
+	0x0000a724, 0x0000a725, 0x0000a724,
+	0x0000a726, 0x0000a727, 0x0000a726,
+	0x0000a728, 0x0000a729, 0x0000a728,
+	0x0000a72a, 0x0000a72b, 0x0000a72a,
+	0x0000a72c, 0x0000a72d, 0x0000a72c,
+	0x0000a72e, 0x0000a72f, 0x0000a72e,
+	0x0000a732, 0x0000a733, 0x0000a732,
+	0x0000a734, 0x0000a735, 0x0000a734,
+	0x0000a736, 0x0000a737, 0x0000a736,
+	0x0000a738, 0x0000a739, 0x0000a738,
+	0x0000a73a, 0x0000a73b, 0x0000a73a,
+	0x0000a73c, 0x0000a73d, 0x0000a73c,
+	0x0000a73e, 0x0000a73f, 0x0000a73e,
+	0x0000a740, 0x0000a741, 0x0000a740,
+	0x0000a742, 0x0000a743, 0x0000a742,
+	0x0000a744, 0x0000a745, 0x0000a744,
+	0x0000a746, 0x0000a747, 0x0000a746,
+	0x0000a748, 0x0000a749, 0x0000a748,
+	0x0000a74a, 0x0000a74b, 0x0000a74a,
+	0x0000a74c, 0x0000a74d, 0x0000a74c,
+	0x0000a74e, 0x0000a74f, 0x0000a74e,
+	0x0000a750, 0x0000a751, 0x0000a750,
+	0x0000a752, 0x0000a753, 0x0000a752,
+	0x0000a754, 0x0000a755, 0x0000a754,
+	0x0000a756, 0x0000a757, 0x0000a756,
+	0x0000a758, 0x0000a759, 0x0000a758,
+	0x0000a75a, 0x0000a75b, 0x0000a75a,
+	0x0000a75c, 0x0000a75d, 0x0000a75c,
+	0x0000a75e, 0x0000a75f, 0x0000a75e,
+	0x0000a760, 0x0000a761, 0x0000a760,
+	0x0000a762, 0x0000a763, 0x0000a762,
+	0x0000a764, 0x0000a765, 0x0000a764,
+	0x0000a766, 0x0000a767, 0x0000a766,
+	0x0000a768, 0x0000a769, 0x0000a768,
+	0x0000a76a, 0x0000a76b, 0x0000a76a,
+	0x0000a76c, 0x0000a76d, 0x0000a76c,
+	0x0000a76e, 0x0000a76f, 0x0000a76e,
+	0x0000a779, 0x0000a77a, 0x0000a779,
+	0x0000a77b, 0x0000a77c, 0x0000a77b,
+	0x0000a77d, 0x00001d79, 0x0000a77d,
+	0x0000a77e, 0x0000a77f, 0x0000a77e,
+	0x0000a780, 0x0000a781, 0x0000a780,
+	0x0000a782, 0x0000a783, 0x0000a782,
+	0x0000a784, 0x0000a785, 0x0000a784,
+	0x0000a786, 0x0000a787, 0x0000a786,
+	0x0000a78b, 0x0000a78c, 0x0000a78b,
+	0x0000a78d, 0x00000265, 0x0000a78d,
+	0x0000a790, 0x0000a791, 0x0000a790,
+	0x0000a7a0, 0x0000a7a1, 0x0000a7a0,
+	0x0000a7a2, 0x0000a7a3, 0x0000a7a2,
+	0x0000a7a4, 0x0000a7a5, 0x0000a7a4,
+	0x0000a7a6, 0x0000a7a7, 0x0000a7a6,
+	0x0000a7a8, 0x0000a7a9, 0x0000a7a8,
+	0x0000ff21, 0x0000ff41, 0x0000ff21,
+	0x0000ff22, 0x0000ff42, 0x0000ff22,
+	0x0000ff23, 0x0000ff43, 0x0000ff23,
+	0x0000ff24, 0x0000ff44, 0x0000ff24,
+	0x0000ff25, 0x0000ff45, 0x0000ff25,
+	0x0000ff26, 0x0000ff46, 0x0000ff26,
+	0x0000ff27, 0x0000ff47, 0x0000ff27,
+	0x0000ff28, 0x0000ff48, 0x0000ff28,
+	0x0000ff29, 0x0000ff49, 0x0000ff29,
+	0x0000ff2a, 0x0000ff4a, 0x0000ff2a,
+	0x0000ff2b, 0x0000ff4b, 0x0000ff2b,
+	0x0000ff2c, 0x0000ff4c, 0x0000ff2c,
+	0x0000ff2d, 0x0000ff4d, 0x0000ff2d,
+	0x0000ff2e, 0x0000ff4e, 0x0000ff2e,
+	0x0000ff2f, 0x0000ff4f, 0x0000ff2f,
+	0x0000ff30, 0x0000ff50, 0x0000ff30,
+	0x0000ff31, 0x0000ff51, 0x0000ff31,
+	0x0000ff32, 0x0000ff52, 0x0000ff32,
+	0x0000ff33, 0x0000ff53, 0x0000ff33,
+	0x0000ff34, 0x0000ff54, 0x0000ff34,
+	0x0000ff35, 0x0000ff55, 0x0000ff35,
+	0x0000ff36, 0x0000ff56, 0x0000ff36,
+	0x0000ff37, 0x0000ff57, 0x0000ff37,
+	0x0000ff38, 0x0000ff58, 0x0000ff38,
+	0x0000ff39, 0x0000ff59, 0x0000ff39,
+	0x0000ff3a, 0x0000ff5a, 0x0000ff3a,
+	0x00010400, 0x00010428, 0x00010400,
+	0x00010401, 0x00010429, 0x00010401,
+	0x00010402, 0x0001042a, 0x00010402,
+	0x00010403, 0x0001042b, 0x00010403,
+	0x00010404, 0x0001042c, 0x00010404,
+	0x00010405, 0x0001042d, 0x00010405,
+	0x00010406, 0x0001042e, 0x00010406,
+	0x00010407, 0x0001042f, 0x00010407,
+	0x00010408, 0x00010430, 0x00010408,
+	0x00010409, 0x00010431, 0x00010409,
+	0x0001040a, 0x00010432, 0x0001040a,
+	0x0001040b, 0x00010433, 0x0001040b,
+	0x0001040c, 0x00010434, 0x0001040c,
+	0x0001040d, 0x00010435, 0x0001040d,
+	0x0001040e, 0x00010436, 0x0001040e,
+	0x0001040f, 0x00010437, 0x0001040f,
+	0x00010410, 0x00010438, 0x00010410,
+	0x00010411, 0x00010439, 0x00010411,
+	0x00010412, 0x0001043a, 0x00010412,
+	0x00010413, 0x0001043b, 0x00010413,
+	0x00010414, 0x0001043c, 0x00010414,
+	0x00010415, 0x0001043d, 0x00010415,
+	0x00010416, 0x0001043e, 0x00010416,
+	0x00010417, 0x0001043f, 0x00010417,
+	0x00010418, 0x00010440, 0x00010418,
+	0x00010419, 0x00010441, 0x00010419,
+	0x0001041a, 0x00010442, 0x0001041a,
+	0x0001041b, 0x00010443, 0x0001041b,
+	0x0001041c, 0x00010444, 0x0001041c,
+	0x0001041d, 0x00010445, 0x0001041d,
+	0x0001041e, 0x00010446, 0x0001041e,
+	0x0001041f, 0x00010447, 0x0001041f,
+	0x00010420, 0x00010448, 0x00010420,
+	0x00010421, 0x00010449, 0x00010421,
+	0x00010422, 0x0001044a, 0x00010422,
+	0x00010423, 0x0001044b, 0x00010423,
+	0x00010424, 0x0001044c, 0x00010424,
+	0x00010425, 0x0001044d, 0x00010425,
+	0x00010426, 0x0001044e, 0x00010426,
+	0x00010427, 0x0001044f, 0x00010427,
+	0x00000061, 0x00000041, 0x00000041,
+	0x00000062, 0x00000042, 0x00000042,
+	0x00000063, 0x00000043, 0x00000043,
+	0x00000064, 0x00000044, 0x00000044,
+	0x00000065, 0x00000045, 0x00000045,
+	0x00000066, 0x00000046, 0x00000046,
+	0x00000067, 0x00000047, 0x00000047,
+	0x00000068, 0x00000048, 0x00000048,
+	0x00000069, 0x00000049, 0x00000049,
+	0x0000006a, 0x0000004a, 0x0000004a,
+	0x0000006b, 0x0000004b, 0x0000004b,
+	0x0000006c, 0x0000004c, 0x0000004c,
+	0x0000006d, 0x0000004d, 0x0000004d,
+	0x0000006e, 0x0000004e, 0x0000004e,
+	0x0000006f, 0x0000004f, 0x0000004f,
+	0x00000070, 0x00000050, 0x00000050,
+	0x00000071, 0x00000051, 0x00000051,
+	0x00000072, 0x00000052, 0x00000052,
+	0x00000073, 0x00000053, 0x00000053,
+	0x00000074, 0x00000054, 0x00000054,
+	0x00000075, 0x00000055, 0x00000055,
+	0x00000076, 0x00000056, 0x00000056,
+	0x00000077, 0x00000057, 0x00000057,
+	0x00000078, 0x00000058, 0x00000058,
+	0x00000079, 0x00000059, 0x00000059,
+	0x0000007a, 0x0000005a, 0x0000005a,
+	0x000000b5, 0x0000039c, 0x0000039c,
+	0x000000e0, 0x000000c0, 0x000000c0,
+	0x000000e1, 0x000000c1, 0x000000c1,
+	0x000000e2, 0x000000c2, 0x000000c2,
+	0x000000e3, 0x000000c3, 0x000000c3,
+	0x000000e4, 0x000000c4, 0x000000c4,
+	0x000000e5, 0x000000c5, 0x000000c5,
+	0x000000e6, 0x000000c6, 0x000000c6,
+	0x000000e7, 0x000000c7, 0x000000c7,
+	0x000000e8, 0x000000c8, 0x000000c8,
+	0x000000e9, 0x000000c9, 0x000000c9,
+	0x000000ea, 0x000000ca, 0x000000ca,
+	0x000000eb, 0x000000cb, 0x000000cb,
+	0x000000ec, 0x000000cc, 0x000000cc,
+	0x000000ed, 0x000000cd, 0x000000cd,
+	0x000000ee, 0x000000ce, 0x000000ce,
+	0x000000ef, 0x000000cf, 0x000000cf,
+	0x000000f0, 0x000000d0, 0x000000d0,
+	0x000000f1, 0x000000d1, 0x000000d1,
+	0x000000f2, 0x000000d2, 0x000000d2,
+	0x000000f3, 0x000000d3, 0x000000d3,
+	0x000000f4, 0x000000d4, 0x000000d4,
+	0x000000f5, 0x000000d5, 0x000000d5,
+	0x000000f6, 0x000000d6, 0x000000d6,
+	0x000000f8, 0x000000d8, 0x000000d8,
+	0x000000f9, 0x000000d9, 0x000000d9,
+	0x000000fa, 0x000000da, 0x000000da,
+	0x000000fb, 0x000000db, 0x000000db,
+	0x000000fc, 0x000000dc, 0x000000dc,
+	0x000000fd, 0x000000dd, 0x000000dd,
+	0x000000fe, 0x000000de, 0x000000de,
+	0x000000ff, 0x00000178, 0x00000178,
+	0x00000101, 0x00000100, 0x00000100,
+	0x00000103, 0x00000102, 0x00000102,
+	0x00000105, 0x00000104, 0x00000104,
+	0x00000107, 0x00000106, 0x00000106,
+	0x00000109, 0x00000108, 0x00000108,
+	0x0000010b, 0x0000010a, 0x0000010a,
+	0x0000010d, 0x0000010c, 0x0000010c,
+	0x0000010f, 0x0000010e, 0x0000010e,
+	0x00000111, 0x00000110, 0x00000110,
+	0x00000113, 0x00000112, 0x00000112,
+	0x00000115, 0x00000114, 0x00000114,
+	0x00000117, 0x00000116, 0x00000116,
+	0x00000119, 0x00000118, 0x00000118,
+	0x0000011b, 0x0000011a, 0x0000011a,
+	0x0000011d, 0x0000011c, 0x0000011c,
+	0x0000011f, 0x0000011e, 0x0000011e,
+	0x00000121, 0x00000120, 0x00000120,
+	0x00000123, 0x00000122, 0x00000122,
+	0x00000125, 0x00000124, 0x00000124,
+	0x00000127, 0x00000126, 0x00000126,
+	0x00000129, 0x00000128, 0x00000128,
+	0x0000012b, 0x0000012a, 0x0000012a,
+	0x0000012d, 0x0000012c, 0x0000012c,
+	0x0000012f, 0x0000012e, 0x0000012e,
+	0x00000131, 0x00000049, 0x00000049,
+	0x00000133, 0x00000132, 0x00000132,
+	0x00000135, 0x00000134, 0x00000134,
+	0x00000137, 0x00000136, 0x00000136,
+	0x0000013a, 0x00000139, 0x00000139,
+	0x0000013c, 0x0000013b, 0x0000013b,
+	0x0000013e, 0x0000013d, 0x0000013d,
+	0x00000140, 0x0000013f, 0x0000013f,
+	0x00000142, 0x00000141, 0x00000141,
+	0x00000144, 0x00000143, 0x00000143,
+	0x00000146, 0x00000145, 0x00000145,
+	0x00000148, 0x00000147, 0x00000147,
+	0x0000014b, 0x0000014a, 0x0000014a,
+	0x0000014d, 0x0000014c, 0x0000014c,
+	0x0000014f, 0x0000014e, 0x0000014e,
+	0x00000151, 0x00000150, 0x00000150,
+	0x00000153, 0x00000152, 0x00000152,
+	0x00000155, 0x00000154, 0x00000154,
+	0x00000157, 0x00000156, 0x00000156,
+	0x00000159, 0x00000158, 0x00000158,
+	0x0000015b, 0x0000015a, 0x0000015a,
+	0x0000015d, 0x0000015c, 0x0000015c,
+	0x0000015f, 0x0000015e, 0x0000015e,
+	0x00000161, 0x00000160, 0x00000160,
+	0x00000163, 0x00000162, 0x00000162,
+	0x00000165, 0x00000164, 0x00000164,
+	0x00000167, 0x00000166, 0x00000166,
+	0x00000169, 0x00000168, 0x00000168,
+	0x0000016b, 0x0000016a, 0x0000016a,
+	0x0000016d, 0x0000016c, 0x0000016c,
+	0x0000016f, 0x0000016e, 0x0000016e,
+	0x00000171, 0x00000170, 0x00000170,
+	0x00000173, 0x00000172, 0x00000172,
+	0x00000175, 0x00000174, 0x00000174,
+	0x00000177, 0x00000176, 0x00000176,
+	0x0000017a, 0x00000179, 0x00000179,
+	0x0000017c, 0x0000017b, 0x0000017b,
+	0x0000017e, 0x0000017d, 0x0000017d,
+	0x0000017f, 0x00000053, 0x00000053,
+	0x00000180, 0x00000243, 0x00000243,
+	0x00000183, 0x00000182, 0x00000182,
+	0x00000185, 0x00000184, 0x00000184,
+	0x00000188, 0x00000187, 0x00000187,
+	0x0000018c, 0x0000018b, 0x0000018b,
+	0x00000192, 0x00000191, 0x00000191,
+	0x00000195, 0x000001f6, 0x000001f6,
+	0x00000199, 0x00000198, 0x00000198,
+	0x0000019a, 0x0000023d, 0x0000023d,
+	0x0000019e, 0x00000220, 0x00000220,
+	0x000001a1, 0x000001a0, 0x000001a0,
+	0x000001a3, 0x000001a2, 0x000001a2,
+	0x000001a5, 0x000001a4, 0x000001a4,
+	0x000001a8, 0x000001a7, 0x000001a7,
+	0x000001ad, 0x000001ac, 0x000001ac,
+	0x000001b0, 0x000001af, 0x000001af,
+	0x000001b4, 0x000001b3, 0x000001b3,
+	0x000001b6, 0x000001b5, 0x000001b5,
+	0x000001b9, 0x000001b8, 0x000001b8,
+	0x000001bd, 0x000001bc, 0x000001bc,
+	0x000001bf, 0x000001f7, 0x000001f7,
+	0x000001c6, 0x000001c4, 0x000001c5,
+	0x000001c9, 0x000001c7, 0x000001c8,
+	0x000001cc, 0x000001ca, 0x000001cb,
+	0x000001ce, 0x000001cd, 0x000001cd,
+	0x000001d0, 0x000001cf, 0x000001cf,
+	0x000001d2, 0x000001d1, 0x000001d1,
+	0x000001d4, 0x000001d3, 0x000001d3,
+	0x000001d6, 0x000001d5, 0x000001d5,
+	0x000001d8, 0x000001d7, 0x000001d7,
+	0x000001da, 0x000001d9, 0x000001d9,
+	0x000001dc, 0x000001db, 0x000001db,
+	0x000001dd, 0x0000018e, 0x0000018e,
+	0x000001df, 0x000001de, 0x000001de,
+	0x000001e1, 0x000001e0, 0x000001e0,
+	0x000001e3, 0x000001e2, 0x000001e2,
+	0x000001e5, 0x000001e4, 0x000001e4,
+	0x000001e7, 0x000001e6, 0x000001e6,
+	0x000001e9, 0x000001e8, 0x000001e8,
+	0x000001eb, 0x000001ea, 0x000001ea,
+	0x000001ed, 0x000001ec, 0x000001ec,
+	0x000001ef, 0x000001ee, 0x000001ee,
+	0x000001f3, 0x000001f1, 0x000001f2,
+	0x000001f5, 0x000001f4, 0x000001f4,
+	0x000001f9, 0x000001f8, 0x000001f8,
+	0x000001fb, 0x000001fa, 0x000001fa,
+	0x000001fd, 0x000001fc, 0x000001fc,
+	0x000001ff, 0x000001fe, 0x000001fe,
+	0x00000201, 0x00000200, 0x00000200,
+	0x00000203, 0x00000202, 0x00000202,
+	0x00000205, 0x00000204, 0x00000204,
+	0x00000207, 0x00000206, 0x00000206,
+	0x00000209, 0x00000208, 0x00000208,
+	0x0000020b, 0x0000020a, 0x0000020a,
+	0x0000020d, 0x0000020c, 0x0000020c,
+	0x0000020f, 0x0000020e, 0x0000020e,
+	0x00000211, 0x00000210, 0x00000210,
+	0x00000213, 0x00000212, 0x00000212,
+	0x00000215, 0x00000214, 0x00000214,
+	0x00000217, 0x00000216, 0x00000216,
+	0x00000219, 0x00000218, 0x00000218,
+	0x0000021b, 0x0000021a, 0x0000021a,
+	0x0000021d, 0x0000021c, 0x0000021c,
+	0x0000021f, 0x0000021e, 0x0000021e,
+	0x00000223, 0x00000222, 0x00000222,
+	0x00000225, 0x00000224, 0x00000224,
+	0x00000227, 0x00000226, 0x00000226,
+	0x00000229, 0x00000228, 0x00000228,
+	0x0000022b, 0x0000022a, 0x0000022a,
+	0x0000022d, 0x0000022c, 0x0000022c,
+	0x0000022f, 0x0000022e, 0x0000022e,
+	0x00000231, 0x00000230, 0x00000230,
+	0x00000233, 0x00000232, 0x00000232,
+	0x0000023c, 0x0000023b, 0x0000023b,
+	0x0000023f, 0x00002c7e, 0x00002c7e,
+	0x00000240, 0x00002c7f, 0x00002c7f,
+	0x00000242, 0x00000241, 0x00000241,
+	0x00000247, 0x00000246, 0x00000246,
+	0x00000249, 0x00000248, 0x00000248,
+	0x0000024b, 0x0000024a, 0x0000024a,
+	0x0000024d, 0x0000024c, 0x0000024c,
+	0x0000024f, 0x0000024e, 0x0000024e,
+	0x00000250, 0x00002c6f, 0x00002c6f,
+	0x00000251, 0x00002c6d, 0x00002c6d,
+	0x00000252, 0x00002c70, 0x00002c70,
+	0x00000253, 0x00000181, 0x00000181,
+	0x00000254, 0x00000186, 0x00000186,
+	0x00000256, 0x00000189, 0x00000189,
+	0x00000257, 0x0000018a, 0x0000018a,
+	0x00000259, 0x0000018f, 0x0000018f,
+	0x0000025b, 0x00000190, 0x00000190,
+	0x00000260, 0x00000193, 0x00000193,
+	0x00000263, 0x00000194, 0x00000194,
+	0x00000265, 0x0000a78d, 0x0000a78d,
+	0x00000268, 0x00000197, 0x00000197,
+	0x00000269, 0x00000196, 0x00000196,
+	0x0000026b, 0x00002c62, 0x00002c62,
+	0x0000026f, 0x0000019c, 0x0000019c,
+	0x00000271, 0x00002c6e, 0x00002c6e,
+	0x00000272, 0x0000019d, 0x0000019d,
+	0x00000275, 0x0000019f, 0x0000019f,
+	0x0000027d, 0x00002c64, 0x00002c64,
+	0x00000280, 0x000001a6, 0x000001a6,
+	0x00000283, 0x000001a9, 0x000001a9,
+	0x00000288, 0x000001ae, 0x000001ae,
+	0x00000289, 0x00000244, 0x00000244,
+	0x0000028a, 0x000001b1, 0x000001b1,
+	0x0000028b, 0x000001b2, 0x000001b2,
+	0x0000028c, 0x00000245, 0x00000245,
+	0x00000292, 0x000001b7, 0x000001b7,
+	0x00000345, 0x00000399, 0x00000399,
+	0x00000371, 0x00000370, 0x00000370,
+	0x00000373, 0x00000372, 0x00000372,
+	0x00000377, 0x00000376, 0x00000376,
+	0x0000037b, 0x000003fd, 0x000003fd,
+	0x0000037c, 0x000003fe, 0x000003fe,
+	0x0000037d, 0x000003ff, 0x000003ff,
+	0x000003ac, 0x00000386, 0x00000386,
+	0x000003ad, 0x00000388, 0x00000388,
+	0x000003ae, 0x00000389, 0x00000389,
+	0x000003af, 0x0000038a, 0x0000038a,
+	0x000003b1, 0x00000391, 0x00000391,
+	0x000003b2, 0x00000392, 0x00000392,
+	0x000003b3, 0x00000393, 0x00000393,
+	0x000003b4, 0x00000394, 0x00000394,
+	0x000003b5, 0x00000395, 0x00000395,
+	0x000003b6, 0x00000396, 0x00000396,
+	0x000003b7, 0x00000397, 0x00000397,
+	0x000003b8, 0x00000398, 0x00000398,
+	0x000003b9, 0x00000399, 0x00000399,
+	0x000003ba, 0x0000039a, 0x0000039a,
+	0x000003bb, 0x0000039b, 0x0000039b,
+	0x000003bc, 0x0000039c, 0x0000039c,
+	0x000003bd, 0x0000039d, 0x0000039d,
+	0x000003be, 0x0000039e, 0x0000039e,
+	0x000003bf, 0x0000039f, 0x0000039f,
+	0x000003c0, 0x000003a0, 0x000003a0,
+	0x000003c1, 0x000003a1, 0x000003a1,
+	0x000003c2, 0x000003a3, 0x000003a3,
+	0x000003c3, 0x000003a3, 0x000003a3,
+	0x000003c4, 0x000003a4, 0x000003a4,
+	0x000003c5, 0x000003a5, 0x000003a5,
+	0x000003c6, 0x000003a6, 0x000003a6,
+	0x000003c7, 0x000003a7, 0x000003a7,
+	0x000003c8, 0x000003a8, 0x000003a8,
+	0x000003c9, 0x000003a9, 0x000003a9,
+	0x000003ca, 0x000003aa, 0x000003aa,
+	0x000003cb, 0x000003ab, 0x000003ab,
+	0x000003cc, 0x0000038c, 0x0000038c,
+	0x000003cd, 0x0000038e, 0x0000038e,
+	0x000003ce, 0x0000038f, 0x0000038f,
+	0x000003d0, 0x00000392, 0x00000392,
+	0x000003d1, 0x00000398, 0x00000398,
+	0x000003d5, 0x000003a6, 0x000003a6,
+	0x000003d6, 0x000003a0, 0x000003a0,
+	0x000003d7, 0x000003cf, 0x000003cf,
+	0x000003d9, 0x000003d8, 0x000003d8,
+	0x000003db, 0x000003da, 0x000003da,
+	0x000003dd, 0x000003dc, 0x000003dc,
+	0x000003df, 0x000003de, 0x000003de,
+	0x000003e1, 0x000003e0, 0x000003e0,
+	0x000003e3, 0x000003e2, 0x000003e2,
+	0x000003e5, 0x000003e4, 0x000003e4,
+	0x000003e7, 0x000003e6, 0x000003e6,
+	0x000003e9, 0x000003e8, 0x000003e8,
+	0x000003eb, 0x000003ea, 0x000003ea,
+	0x000003ed, 0x000003ec, 0x000003ec,
+	0x000003ef, 0x000003ee, 0x000003ee,
+	0x000003f0, 0x0000039a, 0x0000039a,
+	0x000003f1, 0x000003a1, 0x000003a1,
+	0x000003f2, 0x000003f9, 0x000003f9,
+	0x000003f5, 0x00000395, 0x00000395,
+	0x000003f8, 0x000003f7, 0x000003f7,
+	0x000003fb, 0x000003fa, 0x000003fa,
+	0x00000430, 0x00000410, 0x00000410,
+	0x00000431, 0x00000411, 0x00000411,
+	0x00000432, 0x00000412, 0x00000412,
+	0x00000433, 0x00000413, 0x00000413,
+	0x00000434, 0x00000414, 0x00000414,
+	0x00000435, 0x00000415, 0x00000415,
+	0x00000436, 0x00000416, 0x00000416,
+	0x00000437, 0x00000417, 0x00000417,
+	0x00000438, 0x00000418, 0x00000418,
+	0x00000439, 0x00000419, 0x00000419,
+	0x0000043a, 0x0000041a, 0x0000041a,
+	0x0000043b, 0x0000041b, 0x0000041b,
+	0x0000043c, 0x0000041c, 0x0000041c,
+	0x0000043d, 0x0000041d, 0x0000041d,
+	0x0000043e, 0x0000041e, 0x0000041e,
+	0x0000043f, 0x0000041f, 0x0000041f,
+	0x00000440, 0x00000420, 0x00000420,
+	0x00000441, 0x00000421, 0x00000421,
+	0x00000442, 0x00000422, 0x00000422,
+	0x00000443, 0x00000423, 0x00000423,
+	0x00000444, 0x00000424, 0x00000424,
+	0x00000445, 0x00000425, 0x00000425,
+	0x00000446, 0x00000426, 0x00000426,
+	0x00000447, 0x00000427, 0x00000427,
+	0x00000448, 0x00000428, 0x00000428,
+	0x00000449, 0x00000429, 0x00000429,
+	0x0000044a, 0x0000042a, 0x0000042a,
+	0x0000044b, 0x0000042b, 0x0000042b,
+	0x0000044c, 0x0000042c, 0x0000042c,
+	0x0000044d, 0x0000042d, 0x0000042d,
+	0x0000044e, 0x0000042e, 0x0000042e,
+	0x0000044f, 0x0000042f, 0x0000042f,
+	0x00000450, 0x00000400, 0x00000400,
+	0x00000451, 0x00000401, 0x00000401,
+	0x00000452, 0x00000402, 0x00000402,
+	0x00000453, 0x00000403, 0x00000403,
+	0x00000454, 0x00000404, 0x00000404,
+	0x00000455, 0x00000405, 0x00000405,
+	0x00000456, 0x00000406, 0x00000406,
+	0x00000457, 0x00000407, 0x00000407,
+	0x00000458, 0x00000408, 0x00000408,
+	0x00000459, 0x00000409, 0x00000409,
+	0x0000045a, 0x0000040a, 0x0000040a,
+	0x0000045b, 0x0000040b, 0x0000040b,
+	0x0000045c, 0x0000040c, 0x0000040c,
+	0x0000045d, 0x0000040d, 0x0000040d,
+	0x0000045e, 0x0000040e, 0x0000040e,
+	0x0000045f, 0x0000040f, 0x0000040f,
+	0x00000461, 0x00000460, 0x00000460,
+	0x00000463, 0x00000462, 0x00000462,
+	0x00000465, 0x00000464, 0x00000464,
+	0x00000467, 0x00000466, 0x00000466,
+	0x00000469, 0x00000468, 0x00000468,
+	0x0000046b, 0x0000046a, 0x0000046a,
+	0x0000046d, 0x0000046c, 0x0000046c,
+	0x0000046f, 0x0000046e, 0x0000046e,
+	0x00000471, 0x00000470, 0x00000470,
+	0x00000473, 0x00000472, 0x00000472,
+	0x00000475, 0x00000474, 0x00000474,
+	0x00000477, 0x00000476, 0x00000476,
+	0x00000479, 0x00000478, 0x00000478,
+	0x0000047b, 0x0000047a, 0x0000047a,
+	0x0000047d, 0x0000047c, 0x0000047c,
+	0x0000047f, 0x0000047e, 0x0000047e,
+	0x00000481, 0x00000480, 0x00000480,
+	0x0000048b, 0x0000048a, 0x0000048a,
+	0x0000048d, 0x0000048c, 0x0000048c,
+	0x0000048f, 0x0000048e, 0x0000048e,
+	0x00000491, 0x00000490, 0x00000490,
+	0x00000493, 0x00000492, 0x00000492,
+	0x00000495, 0x00000494, 0x00000494,
+	0x00000497, 0x00000496, 0x00000496,
+	0x00000499, 0x00000498, 0x00000498,
+	0x0000049b, 0x0000049a, 0x0000049a,
+	0x0000049d, 0x0000049c, 0x0000049c,
+	0x0000049f, 0x0000049e, 0x0000049e,
+	0x000004a1, 0x000004a0, 0x000004a0,
+	0x000004a3, 0x000004a2, 0x000004a2,
+	0x000004a5, 0x000004a4, 0x000004a4,
+	0x000004a7, 0x000004a6, 0x000004a6,
+	0x000004a9, 0x000004a8, 0x000004a8,
+	0x000004ab, 0x000004aa, 0x000004aa,
+	0x000004ad, 0x000004ac, 0x000004ac,
+	0x000004af, 0x000004ae, 0x000004ae,
+	0x000004b1, 0x000004b0, 0x000004b0,
+	0x000004b3, 0x000004b2, 0x000004b2,
+	0x000004b5, 0x000004b4, 0x000004b4,
+	0x000004b7, 0x000004b6, 0x000004b6,
+	0x000004b9, 0x000004b8, 0x000004b8,
+	0x000004bb, 0x000004ba, 0x000004ba,
+	0x000004bd, 0x000004bc, 0x000004bc,
+	0x000004bf, 0x000004be, 0x000004be,
+	0x000004c2, 0x000004c1, 0x000004c1,
+	0x000004c4, 0x000004c3, 0x000004c3,
+	0x000004c6, 0x000004c5, 0x000004c5,
+	0x000004c8, 0x000004c7, 0x000004c7,
+	0x000004ca, 0x000004c9, 0x000004c9,
+	0x000004cc, 0x000004cb, 0x000004cb,
+	0x000004ce, 0x000004cd, 0x000004cd,
+	0x000004cf, 0x000004c0, 0x000004c0,
+	0x000004d1, 0x000004d0, 0x000004d0,
+	0x000004d3, 0x000004d2, 0x000004d2,
+	0x000004d5, 0x000004d4, 0x000004d4,
+	0x000004d7, 0x000004d6, 0x000004d6,
+	0x000004d9, 0x000004d8, 0x000004d8,
+	0x000004db, 0x000004da, 0x000004da,
+	0x000004dd, 0x000004dc, 0x000004dc,
+	0x000004df, 0x000004de, 0x000004de,
+	0x000004e1, 0x000004e0, 0x000004e0,
+	0x000004e3, 0x000004e2, 0x000004e2,
+	0x000004e5, 0x000004e4, 0x000004e4,
+	0x000004e7, 0x000004e6, 0x000004e6,
+	0x000004e9, 0x000004e8, 0x000004e8,
+	0x000004eb, 0x000004ea, 0x000004ea,
+	0x000004ed, 0x000004ec, 0x000004ec,
+	0x000004ef, 0x000004ee, 0x000004ee,
+	0x000004f1, 0x000004f0, 0x000004f0,
+	0x000004f3, 0x000004f2, 0x000004f2,
+	0x000004f5, 0x000004f4, 0x000004f4,
+	0x000004f7, 0x000004f6, 0x000004f6,
+	0x000004f9, 0x000004f8, 0x000004f8,
+	0x000004fb, 0x000004fa, 0x000004fa,
+	0x000004fd, 0x000004fc, 0x000004fc,
+	0x000004ff, 0x000004fe, 0x000004fe,
+	0x00000501, 0x00000500, 0x00000500,
+	0x00000503, 0x00000502, 0x00000502,
+	0x00000505, 0x00000504, 0x00000504,
+	0x00000507, 0x00000506, 0x00000506,
+	0x00000509, 0x00000508, 0x00000508,
+	0x0000050b, 0x0000050a, 0x0000050a,
+	0x0000050d, 0x0000050c, 0x0000050c,
+	0x0000050f, 0x0000050e, 0x0000050e,
+	0x00000511, 0x00000510, 0x00000510,
+	0x00000513, 0x00000512, 0x00000512,
+	0x00000515, 0x00000514, 0x00000514,
+	0x00000517, 0x00000516, 0x00000516,
+	0x00000519, 0x00000518, 0x00000518,
+	0x0000051b, 0x0000051a, 0x0000051a,
+	0x0000051d, 0x0000051c, 0x0000051c,
+	0x0000051f, 0x0000051e, 0x0000051e,
+	0x00000521, 0x00000520, 0x00000520,
+	0x00000523, 0x00000522, 0x00000522,
+	0x00000525, 0x00000524, 0x00000524,
+	0x00000527, 0x00000526, 0x00000526,
+	0x00000561, 0x00000531, 0x00000531,
+	0x00000562, 0x00000532, 0x00000532,
+	0x00000563, 0x00000533, 0x00000533,
+	0x00000564, 0x00000534, 0x00000534,
+	0x00000565, 0x00000535, 0x00000535,
+	0x00000566, 0x00000536, 0x00000536,
+	0x00000567, 0x00000537, 0x00000537,
+	0x00000568, 0x00000538, 0x00000538,
+	0x00000569, 0x00000539, 0x00000539,
+	0x0000056a, 0x0000053a, 0x0000053a,
+	0x0000056b, 0x0000053b, 0x0000053b,
+	0x0000056c, 0x0000053c, 0x0000053c,
+	0x0000056d, 0x0000053d, 0x0000053d,
+	0x0000056e, 0x0000053e, 0x0000053e,
+	0x0000056f, 0x0000053f, 0x0000053f,
+	0x00000570, 0x00000540, 0x00000540,
+	0x00000571, 0x00000541, 0x00000541,
+	0x00000572, 0x00000542, 0x00000542,
+	0x00000573, 0x00000543, 0x00000543,
+	0x00000574, 0x00000544, 0x00000544,
+	0x00000575, 0x00000545, 0x00000545,
+	0x00000576, 0x00000546, 0x00000546,
+	0x00000577, 0x00000547, 0x00000547,
+	0x00000578, 0x00000548, 0x00000548,
+	0x00000579, 0x00000549, 0x00000549,
+	0x0000057a, 0x0000054a, 0x0000054a,
+	0x0000057b, 0x0000054b, 0x0000054b,
+	0x0000057c, 0x0000054c, 0x0000054c,
+	0x0000057d, 0x0000054d, 0x0000054d,
+	0x0000057e, 0x0000054e, 0x0000054e,
+	0x0000057f, 0x0000054f, 0x0000054f,
+	0x00000580, 0x00000550, 0x00000550,
+	0x00000581, 0x00000551, 0x00000551,
+	0x00000582, 0x00000552, 0x00000552,
+	0x00000583, 0x00000553, 0x00000553,
+	0x00000584, 0x00000554, 0x00000554,
+	0x00000585, 0x00000555, 0x00000555,
+	0x00000586, 0x00000556, 0x00000556,
+	0x00001d79, 0x0000a77d, 0x0000a77d,
+	0x00001d7d, 0x00002c63, 0x00002c63,
+	0x00001e01, 0x00001e00, 0x00001e00,
+	0x00001e03, 0x00001e02, 0x00001e02,
+	0x00001e05, 0x00001e04, 0x00001e04,
+	0x00001e07, 0x00001e06, 0x00001e06,
+	0x00001e09, 0x00001e08, 0x00001e08,
+	0x00001e0b, 0x00001e0a, 0x00001e0a,
+	0x00001e0d, 0x00001e0c, 0x00001e0c,
+	0x00001e0f, 0x00001e0e, 0x00001e0e,
+	0x00001e11, 0x00001e10, 0x00001e10,
+	0x00001e13, 0x00001e12, 0x00001e12,
+	0x00001e15, 0x00001e14, 0x00001e14,
+	0x00001e17, 0x00001e16, 0x00001e16,
+	0x00001e19, 0x00001e18, 0x00001e18,
+	0x00001e1b, 0x00001e1a, 0x00001e1a,
+	0x00001e1d, 0x00001e1c, 0x00001e1c,
+	0x00001e1f, 0x00001e1e, 0x00001e1e,
+	0x00001e21, 0x00001e20, 0x00001e20,
+	0x00001e23, 0x00001e22, 0x00001e22,
+	0x00001e25, 0x00001e24, 0x00001e24,
+	0x00001e27, 0x00001e26, 0x00001e26,
+	0x00001e29, 0x00001e28, 0x00001e28,
+	0x00001e2b, 0x00001e2a, 0x00001e2a,
+	0x00001e2d, 0x00001e2c, 0x00001e2c,
+	0x00001e2f, 0x00001e2e, 0x00001e2e,
+	0x00001e31, 0x00001e30, 0x00001e30,
+	0x00001e33, 0x00001e32, 0x00001e32,
+	0x00001e35, 0x00001e34, 0x00001e34,
+	0x00001e37, 0x00001e36, 0x00001e36,
+	0x00001e39, 0x00001e38, 0x00001e38,
+	0x00001e3b, 0x00001e3a, 0x00001e3a,
+	0x00001e3d, 0x00001e3c, 0x00001e3c,
+	0x00001e3f, 0x00001e3e, 0x00001e3e,
+	0x00001e41, 0x00001e40, 0x00001e40,
+	0x00001e43, 0x00001e42, 0x00001e42,
+	0x00001e45, 0x00001e44, 0x00001e44,
+	0x00001e47, 0x00001e46, 0x00001e46,
+	0x00001e49, 0x00001e48, 0x00001e48,
+	0x00001e4b, 0x00001e4a, 0x00001e4a,
+	0x00001e4d, 0x00001e4c, 0x00001e4c,
+	0x00001e4f, 0x00001e4e, 0x00001e4e,
+	0x00001e51, 0x00001e50, 0x00001e50,
+	0x00001e53, 0x00001e52, 0x00001e52,
+	0x00001e55, 0x00001e54, 0x00001e54,
+	0x00001e57, 0x00001e56, 0x00001e56,
+	0x00001e59, 0x00001e58, 0x00001e58,
+	0x00001e5b, 0x00001e5a, 0x00001e5a,
+	0x00001e5d, 0x00001e5c, 0x00001e5c,
+	0x00001e5f, 0x00001e5e, 0x00001e5e,
+	0x00001e61, 0x00001e60, 0x00001e60,
+	0x00001e63, 0x00001e62, 0x00001e62,
+	0x00001e65, 0x00001e64, 0x00001e64,
+	0x00001e67, 0x00001e66, 0x00001e66,
+	0x00001e69, 0x00001e68, 0x00001e68,
+	0x00001e6b, 0x00001e6a, 0x00001e6a,
+	0x00001e6d, 0x00001e6c, 0x00001e6c,
+	0x00001e6f, 0x00001e6e, 0x00001e6e,
+	0x00001e71, 0x00001e70, 0x00001e70,
+	0x00001e73, 0x00001e72, 0x00001e72,
+	0x00001e75, 0x00001e74, 0x00001e74,
+	0x00001e77, 0x00001e76, 0x00001e76,
+	0x00001e79, 0x00001e78, 0x00001e78,
+	0x00001e7b, 0x00001e7a, 0x00001e7a,
+	0x00001e7d, 0x00001e7c, 0x00001e7c,
+	0x00001e7f, 0x00001e7e, 0x00001e7e,
+	0x00001e81, 0x00001e80, 0x00001e80,
+	0x00001e83, 0x00001e82, 0x00001e82,
+	0x00001e85, 0x00001e84, 0x00001e84,
+	0x00001e87, 0x00001e86, 0x00001e86,
+	0x00001e89, 0x00001e88, 0x00001e88,
+	0x00001e8b, 0x00001e8a, 0x00001e8a,
+	0x00001e8d, 0x00001e8c, 0x00001e8c,
+	0x00001e8f, 0x00001e8e, 0x00001e8e,
+	0x00001e91, 0x00001e90, 0x00001e90,
+	0x00001e93, 0x00001e92, 0x00001e92,
+	0x00001e95, 0x00001e94, 0x00001e94,
+	0x00001e9b, 0x00001e60, 0x00001e60,
+	0x00001ea1, 0x00001ea0, 0x00001ea0,
+	0x00001ea3, 0x00001ea2, 0x00001ea2,
+	0x00001ea5, 0x00001ea4, 0x00001ea4,
+	0x00001ea7, 0x00001ea6, 0x00001ea6,
+	0x00001ea9, 0x00001ea8, 0x00001ea8,
+	0x00001eab, 0x00001eaa, 0x00001eaa,
+	0x00001ead, 0x00001eac, 0x00001eac,
+	0x00001eaf, 0x00001eae, 0x00001eae,
+	0x00001eb1, 0x00001eb0, 0x00001eb0,
+	0x00001eb3, 0x00001eb2, 0x00001eb2,
+	0x00001eb5, 0x00001eb4, 0x00001eb4,
+	0x00001eb7, 0x00001eb6, 0x00001eb6,
+	0x00001eb9, 0x00001eb8, 0x00001eb8,
+	0x00001ebb, 0x00001eba, 0x00001eba,
+	0x00001ebd, 0x00001ebc, 0x00001ebc,
+	0x00001ebf, 0x00001ebe, 0x00001ebe,
+	0x00001ec1, 0x00001ec0, 0x00001ec0,
+	0x00001ec3, 0x00001ec2, 0x00001ec2,
+	0x00001ec5, 0x00001ec4, 0x00001ec4,
+	0x00001ec7, 0x00001ec6, 0x00001ec6,
+	0x00001ec9, 0x00001ec8, 0x00001ec8,
+	0x00001ecb, 0x00001eca, 0x00001eca,
+	0x00001ecd, 0x00001ecc, 0x00001ecc,
+	0x00001ecf, 0x00001ece, 0x00001ece,
+	0x00001ed1, 0x00001ed0, 0x00001ed0,
+	0x00001ed3, 0x00001ed2, 0x00001ed2,
+	0x00001ed5, 0x00001ed4, 0x00001ed4,
+	0x00001ed7, 0x00001ed6, 0x00001ed6,
+	0x00001ed9, 0x00001ed8, 0x00001ed8,
+	0x00001edb, 0x00001eda, 0x00001eda,
+	0x00001edd, 0x00001edc, 0x00001edc,
+	0x00001edf, 0x00001ede, 0x00001ede,
+	0x00001ee1, 0x00001ee0, 0x00001ee0,
+	0x00001ee3, 0x00001ee2, 0x00001ee2,
+	0x00001ee5, 0x00001ee4, 0x00001ee4,
+	0x00001ee7, 0x00001ee6, 0x00001ee6,
+	0x00001ee9, 0x00001ee8, 0x00001ee8,
+	0x00001eeb, 0x00001eea, 0x00001eea,
+	0x00001eed, 0x00001eec, 0x00001eec,
+	0x00001eef, 0x00001eee, 0x00001eee,
+	0x00001ef1, 0x00001ef0, 0x00001ef0,
+	0x00001ef3, 0x00001ef2, 0x00001ef2,
+	0x00001ef5, 0x00001ef4, 0x00001ef4,
+	0x00001ef7, 0x00001ef6, 0x00001ef6,
+	0x00001ef9, 0x00001ef8, 0x00001ef8,
+	0x00001efb, 0x00001efa, 0x00001efa,
+	0x00001efd, 0x00001efc, 0x00001efc,
+	0x00001eff, 0x00001efe, 0x00001efe,
+	0x00001f00, 0x00001f08, 0x00001f08,
+	0x00001f01, 0x00001f09, 0x00001f09,
+	0x00001f02, 0x00001f0a, 0x00001f0a,
+	0x00001f03, 0x00001f0b, 0x00001f0b,
+	0x00001f04, 0x00001f0c, 0x00001f0c,
+	0x00001f05, 0x00001f0d, 0x00001f0d,
+	0x00001f06, 0x00001f0e, 0x00001f0e,
+	0x00001f07, 0x00001f0f, 0x00001f0f,
+	0x00001f10, 0x00001f18, 0x00001f18,
+	0x00001f11, 0x00001f19, 0x00001f19,
+	0x00001f12, 0x00001f1a, 0x00001f1a,
+	0x00001f13, 0x00001f1b, 0x00001f1b,
+	0x00001f14, 0x00001f1c, 0x00001f1c,
+	0x00001f15, 0x00001f1d, 0x00001f1d,
+	0x00001f20, 0x00001f28, 0x00001f28,
+	0x00001f21, 0x00001f29, 0x00001f29,
+	0x00001f22, 0x00001f2a, 0x00001f2a,
+	0x00001f23, 0x00001f2b, 0x00001f2b,
+	0x00001f24, 0x00001f2c, 0x00001f2c,
+	0x00001f25, 0x00001f2d, 0x00001f2d,
+	0x00001f26, 0x00001f2e, 0x00001f2e,
+	0x00001f27, 0x00001f2f, 0x00001f2f,
+	0x00001f30, 0x00001f38, 0x00001f38,
+	0x00001f31, 0x00001f39, 0x00001f39,
+	0x00001f32, 0x00001f3a, 0x00001f3a,
+	0x00001f33, 0x00001f3b, 0x00001f3b,
+	0x00001f34, 0x00001f3c, 0x00001f3c,
+	0x00001f35, 0x00001f3d, 0x00001f3d,
+	0x00001f36, 0x00001f3e, 0x00001f3e,
+	0x00001f37, 0x00001f3f, 0x00001f3f,
+	0x00001f40, 0x00001f48, 0x00001f48,
+	0x00001f41, 0x00001f49, 0x00001f49,
+	0x00001f42, 0x00001f4a, 0x00001f4a,
+	0x00001f43, 0x00001f4b, 0x00001f4b,
+	0x00001f44, 0x00001f4c, 0x00001f4c,
+	0x00001f45, 0x00001f4d, 0x00001f4d,
+	0x00001f51, 0x00001f59, 0x00001f59,
+	0x00001f53, 0x00001f5b, 0x00001f5b,
+	0x00001f55, 0x00001f5d, 0x00001f5d,
+	0x00001f57, 0x00001f5f, 0x00001f5f,
+	0x00001f60, 0x00001f68, 0x00001f68,
+	0x00001f61, 0x00001f69, 0x00001f69,
+	0x00001f62, 0x00001f6a, 0x00001f6a,
+	0x00001f63, 0x00001f6b, 0x00001f6b,
+	0x00001f64, 0x00001f6c, 0x00001f6c,
+	0x00001f65, 0x00001f6d, 0x00001f6d,
+	0x00001f66, 0x00001f6e, 0x00001f6e,
+	0x00001f67, 0x00001f6f, 0x00001f6f,
+	0x00001f70, 0x00001fba, 0x00001fba,
+	0x00001f71, 0x00001fbb, 0x00001fbb,
+	0x00001f72, 0x00001fc8, 0x00001fc8,
+	0x00001f73, 0x00001fc9, 0x00001fc9,
+	0x00001f74, 0x00001fca, 0x00001fca,
+	0x00001f75, 0x00001fcb, 0x00001fcb,
+	0x00001f76, 0x00001fda, 0x00001fda,
+	0x00001f77, 0x00001fdb, 0x00001fdb,
+	0x00001f78, 0x00001ff8, 0x00001ff8,
+	0x00001f79, 0x00001ff9, 0x00001ff9,
+	0x00001f7a, 0x00001fea, 0x00001fea,
+	0x00001f7b, 0x00001feb, 0x00001feb,
+	0x00001f7c, 0x00001ffa, 0x00001ffa,
+	0x00001f7d, 0x00001ffb, 0x00001ffb,
+	0x00001f80, 0x00001f88, 0x00001f88,
+	0x00001f81, 0x00001f89, 0x00001f89,
+	0x00001f82, 0x00001f8a, 0x00001f8a,
+	0x00001f83, 0x00001f8b, 0x00001f8b,
+	0x00001f84, 0x00001f8c, 0x00001f8c,
+	0x00001f85, 0x00001f8d, 0x00001f8d,
+	0x00001f86, 0x00001f8e, 0x00001f8e,
+	0x00001f87, 0x00001f8f, 0x00001f8f,
+	0x00001f90, 0x00001f98, 0x00001f98,
+	0x00001f91, 0x00001f99, 0x00001f99,
+	0x00001f92, 0x00001f9a, 0x00001f9a,
+	0x00001f93, 0x00001f9b, 0x00001f9b,
+	0x00001f94, 0x00001f9c, 0x00001f9c,
+	0x00001f95, 0x00001f9d, 0x00001f9d,
+	0x00001f96, 0x00001f9e, 0x00001f9e,
+	0x00001f97, 0x00001f9f, 0x00001f9f,
+	0x00001fa0, 0x00001fa8, 0x00001fa8,
+	0x00001fa1, 0x00001fa9, 0x00001fa9,
+	0x00001fa2, 0x00001faa, 0x00001faa,
+	0x00001fa3, 0x00001fab, 0x00001fab,
+	0x00001fa4, 0x00001fac, 0x00001fac,
+	0x00001fa5, 0x00001fad, 0x00001fad,
+	0x00001fa6, 0x00001fae, 0x00001fae,
+	0x00001fa7, 0x00001faf, 0x00001faf,
+	0x00001fb0, 0x00001fb8, 0x00001fb8,
+	0x00001fb1, 0x00001fb9, 0x00001fb9,
+	0x00001fb3, 0x00001fbc, 0x00001fbc,
+	0x00001fbe, 0x00000399, 0x00000399,
+	0x00001fc3, 0x00001fcc, 0x00001fcc,
+	0x00001fd0, 0x00001fd8, 0x00001fd8,
+	0x00001fd1, 0x00001fd9, 0x00001fd9,
+	0x00001fe0, 0x00001fe8, 0x00001fe8,
+	0x00001fe1, 0x00001fe9, 0x00001fe9,
+	0x00001fe5, 0x00001fec, 0x00001fec,
+	0x00001ff3, 0x00001ffc, 0x00001ffc,
+	0x0000214e, 0x00002132, 0x00002132,
+	0x00002170, 0x00002160, 0x00002160,
+	0x00002171, 0x00002161, 0x00002161,
+	0x00002172, 0x00002162, 0x00002162,
+	0x00002173, 0x00002163, 0x00002163,
+	0x00002174, 0x00002164, 0x00002164,
+	0x00002175, 0x00002165, 0x00002165,
+	0x00002176, 0x00002166, 0x00002166,
+	0x00002177, 0x00002167, 0x00002167,
+	0x00002178, 0x00002168, 0x00002168,
+	0x00002179, 0x00002169, 0x00002169,
+	0x0000217a, 0x0000216a, 0x0000216a,
+	0x0000217b, 0x0000216b, 0x0000216b,
+	0x0000217c, 0x0000216c, 0x0000216c,
+	0x0000217d, 0x0000216d, 0x0000216d,
+	0x0000217e, 0x0000216e, 0x0000216e,
+	0x0000217f, 0x0000216f, 0x0000216f,
+	0x00002184, 0x00002183, 0x00002183,
+	0x000024d0, 0x000024b6, 0x000024b6,
+	0x000024d1, 0x000024b7, 0x000024b7,
+	0x000024d2, 0x000024b8, 0x000024b8,
+	0x000024d3, 0x000024b9, 0x000024b9,
+	0x000024d4, 0x000024ba, 0x000024ba,
+	0x000024d5, 0x000024bb, 0x000024bb,
+	0x000024d6, 0x000024bc, 0x000024bc,
+	0x000024d7, 0x000024bd, 0x000024bd,
+	0x000024d8, 0x000024be, 0x000024be,
+	0x000024d9, 0x000024bf, 0x000024bf,
+	0x000024da, 0x000024c0, 0x000024c0,
+	0x000024db, 0x000024c1, 0x000024c1,
+	0x000024dc, 0x000024c2, 0x000024c2,
+	0x000024dd, 0x000024c3, 0x000024c3,
+	0x000024de, 0x000024c4, 0x000024c4,
+	0x000024df, 0x000024c5, 0x000024c5,
+	0x000024e0, 0x000024c6, 0x000024c6,
+	0x000024e1, 0x000024c7, 0x000024c7,
+	0x000024e2, 0x000024c8, 0x000024c8,
+	0x000024e3, 0x000024c9, 0x000024c9,
+	0x000024e4, 0x000024ca, 0x000024ca,
+	0x000024e5, 0x000024cb, 0x000024cb,
+	0x000024e6, 0x000024cc, 0x000024cc,
+	0x000024e7, 0x000024cd, 0x000024cd,
+	0x000024e8, 0x000024ce, 0x000024ce,
+	0x000024e9, 0x000024cf, 0x000024cf,
+	0x00002c30, 0x00002c00, 0x00002c00,
+	0x00002c31, 0x00002c01, 0x00002c01,
+	0x00002c32, 0x00002c02, 0x00002c02,
+	0x00002c33, 0x00002c03, 0x00002c03,
+	0x00002c34, 0x00002c04, 0x00002c04,
+	0x00002c35, 0x00002c05, 0x00002c05,
+	0x00002c36, 0x00002c06, 0x00002c06,
+	0x00002c37, 0x00002c07, 0x00002c07,
+	0x00002c38, 0x00002c08, 0x00002c08,
+	0x00002c39, 0x00002c09, 0x00002c09,
+	0x00002c3a, 0x00002c0a, 0x00002c0a,
+	0x00002c3b, 0x00002c0b, 0x00002c0b,
+	0x00002c3c, 0x00002c0c, 0x00002c0c,
+	0x00002c3d, 0x00002c0d, 0x00002c0d,
+	0x00002c3e, 0x00002c0e, 0x00002c0e,
+	0x00002c3f, 0x00002c0f, 0x00002c0f,
+	0x00002c40, 0x00002c10, 0x00002c10,
+	0x00002c41, 0x00002c11, 0x00002c11,
+	0x00002c42, 0x00002c12, 0x00002c12,
+	0x00002c43, 0x00002c13, 0x00002c13,
+	0x00002c44, 0x00002c14, 0x00002c14,
+	0x00002c45, 0x00002c15, 0x00002c15,
+	0x00002c46, 0x00002c16, 0x00002c16,
+	0x00002c47, 0x00002c17, 0x00002c17,
+	0x00002c48, 0x00002c18, 0x00002c18,
+	0x00002c49, 0x00002c19, 0x00002c19,
+	0x00002c4a, 0x00002c1a, 0x00002c1a,
+	0x00002c4b, 0x00002c1b, 0x00002c1b,
+	0x00002c4c, 0x00002c1c, 0x00002c1c,
+	0x00002c4d, 0x00002c1d, 0x00002c1d,
+	0x00002c4e, 0x00002c1e, 0x00002c1e,
+	0x00002c4f, 0x00002c1f, 0x00002c1f,
+	0x00002c50, 0x00002c20, 0x00002c20,
+	0x00002c51, 0x00002c21, 0x00002c21,
+	0x00002c52, 0x00002c22, 0x00002c22,
+	0x00002c53, 0x00002c23, 0x00002c23,
+	0x00002c54, 0x00002c24, 0x00002c24,
+	0x00002c55, 0x00002c25, 0x00002c25,
+	0x00002c56, 0x00002c26, 0x00002c26,
+	0x00002c57, 0x00002c27, 0x00002c27,
+	0x00002c58, 0x00002c28, 0x00002c28,
+	0x00002c59, 0x00002c29, 0x00002c29,
+	0x00002c5a, 0x00002c2a, 0x00002c2a,
+	0x00002c5b, 0x00002c2b, 0x00002c2b,
+	0x00002c5c, 0x00002c2c, 0x00002c2c,
+	0x00002c5d, 0x00002c2d, 0x00002c2d,
+	0x00002c5e, 0x00002c2e, 0x00002c2e,
+	0x00002c61, 0x00002c60, 0x00002c60,
+	0x00002c65, 0x0000023a, 0x0000023a,
+	0x00002c66, 0x0000023e, 0x0000023e,
+	0x00002c68, 0x00002c67, 0x00002c67,
+	0x00002c6a, 0x00002c69, 0x00002c69,
+	0x00002c6c, 0x00002c6b, 0x00002c6b,
+	0x00002c73, 0x00002c72, 0x00002c72,
+	0x00002c76, 0x00002c75, 0x00002c75,
+	0x00002c81, 0x00002c80, 0x00002c80,
+	0x00002c83, 0x00002c82, 0x00002c82,
+	0x00002c85, 0x00002c84, 0x00002c84,
+	0x00002c87, 0x00002c86, 0x00002c86,
+	0x00002c89, 0x00002c88, 0x00002c88,
+	0x00002c8b, 0x00002c8a, 0x00002c8a,
+	0x00002c8d, 0x00002c8c, 0x00002c8c,
+	0x00002c8f, 0x00002c8e, 0x00002c8e,
+	0x00002c91, 0x00002c90, 0x00002c90,
+	0x00002c93, 0x00002c92, 0x00002c92,
+	0x00002c95, 0x00002c94, 0x00002c94,
+	0x00002c97, 0x00002c96, 0x00002c96,
+	0x00002c99, 0x00002c98, 0x00002c98,
+	0x00002c9b, 0x00002c9a, 0x00002c9a,
+	0x00002c9d, 0x00002c9c, 0x00002c9c,
+	0x00002c9f, 0x00002c9e, 0x00002c9e,
+	0x00002ca1, 0x00002ca0, 0x00002ca0,
+	0x00002ca3, 0x00002ca2, 0x00002ca2,
+	0x00002ca5, 0x00002ca4, 0x00002ca4,
+	0x00002ca7, 0x00002ca6, 0x00002ca6,
+	0x00002ca9, 0x00002ca8, 0x00002ca8,
+	0x00002cab, 0x00002caa, 0x00002caa,
+	0x00002cad, 0x00002cac, 0x00002cac,
+	0x00002caf, 0x00002cae, 0x00002cae,
+	0x00002cb1, 0x00002cb0, 0x00002cb0,
+	0x00002cb3, 0x00002cb2, 0x00002cb2,
+	0x00002cb5, 0x00002cb4, 0x00002cb4,
+	0x00002cb7, 0x00002cb6, 0x00002cb6,
+	0x00002cb9, 0x00002cb8, 0x00002cb8,
+	0x00002cbb, 0x00002cba, 0x00002cba,
+	0x00002cbd, 0x00002cbc, 0x00002cbc,
+	0x00002cbf, 0x00002cbe, 0x00002cbe,
+	0x00002cc1, 0x00002cc0, 0x00002cc0,
+	0x00002cc3, 0x00002cc2, 0x00002cc2,
+	0x00002cc5, 0x00002cc4, 0x00002cc4,
+	0x00002cc7, 0x00002cc6, 0x00002cc6,
+	0x00002cc9, 0x00002cc8, 0x00002cc8,
+	0x00002ccb, 0x00002cca, 0x00002cca,
+	0x00002ccd, 0x00002ccc, 0x00002ccc,
+	0x00002ccf, 0x00002cce, 0x00002cce,
+	0x00002cd1, 0x00002cd0, 0x00002cd0,
+	0x00002cd3, 0x00002cd2, 0x00002cd2,
+	0x00002cd5, 0x00002cd4, 0x00002cd4,
+	0x00002cd7, 0x00002cd6, 0x00002cd6,
+	0x00002cd9, 0x00002cd8, 0x00002cd8,
+	0x00002cdb, 0x00002cda, 0x00002cda,
+	0x00002cdd, 0x00002cdc, 0x00002cdc,
+	0x00002cdf, 0x00002cde, 0x00002cde,
+	0x00002ce1, 0x00002ce0, 0x00002ce0,
+	0x00002ce3, 0x00002ce2, 0x00002ce2,
+	0x00002cec, 0x00002ceb, 0x00002ceb,
+	0x00002cee, 0x00002ced, 0x00002ced,
+	0x00002d00, 0x000010a0, 0x000010a0,
+	0x00002d01, 0x000010a1, 0x000010a1,
+	0x00002d02, 0x000010a2, 0x000010a2,
+	0x00002d03, 0x000010a3, 0x000010a3,
+	0x00002d04, 0x000010a4, 0x000010a4,
+	0x00002d05, 0x000010a5, 0x000010a5,
+	0x00002d06, 0x000010a6, 0x000010a6,
+	0x00002d07, 0x000010a7, 0x000010a7,
+	0x00002d08, 0x000010a8, 0x000010a8,
+	0x00002d09, 0x000010a9, 0x000010a9,
+	0x00002d0a, 0x000010aa, 0x000010aa,
+	0x00002d0b, 0x000010ab, 0x000010ab,
+	0x00002d0c, 0x000010ac, 0x000010ac,
+	0x00002d0d, 0x000010ad, 0x000010ad,
+	0x00002d0e, 0x000010ae, 0x000010ae,
+	0x00002d0f, 0x000010af, 0x000010af,
+	0x00002d10, 0x000010b0, 0x000010b0,
+	0x00002d11, 0x000010b1, 0x000010b1,
+	0x00002d12, 0x000010b2, 0x000010b2,
+	0x00002d13, 0x000010b3, 0x000010b3,
+	0x00002d14, 0x000010b4, 0x000010b4,
+	0x00002d15, 0x000010b5, 0x000010b5,
+	0x00002d16, 0x000010b6, 0x000010b6,
+	0x00002d17, 0x000010b7, 0x000010b7,
+	0x00002d18, 0x000010b8, 0x000010b8,
+	0x00002d19, 0x000010b9, 0x000010b9,
+	0x00002d1a, 0x000010ba, 0x000010ba,
+	0x00002d1b, 0x000010bb, 0x000010bb,
+	0x00002d1c, 0x000010bc, 0x000010bc,
+	0x00002d1d, 0x000010bd, 0x000010bd,
+	0x00002d1e, 0x000010be, 0x000010be,
+	0x00002d1f, 0x000010bf, 0x000010bf,
+	0x00002d20, 0x000010c0, 0x000010c0,
+	0x00002d21, 0x000010c1, 0x000010c1,
+	0x00002d22, 0x000010c2, 0x000010c2,
+	0x00002d23, 0x000010c3, 0x000010c3,
+	0x00002d24, 0x000010c4, 0x000010c4,
+	0x00002d25, 0x000010c5, 0x000010c5,
+	0x0000a641, 0x0000a640, 0x0000a640,
+	0x0000a643, 0x0000a642, 0x0000a642,
+	0x0000a645, 0x0000a644, 0x0000a644,
+	0x0000a647, 0x0000a646, 0x0000a646,
+	0x0000a649, 0x0000a648, 0x0000a648,
+	0x0000a64b, 0x0000a64a, 0x0000a64a,
+	0x0000a64d, 0x0000a64c, 0x0000a64c,
+	0x0000a64f, 0x0000a64e, 0x0000a64e,
+	0x0000a651, 0x0000a650, 0x0000a650,
+	0x0000a653, 0x0000a652, 0x0000a652,
+	0x0000a655, 0x0000a654, 0x0000a654,
+	0x0000a657, 0x0000a656, 0x0000a656,
+	0x0000a659, 0x0000a658, 0x0000a658,
+	0x0000a65b, 0x0000a65a, 0x0000a65a,
+	0x0000a65d, 0x0000a65c, 0x0000a65c,
+	0x0000a65f, 0x0000a65e, 0x0000a65e,
+	0x0000a661, 0x0000a660, 0x0000a660,
+	0x0000a663, 0x0000a662, 0x0000a662,
+	0x0000a665, 0x0000a664, 0x0000a664,
+	0x0000a667, 0x0000a666, 0x0000a666,
+	0x0000a669, 0x0000a668, 0x0000a668,
+	0x0000a66b, 0x0000a66a, 0x0000a66a,
+	0x0000a66d, 0x0000a66c, 0x0000a66c,
+	0x0000a681, 0x0000a680, 0x0000a680,
+	0x0000a683, 0x0000a682, 0x0000a682,
+	0x0000a685, 0x0000a684, 0x0000a684,
+	0x0000a687, 0x0000a686, 0x0000a686,
+	0x0000a689, 0x0000a688, 0x0000a688,
+	0x0000a68b, 0x0000a68a, 0x0000a68a,
+	0x0000a68d, 0x0000a68c, 0x0000a68c,
+	0x0000a68f, 0x0000a68e, 0x0000a68e,
+	0x0000a691, 0x0000a690, 0x0000a690,
+	0x0000a693, 0x0000a692, 0x0000a692,
+	0x0000a695, 0x0000a694, 0x0000a694,
+	0x0000a697, 0x0000a696, 0x0000a696,
+	0x0000a723, 0x0000a722, 0x0000a722,
+	0x0000a725, 0x0000a724, 0x0000a724,
+	0x0000a727, 0x0000a726, 0x0000a726,
+	0x0000a729, 0x0000a728, 0x0000a728,
+	0x0000a72b, 0x0000a72a, 0x0000a72a,
+	0x0000a72d, 0x0000a72c, 0x0000a72c,
+	0x0000a72f, 0x0000a72e, 0x0000a72e,
+	0x0000a733, 0x0000a732, 0x0000a732,
+	0x0000a735, 0x0000a734, 0x0000a734,
+	0x0000a737, 0x0000a736, 0x0000a736,
+	0x0000a739, 0x0000a738, 0x0000a738,
+	0x0000a73b, 0x0000a73a, 0x0000a73a,
+	0x0000a73d, 0x0000a73c, 0x0000a73c,
+	0x0000a73f, 0x0000a73e, 0x0000a73e,
+	0x0000a741, 0x0000a740, 0x0000a740,
+	0x0000a743, 0x0000a742, 0x0000a742,
+	0x0000a745, 0x0000a744, 0x0000a744,
+	0x0000a747, 0x0000a746, 0x0000a746,
+	0x0000a749, 0x0000a748, 0x0000a748,
+	0x0000a74b, 0x0000a74a, 0x0000a74a,
+	0x0000a74d, 0x0000a74c, 0x0000a74c,
+	0x0000a74f, 0x0000a74e, 0x0000a74e,
+	0x0000a751, 0x0000a750, 0x0000a750,
+	0x0000a753, 0x0000a752, 0x0000a752,
+	0x0000a755, 0x0000a754, 0x0000a754,
+	0x0000a757, 0x0000a756, 0x0000a756,
+	0x0000a759, 0x0000a758, 0x0000a758,
+	0x0000a75b, 0x0000a75a, 0x0000a75a,
+	0x0000a75d, 0x0000a75c, 0x0000a75c,
+	0x0000a75f, 0x0000a75e, 0x0000a75e,
+	0x0000a761, 0x0000a760, 0x0000a760,
+	0x0000a763, 0x0000a762, 0x0000a762,
+	0x0000a765, 0x0000a764, 0x0000a764,
+	0x0000a767, 0x0000a766, 0x0000a766,
+	0x0000a769, 0x0000a768, 0x0000a768,
+	0x0000a76b, 0x0000a76a, 0x0000a76a,
+	0x0000a76d, 0x0000a76c, 0x0000a76c,
+	0x0000a76f, 0x0000a76e, 0x0000a76e,
+	0x0000a77a, 0x0000a779, 0x0000a779,
+	0x0000a77c, 0x0000a77b, 0x0000a77b,
+	0x0000a77f, 0x0000a77e, 0x0000a77e,
+	0x0000a781, 0x0000a780, 0x0000a780,
+	0x0000a783, 0x0000a782, 0x0000a782,
+	0x0000a785, 0x0000a784, 0x0000a784,
+	0x0000a787, 0x0000a786, 0x0000a786,
+	0x0000a78c, 0x0000a78b, 0x0000a78b,
+	0x0000a791, 0x0000a790, 0x0000a790,
+	0x0000a7a1, 0x0000a7a0, 0x0000a7a0,
+	0x0000a7a3, 0x0000a7a2, 0x0000a7a2,
+	0x0000a7a5, 0x0000a7a4, 0x0000a7a4,
+	0x0000a7a7, 0x0000a7a6, 0x0000a7a6,
+	0x0000a7a9, 0x0000a7a8, 0x0000a7a8,
+	0x0000ff41, 0x0000ff21, 0x0000ff21,
+	0x0000ff42, 0x0000ff22, 0x0000ff22,
+	0x0000ff43, 0x0000ff23, 0x0000ff23,
+	0x0000ff44, 0x0000ff24, 0x0000ff24,
+	0x0000ff45, 0x0000ff25, 0x0000ff25,
+	0x0000ff46, 0x0000ff26, 0x0000ff26,
+	0x0000ff47, 0x0000ff27, 0x0000ff27,
+	0x0000ff48, 0x0000ff28, 0x0000ff28,
+	0x0000ff49, 0x0000ff29, 0x0000ff29,
+	0x0000ff4a, 0x0000ff2a, 0x0000ff2a,
+	0x0000ff4b, 0x0000ff2b, 0x0000ff2b,
+	0x0000ff4c, 0x0000ff2c, 0x0000ff2c,
+	0x0000ff4d, 0x0000ff2d, 0x0000ff2d,
+	0x0000ff4e, 0x0000ff2e, 0x0000ff2e,
+	0x0000ff4f, 0x0000ff2f, 0x0000ff2f,
+	0x0000ff50, 0x0000ff30, 0x0000ff30,
+	0x0000ff51, 0x0000ff31, 0x0000ff31,
+	0x0000ff52, 0x0000ff32, 0x0000ff32,
+	0x0000ff53, 0x0000ff33, 0x0000ff33,
+	0x0000ff54, 0x0000ff34, 0x0000ff34,
+	0x0000ff55, 0x0000ff35, 0x0000ff35,
+	0x0000ff56, 0x0000ff36, 0x0000ff36,
+	0x0000ff57, 0x0000ff37, 0x0000ff37,
+	0x0000ff58, 0x0000ff38, 0x0000ff38,
+	0x0000ff59, 0x0000ff39, 0x0000ff39,
+	0x0000ff5a, 0x0000ff3a, 0x0000ff3a,
+	0x00010428, 0x00010400, 0x00010400,
+	0x00010429, 0x00010401, 0x00010401,
+	0x0001042a, 0x00010402, 0x00010402,
+	0x0001042b, 0x00010403, 0x00010403,
+	0x0001042c, 0x00010404, 0x00010404,
+	0x0001042d, 0x00010405, 0x00010405,
+	0x0001042e, 0x00010406, 0x00010406,
+	0x0001042f, 0x00010407, 0x00010407,
+	0x00010430, 0x00010408, 0x00010408,
+	0x00010431, 0x00010409, 0x00010409,
+	0x00010432, 0x0001040a, 0x0001040a,
+	0x00010433, 0x0001040b, 0x0001040b,
+	0x00010434, 0x0001040c, 0x0001040c,
+	0x00010435, 0x0001040d, 0x0001040d,
+	0x00010436, 0x0001040e, 0x0001040e,
+	0x00010437, 0x0001040f, 0x0001040f,
+	0x00010438, 0x00010410, 0x00010410,
+	0x00010439, 0x00010411, 0x00010411,
+	0x0001043a, 0x00010412, 0x00010412,
+	0x0001043b, 0x00010413, 0x00010413,
+	0x0001043c, 0x00010414, 0x00010414,
+	0x0001043d, 0x00010415, 0x00010415,
+	0x0001043e, 0x00010416, 0x00010416,
+	0x0001043f, 0x00010417, 0x00010417,
+	0x00010440, 0x00010418, 0x00010418,
+	0x00010441, 0x00010419, 0x00010419,
+	0x00010442, 0x0001041a, 0x0001041a,
+	0x00010443, 0x0001041b, 0x0001041b,
+	0x00010444, 0x0001041c, 0x0001041c,
+	0x00010445, 0x0001041d, 0x0001041d,
+	0x00010446, 0x0001041e, 0x0001041e,
+	0x00010447, 0x0001041f, 0x0001041f,
+	0x00010448, 0x00010420, 0x00010420,
+	0x00010449, 0x00010421, 0x00010421,
+	0x0001044a, 0x00010422, 0x00010422,
+	0x0001044b, 0x00010423, 0x00010423,
+	0x0001044c, 0x00010424, 0x00010424,
+	0x0001044d, 0x00010425, 0x00010425,
+	0x0001044e, 0x00010426, 0x00010426,
+	0x0001044f, 0x00010427, 0x00010427,
+	0x000001c5, 0x000001c4, 0x000001c6,
+	0x000001c8, 0x000001c7, 0x000001c9,
+	0x000001cb, 0x000001ca, 0x000001cc,
+	0x000001f2, 0x000001f1, 0x000001f3
 };
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index 18dad71..5fb2699 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mssql.c 298255 2010-04-21 14:19:27Z felipe $ */
+/* $Id: php_mssql.c 303375 2010-09-15 02:12:46Z felipe $ */
 
 #ifdef COMPILE_DL_MSSQL
 #define HAVE_MSSQL 1
@@ -539,7 +539,7 @@ PHP_MINFO_FUNCTION(mssql)
 static void php_mssql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 {
 	char *host = NULL, *user = NULL, *passwd = NULL;
-	int host_len, user_len, passwd_len;
+	int host_len = 0, user_len = 0, passwd_len = 0;
 	zend_bool new_link = 0;
 	char *hashed_details;
 	int hashed_details_length;
@@ -1059,6 +1059,14 @@ static void php_mssql_get_column_content_without_type(mssql_link *mssql_ptr,int
 		unsigned char *res_buf;
 		int res_length = dbdatlen(mssql_ptr->link, offset);
 
+		if (res_length == 0) {
+			ZVAL_NULL(result);
+			return;
+		} else if (res_length < 0) {
+			ZVAL_FALSE(result);
+			return;
+		}
+
 		res_buf = (unsigned char *) emalloc(res_length+1);
 		bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
 		res_buf[res_length] = '\0';
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index d8b67a4..d63cd15 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -17,8 +17,8 @@
    |          Georg Richter <georg at php.net>                               |
    +----------------------------------------------------------------------+
 */
- 
-/* $Id: php_mysql.c 300792 2010-06-28 01:19:08Z felipe $ */
+
+/* $Id: php_mysql.c 304071 2010-10-05 09:48:07Z kalle $ */
 
 /* TODO:
  *
@@ -130,7 +130,7 @@ typedef struct _php_mysql_conn {
 #define MYSQL_DISABLE_MQ if (mysql->multi_query) { \
 	mysql_set_server_option(mysql->conn, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
 	mysql->multi_query = 0; \
-} 
+}
 #else
 #define MYSQL_DISABLE_MQ
 #endif
@@ -251,7 +251,7 @@ static const zend_function_entry mysql_functions[] = {
 #endif	/* NETWARE */
 	PHP_FE(mysql_query,									arginfo_mysql_query)
 	PHP_FE(mysql_unbuffered_query,						arginfo_mysql_query)
-	PHP_FE(mysql_db_query,								arginfo_mysql_db_query)
+	PHP_DEP_FE(mysql_db_query,							arginfo_mysql_db_query)
 	PHP_FE(mysql_list_dbs,								arginfo__optional_mysql_link)
 	PHP_DEP_FE(mysql_list_tables,						arginfo_mysql_select_db)
 	PHP_FE(mysql_list_fields,							arginfo_mysql_list_fields)
@@ -295,7 +295,7 @@ static const zend_function_entry mysql_functions[] = {
 	PHP_FE(mysql_info,									arginfo__optional_mysql_link)
 #ifdef MYSQL_HAS_SET_CHARSET
 	PHP_FE(mysql_set_charset,							arginfo_mysql_set_charset)
-#endif	 
+#endif
 	/* for downwards compatability */
 	PHP_FALIAS(mysql,				mysql_db_query,		arginfo_mysql_db_query)
 	PHP_FALIAS(mysql_fieldname,		mysql_field_name,	arginfo_mysql_field_name)
@@ -450,7 +450,7 @@ static int php_mysql_select_db(php_mysql_conn *mysql, char *db TSRMLS_DC)
 static void _close_mysql_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
 	php_mysql_conn *link = (php_mysql_conn *)rsrc->ptr;
-	void (*handler) (int); 
+	void (*handler) (int);
 
 	handler = signal(SIGPIPE, SIG_IGN);
 	mysql_close(link->conn);
@@ -543,11 +543,11 @@ ZEND_MODULE_STARTUP_D(mysql)
 	REGISTER_LONG_CONSTANT("MYSQL_NUM", MYSQL_NUM, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQL_BOTH", MYSQL_BOTH, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_COMPRESS", CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT);
-#if MYSQL_VERSION_ID >= 40000	
+#if MYSQL_VERSION_ID >= 40000
 	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT);
 #endif
 	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT); 
+	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
 
 #ifndef MYSQL_USE_MYSQLND
 #if MYSQL_VERSION_ID >= 40000
@@ -637,7 +637,7 @@ PHP_RSHUTDOWN_FUNCTION(mysql)
 		efree(MySG(connect_error));
 	}
 
-#ifdef MYSQL_USE_MYSQLND
+#if defined(A0) && MYSQL_USE_MYSQLND
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysql_persistent_helper TSRMLS_CC);
 #endif
 
@@ -717,7 +717,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #if !defined(PHP_WIN32) && !defined(NETWARE)
 		struct servent *serv_ptr;
 		char *env;
-		
+
 		MySG(default_port) = MYSQL_PORT;
 		if ((serv_ptr = getservbyname("mysql", "tcp"))) {
 			MySG(default_port) = (uint) ntohs((ushort) serv_ptr->s_port);
@@ -729,7 +729,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 		MySG(default_port) = MYSQL_PORT;
 #endif
 	}
-	
+
 	if (PG(sql_safe_mode)) {
 		if (ZEND_NUM_ARGS()>0) {
 			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
@@ -748,7 +748,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
         	}
 		} else {
 			if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!bl", &host_and_port, &host_len,
-										&user, &user_len, &passwd, &passwd_len, 
+										&user, &user_len, &passwd, &passwd_len,
 										&new_link, &client_flags)==FAILURE) {
 				return;
 			}
@@ -835,7 +835,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #else
 			mysql->multi_query = 0;
 #endif
-			
+
 #ifndef MYSQL_USE_MYSQLND
 			mysql->conn = mysql_init(NULL);
 #else
@@ -888,9 +888,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 			mysql->multi_query = 0;
 #endif
 			/* ensure that the link did not die */
-#if defined(MYSQL_USE_MYSQLND)
+#if defined(A0) && MYSQL_USE_MYSQLND
 			mysqlnd_end_psession(mysql->conn);
-#endif	
+#endif
 			if (mysql_ping(mysql->conn)) {
 				if (mysql_errno(mysql->conn) == 2006) {
 #ifndef MYSQL_USE_MYSQLND
@@ -915,7 +915,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 		ZEND_REGISTER_RESOURCE(return_value, mysql, le_plink);
 	} else { /* non persistent */
 		zend_rsrc_list_entry *index_ptr, new_index_ptr;
-		
+
 		/* first we check the hash for the hashed_details key.  if it exists,
 		 * it should point us to the right offset where the actual mysql link sits.
 		 * if it doesn't, open a new mysql link, add it to the resource list,
@@ -973,7 +973,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 		}
 
 #ifndef MYSQL_USE_MYSQLND
-		if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) 
+		if (mysql_real_connect(mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL)
 #else
 		if (mysqlnd_connect(mysql->conn, host, user, passwd, 0, NULL, 0, port, socket, client_flags TSRMLS_CC) == NULL)
 #endif
@@ -1074,7 +1074,7 @@ PHP_FUNCTION(mysql_close)
 #endif
 	zend_list_delete(resource_id);
 
-	if (!mysql_link 
+	if (!mysql_link
 		|| (mysql_link && Z_RESVAL_P(mysql_link)==MySG(default_link))) {
 		MySG(default_link) = -1;
 		if (mysql_link) {
@@ -1096,7 +1096,7 @@ PHP_FUNCTION(mysql_select_db)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &db, &db_len, &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1107,11 +1107,11 @@ PHP_FUNCTION(mysql_select_db)
 	}
 
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
-	
+
 	if (php_mysql_select_db(mysql, db TSRMLS_CC)) {
 		RETURN_TRUE;
 	} else {
-		RETURN_FALSE;	
+		RETURN_FALSE;
 	}
 }
 /* }}} */
@@ -1126,7 +1126,7 @@ PHP_FUNCTION(mysql_get_client_info)
 		return;
 	}
 
-	RETURN_STRING((char *)mysql_get_client_info(),1);	
+	RETURN_STRING((char *)mysql_get_client_info(),1);
 }
 /* }}} */
 
@@ -1241,7 +1241,7 @@ PHP_FUNCTION(mysql_thread_id)
 
 	if (ZEND_NUM_ARGS() == 0) {
 		id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-		CHECK_LINK(id);		
+		CHECK_LINK(id);
 	}
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
 
@@ -1267,7 +1267,7 @@ PHP_FUNCTION(mysql_stat)
 
 	if (ZEND_NUM_ARGS() == 0) {
 		id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-		CHECK_LINK(id);		
+		CHECK_LINK(id);
 	}
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
 
@@ -1380,7 +1380,7 @@ PHP_FUNCTION(mysql_drop_db)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &db, &db_len, &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1408,9 +1408,9 @@ static void php_mysql_do_query_general(char *query, int query_len, zval *mysql_l
 {
 	php_mysql_conn *mysql;
 	MYSQL_RES *mysql_result;
-	
+
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, link_id, "MySQL-Link", le_link, le_plink);
-	
+
 	if (db) {
 		if (!php_mysql_select_db(mysql, db TSRMLS_CC)) {
 			RETURN_FALSE;
@@ -1426,7 +1426,7 @@ static void php_mysql_do_query_general(char *query, int query_len, zval *mysql_l
 	if (MySG(trace_mode)) {
 		if (!strncasecmp("select", query, 6)){
 			MYSQL_ROW 	row;
-			
+
 			char *newquery;
 			int newql = spprintf (&newquery, 0, "EXPLAIN %s", query);
 			mysql_real_query(mysql->conn, newquery, newql);
@@ -1446,7 +1446,7 @@ static void php_mysql_do_query_general(char *query, int query_len, zval *mysql_l
 				}
 				mysql_free_result(mysql_result);
 			}
-		}	
+		}
 	} /* end explain */
 #endif
 
@@ -1456,7 +1456,7 @@ static void php_mysql_do_query_general(char *query, int query_len, zval *mysql_l
 		/* check possible error */
 		if (MySG(trace_mode)){
 			if (mysql_errno(mysql->conn)){
-				php_error_docref("http://www.mysql.com/doc" TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->conn)); 
+				php_error_docref("http://www.mysql.com/doc" TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->conn));
 			}
 		}
 		RETURN_FALSE;
@@ -1466,7 +1466,7 @@ static void php_mysql_do_query_general(char *query, int query_len, zval *mysql_l
 		/* check possible error */
 		if (MySG(trace_mode)){
 			if (mysql_errno(mysql->conn)){
-				php_error_docref("http://www.mysql.com/doc" TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->conn)); 
+				php_error_docref("http://www.mysql.com/doc" TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->conn));
 			}
 		}
 		RETURN_FALSE;
@@ -1501,7 +1501,7 @@ static void php_mysql_do_query(INTERNAL_FUNCTION_PARAMETERS, int use_store)
 	int query_len;
 	zval *mysql_link = NULL;
 	int id = -1;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &query, &query_len, &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1552,7 +1552,7 @@ PHP_FUNCTION(mysql_db_query)
 	}
 
 	php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "This function is deprecated; use mysql_query() instead");
-	
+
 	php_mysql_do_query_general(query, query_len, mysql_link, id, db, MYSQL_STORE_RESULT, return_value TSRMLS_CC);
 }
 /* }}} */
@@ -1599,7 +1599,7 @@ PHP_FUNCTION(mysql_list_tables)
 	int id = -1;
 	php_mysql_conn *mysql;
 	MYSQL_RES *mysql_result;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &db, &db_len, &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1702,7 +1702,7 @@ PHP_FUNCTION(mysql_error)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1717,9 +1717,9 @@ PHP_FUNCTION(mysql_error)
 			}
 		}
 	}
-	
+
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
-	
+
 	RETURN_STRING((char *)mysql_error(mysql->conn), 1);
 }
 /* }}} */
@@ -1733,11 +1733,11 @@ PHP_FUNCTION(mysql_errno)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
 		return;
 	}
-	
+
 	if (!mysql_link) {
 		id = MySG(default_link);
 		if (id==-1) {
@@ -1748,9 +1748,9 @@ PHP_FUNCTION(mysql_errno)
 			}
 		}
 	}
-	
+
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
-	
+
 	RETURN_LONG(mysql_errno(mysql->conn));
 }
 #endif
@@ -1764,7 +1764,7 @@ PHP_FUNCTION(mysql_affected_rows)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1775,7 +1775,7 @@ PHP_FUNCTION(mysql_affected_rows)
 	}
 
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
-	
+
 	/* conversion from int64 to long happing here */
 	Z_LVAL_P(return_value) = (long) mysql_affected_rows(mysql->conn);
 	Z_TYPE_P(return_value) = IS_LONG;
@@ -1846,7 +1846,7 @@ PHP_FUNCTION(mysql_insert_id)
 	zval *mysql_link = NULL;
 	int id = -1;
 	php_mysql_conn *mysql;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
 		return;
 	}
@@ -1857,7 +1857,7 @@ PHP_FUNCTION(mysql_insert_id)
 	}
 
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
-	
+
 	/* conversion from int64 to long happing here */
 	Z_LVAL_P(return_value) = (long) mysql_insert_id(mysql->conn);
 	Z_TYPE_P(return_value) = IS_LONG;
@@ -1886,15 +1886,15 @@ Q: String or long first?
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &result, &row, &field) == FAILURE) {
 		return;
 	}
-	
+
 	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_LVAL_P(result));
 		RETURN_FALSE;
 	}
 	mysql_data_seek(mysql_result, row);
-	
+
 	if (field) {
 		switch(Z_TYPE_P(field)) {
 			case IS_STRING: {
@@ -1944,7 +1944,7 @@ Q: String or long first?
 	}
 
 #ifndef MYSQL_USE_MYSQLND
-	if ((sql_row=mysql_fetch_row(mysql_result))==NULL 
+	if ((sql_row=mysql_fetch_row(mysql_result))==NULL
 		|| (sql_row_lengths=mysql_fetch_lengths(mysql_result))==NULL) { /* shouldn't happen? */
 		RETURN_FALSE;
 	}
@@ -1953,7 +1953,7 @@ Q: String or long first?
 
 		if (PG(magic_quotes_runtime)) {
 			Z_STRVAL_P(return_value) = php_addslashes(sql_row[field_offset], sql_row_lengths[field_offset],&Z_STRLEN_P(return_value), 0 TSRMLS_CC);
-		} else {	
+		} else {
 			Z_STRLEN_P(return_value) = sql_row_lengths[field_offset];
 			Z_STRVAL_P(return_value) = (char *) safe_estrndup(sql_row[field_offset], Z_STRLEN_P(return_value));
 		}
@@ -1973,13 +1973,13 @@ PHP_FUNCTION(mysql_num_rows)
 {
 	zval *result;
 	MYSQL_RES *mysql_result;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &result) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
-	
+
 	/* conversion from int64 to long happing here */
 	Z_LVAL_P(return_value) = (long) mysql_num_rows(mysql_result);
 	Z_TYPE_P(return_value) = IS_LONG;
@@ -1992,13 +1992,13 @@ PHP_FUNCTION(mysql_num_fields)
 {
 	zval *result;
 	MYSQL_RES *mysql_result;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &result) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
-	
+
 	Z_LVAL_P(return_value) = mysql_num_fields(mysql_result);
 	Z_TYPE_P(return_value) = IS_LONG;
 }
@@ -2006,7 +2006,7 @@ PHP_FUNCTION(mysql_num_fields)
 
 /* {{{ php_mysql_fetch_hash
  */
-static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, int expected_args, int into_object)
+static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int expected_args, int into_object)
 {
 	MYSQL_RES *mysql_result;
 	zval            *res, *ctor_params = NULL;
@@ -2053,7 +2053,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
 		result_type = MYSQL_BOTH;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &res, -1, "MySQL result", le_result);
 
 #ifndef MYSQL_USE_MYSQLND
@@ -2063,7 +2063,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 	}
 
 	array_init(return_value);
-	
+
 	mysql_field_seek(mysql_result, 0);
 	for (mysql_field = mysql_fetch_field(mysql_result), i = 0;
 		 mysql_field;
@@ -2111,11 +2111,11 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 		zval dataset = *return_value;
 		zend_fcall_info fci;
 		zend_fcall_info_cache fcc;
-		zval *retval_ptr; 
-	
+		zval *retval_ptr;
+
 		object_and_properties_init(return_value, ce, NULL);
 		zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC);
-	
+
 		if (ce->constructor) {
 			fci.size = sizeof(fci);
 			fci.function_table = &ce->function_table;
@@ -2127,7 +2127,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 				if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
 					HashTable *ht = Z_ARRVAL_P(ctor_params);
 					Bucket *p;
-	
+
 					fci.param_count = 0;
 					fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
 					p = ht->pListHead;
@@ -2138,7 +2138,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 				} else {
 					/* Two problems why we throw exceptions here: PHP is typeless
 					 * and hence passing one argument that's not an array could be
-					 * by mistake and the other way round is possible, too. The 
+					 * by mistake and the other way round is possible, too. The
 					 * single value is an array. Also we'd have to make that one
 					 * argument passed by reference.
 					 */
@@ -2156,7 +2156,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
 			fcc.calling_scope = EG(scope);
 			fcc.called_scope = Z_OBJCE_P(return_value);
 			fcc.object_ptr = return_value;
-		
+
 			if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
 				zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name, ce->constructor->common.function_name);
 			} else {
@@ -2222,11 +2222,11 @@ PHP_FUNCTION(mysql_data_seek)
 	zval *result;
 	long offset;
 	MYSQL_RES *mysql_result;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset)) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
 
 	if (offset<0 || offset>=(int)mysql_num_rows(mysql_result)) {
@@ -2250,9 +2250,9 @@ PHP_FUNCTION(mysql_fetch_lengths)
 	int i;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &result) == FAILURE) {
-		return;	
+		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
 
 	if ((lengths=mysql_fetch_lengths(mysql_result))==NULL) {
@@ -2260,7 +2260,7 @@ PHP_FUNCTION(mysql_fetch_lengths)
 	}
 	array_init(return_value);
 	num_fields = mysql_num_fields(mysql_result);
-	
+
 	for (i=0; i<num_fields; i++) {
 		add_index_long(return_value, i, lengths[i]);
 	}
@@ -2351,11 +2351,11 @@ PHP_FUNCTION(mysql_fetch_field)
 	long field=0;
 	MYSQL_RES *mysql_result;
 	const MYSQL_FIELD *mysql_field;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &result, &field) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
 
 	if (ZEND_NUM_ARGS() > 1) {
@@ -2370,8 +2370,8 @@ PHP_FUNCTION(mysql_fetch_field)
 	}
 	object_init(return_value);
 
-	add_property_string(return_value, "name",(mysql_field->name?mysql_field->name:""), 1);
-	add_property_string(return_value, "table",(mysql_field->table?mysql_field->table:""), 1);
+	add_property_string(return_value, "name", (char *) (mysql_field->name?mysql_field->name:""), 1);
+	add_property_string(return_value, "table",(char *) (mysql_field->table?mysql_field->table:""), 1);
 	add_property_string(return_value, "def",(mysql_field->def?mysql_field->def:""), 1);
 	add_property_long(return_value, "max_length", mysql_field->max_length);
 	add_property_long(return_value, "not_null", IS_NOT_NULL(mysql_field->flags)?1:0);
@@ -2394,10 +2394,10 @@ PHP_FUNCTION(mysql_field_seek)
 	zval *result;
 	long offset;
 	MYSQL_RES *mysql_result;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &offset) == FAILURE) {
 		return;
-	}	
+	}
 	ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, &result, -1, "MySQL result", le_result);
 
 	if (offset<0 || offset>=(int)mysql_num_fields(mysql_result)) {
@@ -2415,7 +2415,7 @@ PHP_FUNCTION(mysql_field_seek)
 #define PHP_MYSQL_FIELD_LEN 3
 #define PHP_MYSQL_FIELD_TYPE 4
 #define PHP_MYSQL_FIELD_FLAGS 5
- 
+
 /* {{{ php_mysql_field_info
  */
 static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
@@ -2430,9 +2430,9 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &result, &field) == FAILURE) {
 		return;
 	}
-	
+
 	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_LVAL_P(result));
 		RETURN_FALSE;
@@ -2441,7 +2441,7 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
 	if ((mysql_field=mysql_fetch_field(mysql_result))==NULL) {
 		RETURN_FALSE;
 	}
-	
+
 	switch (entry_type) {
 		case PHP_MYSQL_FIELD_NAME:
 			Z_STRLEN_P(return_value) = strlen(mysql_field->name);
@@ -2531,7 +2531,7 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
 				buf[len-1] = 0;
 				len--;
 			}
-			
+
 	   		Z_STRLEN_P(return_value) = len;
    			Z_STRVAL_P(return_value) = estrndup(buf, len);
    			Z_TYPE_P(return_value) = IS_STRING;
@@ -2624,7 +2624,7 @@ PHP_FUNCTION(mysql_ping)
 	} else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &mysql_link)==FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
 
 	PHPMY_UNBUFFERED_QUERY_CHECK();
diff --git a/ext/mysql/tests/mysql_trace_mode.phpt b/ext/mysql/tests/mysql_trace_mode.phpt
index 622f413..6d163d4 100644
--- a/ext/mysql/tests/mysql_trace_mode.phpt
+++ b/ext/mysql/tests/mysql_trace_mode.phpt
@@ -29,6 +29,8 @@ print "done!\n";
 require_once("clean_table.inc");
 ?>
 --EXPECTF--
+Deprecated: Function mysql_db_query() is deprecated in %s on line %d
+
 Deprecated: mysql_db_query(): %s
 
 Deprecated: mysql_escape_string(): %s
diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4
index f844704..409d7d0 100644
--- a/ext/mysqli/config.m4
+++ b/ext/mysqli/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 286640 2009-08-02 01:07:38Z jani $
+dnl $Id: config.m4 302549 2010-08-20 12:25:17Z andrey $
 dnl config.m4 for extension mysqli
 
 PHP_ARG_WITH(mysqli, for MySQLi support,
@@ -80,6 +80,7 @@ if test "$PHP_MYSQLI" != "no"; then
                   mysqli_exception.c $mysqli_extra_sources"
   PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared)
   PHP_SUBST(MYSQLI_SHARED_LIBADD)
+  PHP_INSTALL_HEADERS([ext/mysqli/php_mysqli_structs.h])
 
   if test "$PHP_MYSQLI" = "mysqlnd"; then
     PHP_ADD_EXTENSION_DEP(mysqli, mysqlnd)
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 6e78fc4..de1d540 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli.c 299771 2010-05-26 07:28:43Z andrey $ 
+  $Id: mysqli.c 305907 2010-12-02 14:21:23Z andrey $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -31,6 +31,7 @@
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 #include "zend_exceptions.h"
 
 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
@@ -398,7 +399,7 @@ void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysq
 
 	p.name = (char*) pname;
 	p.name_len = pname_len;
-	p.read_func = (r_func) ? r_func : mysqli_read_na; 
+	p.read_func = (r_func) ? r_func : mysqli_read_na;
 	p.write_func = (w_func) ? w_func : mysqli_write_na;
 	zend_hash_add(h, pname, pname_len + 1, &p, sizeof(mysqli_prop_handler), NULL);
 }
@@ -437,7 +438,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
 				break;
 			}
 			default:
-				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for has_set_exists");	
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for has_set_exists");
 		}
 	} else {
 		zend_object_handlers * std_hnd = zend_get_std_object_handlers();
@@ -463,7 +464,7 @@ HashTable * mysqli_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
 		zval member;
 		zval *value;
 		INIT_ZVAL(member);
-		ZVAL_STRINGL(&member, entry->name, entry->name_len, 0); 
+		ZVAL_STRINGL(&member, entry->name, entry->name_len, 0);
 		value = mysqli_read_property(object, &member, BP_VAR_IS TSRMLS_CC);
 		if (value != EG(uninitialized_zval_ptr)) {
 			Z_ADDREF_P(value);
@@ -497,7 +498,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
 		   mysqli_base_class->parent != NULL) {
 		mysqli_base_class = mysqli_base_class->parent;
 	}
-	zend_hash_find(&classes, mysqli_base_class->name, mysqli_base_class->name_length + 1, 
+	zend_hash_find(&classes, mysqli_base_class->name, mysqli_base_class->name_length + 1,
 					(void **) &intern->prop_handler);
 
 	zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
@@ -527,46 +528,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
 /* }}} */
 
 
-/* Dependancies */
-static const  zend_module_dep mysqli_deps[] = {
-#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
-	ZEND_MOD_REQUIRED("spl")
-#endif
-#if defined(MYSQLI_USE_MYSQLND)
-	ZEND_MOD_REQUIRED("mysqlnd")
-#endif
-	{NULL, NULL, NULL}
-};
-
-/* {{{ mysqli_module_entry
- */
-zend_module_entry mysqli_module_entry = {
-#if ZEND_MODULE_API_NO >= 20050922
-	STANDARD_MODULE_HEADER_EX, NULL,
-	mysqli_deps,
-#elif ZEND_MODULE_API_NO >= 20010901
-	STANDARD_MODULE_HEADER,
-#endif
-	"mysqli",
-	mysqli_functions,
-	PHP_MINIT(mysqli),
-	PHP_MSHUTDOWN(mysqli),
-	PHP_RINIT(mysqli),
-	PHP_RSHUTDOWN(mysqli),
-	PHP_MINFO(mysqli),
-	"0.1", /* Replace with version number for your extension */
-	PHP_MODULE_GLOBALS(mysqli),
-	PHP_GINIT(mysqli),
-	NULL,
-	NULL,
-	STANDARD_MODULE_PROPERTIES_EX
-};
-/* }}} */
-
-#ifdef COMPILE_DL_MYSQLI
-ZEND_GET_MODULE(mysqli)
-#endif
-
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
@@ -621,7 +582,7 @@ PHP_MINIT_FUNCTION(mysqli)
 {
 	zend_class_entry *ce,cex;
 	zend_object_handlers *std_hnd = zend_get_std_object_handlers();
-	
+
 	REGISTER_INI_ENTRIES();
 #ifndef MYSQLI_USE_MYSQLND
 #if MYSQL_VERSION_ID >= 40000
@@ -655,7 +616,7 @@ PHP_MINIT_FUNCTION(mysqli)
 #endif
 	mysqli_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
 	zend_declare_property_long(mysqli_exception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
-	zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED TSRMLS_CC);	
+	zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED TSRMLS_CC);
 
 	REGISTER_MYSQLI_CLASS_ENTRY("mysqli_driver", mysqli_driver_class_entry, mysqli_driver_methods);
 	ce = mysqli_driver_class_entry;
@@ -693,7 +654,7 @@ PHP_MINIT_FUNCTION(mysqli)
 	MYSQLI_ADD_PROPERTIES(&mysqli_stmt_properties, mysqli_stmt_property_entries);
 	MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_stmt_property_info_entries);
 	zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL);
-	
+
 	/* mysqli_options */
 	REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_GROUP", MYSQL_READ_DEFAULT_GROUP, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_FILE", MYSQL_READ_DEFAULT_FILE, CONST_CS | CONST_PERSISTENT);
@@ -707,8 +668,11 @@ PHP_MINIT_FUNCTION(mysqli)
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
 	REGISTER_LONG_CONSTANT("MYSQLI_OPT_INT_AND_FLOAT_NATIVE", MYSQLND_OPT_INT_AND_FLOAT_NATIVE, CONST_CS | CONST_PERSISTENT);
 #endif
+#if MYSQL_VERSION_ID > 50110 || defined(MYSQLI_USE_MYSQLND)
+	REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
+#endif
 
-	/* mysqli_real_connect flags */	
+	/* mysqli_real_connect flags */
 	REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_COMPRESS",CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
@@ -727,7 +691,7 @@ PHP_MINIT_FUNCTION(mysqli)
 	REGISTER_LONG_CONSTANT("MYSQLI_ASSOC", MYSQLI_ASSOC, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_NUM", MYSQLI_NUM, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_BOTH", MYSQLI_BOTH, CONST_CS | CONST_PERSISTENT);
-	
+
 	/* for mysqli_stmt_set_attr */
 	REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH", STMT_ATTR_UPDATE_MAX_LENGTH, CONST_CS | CONST_PERSISTENT);
 
@@ -742,7 +706,7 @@ PHP_MINIT_FUNCTION(mysqli)
 #if MYSQL_VERSION_ID > 50007 || defined(MYSQLI_USE_MYSQLND)
 	REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_PREFETCH_ROWS", STMT_ATTR_PREFETCH_ROWS, CONST_CS | CONST_PERSISTENT);
 #endif
-	
+
 	/* column information */
 	REGISTER_LONG_CONSTANT("MYSQLI_NOT_NULL_FLAG", NOT_NULL_FLAG, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_PRI_KEY_FLAG", PRI_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
@@ -800,6 +764,7 @@ PHP_MINIT_FUNCTION(mysqli)
 #endif
 
 	REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_NAME", MYSQL_SET_CHARSET_NAME, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("MYSQLI_SET_CHARSET_DIR", MYSQL_SET_CHARSET_DIR, CONST_CS | CONST_PERSISTENT);
 
 	/* bind support */
 	REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT);
@@ -830,6 +795,9 @@ PHP_MINIT_FUNCTION(mysqli)
 #ifdef SERVER_QUERY_WAS_SLOW
 	REGISTER_LONG_CONSTANT("MYSQLI_SERVER_QUERY_WAS_SLOW", SERVER_QUERY_WAS_SLOW, CONST_CS | CONST_PERSISTENT);
 #endif
+#ifdef SERVER_PS_OUT_PARAMS
+	REGISTER_LONG_CONSTANT("MYSQLI_SERVER_PS_OUT_PARAMS", SERVER_PS_OUT_PARAMS, CONST_CS | CONST_PERSISTENT);
+#endif
 
 	REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_GRANT",      REFRESH_GRANT, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_LOG",        REFRESH_LOG, CONST_CS | CONST_PERSISTENT);
@@ -891,12 +859,12 @@ PHP_RINIT_FUNCTION(mysqli)
 #endif
 	MyG(error_msg) = NULL;
 	MyG(error_no) = 0;
+	MyG(report_mode) = 0;
 
 	return SUCCESS;
 }
 /* }}} */
 
-
 #ifdef MYSQLI_USE_MYSQLND
 static void php_mysqli_persistent_helper_for_every(void *p)
 {
@@ -928,7 +896,8 @@ PHP_RSHUTDOWN_FUNCTION(mysqli)
 	if (MyG(error_msg)) {
 		efree(MyG(error_msg));
 	}
-#ifdef MYSQLI_USE_MYSQLND
+#if defined(A0) && MYSQLI_USE_MYSQLND
+	/* psession is being called when the connection is freed - explicitly or implicitly */
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_helper_once TSRMLS_CC);
 #endif
 	return SUCCESS;
@@ -961,9 +930,51 @@ PHP_MINFO_FUNCTION(mysqli)
 }
 /* }}} */
 
-/* {{{ mixed mysqli_stmt_construct() 
+
+/* Dependancies */
+static const  zend_module_dep mysqli_deps[] = {
+#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
+	ZEND_MOD_REQUIRED("spl")
+#endif
+#if defined(MYSQLI_USE_MYSQLND)
+	ZEND_MOD_REQUIRED("mysqlnd")
+#endif
+	{NULL, NULL, NULL}
+};
+
+/* {{{ mysqli_module_entry
+ */
+zend_module_entry mysqli_module_entry = {
+#if ZEND_MODULE_API_NO >= 20050922
+	STANDARD_MODULE_HEADER_EX, NULL,
+	mysqli_deps,
+#elif ZEND_MODULE_API_NO >= 20010901
+	STANDARD_MODULE_HEADER,
+#endif
+	"mysqli",
+	mysqli_functions,
+	PHP_MINIT(mysqli),
+	PHP_MSHUTDOWN(mysqli),
+	PHP_RINIT(mysqli),
+	PHP_RSHUTDOWN(mysqli),
+	PHP_MINFO(mysqli),
+	"0.1", /* Replace with version number for your extension */
+	PHP_MODULE_GLOBALS(mysqli),
+	PHP_GINIT(mysqli),
+	NULL,
+	NULL,
+	STANDARD_MODULE_PROPERTIES_EX
+};
+/* }}} */
+
+#ifdef COMPILE_DL_MYSQLI
+ZEND_GET_MODULE(mysqli)
+#endif
+
+
+/* {{{ mixed mysqli_stmt_construct()
 constructor for statement object.
-Parameters: 
+Parameters:
   object -> mysqli_stmt_init
   object, query -> mysqli_prepare
 */
@@ -1018,9 +1029,9 @@ PHP_FUNCTION(mysqli_stmt_construct)
 }
 /* }}} */
 
-/* {{{ mixed mysqli_result_construct() 
+/* {{{ mixed mysqli_result_construct()
 constructor for result object.
-Parameters: 
+Parameters:
   object [, mode] -> mysqli_store/use_result
 */
 PHP_FUNCTION(mysqli_result_construct)
@@ -1086,6 +1097,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 	MYSQL_FIELD		*fields;
 	MYSQL_ROW		row;
 	unsigned long	*field_len;
+	zend_bool magic_quotes_warning_sent = FALSE;
 #endif
 
 	if (into_object) {
@@ -1118,7 +1130,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 			}
 		}
 	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); 
+	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
 
 	if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
@@ -1163,16 +1175,20 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 				 */
 				snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
 				ZVAL_STRING(res, tmp, 1);
-			} else 
+			} else
 #endif
 			{
 
 				/* check if we need magic quotes */
 				if (PG(magic_quotes_runtime)) {
+					if (magic_quotes_warning_sent == FALSE) {
+						magic_quotes_warning_sent = TRUE;
+						php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
+					}
 					Z_TYPE_P(res) = IS_STRING;
 					Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
 				} else {
-					ZVAL_STRINGL(res, row[i], field_len[i], 1);	
+					ZVAL_STRINGL(res, row[i], field_len[i], 1);
 				}
 			}
 
@@ -1195,14 +1211,59 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 		}
 	}
 #else
-	mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
+	if (PG(magic_quotes_runtime)) {
+		HashPosition pos_values;
+		zval **entry_values;
+		zval new_return_value;
+		char * string_key;
+		uint   string_key_len;
+		ulong  num_key;
+
+		mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), &new_return_value, MYSQLND_MYSQLI);
+		if (Z_TYPE(new_return_value) == IS_ARRAY) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
+			array_init(return_value);
+			zend_hash_internal_pointer_reset_ex(Z_ARRVAL(new_return_value), &pos_values);
+			while (zend_hash_get_current_data_ex(Z_ARRVAL(new_return_value), (void **)&entry_values, &pos_values) == SUCCESS) {
+				if (Z_TYPE_PP(entry_values) == IS_STRING) {
+					int new_str_len;
+					char * new_str = php_addslashes(Z_STRVAL_PP(entry_values), Z_STRLEN_PP(entry_values), &new_str_len, 0 TSRMLS_CC);
+					switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
+						case HASH_KEY_IS_LONG:
+							add_index_stringl(return_value, num_key, new_str, new_str_len, 0);
+							break;
+						case HASH_KEY_IS_STRING:
+							add_assoc_stringl_ex(return_value, string_key, string_key_len, new_str, new_str_len, 0);
+							break;
+					}
+				} else {
+					zval_add_ref(entry_values);
+					switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
+						case HASH_KEY_IS_LONG:
+							add_index_zval(return_value, num_key, *entry_values);
+							break;
+						case HASH_KEY_IS_STRING:
+							add_assoc_zval_ex(return_value, string_key, string_key_len, *entry_values);
+							break;
+					}
+				}
+				zend_hash_move_forward_ex(Z_ARRVAL(new_return_value), &pos_values);
+			}
+		} else {
+			RETVAL_NULL();
+		}
+		zval_dtor(&new_return_value);
+	} else {
+		mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
+	}
+
 #endif
 
 	if (into_object && Z_TYPE_P(return_value) != IS_NULL) {
 		zval dataset = *return_value;
 		zend_fcall_info fci;
 		zend_fcall_info_cache fcc;
-		zval *retval_ptr; 
+		zval *retval_ptr;
 
 		object_and_properties_init(return_value, ce, NULL);
 		zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC);
@@ -1216,12 +1277,12 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 			fci.retval_ptr_ptr = &retval_ptr;
 			if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
 				if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
-					HashTable *ht = Z_ARRVAL_P(ctor_params);
+					HashTable *params_ht = Z_ARRVAL_P(ctor_params);
 					Bucket *p;
 
 					fci.param_count = 0;
-					fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
-					p = ht->pListHead;
+					fci.params = safe_emalloc(sizeof(zval*), params_ht->nNumOfElements, 0);
+					p = params_ht->pListHead;
 					while (p != NULL) {
 						fci.params[fci.param_count++] = (zval**)p->pData;
 						p = p->pListNext;
@@ -1229,7 +1290,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
 				} else {
 					/* Two problems why we throw exceptions here: PHP is typeless
 					 * and hence passing one argument that's not an array could be
-					 * by mistake and the other way round is possible, too. The 
+					 * by mistake and the other way round is possible, too. The
 					 * single value is an array. Also we'd have to make that one
 					 * argument passed by reference.
 					 */
@@ -1323,7 +1384,7 @@ static int php_local_infile_init(void **ptr, const char *filename, void *userdat
 	mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context);
 
 	if (mysql->li_stream == NULL) {
-		snprintf((char *)data->error_msg, sizeof(data->error_msg), "Can't find file '%-.64s'.", filename);	
+		snprintf((char *)data->error_msg, sizeof(data->error_msg), "Can't find file '%-.64s'.", filename);
 		return 1;
 	}
 
@@ -1372,7 +1433,7 @@ static int php_local_infile_read(void *ptr, char *buf, uint buf_len)
 	ZVAL_LONG(*callback_args[2], buf_len);
 	ZVAL_STRING(*callback_args[3], "", 1);
 
-	if (call_user_function_ex(EG(function_table), 
+	if (call_user_function_ex(EG(function_table),
 						NULL,
 						mysql->li_read,
 						&retval,
@@ -1463,7 +1524,7 @@ static void php_local_infile_end(void *ptr)
 /* }}} */
 
 
-/* {{{ void php_set_local_infile_handler_default 
+/* {{{ void php_set_local_infile_handler_default
 */
 void php_set_local_infile_handler_default(MY_MYSQL *mysql) {
 	/* register internal callback functions */
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 1b4694f..2f2ed2f 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_api.c 300436 2010-06-14 18:19:13Z andrey $ 
+  $Id: mysqli_api.c 305244 2010-11-10 13:57:09Z andrey $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -31,6 +31,7 @@
 #include "php_globals.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 
 /* {{{ proto mixed mysqli_affected_rows(object link)
    Get number of affected rows in previous MySQL operation */
@@ -229,7 +230,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
 
 	if (zend_parse_method_parameters((getThis()) ? 1:2 TSRMLS_CC, getThis(), "Os", &mysql_stmt, mysqli_stmt_class_entry,
 									&types, &types_len) == FAILURE) {
-		return;	
+		return;
 	}
 
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
@@ -260,7 +261,7 @@ PHP_FUNCTION(mysqli_stmt_bind_param)
 	args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
 
 	if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
-		zend_wrong_param_count(TSRMLS_C); 
+		zend_wrong_param_count(TSRMLS_C);
 		rc = 1;
 	} else {
 		rc = mysqli_stmt_bind_param_do_bind(stmt, argc, num_vars, args, start, types TSRMLS_CC);
@@ -351,8 +352,8 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
 #if MYSQL_VERSION_ID > 50002 || defined(MYSQLI_USE_MYSQLND)
 			case MYSQL_TYPE_BIT:
 #endif
-				stmt->result.buf[ofs].type = IS_STRING; 
-				stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); 
+				stmt->result.buf[ofs].type = IS_STRING;
+				stmt->result.buf[ofs].buflen = sizeof(my_ulonglong);
 				stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen);
 				bind[ofs].buffer_type = col_type;
 				bind[ofs].buffer = stmt->result.buf[ofs].val;
@@ -379,17 +380,17 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,
 			case MYSQL_TYPE_NEWDECIMAL:
 #endif
 			{
-#if MYSQL_VERSION_ID > 50099
+#if MYSQL_VERSION_ID >= 50107
 				/* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */
 				my_bool tmp;
 #else
-				ulong tmp = 0;
+				uint tmp = 0;
 #endif
 				stmt->result.buf[ofs].type = IS_STRING;
 				/*
 					If the user has called $stmt->store_result() then we have asked
 					max_length to be updated. this is done only for BLOBS because we don't want to allocate
-					big chunkgs of memory 2^16 or 2^24 
+					big chunkgs of memory 2^16 or 2^24
 				*/
 				if (stmt->stmt->fields[ofs].max_length == 0 &&
 					!mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp)
@@ -483,7 +484,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
 	}
 
 	if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
-		return;	
+		return;
 	}
 
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
@@ -544,7 +545,7 @@ PHP_FUNCTION(mysqli_change_user)
 	if (mysql_get_server_version(mysql->mysql) < 501023L) {
 		/*
 		  Request the current charset, or it will be reset to the system one.
-		  5.0 doesn't support it. Support added in 5.1.23 by fixing the following bug : 
+		  5.0 doesn't support it. Support added in 5.1.23 by fixing the following bug :
 		  Bug #30472 libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call
 		*/
 		rc = mysql_set_character_set(mysql->mysql, old_charset->csname);
@@ -587,6 +588,9 @@ void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRM
 		if (zend_hash_find(&EG(persistent_list), mysql->hash_key, strlen(mysql->hash_key) + 1, (void **)&le) == SUCCESS) {
 			if (Z_TYPE_P(le) == php_le_pmysqli()) {
 				mysqli_plist_entry *plist = (mysqli_plist_entry *) le->ptr;
+#if defined(MYSQLI_USE_MYSQLND)
+				mysqlnd_end_psession(mysql->mysql);
+#endif
 				zend_ptr_stack_push(&plist->free_links, mysql->mysql);
 
 				MyG(num_active_persistent)--;
@@ -608,7 +612,7 @@ PHP_FUNCTION(mysqli_close)
 {
 	zval		*mysql_link;
 	MY_MYSQL	*mysql;
-	
+
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
 		return;
 	}
@@ -680,7 +684,7 @@ PHP_FUNCTION(mysqli_debug)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &debug, &debug_len) == FAILURE) {
 		return;
 	}
-	
+
 	mysql_debug(debug);
 	RETURN_TRUE;
 }
@@ -720,7 +724,7 @@ PHP_FUNCTION(mysqli_errno)
 
 /* {{{ proto string mysqli_error(object link)
    Returns the text of the error message from previous MySQL operation */
-PHP_FUNCTION(mysqli_error) 
+PHP_FUNCTION(mysqli_error)
 {
 	MY_MYSQL	*mysql;
 	zval		*mysql_link;
@@ -739,7 +743,7 @@ static void
 php_mysqli_stmt_copy_it(zval *** copies, zval *original, uint param_count, uint current)
 {
 	if (!*copies) {
-		*copies = ecalloc(param_count, sizeof(zval *));					
+		*copies = ecalloc(param_count, sizeof(zval *));
 	}
 	MAKE_STD_ZVAL((*copies)[current]);
 	*(*copies)[current] = *original;
@@ -852,13 +856,13 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 	ulong			ret;
 	unsigned int	uval;
 	my_ulonglong	llval;
-	
+
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
-	
+
 	/* reset buffers */
 	for (i = 0; i < stmt->result.var_cnt; i++) {
 		if (stmt->result.buf[i].type == IS_STRING) {
@@ -884,7 +888,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 			if (!stmt->result.is_null[i]) {
 				switch (stmt->result.buf[i].type) {
 					case IS_LONG:
-						if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG) 
+						if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
 						    && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
 						{
 							/* unsigned int (11) */
@@ -895,7 +899,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 								int j=10;
 								tmp= emalloc(11);
 								p= &tmp[9];
-								do { 
+								do {
 									*p-- = (uval % 10) + 48;
 									uval = uval / 10;
 								} while (--j > 0);
@@ -906,7 +910,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 							}
 #endif
 						}
-						if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) { 
+						if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
 							ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val);
 						} else {
 							ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val);
@@ -942,7 +946,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 #if SIZEOF_LONG==8
 							if (uns && llval > 9223372036854775807L) {
 #elif SIZEOF_LONG==4
-							if ((uns && llval > L64(2147483647)) || 
+							if ((uns && llval > L64(2147483647)) ||
 								(!uns && (( L64(2147483647) < (my_longlong) llval) ||
 								(L64(-2147483648) > (my_longlong) llval))))
 							{
@@ -987,7 +991,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
 		case 0:
 #ifdef MYSQL_DATA_TRUNCATED
 		/* according to SQL standard truncation (e.g. loss of precision is
-		   not an error) - for detecting possible truncation you have to 
+		   not an error) - for detecting possible truncation you have to
 		   check mysqli_stmt_warning
 		*/
 		case MYSQL_DATA_TRUNCATED:
@@ -1043,11 +1047,11 @@ PHP_FUNCTION(mysqli_stmt_fetch)
 /* {{{  php_add_field_properties */
 static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRMLS_DC)
 {
-	add_property_string(value, "name",(field->name ? field->name : ""), 1);
-	add_property_string(value, "orgname",(field->org_name ? field->org_name : ""), 1);
-	add_property_string(value, "table",(field->table ? field->table : ""), 1);
-	add_property_string(value, "orgtable",(field->org_table ? field->org_table : ""), 1);
-	add_property_string(value, "def",(field->def ? field->def : ""), 1);
+	add_property_string(value, "name", (char *) (field->name ? field->name : ""), 1);
+	add_property_string(value, "orgname", (char *) (field->org_name ? field->org_name : ""), 1);
+	add_property_string(value, "table", (char *) (field->table ? field->table : ""), 1);
+	add_property_string(value, "orgtable", (char *) (field->org_table ? field->org_table : ""), 1);
+	add_property_string(value, "def", (field->def ? field->def : ""), 1);
 
 	add_property_long(value, "max_length", field->max_length);
 	add_property_long(value, "length", field->length);
@@ -1060,7 +1064,7 @@ static void php_add_field_properties(zval *value, const MYSQL_FIELD *field TSRML
 
 /* {{{ proto mixed mysqli_fetch_field (object result)
    Get column information from a result and return as an object */
-PHP_FUNCTION(mysqli_fetch_field) 
+PHP_FUNCTION(mysqli_fetch_field)
 {
 	MYSQL_RES	*result;
 	zval		*mysql_result;
@@ -1083,7 +1087,7 @@ PHP_FUNCTION(mysqli_fetch_field)
 
 /* {{{ proto mixed mysqli_fetch_fields (object result)
    Return array of objects containing field meta-data */
-PHP_FUNCTION(mysqli_fetch_fields) 
+PHP_FUNCTION(mysqli_fetch_fields)
 {
 	MYSQL_RES	*result;
 	zval		*mysql_result;
@@ -1113,7 +1117,7 @@ PHP_FUNCTION(mysqli_fetch_fields)
 
 /* {{{ proto mixed mysqli_fetch_field_direct (object result, int offset)
    Fetch meta-data for a single field */
-PHP_FUNCTION(mysqli_fetch_field_direct) 
+PHP_FUNCTION(mysqli_fetch_field_direct)
 {
 	MYSQL_RES	*result;
 	zval		*mysql_result;
@@ -1125,10 +1129,10 @@ 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)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field offset is invalid for resultset");
-		RETURN_FALSE; 
+		RETURN_FALSE;
 	}
 
 	if (!(field = mysql_fetch_field_direct(result,offset))) {
@@ -1142,7 +1146,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct)
 
 /* {{{ proto mixed mysqli_fetch_lengths (object result)
    Get the length of each output in a result */
-PHP_FUNCTION(mysqli_fetch_lengths) 
+PHP_FUNCTION(mysqli_fetch_lengths)
 {
 	MYSQL_RES		*result;
 	zval			*mysql_result;
@@ -1169,7 +1173,7 @@ PHP_FUNCTION(mysqli_fetch_lengths)
 
 /* {{{ proto array mysqli_fetch_row (object result)
    Get a result row as an enumerated array */
-PHP_FUNCTION(mysqli_fetch_row) 
+PHP_FUNCTION(mysqli_fetch_row)
 {
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_NUM, 0);
 }
@@ -1208,7 +1212,7 @@ PHP_FUNCTION(mysqli_field_seek)
 
 	if (fieldnr < 0 || fieldnr >= mysql_num_fields(result)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid field offset");
-		RETURN_FALSE; 
+		RETURN_FALSE;
 	}
 
 	mysql_field_seek(result, fieldnr);
@@ -1234,7 +1238,7 @@ PHP_FUNCTION(mysqli_field_tell)
 
 /* {{{ proto void mysqli_free_result(object result)
    Free query result memory for the given result handle */
-PHP_FUNCTION(mysqli_free_result) 
+PHP_FUNCTION(mysqli_free_result)
 {
 	MYSQL_RES	*result;
 	zval		*mysql_result;
@@ -1265,7 +1269,7 @@ PHP_FUNCTION(mysqli_get_client_version)
 }
 /* }}} */
 
-/* {{{ proto string mysqli_get_host_info (object link) 
+/* {{{ proto string mysqli_get_host_info (object link)
    Get MySQL host info */
 PHP_FUNCTION(mysqli_get_host_info)
 {
@@ -1313,7 +1317,7 @@ PHP_FUNCTION(mysqli_get_server_info)
 
 /* }}} */
 
-/* {{{ proto int mysqli_get_server_version(object link) 
+/* {{{ proto int mysqli_get_server_version(object link)
    Return the MySQL version for the server referenced by the given link */
 PHP_FUNCTION(mysqli_get_server_version)
 {
@@ -1379,7 +1383,7 @@ void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS)
 	mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
 
 	if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry TSRMLS_CC)) {
-		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);	
+		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
 	} else {
 		((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
 	}
@@ -1651,6 +1655,9 @@ static int mysqli_options_get_option_zval_type(int option)
 #ifdef MYSQL_OPT_COMPRESS
 		case MYSQL_OPT_COMPRESS:
 #endif /* mysqlnd @ PHP 5.3.2 */
+#ifdef MYSQL_OPT_SSL_VERIFY_SERVER_CERT
+	REGISTER_LONG_CONSTANT("MYSQLI_OPT_SSL_VERIFY_SERVER_CERT", MYSQL_OPT_SSL_VERIFY_SERVER_CERT, CONST_CS | CONST_PERSISTENT);
+#endif /* MySQL 5.1.1., mysqlnd @ PHP 5.3.3 */
 			return IS_LONG;
 
 #ifdef MYSQL_SHARED_MEMORY_BASE_NAME
@@ -1756,7 +1763,7 @@ PHP_FUNCTION(mysqli_prepare)
 	MY_MYSQL		*mysql;
 	MY_STMT			*stmt;
 	char			*query = NULL;
-	unsigned int	query_len;
+	int				query_len;
 	zval			*mysql_link;
 	MYSQLI_RESOURCE	*mysqli_resource;
 
@@ -1828,7 +1835,7 @@ PHP_FUNCTION(mysqli_prepare)
 
 
 /* {{{ proto bool mysqli_real_connect(object link [,string hostname [,string username [,string passwd [,string dbname [,int port [,string socket [,int flags]]]]]]])
-   Open a connection to a mysql server */ 
+   Open a connection to a mysql server */
 PHP_FUNCTION(mysqli_real_connect)
 {
 	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE, FALSE);
@@ -1840,10 +1847,10 @@ PHP_FUNCTION(mysqli_real_connect)
    Binary-safe version of mysql_query() */
 PHP_FUNCTION(mysqli_real_query)
 {
-	MY_MYSQL		*mysql;
-	zval			*mysql_link;
-	char			*query = NULL;
-	unsigned int	query_len;
+	MY_MYSQL	*mysql;
+	zval		*mysql_link;
+	char		*query = NULL;
+	int			query_len;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
 		return;
@@ -1867,7 +1874,7 @@ PHP_FUNCTION(mysqli_real_query)
 }
 /* }}} */
 
-/* {{{ proto string mysqli_real_escape_string(object link, string escapestr) 
+/* {{{ proto string mysqli_real_escape_string(object link, string escapestr)
    Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection */
 PHP_FUNCTION(mysqli_real_escape_string) {
 	MY_MYSQL	*mysql;
@@ -1877,7 +1884,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &escapestr, &escapestr_len) == FAILURE) {
 		return;
-	}	
+	}
 	MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
 
 	newstr = safe_emalloc(2, escapestr_len, 1);
@@ -2003,19 +2010,19 @@ PHP_FUNCTION(mysqli_stmt_field_count)
 {
 	MY_STMT		*stmt;
 	zval		*mysql_stmt;
-	
+
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
-		
+
 	RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
 }
 /* }}} */
 
 /* {{{ proto void mysqli_stmt_free_result(object stmt)
    Free stored result memory for the given statement handle */
-PHP_FUNCTION(mysqli_stmt_free_result) 
+PHP_FUNCTION(mysqli_stmt_free_result)
 {
 	MY_STMT		*stmt;
 	zval		*mysql_stmt;
@@ -2058,7 +2065,7 @@ PHP_FUNCTION(mysqli_stmt_param_count)
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
-		
+
 	RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
 }
 /* }}} */
@@ -2104,7 +2111,7 @@ PHP_FUNCTION(mysqli_stmt_num_rows)
 
 /* {{{ proto bool mysqli_select_db(object link, string dbname)
    Select a MySQL database */
-PHP_FUNCTION(mysqli_select_db) 
+PHP_FUNCTION(mysqli_select_db)
 {
 	MY_MYSQL	*mysql;
 	zval		*mysql_link;
@@ -2113,7 +2120,7 @@ PHP_FUNCTION(mysqli_select_db)
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &dbname, &dbname_len) == FAILURE) {
 		return;
-	} 
+	}
 	MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
 
 	if (mysql_select_db(mysql->mysql, dbname)) {
@@ -2126,7 +2133,7 @@ PHP_FUNCTION(mysqli_select_db)
 
 /* {{{ proto string mysqli_sqlstate(object link)
    Returns the SQLSTATE error from previous MySQL operation */
-PHP_FUNCTION(mysqli_sqlstate) 
+PHP_FUNCTION(mysqli_sqlstate)
 {
 	MY_MYSQL	*mysql;
 	zval		*mysql_link;
@@ -2164,8 +2171,8 @@ PHP_FUNCTION(mysqli_ssl_set)
 	RETURN_TRUE;
 }
 /* }}} */
-  
-/* {{{ proto mixed mysqli_stat(object link) 
+
+/* {{{ proto mixed mysqli_stat(object link)
    Get current system status */
 PHP_FUNCTION(mysqli_stat)
 {
@@ -2216,7 +2223,7 @@ PHP_FUNCTION(mysqli_refresh)
 #endif
 }
 /* }}} */
- 
+
 /* {{{ proto int mysqli_stmt_attr_set(object stmt, long attr, long mode)
 */
 PHP_FUNCTION(mysqli_stmt_attr_set)
@@ -2224,8 +2231,10 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
 	MY_STMT	*stmt;
 	zval	*mysql_stmt;
 	long	mode_in;
+	my_bool	mode_b;
 	ulong	mode;
 	ulong	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) {
 		return;
@@ -2237,11 +2246,22 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
 		RETURN_FALSE;
 	}
 
-	mode = mode_in;
+	switch (attr) {
+#if MYSQL_VERSION_ID >= 50107
+	case STMT_ATTR_UPDATE_MAX_LENGTH:
+		mode_b = (my_bool) mode_in;
+		mode_p = &mode_b;
+		break;
+#endif
+	default:
+		mode = mode_in;
+		mode_p = &mode;
+		break;
+	}
 #if !defined(MYSQLI_USE_MYSQLND)
-	if (mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+	if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
 #else
-	if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode)) {
+	if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
 #endif
 		RETURN_FALSE;
 	}
@@ -2255,11 +2275,7 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
 {
 	MY_STMT	*stmt;
 	zval	*mysql_stmt;
-#if !defined(MYSQLI_USE_MYSQLND) && MYSQL_VERSION_ID > 50099
-	my_bool value;
-#else
 	ulong	value = 0;
-#endif
 	ulong	attr;
 	int		rc;
 
@@ -2271,6 +2287,11 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
 	if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
 		RETURN_FALSE;
 	}
+
+#if MYSQL_VERSION_ID >= 50107
+	if (attr == STMT_ATTR_UPDATE_MAX_LENGTH)
+		value = *((my_bool *)&value);
+#endif
 	RETURN_LONG((long)value);
 }
 /* }}} */
@@ -2293,7 +2314,7 @@ PHP_FUNCTION(mysqli_stmt_errno)
 
 /* {{{ proto string mysqli_stmt_error(object stmt)
 */
-PHP_FUNCTION(mysqli_stmt_error) 
+PHP_FUNCTION(mysqli_stmt_error)
 {
 	MY_STMT	*stmt;
 	zval 	*mysql_stmt;
@@ -2302,7 +2323,7 @@ PHP_FUNCTION(mysqli_stmt_error)
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
-	
+
 	RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1);
 }
 /* }}} */
@@ -2398,7 +2419,7 @@ PHP_FUNCTION(mysqli_stmt_store_result)
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
-	
+
 #if !defined(MYSQLI_USE_MYSQLND)
 	{
 		/*
@@ -2416,14 +2437,18 @@ PHP_FUNCTION(mysqli_stmt_store_result)
 				stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
 				stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
 			{
+#if MYSQL_VERSION_ID >= 50107
 				my_bool	tmp=1;
+#else
+				uint tmp=1;
+#endif
 				mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
 				break;
 			}
 		}
 	}
 #endif
-	
+
 	if (mysql_stmt_store_result(stmt->stmt)){
 		MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
 		RETURN_FALSE;
diff --git a/ext/mysqli/mysqli_driver.c b/ext/mysqli/mysqli_driver.c
index 2d553f9..780489b 100644
--- a/ext/mysqli/mysqli_driver.c
+++ b/ext/mysqli/mysqli_driver.c
@@ -124,9 +124,9 @@ static int driver_driver_version_read(mysqli_object *obj, zval **retval TSRMLS_D
 }
 /* }}} */
 
-MAP_PROPERTY_MYG_BOOL_READ(driver_reconnect_read, reconnect);
-MAP_PROPERTY_MYG_BOOL_WRITE(driver_reconnect_write, reconnect);
-MAP_PROPERTY_MYG_LONG_READ(driver_report_read, report_mode);
+MAP_PROPERTY_MYG_BOOL_READ(driver_reconnect_read, reconnect)
+MAP_PROPERTY_MYG_BOOL_WRITE(driver_reconnect_write, reconnect)
+MAP_PROPERTY_MYG_LONG_READ(driver_report_read, report_mode)
 
 ZEND_FUNCTION(mysqli_driver_construct)
 {
diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c
index 1b3eb47..761ffc7 100644
--- a/ext/mysqli/mysqli_embedded.c
+++ b/ext/mysqli/mysqli_embedded.c
@@ -53,7 +53,7 @@ PHP_FUNCTION(mysqli_embedded_server_start)
 	/* get arguments */
 	if ((argc = zend_hash_num_elements(HASH_OF(args)))) {
 		arguments = safe_emalloc(sizeof(char *), argc + 1, 0);
-		arguments[0] = NULL; 
+		arguments[0] = NULL;
 
 		zend_hash_internal_pointer_reset_ex(HASH_OF(args), &pos);
 
@@ -74,7 +74,7 @@ PHP_FUNCTION(mysqli_embedded_server_start)
 	/* get groups */
 	if ((zend_hash_num_elements(HASH_OF(grps)))) {
 		groups = safe_emalloc(sizeof(char *), zend_hash_num_elements(HASH_OF(grps)) + 1, 0);
-		groups[0] = NULL; 
+		groups[0] = NULL;
 
 		zend_hash_internal_pointer_reset_ex(HASH_OF(grps), &pos);
 
@@ -89,7 +89,7 @@ PHP_FUNCTION(mysqli_embedded_server_start)
 
 			groups[++index] = Z_STRVAL_PP(item);
 		}
-		groups[index] = NULL;	
+		groups[index] = NULL;
 	} else {
 		groups = safe_emalloc(sizeof(char *), 1, 0);
 		groups[0] = NULL;
diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c
index 2bf65d0..6372fb8 100644
--- a/ext/mysqli/mysqli_exception.c
+++ b/ext/mysqli/mysqli_exception.c
@@ -26,6 +26,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 #include "zend_exceptions.h"
 
 /* {{{ mysqli_exception_methods[]
@@ -35,13 +36,13 @@ const zend_function_entry mysqli_exception_methods[] = {
 };
 /* }}} */
 
-void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...) 
+void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...)
 {
 	zval	*sql_ex;
 	va_list arg;
 	char 	*message;
 
-	va_start(arg, format); 
+	va_start(arg, format);
 	vspprintf(&message, 0, format, arg);
 	va_end(arg);;
 
diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c
index a672041..0c482b2 100644
--- a/ext/mysqli/mysqli_fe.c
+++ b/ext/mysqli/mysqli_fe.c
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_fe.c 301049 2010-07-07 12:09:36Z andrey $ 
+  $Id: mysqli_fe.c 303978 2010-10-04 10:43:21Z uw $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -30,6 +30,8 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_fe.h"
+#include "mysqli_priv.h"
 
 #if PHP_VERSION_ID >= 50399
 #define MYSQLI_ZEND_ARG_OBJ_INFO_LINK() ZEND_ARG_OBJ_INFO(0, link, mysqli, 0)
@@ -43,22 +45,22 @@
 
 ZEND_BEGIN_ARG_INFO(arginfo_mysqli_stmt_bind_result, 1)
 	MYSQLI_ZEND_ARG_OBJ_INFO_STMT()
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_mysqli_stmt_bind_param, 1)
 	MYSQLI_ZEND_ARG_OBJ_INFO_STMT()
 	ZEND_ARG_INFO(0, types)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_class_mysqli_stmt_bind_result, 1)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_class_mysqli_stmt_bind_param, 1)
 	ZEND_ARG_INFO(0, types)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(all_args_force_by_ref, 1)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_poll, 0, 0, 4)
 	ZEND_ARG_ARRAY_INFO(1, read, 1)
@@ -66,7 +68,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_poll, 0, 0, 4)
 	ZEND_ARG_ARRAY_INFO(1, error, 1)
 	ZEND_ARG_INFO(0, sec)
 	ZEND_ARG_INFO(0, usec)
-ZEND_END_ARG_INFO();
+ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_no_params, 0, 0, 0)
 ZEND_END_ARG_INFO()
@@ -360,7 +362,7 @@ const zend_function_entry mysqli_functions[] = {
 	PHP_FE(mysqli_fetch_all,							arginfo_mysqli_only_result)
 #endif
 	PHP_FE(mysqli_fetch_array,							arginfo_mysqli_fetch_array)
-	PHP_FE(mysqli_fetch_assoc,							arginfo_mysqli_only_result) 
+	PHP_FE(mysqli_fetch_assoc,							arginfo_mysqli_only_result)
 	PHP_FE(mysqli_fetch_object,							arginfo_mysqli_fetch_object)
 	PHP_FE(mysqli_fetch_row,							arginfo_mysqli_only_result)
 	PHP_FE(mysqli_field_count,							arginfo_mysqli_only_link)
@@ -372,7 +374,7 @@ const zend_function_entry mysqli_functions[] = {
 	PHP_FE(mysqli_get_connection_stats,					arginfo_mysqli_only_link)
 	PHP_FE(mysqli_get_client_stats,						arginfo_mysqli_no_params)
 #endif
-#ifdef HAVE_MYSQLI_GET_CHARSET 
+#ifdef HAVE_MYSQLI_GET_CHARSET
 	PHP_FE(mysqli_get_charset,							arginfo_mysqli_only_link)
 #endif
 	PHP_FE(mysqli_get_client_info,						arginfo_mysqli_only_link)
@@ -484,7 +486,7 @@ const zend_function_entry mysqli_link_methods[] = {
 	PHP_FALIAS(connect, mysqli_connect, arginfo_mysqli_connect)
 	PHP_FALIAS(dump_debug_info, mysqli_dump_debug_info, arginfo_mysqli_no_params)
 	PHP_FALIAS(debug, mysqli_debug, arginfo_mysqli_debug)
-#ifdef HAVE_MYSQLI_GET_CHARSET 
+#ifdef HAVE_MYSQLI_GET_CHARSET
 	PHP_FALIAS(get_charset, mysqli_get_charset, arginfo_mysqli_no_params)
 #endif
 	PHP_FALIAS(get_client_info, mysqli_get_client_info, arginfo_mysqli_no_params)
@@ -505,6 +507,9 @@ const zend_function_entry mysqli_link_methods[] = {
 	PHP_FALIAS(next_result, mysqli_next_result, arginfo_mysqli_no_params)
 	PHP_FALIAS(options, mysqli_options, arginfo_class_mysqli_options)
 	PHP_FALIAS(ping, mysqli_ping, arginfo_mysqli_no_params)
+#if defined(MYSQLI_USE_MYSQLND)
+	ZEND_FENTRY(poll, ZEND_FN(mysqli_poll), arginfo_mysqli_poll, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+#endif
 	PHP_FALIAS(prepare, mysqli_prepare, arginfo_class_mysqli_query)
 	PHP_FALIAS(query, mysqli_query, arginfo_class_mysqli_query)
 	PHP_FALIAS(real_connect, mysqli_real_connect, arginfo_class_mysqli_real_connect)
@@ -547,8 +552,8 @@ const zend_function_entry mysqli_result_methods[] = {
 	PHP_FALIAS(fetch_all, mysqli_fetch_all, arginfo_mysqli_no_params)
 #endif
 	PHP_FALIAS(fetch_array, mysqli_fetch_array, arginfo_class_mysqli_fetch_array)
-	PHP_FALIAS(fetch_assoc, mysqli_fetch_assoc, arginfo_mysqli_no_params) 
-	PHP_FALIAS(fetch_object,mysqli_fetch_object, arginfo_class_mysqli_fetch_object) 
+	PHP_FALIAS(fetch_assoc, mysqli_fetch_assoc, arginfo_mysqli_no_params)
+	PHP_FALIAS(fetch_object,mysqli_fetch_object, arginfo_class_mysqli_fetch_object)
 	PHP_FALIAS(fetch_row, mysqli_fetch_row, arginfo_mysqli_no_params)
 	PHP_FALIAS(field_seek, mysqli_field_seek, arginfo_class_mysqli_result_and_fieldnr)
 	PHP_FALIAS(free_result, mysqli_free_result, arginfo_mysqli_no_params)
diff --git a/ext/mysqli/mysqli_fe.h b/ext/mysqli/mysqli_fe.h
new file mode 100644
index 0000000..41345fd
--- /dev/null
+++ b/ext/mysqli/mysqli_fe.h
@@ -0,0 +1,135 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 5                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2010 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.txt                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license at php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Author: Georg Richter <georg at php.net>                                |
+            Andrey Hristov <andrey at php.net>                              |
+  +----------------------------------------------------------------------+
+
+  $Id: php_mysqli_structs.h 302179 2010-08-13 09:57:04Z andrey $
+*/
+
+#ifndef MYSQLI_FE_H
+#define MYSQLI_FE_H
+
+PHP_FUNCTION(mysqli);
+PHP_FUNCTION(mysqli_affected_rows);
+PHP_FUNCTION(mysqli_autocommit);
+PHP_FUNCTION(mysqli_change_user);
+PHP_FUNCTION(mysqli_character_set_name);
+PHP_FUNCTION(mysqli_set_charset);
+PHP_FUNCTION(mysqli_close);
+PHP_FUNCTION(mysqli_commit);
+PHP_FUNCTION(mysqli_connect);
+PHP_FUNCTION(mysqli_connect_errno);
+PHP_FUNCTION(mysqli_connect_error);
+PHP_FUNCTION(mysqli_data_seek);
+PHP_FUNCTION(mysqli_debug);
+PHP_FUNCTION(mysqli_dump_debug_info);
+PHP_FUNCTION(mysqli_errno);
+PHP_FUNCTION(mysqli_error);
+PHP_FUNCTION(mysqli_fetch_all);
+PHP_FUNCTION(mysqli_fetch_array);
+PHP_FUNCTION(mysqli_fetch_assoc);
+PHP_FUNCTION(mysqli_fetch_object);
+PHP_FUNCTION(mysqli_fetch_field);
+PHP_FUNCTION(mysqli_fetch_fields);
+PHP_FUNCTION(mysqli_fetch_field_direct);
+PHP_FUNCTION(mysqli_fetch_lengths);
+PHP_FUNCTION(mysqli_fetch_row);
+PHP_FUNCTION(mysqli_field_count);
+PHP_FUNCTION(mysqli_field_seek);
+PHP_FUNCTION(mysqli_field_tell);
+PHP_FUNCTION(mysqli_free_result);
+PHP_FUNCTION(mysqli_get_cache_stats);
+PHP_FUNCTION(mysqli_get_client_stats);
+PHP_FUNCTION(mysqli_get_connection_stats);
+PHP_FUNCTION(mysqli_get_charset);
+PHP_FUNCTION(mysqli_get_client_info);
+PHP_FUNCTION(mysqli_get_client_version);
+PHP_FUNCTION(mysqli_get_host_info);
+PHP_FUNCTION(mysqli_get_proto_info);
+PHP_FUNCTION(mysqli_get_server_info);
+PHP_FUNCTION(mysqli_get_server_version);
+PHP_FUNCTION(mysqli_get_warnings);
+PHP_FUNCTION(mysqli_info);
+PHP_FUNCTION(mysqli_insert_id);
+PHP_FUNCTION(mysqli_init);
+PHP_FUNCTION(mysqli_kill);
+PHP_FUNCTION(mysqli_link_construct);
+PHP_FUNCTION(mysqli_set_local_infile_default);
+PHP_FUNCTION(mysqli_set_local_infile_handler);
+PHP_FUNCTION(mysqli_more_results);
+PHP_FUNCTION(mysqli_multi_query);
+PHP_FUNCTION(mysqli_next_result);
+PHP_FUNCTION(mysqli_num_fields);
+PHP_FUNCTION(mysqli_num_rows);
+PHP_FUNCTION(mysqli_options);
+PHP_FUNCTION(mysqli_ping);
+PHP_FUNCTION(mysqli_poll);
+PHP_FUNCTION(mysqli_prepare);
+PHP_FUNCTION(mysqli_query);
+PHP_FUNCTION(mysqli_stmt_result_metadata);
+PHP_FUNCTION(mysqli_report);
+PHP_FUNCTION(mysqli_read_query_result);
+PHP_FUNCTION(mysqli_real_connect);
+PHP_FUNCTION(mysqli_real_query);
+PHP_FUNCTION(mysqli_real_escape_string);
+PHP_FUNCTION(mysqli_reap_async_query);
+PHP_FUNCTION(mysqli_rollback);
+PHP_FUNCTION(mysqli_row_seek);
+PHP_FUNCTION(mysqli_select_db);
+PHP_FUNCTION(mysqli_stmt_attr_get);
+PHP_FUNCTION(mysqli_stmt_attr_set);
+PHP_FUNCTION(mysqli_stmt_bind_param);
+PHP_FUNCTION(mysqli_stmt_bind_result);
+PHP_FUNCTION(mysqli_stmt_execute);
+PHP_FUNCTION(mysqli_stmt_field_count);
+PHP_FUNCTION(mysqli_stmt_init);
+PHP_FUNCTION(mysqli_stmt_prepare);
+PHP_FUNCTION(mysqli_stmt_fetch);
+PHP_FUNCTION(mysqli_stmt_param_count);
+PHP_FUNCTION(mysqli_stmt_send_long_data);
+PHP_FUNCTION(mysqli_embedded_server_end);
+PHP_FUNCTION(mysqli_embedded_server_start);
+PHP_FUNCTION(mysqli_sqlstate);
+PHP_FUNCTION(mysqli_ssl_set);
+PHP_FUNCTION(mysqli_stat);
+PHP_FUNCTION(mysqli_refresh);
+PHP_FUNCTION(mysqli_stmt_affected_rows);
+PHP_FUNCTION(mysqli_stmt_close);
+PHP_FUNCTION(mysqli_stmt_data_seek);
+PHP_FUNCTION(mysqli_stmt_errno);
+PHP_FUNCTION(mysqli_stmt_error);
+PHP_FUNCTION(mysqli_stmt_free_result);
+PHP_FUNCTION(mysqli_stmt_get_result);
+PHP_FUNCTION(mysqli_stmt_get_warnings);
+PHP_FUNCTION(mysqli_stmt_reset);
+PHP_FUNCTION(mysqli_stmt_insert_id);
+PHP_FUNCTION(mysqli_stmt_more_results);
+PHP_FUNCTION(mysqli_stmt_next_result);
+PHP_FUNCTION(mysqli_stmt_num_rows);
+PHP_FUNCTION(mysqli_stmt_sqlstate);
+PHP_FUNCTION(mysqli_stmt_store_result);
+PHP_FUNCTION(mysqli_store_result);
+PHP_FUNCTION(mysqli_thread_id);
+PHP_FUNCTION(mysqli_thread_safe);
+PHP_FUNCTION(mysqli_use_result);
+PHP_FUNCTION(mysqli_warning_count);
+
+PHP_FUNCTION(mysqli_stmt_construct);
+PHP_FUNCTION(mysqli_result_construct);
+PHP_FUNCTION(mysqli_driver_construct);
+PHP_METHOD(mysqli_warning,__construct);
+
+#endif /* MYSQLI_FE_H */
diff --git a/ext/mysqli/mysqli_libmysql.h b/ext/mysqli/mysqli_libmysql.h
index 8e0c735..9fdfd7e 100644
--- a/ext/mysqli/mysqli_libmysql.h
+++ b/ext/mysqli/mysqli_libmysql.h
@@ -43,7 +43,7 @@
 
 /*
   These functions also reside in ext/mysqlnd/mysqlnd_portability.h but since it is only made
-  available if one wants to build mysqli against mysqlnd and they are useful for libmysql as 
+  available if one wants to build mysqli against mysqlnd and they are useful for libmysql as
   well, we check whether they're not defined [build with libmysql is desired] and define them.
 
   Bit values are sent in reverted order of bytes, compared to normal !!!
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 7575bd9..3e0d3e3 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_nonapi.c 299771 2010-05-26 07:28:43Z andrey $ 
+  $Id: mysqli_nonapi.c 305244 2010-11-10 13:57:09Z andrey $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -30,6 +30,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 
 #define SAFE_STR(a) ((a)?a:"")
 
@@ -46,7 +47,7 @@ static void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
 	if (MyG(error_msg)) {
 		efree(MyG(error_msg));
 	}
-	if(mysql_err && *mysql_err) { 
+	if(mysql_err && *mysql_err) {
 		MyG(error_msg) = estrdup(mysql_err);
 	} else {
 		MyG(error_msg) = NULL;
@@ -61,7 +62,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 	MYSQLI_RESOURCE		*mysqli_resource = NULL;
 	zval				*object = getThis();
 	char				*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
-	unsigned int		hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
+	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;
 	uint				hash_len;
@@ -87,7 +88,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 	hostname = username = dbname = passwd = socket = NULL;
 
 	if (!is_real_connect) {
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssssls", &hostname, &hostname_len, &username, &username_len, 
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssssls", &hostname, &hostname_len, &username, &username_len,
 									&passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len) == FAILURE) {
 			return;
 		}
@@ -122,10 +123,6 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 			flags &= ~CLIENT_LOCAL_FILES;
 		}
 	}
-	if (mysql->mysql && mysqli_resource && mysqli_resource->status > MYSQLI_STATUS_INITIALIZED) {
-		/* already connected, we should close the connection */
-		php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC);
-	}
 
 	if (!socket_len || !socket) {
 		socket = MyG(default_socket);
@@ -144,15 +141,20 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 		hostname = MyG(default_host);
 	}
 
+       if (mysql->mysql && mysqli_resource && (mysqli_resource->status > MYSQLI_STATUS_INITIALIZED || (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)))) {
+                /* already connected, we should close the connection */
+                php_mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT, mysqli_resource->status TSRMLS_CC);
+        }
+
 	if (strlen(SAFE_STR(hostname)) > 2 && !strncasecmp(hostname, "p:", 2)) {
 		hostname += 2;
 		if (!MyG(allow_persistent)) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Persistent connections are disabled. Downgrading to normal");			
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Persistent connections are disabled. Downgrading to normal");
 		} else {
 			mysql->persistent = persistent = TRUE;
 
-			hash_len = spprintf(&hash_key, 0, "mysqli_%s_%s%ld%s%s%s", SAFE_STR(hostname), SAFE_STR(socket), 
-								port, SAFE_STR(username), SAFE_STR(dbname), 
+			hash_len = spprintf(&hash_key, 0, "mysqli_%s_%s%ld%s%s%s", SAFE_STR(hostname), SAFE_STR(socket),
+								port, SAFE_STR(username), SAFE_STR(dbname),
 								SAFE_STR(passwd));
 
 			mysql->hash_key = hash_key;
@@ -167,9 +169,6 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
 							mysql->mysql = zend_ptr_stack_pop(&plist->free_links);
 
 							MyG(num_inactive_persistent)--;
-#if defined(MYSQLI_USE_MYSQLND)
-							mysqlnd_end_psession(mysql->mysql);
-#endif	
 							/* reset variables */
 
 #ifndef MYSQLI_NO_CHANGE_USER_ON_PCONNECT
@@ -279,7 +278,7 @@ end:
 	mysql->multi_query = 0;
 
 	if (!object || !instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry TSRMLS_CC)) {
-		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);	
+		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
 	} else {
 		((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr = mysqli_resource;
 	}
@@ -303,7 +302,7 @@ err:
 
 
 /* {{{ proto object mysqli_connect([string hostname [,string username [,string passwd [,string dbname [,int port [,string socket]]]]]])
-   Open a connection to a mysql server */ 
+   Open a connection to a mysql server */
 PHP_FUNCTION(mysqli_connect)
 {
 	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, FALSE);
@@ -312,7 +311,7 @@ PHP_FUNCTION(mysqli_connect)
 
 
 /* {{{ proto object mysqli_link_construct()
-  */ 
+  */
 PHP_FUNCTION(mysqli_link_construct)
 {
 	mysqli_common_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE, TRUE);
@@ -330,7 +329,7 @@ PHP_FUNCTION(mysqli_connect_errno)
 
 /* {{{ proto string mysqli_connect_error(void)
    Returns the text of the error message from previous MySQL operation */
-PHP_FUNCTION(mysqli_connect_error) 
+PHP_FUNCTION(mysqli_connect_error)
 {
 	if (MyG(error_msg)) {
 		RETURN_STRING(MyG(error_msg),1);
@@ -343,7 +342,7 @@ PHP_FUNCTION(mysqli_connect_error)
 
 /* {{{ proto mixed mysqli_fetch_array (object result [,int resulttype])
    Fetch a result row as an associative array, a numeric array, or both */
-PHP_FUNCTION(mysqli_fetch_array) 
+PHP_FUNCTION(mysqli_fetch_array)
 {
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 0);
 }
@@ -351,21 +350,21 @@ PHP_FUNCTION(mysqli_fetch_array)
 
 /* {{{ proto mixed mysqli_fetch_assoc (object result)
    Fetch a result row as an associative array */
-PHP_FUNCTION(mysqli_fetch_assoc) 
+PHP_FUNCTION(mysqli_fetch_assoc)
 {
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 0);
 }
 /* }}} */
 
 
-/* {{{ proto mixed mysqli_fetch_all (object result [,int resulttype]) 
+/* {{{ proto mixed mysqli_fetch_all (object result [,int resulttype])
    Fetches all result rows as an associative array, a numeric array, or both */
 #if defined(MYSQLI_USE_MYSQLND)
-PHP_FUNCTION(mysqli_fetch_all) 
+PHP_FUNCTION(mysqli_fetch_all)
 {
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-	long			mode = MYSQLND_FETCH_NUM;
+	MYSQL_RES	*result;
+	zval		*mysql_result;
+	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;
@@ -385,7 +384,7 @@ PHP_FUNCTION(mysqli_fetch_all)
 
 /* {{{ proto array mysqli_cache_stats(void) U
    Returns statistics about the zval cache */
-PHP_FUNCTION(mysqli_get_cache_stats) 
+PHP_FUNCTION(mysqli_get_cache_stats)
 {
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
@@ -397,7 +396,7 @@ PHP_FUNCTION(mysqli_get_cache_stats)
 
 /* {{{ proto array mysqli_get_client_stats(void)
    Returns statistics about the zval cache */
-PHP_FUNCTION(mysqli_get_client_stats) 
+PHP_FUNCTION(mysqli_get_client_stats)
 {
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
@@ -409,7 +408,7 @@ PHP_FUNCTION(mysqli_get_client_stats)
 
 /* {{{ proto array mysqli_get_connection_stats(void)
    Returns statistics about the zval cache */
-PHP_FUNCTION(mysqli_get_connection_stats) 
+PHP_FUNCTION(mysqli_get_connection_stats)
 {
 	MY_MYSQL	*mysql;
 	zval		*mysql_link;
@@ -428,9 +427,9 @@ PHP_FUNCTION(mysqli_get_connection_stats)
 
 /* {{{ proto mixed mysqli_fetch_object (object result [, string class_name [, NULL|array ctor_params]])
    Fetch a result row as an object */
-PHP_FUNCTION(mysqli_fetch_object) 
+PHP_FUNCTION(mysqli_fetch_object)
 {
-	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 1);	
+	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 1);
 }
 /* }}} */
 
@@ -438,22 +437,22 @@ PHP_FUNCTION(mysqli_fetch_object)
    allows to execute multiple queries  */
 PHP_FUNCTION(mysqli_multi_query)
 {
-	MY_MYSQL		*mysql;
-	zval			*mysql_link;
-	char			*query = NULL;
-	unsigned int 	query_len;
+	MY_MYSQL	*mysql;
+	zval		*mysql_link;
+	char		*query = NULL;
+	int 		query_len;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
 		return;
 	}
 	MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
 
-	MYSQLI_ENABLE_MQ;	
+	MYSQLI_ENABLE_MQ;
 	if (mysql_real_query(mysql->mysql, query, query_len)) {
 #ifndef MYSQLI_USE_MYSQLND
 		char s_error[MYSQL_ERRMSG_SIZE], s_sqlstate[SQLSTATE_LENGTH+1];
 		unsigned int s_errno;
-		/* we have to save error information, cause 
+		/* we have to save error information, cause
 		MYSQLI_DISABLE_MQ will reset error information */
 		strcpy(s_error, mysql_error(mysql->mysql));
 		strcpy(s_sqlstate, mysql_sqlstate(mysql->mysql));
@@ -468,7 +467,7 @@ PHP_FUNCTION(mysqli_multi_query)
 		/* restore error information */
 		strcpy(mysql->mysql->net.last_error, s_error);
 		strcpy(mysql->mysql->net.sqlstate, s_sqlstate);
-		mysql->mysql->net.last_errno = s_errno;	
+		mysql->mysql->net.last_errno = s_errno;
 #else
 		mysql->mysql->error_info = error_info;
 #endif
@@ -486,8 +485,8 @@ PHP_FUNCTION(mysqli_query)
 	MYSQLI_RESOURCE		*mysqli_resource;
 	MYSQL_RES 			*result;
 	char				*query = NULL;
-	unsigned int 		query_len;
-	unsigned long 		resultmode = MYSQLI_STORE_RESULT;
+	int 				query_len;
+	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;
@@ -541,7 +540,7 @@ PHP_FUNCTION(mysqli_query)
 	}
 	if (!result) {
 		php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
-										"%s", mysql_error(mysql->mysql)); 
+										"%s", mysql_error(mysql->mysql));
 		RETURN_FALSE;
 	}
 
@@ -575,7 +574,7 @@ static int mysqlnd_zval_array_to_mysqlnd_array(zval *in_array, MYSQLND ***out_ar
 		i++;
 		if (Z_TYPE_PP(elem) != IS_OBJECT ||
 			!instanceof_function(Z_OBJCE_PP(elem), mysqli_link_class_entry TSRMLS_CC)) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter %d not a mysqli object", i);			
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter %d not a mysqli object", i);
 		} else {
 			MY_MYSQL *mysql;
 			MYSQLI_RESOURCE *my_res;
@@ -775,7 +774,7 @@ PHP_FUNCTION(mysqli_reap_async_query)
 
 	if (!result) {
 		php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
-										"%s", mysql_error(mysql->mysql)); 
+										"%s", mysql_error(mysql->mysql));
 		RETURN_FALSE;
 	}
 
@@ -813,7 +812,7 @@ PHP_FUNCTION(mysqli_stmt_get_result)
 	mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
 	mysqli_resource->ptr = (void *)result;
 	mysqli_resource->status = MYSQLI_STATUS_VALID;
-	MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);	
+	MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
 }
 /* }}} */
 #endif
@@ -833,14 +832,14 @@ PHP_FUNCTION(mysqli_get_warnings)
 	MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID);
 
 	if (mysql_warning_count(mysql->mysql)) {
-		w = php_get_warnings(mysql->mysql TSRMLS_CC); 
+		w = php_get_warnings(mysql->mysql TSRMLS_CC);
 	} else {
 		RETURN_FALSE;
 	}
 	mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
 	mysqli_resource->ptr = mysqli_resource->info = (void *)w;
 	mysqli_resource->status = MYSQLI_STATUS_VALID;
-	MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);	
+	MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
 }
 /* }}} */
 
@@ -858,7 +857,7 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
 	MYSQLI_FETCH_RESOURCE_STMT(stmt, &stmt_link, MYSQLI_STATUS_VALID);
 
 	if (mysqli_stmt_warning_count(stmt->stmt)) {
-		w = php_get_warnings(mysqli_stmt_get_connection(stmt->stmt) TSRMLS_CC); 
+		w = php_get_warnings(mysqli_stmt_get_connection(stmt->stmt) TSRMLS_CC);
 	} else {
 		RETURN_FALSE;
 	}
@@ -874,10 +873,10 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
    sets client character set */
 PHP_FUNCTION(mysqli_set_charset)
 {
-	MY_MYSQL			*mysql;
-	zval				*mysql_link;
-	char				*cs_name;
-	int					csname_len;
+	MY_MYSQL	*mysql;
+	zval		*mysql_link;
+	char		*cs_name;
+	int			csname_len;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &csname_len) == FAILURE) {
 		return;
@@ -892,7 +891,7 @@ PHP_FUNCTION(mysqli_set_charset)
 /* }}} */
 #endif
 
-#ifdef HAVE_MYSQLI_GET_CHARSET 
+#ifdef HAVE_MYSQLI_GET_CHARSET
 /* {{{ proto object mysqli_get_charset(object link) U
    returns a character set object */
 PHP_FUNCTION(mysqli_get_charset)
@@ -926,8 +925,8 @@ PHP_FUNCTION(mysqli_get_charset)
 	comment = cs.comment;
 #else
 	cs = mysql->mysql->charset;
-	name = cs->name;	
-	collation = cs->collation;	
+	name = cs->name;
+	collation = cs->collation;
 	minlength = cs->char_minlen;
 	maxlength = cs->char_maxlen;
 	number = cs->nr;
diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h
new file mode 100644
index 0000000..c7e9e91
--- /dev/null
+++ b/ext/mysqli/mysqli_priv.h
@@ -0,0 +1,156 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 5                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2010 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.01 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_01.txt                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license at php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Author: Georg Richter <georg at php.net>                                |
+  +----------------------------------------------------------------------+
+
+  $Id: php_mysqli_structs.h 302179 2010-08-13 09:57:04Z andrey $
+*/
+
+#ifndef MYSQLI_PRIV_H
+#define MYSQLI_PRIV_H
+
+#ifdef PHP_MYSQL_UNIX_SOCK_ADDR
+#ifdef MYSQL_UNIX_ADDR
+#undef MYSQL_UNIX_ADDR
+#endif
+#define MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
+#endif
+
+/* character set support */
+#if defined(MYSQLND_VERSION_ID) || MYSQL_VERSION_ID > 50009
+#define HAVE_MYSQLI_GET_CHARSET
+#endif
+
+#if defined(MYSQLND_VERSION_ID) || (MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID > 50005
+#define HAVE_MYSQLI_SET_CHARSET
+#endif
+
+
+extern const zend_function_entry mysqli_functions[];
+extern const zend_function_entry mysqli_link_methods[];
+extern const zend_function_entry mysqli_stmt_methods[];
+extern const zend_function_entry mysqli_result_methods[];
+extern const zend_function_entry mysqli_driver_methods[];
+extern const zend_function_entry mysqli_warning_methods[];
+extern const zend_function_entry mysqli_exception_methods[];
+
+extern const mysqli_property_entry mysqli_link_property_entries[];
+extern const mysqli_property_entry mysqli_result_property_entries[];
+extern const mysqli_property_entry mysqli_stmt_property_entries[];
+extern const mysqli_property_entry mysqli_driver_property_entries[];
+extern const mysqli_property_entry mysqli_warning_property_entries[];
+
+extern zend_property_info mysqli_link_property_info_entries[];
+extern zend_property_info mysqli_result_property_info_entries[];
+extern zend_property_info mysqli_stmt_property_info_entries[];
+extern zend_property_info mysqli_driver_property_info_entries[];
+extern zend_property_info mysqli_warning_property_info_entries[];
+
+extern int php_le_pmysqli(void);
+extern void php_mysqli_dtor_p_elements(void *data);
+
+extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRMLS_DC);
+
+extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flag, int into_object);
+extern void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC);
+extern void php_clear_mysql(MY_MYSQL *);
+extern MYSQLI_WARNING *php_get_warnings(MYSQL *mysql TSRMLS_DC);
+extern void php_clear_warnings(MYSQLI_WARNING *w);
+extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type);
+extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC);
+extern void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC);
+extern void php_set_local_infile_handler_default(MY_MYSQL *);
+extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
+
+#ifdef HAVE_SPL
+extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
+#endif
+
+#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \
+	zend_class_entry tmp_ce; \
+	INIT_CLASS_ENTRY(tmp_ce, name,class_functions); \
+	tmp_ce.create_object = mysqli_objects_new; \
+	mysqli_entry = zend_register_internal_class(&tmp_ce TSRMLS_CC); \
+} \
+
+#define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
+
+PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
+
+
+#define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \
+	mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
+	mysql->multi_query = 0; \
+}
+
+#define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \
+	mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \
+	mysql->multi_query = 1; \
+}
+
+
+#define MYSQLI_RETURN_LONG_LONG(__val) \
+{ \
+	if ((__val) < LONG_MAX) {		\
+		RETURN_LONG((long) (__val));		\
+	} else {				\
+		char *ret;			\
+		/* always used with my_ulonglong -> %llu */ \
+		int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (__val));	\
+		RETURN_STRINGL(ret, l, 0);		\
+	}					\
+}
+
+#define MYSQLI_STORE_RESULT 0
+#define MYSQLI_USE_RESULT 	1
+#ifdef MYSQLI_USE_MYSQLND
+#define MYSQLI_ASYNC	 	8
+#else
+/* libmysql */
+#define MYSQLI_ASYNC	 	0
+#endif
+
+/* for mysqli_fetch_assoc */
+#define MYSQLI_ASSOC	1
+#define MYSQLI_NUM		2
+#define MYSQLI_BOTH		3
+
+/* fetch types */
+#define FETCH_SIMPLE		1
+#define FETCH_RESULT		2
+
+/*** REPORT MODES ***/
+#define MYSQLI_REPORT_OFF           0
+#define MYSQLI_REPORT_ERROR			1
+#define MYSQLI_REPORT_STRICT		2
+#define MYSQLI_REPORT_INDEX			4
+#define MYSQLI_REPORT_CLOSE			8
+#define MYSQLI_REPORT_ALL		  255
+
+#define MYSQLI_REPORT_MYSQL_ERROR(mysql) \
+if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_errno(mysql)) { \
+	php_mysqli_report_error(mysql_sqlstate(mysql), mysql_errno(mysql), mysql_error(mysql) TSRMLS_CC); \
+}
+
+#define MYSQLI_REPORT_STMT_ERROR(stmt) \
+if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_stmt_errno(stmt)) { \
+	php_mysqli_report_error(mysql_stmt_sqlstate(stmt), mysql_stmt_errno(stmt), mysql_stmt_error(stmt) TSRMLS_CC); \
+}
+
+void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor);
+
+void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS);
+
+#endif /* MYSQLI_PRIV_H */
diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c
index 2578a54..6cf6c18 100644
--- a/ext/mysqli/mysqli_prop.c
+++ b/ext/mysqli/mysqli_prop.c
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_prop.c 296270 2010-03-16 12:36:57Z andrey $ 
+  $Id: mysqli_prop.c 304070 2010-10-05 09:40:36Z kalle $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -28,6 +28,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 
 #define CHECK_STATUS(value) \
 	if (!obj->ptr || ((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
@@ -83,7 +84,7 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
 	} else {\
 		l = (__ret_type)__int_func(p);\
 		if (l < LONG_MAX) {\
-			ZVAL_LONG(*retval, l);\
+			ZVAL_LONG(*retval, (long) l);\
 		} else { \
 			char *ret; \
 			int ret_len = spprintf(&ret, 0, __ret_type_sprint_mod, l); \
@@ -158,12 +159,12 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 	MY_MYSQL *mysql;
 	my_ulonglong rc;
 
-	MAKE_STD_ZVAL(*retval); 
+	MAKE_STD_ZVAL(*retval);
 
 	CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
 
  	mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
-	
+
 	if (!mysql) {
 		ZVAL_NULL(*retval);
 	} else {
@@ -174,10 +175,10 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 		if (rc == (my_ulonglong) -1) {
 			ZVAL_LONG(*retval, -1);
 			return SUCCESS;
-		} 
+		}
 
 		if (rc < LONG_MAX) {
-			ZVAL_LONG(*retval, rc);
+			ZVAL_LONG(*retval, (long) rc);
 		} else {
 			char *ret;
 			int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, rc);
@@ -189,18 +190,18 @@ static int link_affected_rows_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_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_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_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_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_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), ulong, "%lu")
+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_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_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_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")
 /* result properties */
 
 /* {{{ property result_type_read */
@@ -247,9 +248,9 @@ static int 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_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC);
+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_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong, MYSQLI_LLU_SPEC)
 
 /* statement properties */
 
@@ -258,7 +259,7 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
 	MY_STMT *p;
 
-	MAKE_STD_ZVAL(*retval); 
+	MAKE_STD_ZVAL(*retval);
 	CHECK_STATUS(MYSQLI_STATUS_VALID);
 
  	p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -278,7 +279,7 @@ static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 	MY_STMT *p;
 	my_ulonglong rc;
 
-	MAKE_STD_ZVAL(*retval); 
+	MAKE_STD_ZVAL(*retval);
 	CHECK_STATUS(MYSQLI_STATUS_VALID);
 
  	p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@@ -287,14 +288,14 @@ static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
 		ZVAL_NULL(*retval);
 	} else {
 		rc = mysql_stmt_affected_rows(p->stmt);
-	
+
 		if (rc == (my_ulonglong) -1) {
 			ZVAL_LONG(*retval, -1);
 			return SUCCESS;
-		} 
-	
+		}
+
 		if (rc < LONG_MAX) {
-			ZVAL_LONG(*retval, rc);
+			ZVAL_LONG(*retval, (long) rc);
 		} else {
 			char *ret;
 			int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, rc);
@@ -305,13 +306,13 @@ static int stmt_affected_rows_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_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));
+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_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))
 
 /* }}} */
 const mysqli_property_entry mysqli_link_property_entries[] = {
@@ -332,7 +333,7 @@ const mysqli_property_entry mysqli_link_property_entries[] = {
 	{"protocol_version",sizeof("protocol_version") - 1,	link_protocol_version_read, NULL},
 	{"thread_id",		sizeof("thread_id") - 1, 		link_thread_id_read, NULL},
 	{"warning_count",	sizeof("warning_count") - 1, 	link_warning_count_read, NULL},
-	{NULL, 0, NULL, NULL}	
+	{NULL, 0, NULL, NULL}
 };
 
 /* should not be const, as it is patched during runtime */
@@ -354,7 +355,7 @@ zend_property_info mysqli_link_property_info_entries[] = {
 	{ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, 0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "thread_id", 		sizeof("thread_id") - 1,		0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "warning_count",	sizeof("warning_count") - 1,	0, NULL, 0, NULL},
-	{0,					NULL, 			0,								0, NULL, 0, NULL}	
+	{0,					NULL, 			0,								0, NULL, 0, NULL}
 };
 
 
@@ -373,7 +374,7 @@ zend_property_info mysqli_result_property_info_entries[] = {
 	{ZEND_ACC_PUBLIC, "lengths",		sizeof("lengths") - 1, 		0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "num_rows",		sizeof("num_rows") - 1, 	0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "type",			sizeof("type") - 1, 		0, NULL, 0, NULL},
-	{0,					NULL, 			0,							0, NULL, 0, NULL}	
+	{0,					NULL, 			0,							0, NULL, 0, NULL}
 };
 
 const mysqli_property_entry mysqli_stmt_property_entries[] = {
@@ -400,7 +401,7 @@ zend_property_info mysqli_stmt_property_info_entries[] = {
 	{ZEND_ACC_PUBLIC, "error",		sizeof("error") - 1,			0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "sqlstate",	sizeof("sqlstate") - 1,			0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "id",			sizeof("id") - 1,				0, NULL, 0, NULL},
-	{0,					NULL, 			0,							0, NULL, 0, NULL}	
+	{0,					NULL, 			0,							0, NULL, 0, NULL}
 };
 
 /*
diff --git a/ext/mysqli/mysqli_report.c b/ext/mysqli/mysqli_report.c
index f48688f..1f1c8d2 100644
--- a/ext/mysqli/mysqli_report.c
+++ b/ext/mysqli/mysqli_report.c
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_report.c 293036 2010-01-03 09:23:27Z sebastian $ 
+  $Id: mysqli_report.c 305244 2010-11-10 13:57:09Z andrey $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -27,13 +27,15 @@
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
 
+extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
+
 /* {{{ proto bool mysqli_report(int flags)
    sets report level */
 PHP_FUNCTION(mysqli_report)
 {
-	long		flags;
+	long flags;
+
 
-	
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
 		return;
 	}
@@ -44,14 +46,14 @@ PHP_FUNCTION(mysqli_report)
 }
 /* }}} */
 
-/* {{{ void php_mysqli_report_error(char *sqlstate, int errorno, char *error) */ 
+/* {{{ void php_mysqli_report_error(char *sqlstate, int errorno, char *error) */
 void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC)
 {
 	php_mysqli_throw_sql_exception((char *)sqlstate, errorno TSRMLS_CC, "%s", error);
 }
 /* }}} */
 
-/* {{{ void php_mysqli_report_index() */ 
+/* {{{ void php_mysqli_report_index() */
 void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC) {
 	char index[15];
 
diff --git a/ext/mysqli/mysqli_report.h b/ext/mysqli/mysqli_report.h
index 8c44802..ad741b2 100644
--- a/ext/mysqli/mysqli_report.h
+++ b/ext/mysqli/mysqli_report.h
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: mysqli_report.h 293036 2010-01-03 09:23:27Z sebastian $
+  $Id: mysqli_report.h 303973 2010-10-04 10:02:58Z uw $
 */
 
 #ifndef __HAVE_MYSQLI_PROFILER_H__
@@ -34,7 +34,7 @@
 #endif
 
 typedef struct {
-	struct timeval	starttime, 
+	struct timeval	starttime,
 					endtime;		/* execution time */
 } PR_TIME_INFO;
 
diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c
index 2236db9..b2d5a55 100644
--- a/ext/mysqli/mysqli_warning.c
+++ b/ext/mysqli/mysqli_warning.c
@@ -26,6 +26,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
+#include "mysqli_priv.h"
 
 /* Define these in the PHP5 tree to make merging easy process */
 #define ZSTR_DUPLICATE (1<<0)
@@ -46,7 +47,7 @@ void php_clear_warnings(MYSQLI_WARNING *w)
 		zval_dtor(&(w->sqlstate));
 		w = w->next;
 		efree(n);
-	} 
+	}
 }
 /* }}} */
 
@@ -61,7 +62,7 @@ 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_STRINGL(&(w->sqlstate), "HY000", sizeof("HY000") - 1,  ZSTR_DUPLICATE);
 
 	w->errorno = errorno;
@@ -111,7 +112,7 @@ MYSQLI_WARNING *php_new_warning(const zval *reason, int errorno TSRMLS_DC)
 	zval_copy_ctor(&(w->reason));
 
 	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);
 
 	w->errorno = errorno;
@@ -182,14 +183,14 @@ MYSQLI_WARNING *php_get_warnings(MYSQL *mysql TSRMLS_DC)
 
 
 /* {{{ bool mysqli_warning::next() */
-PHP_METHOD(mysqli_warning, next) 
+PHP_METHOD(mysqli_warning, next)
 {
 	MYSQLI_WARNING 	*w;
 	zval  			*mysqli_warning;
 	mysqli_object *obj = (mysqli_object *)zend_objects_get_address(getThis() TSRMLS_CC);
 
 	if (obj->ptr) {
-		if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
+		if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
 										 &mysqli_warning, mysqli_warning_class_entry) == FAILURE) {
 			return;
 		}
@@ -231,7 +232,7 @@ static
 int mysqli_warning_sqlstate(mysqli_object *obj, zval **retval TSRMLS_DC)
 {
 	MYSQLI_WARNING *w;
-	
+
 	if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
 		return FAILURE;
 	}
@@ -292,7 +293,7 @@ PHP_METHOD(mysqli_warning, __construct)
 	}
 
 	if (mysql_warning_count(hdl)) {
-		w = php_get_warnings(hdl TSRMLS_CC); 
+		w = php_get_warnings(hdl TSRMLS_CC);
 	} else {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "No warnings found");
 		RETURN_FALSE;
@@ -303,7 +304,7 @@ PHP_METHOD(mysqli_warning, __construct)
 	mysqli_resource->status = MYSQLI_STATUS_VALID;
 
 	if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_warning_class_entry TSRMLS_CC)) {
-		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);	
+		MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
 	} else {
 		((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
 	}
@@ -333,7 +334,7 @@ zend_property_info mysqli_warning_property_info_entries[] = {
 	{ZEND_ACC_PUBLIC, "message", 	sizeof("message") - 1,	0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "sqlstate",	sizeof("sqlstate") - 1,	0, NULL, 0, NULL},
 	{ZEND_ACC_PUBLIC, "errno",		sizeof("errno") - 1, 	0, NULL, 0, NULL},
-	{0,					NULL, 			0,					0, NULL, 0, NULL}	
+	{0,					NULL, 			0,					0, NULL, 0, NULL}
 };
 /* }}} */
 
diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h
index 2c279d0..f843f65 100644
--- a/ext/mysqli/php_mysqli.h
+++ b/ext/mysqli/php_mysqli.h
@@ -17,7 +17,7 @@
   |          Ulf Wendel <uw at php.net>                                     |
   +----------------------------------------------------------------------+
 
-  $Id: php_mysqli.h 293036 2010-01-03 09:23:27Z sebastian $ 
+  $Id: php_mysqli.h 303973 2010-10-04 10:02:58Z uw $
 */
 
 #ifndef PHP_MYSQLI_H
diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h
index 4a7b40c..504c346 100644
--- a/ext/mysqli/php_mysqli_structs.h
+++ b/ext/mysqli/php_mysqli_structs.h
@@ -15,7 +15,7 @@
   | Author: Georg Richter <georg at php.net>                                |
   +----------------------------------------------------------------------+
 
-  $Id: php_mysqli_structs.h 300436 2010-06-14 18:19:13Z andrey $ 
+  $Id: php_mysqli_structs.h 303973 2010-10-04 10:02:58Z uw $
 */
 
 #ifndef PHP_MYSQLI_STRUCTS_H
@@ -54,6 +54,10 @@
 #define WE_HAD_MBSTATE_T
 #endif
 
+#if defined(ulong) && !defined(HAVE_ULONG)
+#define HAVE_ULONG
+#endif
+
 #include <my_global.h>
 
 #if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
@@ -79,25 +83,8 @@
 #include <my_list.h>
 #include <m_ctype.h>
 #include "mysqli_libmysql.h"
-#endif
-
-#ifdef PHP_MYSQL_UNIX_SOCK_ADDR
-#ifdef MYSQL_UNIX_ADDR
-#undef MYSQL_UNIX_ADDR
-#endif
-#define MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
-#endif
-
-#include "php_mysqli.h"
-
-/* character set support */
-#if defined(MYSQLND_VERSION_ID) || MYSQL_VERSION_ID > 50009
-#define HAVE_MYSQLI_GET_CHARSET
-#endif
+#endif /* MYSQLI_USE_MYSQLND */
 
-#if defined(MYSQLND_VERSION_ID) || (MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID > 50005
-#define HAVE_MYSQLI_SET_CHARSET
-#endif
 
 #define MYSQLI_VERSION_ID		101009
 
@@ -137,7 +124,7 @@ typedef struct {
 	unsigned int 	multi_query;
 	zend_bool		persistent;
 #if defined(MYSQLI_USE_MYSQLND)
-	int				async_result_fetch_type;				
+	int				async_result_fetch_type;
 #endif
 } MY_MYSQL;
 
@@ -190,7 +177,9 @@ typedef struct {
 #define PHP_MYSQLI_API __declspec(dllexport)
 #define MYSQLI_LLU_SPEC "%I64u"
 #define MYSQLI_LL_SPEC "%I64d"
+#ifndef L64
 #define L64(x) x##i64
+#endif
 typedef __int64 my_longlong;
 #else
 # if defined(__GNUC__) && __GNUC__ >= 4
@@ -202,7 +191,9 @@ typedef __int64 my_longlong;
 #include <inttypes.h>
 #define MYSQLI_LLU_SPEC "%" PRIu64
 #define MYSQLI_LL_SPEC "%" PRId64
+#ifndef L64
 #define L64(x) x##LL
+#endif
 typedef int64_t my_longlong;
 #endif
 
@@ -210,72 +201,12 @@ typedef int64_t my_longlong;
 #include "TSRM.h"
 #endif
 
-#define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
-
-extern const zend_function_entry mysqli_functions[];
-extern const zend_function_entry mysqli_link_methods[];
-extern const zend_function_entry mysqli_stmt_methods[];
-extern const zend_function_entry mysqli_result_methods[];
-extern const zend_function_entry mysqli_driver_methods[];
-extern const zend_function_entry mysqli_warning_methods[];
-extern const zend_function_entry mysqli_exception_methods[];
-
-extern const mysqli_property_entry mysqli_link_property_entries[];
-extern const mysqli_property_entry mysqli_result_property_entries[];
-extern const mysqli_property_entry mysqli_stmt_property_entries[];
-extern const mysqli_property_entry mysqli_driver_property_entries[];
-extern const mysqli_property_entry mysqli_warning_property_entries[];
-
-extern zend_property_info mysqli_link_property_info_entries[];
-extern zend_property_info mysqli_result_property_info_entries[];
-extern zend_property_info mysqli_stmt_property_info_entries[];
-extern zend_property_info mysqli_driver_property_info_entries[];
-extern zend_property_info mysqli_warning_property_info_entries[];
-
-extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flag, int into_object);
-extern void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC);
-extern void php_clear_mysql(MY_MYSQL *);
-extern MYSQLI_WARNING *php_get_warnings(MYSQL *mysql TSRMLS_DC);
-extern void php_clear_warnings(MYSQLI_WARNING *w);
-extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type);
-extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC);
-extern void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC);
-extern void php_set_local_infile_handler_default(MY_MYSQL *);
-extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
 extern zend_class_entry *mysqli_link_class_entry;
 extern zend_class_entry *mysqli_stmt_class_entry;
 extern zend_class_entry *mysqli_result_class_entry;
 extern zend_class_entry *mysqli_driver_class_entry;
 extern zend_class_entry *mysqli_warning_class_entry;
 extern zend_class_entry *mysqli_exception_class_entry;
-extern int php_le_pmysqli(void);
-extern void php_mysqli_dtor_p_elements(void *data);
-
-extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRMLS_DC);
-
-
-#ifdef HAVE_SPL
-extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
-#endif
-
-PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
-
-#define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \
-	mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
-	mysql->multi_query = 0; \
-} 
-
-#define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \
-	mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \
-	mysql->multi_query = 1; \
-} 
-
-#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \
-	zend_class_entry ce; \
-	INIT_CLASS_ENTRY(ce, name,class_functions); \
-	ce.create_object = mysqli_objects_new; \
-	mysqli_entry = zend_register_internal_class(&ce TSRMLS_CC); \
-} \
 
 #define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval)  \
 	((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr;
@@ -345,58 +276,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
 	intern->ptr = NULL; \
 }
 
-#define MYSQLI_RETURN_LONG_LONG(__val) \
-{ \
-	if ((__val) < LONG_MAX) {		\
-		RETURN_LONG((long) (__val));		\
-	} else {				\
-		char *ret;			\
-		/* always used with my_ulonglong -> %llu */ \
-		int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (__val));	\
-		RETURN_STRINGL(ret, l, 0);		\
-	}					\
-}
-
-#define MYSQLI_STORE_RESULT 0
-#define MYSQLI_USE_RESULT 	1
-#ifdef MYSQLI_USE_MYSQLND
-#define MYSQLI_ASYNC	 	8
-#else
-/* libmysql */
-#define MYSQLI_ASYNC	 	0
-#endif
-
-/* for mysqli_fetch_assoc */
-#define MYSQLI_ASSOC	1
-#define MYSQLI_NUM		2
-#define MYSQLI_BOTH		3
-
-/* fetch types */
-#define FETCH_SIMPLE		1
-#define FETCH_RESULT		2
-
-/*** REPORT MODES ***/
-#define MYSQLI_REPORT_OFF           0
-#define MYSQLI_REPORT_ERROR			1
-#define MYSQLI_REPORT_STRICT		2
-#define MYSQLI_REPORT_INDEX			4
-#define MYSQLI_REPORT_CLOSE			8	
-#define MYSQLI_REPORT_ALL		  255
-
-#define MYSQLI_REPORT_MYSQL_ERROR(mysql) \
-if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_errno(mysql)) { \
-	php_mysqli_report_error(mysql_sqlstate(mysql), mysql_errno(mysql), mysql_error(mysql) TSRMLS_CC); \
-}
-
-#define MYSQLI_REPORT_STMT_ERROR(stmt) \
-if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_stmt_errno(stmt)) { \
-	php_mysqli_report_error(mysql_stmt_sqlstate(stmt), mysql_stmt_errno(stmt), mysql_stmt_error(stmt) TSRMLS_CC); \
-}
-
-void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor);
-
-void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS);
-
 
 ZEND_BEGIN_MODULE_GLOBALS(mysqli)
 	long			default_link;
@@ -435,123 +314,6 @@ ZEND_END_MODULE_GLOBALS(mysqli)
 
 ZEND_EXTERN_MODULE_GLOBALS(mysqli)
 
-
-PHP_MINIT_FUNCTION(mysqli);
-PHP_MSHUTDOWN_FUNCTION(mysqli);
-PHP_RINIT_FUNCTION(mysqli);
-PHP_RSHUTDOWN_FUNCTION(mysqli);
-PHP_MINFO_FUNCTION(mysqli);
-
-PHP_FUNCTION(mysqli);
-PHP_FUNCTION(mysqli_affected_rows);
-PHP_FUNCTION(mysqli_autocommit);
-PHP_FUNCTION(mysqli_change_user);
-PHP_FUNCTION(mysqli_character_set_name);
-PHP_FUNCTION(mysqli_set_charset);
-PHP_FUNCTION(mysqli_close);
-PHP_FUNCTION(mysqli_commit);
-PHP_FUNCTION(mysqli_connect);
-PHP_FUNCTION(mysqli_connect_errno);
-PHP_FUNCTION(mysqli_connect_error);
-PHP_FUNCTION(mysqli_data_seek);
-PHP_FUNCTION(mysqli_debug);
-PHP_FUNCTION(mysqli_dump_debug_info);
-PHP_FUNCTION(mysqli_errno);
-PHP_FUNCTION(mysqli_error);
-PHP_FUNCTION(mysqli_fetch_all);
-PHP_FUNCTION(mysqli_fetch_array);
-PHP_FUNCTION(mysqli_fetch_assoc);
-PHP_FUNCTION(mysqli_fetch_object);
-PHP_FUNCTION(mysqli_fetch_field);
-PHP_FUNCTION(mysqli_fetch_fields);
-PHP_FUNCTION(mysqli_fetch_field_direct);
-PHP_FUNCTION(mysqli_fetch_lengths);
-PHP_FUNCTION(mysqli_fetch_row);
-PHP_FUNCTION(mysqli_field_count);
-PHP_FUNCTION(mysqli_field_seek);
-PHP_FUNCTION(mysqli_field_tell);
-PHP_FUNCTION(mysqli_free_result);
-PHP_FUNCTION(mysqli_get_cache_stats);
-PHP_FUNCTION(mysqli_get_client_stats);
-PHP_FUNCTION(mysqli_get_connection_stats);
-PHP_FUNCTION(mysqli_get_charset);
-PHP_FUNCTION(mysqli_get_client_info);
-PHP_FUNCTION(mysqli_get_client_version);
-PHP_FUNCTION(mysqli_get_host_info);
-PHP_FUNCTION(mysqli_get_proto_info);
-PHP_FUNCTION(mysqli_get_server_info);
-PHP_FUNCTION(mysqli_get_server_version);
-PHP_FUNCTION(mysqli_get_warnings);
-PHP_FUNCTION(mysqli_info);
-PHP_FUNCTION(mysqli_insert_id);
-PHP_FUNCTION(mysqli_init);
-PHP_FUNCTION(mysqli_kill);
-PHP_FUNCTION(mysqli_link_construct);
-PHP_FUNCTION(mysqli_set_local_infile_default);
-PHP_FUNCTION(mysqli_set_local_infile_handler);
-PHP_FUNCTION(mysqli_more_results);
-PHP_FUNCTION(mysqli_multi_query);
-PHP_FUNCTION(mysqli_next_result);
-PHP_FUNCTION(mysqli_num_fields);
-PHP_FUNCTION(mysqli_num_rows);
-PHP_FUNCTION(mysqli_options);
-PHP_FUNCTION(mysqli_ping);
-PHP_FUNCTION(mysqli_poll);
-PHP_FUNCTION(mysqli_prepare);
-PHP_FUNCTION(mysqli_query);
-PHP_FUNCTION(mysqli_stmt_result_metadata);
-PHP_FUNCTION(mysqli_report);
-PHP_FUNCTION(mysqli_read_query_result);
-PHP_FUNCTION(mysqli_real_connect);
-PHP_FUNCTION(mysqli_real_query);
-PHP_FUNCTION(mysqli_real_escape_string);
-PHP_FUNCTION(mysqli_reap_async_query);
-PHP_FUNCTION(mysqli_rollback);
-PHP_FUNCTION(mysqli_row_seek);
-PHP_FUNCTION(mysqli_select_db);
-PHP_FUNCTION(mysqli_stmt_attr_get);
-PHP_FUNCTION(mysqli_stmt_attr_set);
-PHP_FUNCTION(mysqli_stmt_bind_param);
-PHP_FUNCTION(mysqli_stmt_bind_result);
-PHP_FUNCTION(mysqli_stmt_execute);
-PHP_FUNCTION(mysqli_stmt_field_count);
-PHP_FUNCTION(mysqli_stmt_init);
-PHP_FUNCTION(mysqli_stmt_prepare);
-PHP_FUNCTION(mysqli_stmt_fetch);
-PHP_FUNCTION(mysqli_stmt_param_count);
-PHP_FUNCTION(mysqli_stmt_send_long_data);
-PHP_FUNCTION(mysqli_embedded_server_end);
-PHP_FUNCTION(mysqli_embedded_server_start);
-PHP_FUNCTION(mysqli_sqlstate);
-PHP_FUNCTION(mysqli_ssl_set);
-PHP_FUNCTION(mysqli_stat);
-PHP_FUNCTION(mysqli_refresh);
-PHP_FUNCTION(mysqli_stmt_affected_rows);
-PHP_FUNCTION(mysqli_stmt_close);
-PHP_FUNCTION(mysqli_stmt_data_seek);
-PHP_FUNCTION(mysqli_stmt_errno);
-PHP_FUNCTION(mysqli_stmt_error);
-PHP_FUNCTION(mysqli_stmt_free_result);
-PHP_FUNCTION(mysqli_stmt_get_result);
-PHP_FUNCTION(mysqli_stmt_get_warnings);
-PHP_FUNCTION(mysqli_stmt_reset);
-PHP_FUNCTION(mysqli_stmt_insert_id);
-PHP_FUNCTION(mysqli_stmt_more_results);
-PHP_FUNCTION(mysqli_stmt_next_result);
-PHP_FUNCTION(mysqli_stmt_num_rows);
-PHP_FUNCTION(mysqli_stmt_sqlstate);
-PHP_FUNCTION(mysqli_stmt_store_result);
-PHP_FUNCTION(mysqli_store_result);
-PHP_FUNCTION(mysqli_thread_id);
-PHP_FUNCTION(mysqli_thread_safe);
-PHP_FUNCTION(mysqli_use_result);
-PHP_FUNCTION(mysqli_warning_count);
-
-PHP_FUNCTION(mysqli_stmt_construct);
-PHP_FUNCTION(mysqli_result_construct);
-PHP_FUNCTION(mysqli_driver_construct);
-PHP_METHOD(mysqli_warning,__construct);
-
 #endif	/* PHP_MYSQLI_STRUCTS.H */
 
 
diff --git a/ext/mysqli/tests/002.phpt b/ext/mysqli/tests/002.phpt
index c183108..522c99e 100644
--- a/ext/mysqli/tests/002.phpt
+++ b/ext/mysqli/tests/002.phpt
@@ -32,10 +32,10 @@ require_once('skipifconnectfailure.inc');
 		printf("[004] Cannot insert records, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null ORDER BY col1");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
-	mysqli_execute($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
 
diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt
index 9094c86..9374763 100644
--- a/ext/mysqli/tests/003.phpt
+++ b/ext/mysqli/tests/003.phpt
@@ -59,9 +59,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/004.phpt b/ext/mysqli/tests/004.phpt
index 184ecea..ce222fe 100644
--- a/ext/mysqli/tests/004.phpt
+++ b/ext/mysqli/tests/004.phpt
@@ -33,11 +33,11 @@ require_once('skipifconnectfailure.inc');
 		printf("[006] [%d] string\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1");
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_execute($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_execute($stmt);
 	$i = 4;
 	while ($i--) {
-		mysqli_fetch($stmt);
+		mysqli_stmt_fetch($stmt);
 		$test = array($c1, $c2);
 		var_dump($test);
 	}
diff --git a/ext/mysqli/tests/005.phpt b/ext/mysqli/tests/005.phpt
index 0d59f40..07292a1 100644
--- a/ext/mysqli/tests/005.phpt
+++ b/ext/mysqli/tests/005.phpt
@@ -23,9 +23,9 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', '$a')");
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test[] = $c1;
 	$test[] = ($a == $c2) ? "32K String ok" : "32K String failed";
@@ -33,7 +33,7 @@ require_once('skipifconnectfailure.inc');
 	var_dump($test);
 
 	/* this will crash with libmysql from PHP 5.0.6 (or earlier) to 5.3.0 */
-	mysqli_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	mysqli_stmt_close($stmt);
 	mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
diff --git a/ext/mysqli/tests/006.phpt b/ext/mysqli/tests/006.phpt
index 4974265..2043cc5 100644
--- a/ext/mysqli/tests/006.phpt
+++ b/ext/mysqli/tests/006.phpt
@@ -32,9 +32,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/007.phpt b/ext/mysqli/tests/007.phpt
index 05a8ae5..26b5763 100644
--- a/ext/mysqli/tests/007.phpt
+++ b/ext/mysqli/tests/007.phpt
@@ -32,9 +32,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/008.phpt b/ext/mysqli/tests/008.phpt
index ba0e340..0ae09df 100644
--- a/ext/mysqli/tests/008.phpt
+++ b/ext/mysqli/tests/008.phpt
@@ -32,9 +32,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/009.phpt b/ext/mysqli/tests/009.phpt
index 3e26f51..30d42c3 100644
--- a/ext/mysqli/tests/009.phpt
+++ b/ext/mysqli/tests/009.phpt
@@ -39,9 +39,9 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
 		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
-	mysqli_execute($stmt);
-	$rc = mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
+	mysqli_stmt_execute($stmt);
+	$rc = mysqli_stmt_fetch($stmt);
 
 	if (mysqli_get_server_version($link) < 50000) {
 		// 4.1 is faulty and will return big number for $c6
@@ -66,9 +66,9 @@ mysqli fetch bigint values (ok to fail with 4.1.x)
 		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint");
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_execute($stmt);
-	$rc = mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_execute($stmt);
+	$rc = mysqli_stmt_fetch($stmt);
 
 	echo $c1, "\n", $c2, "\n";
 
diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt
index fab0c57..60ff8ea 100644
--- a/ext/mysqli/tests/010.phpt
+++ b/ext/mysqli/tests/010.phpt
@@ -35,9 +35,9 @@ require_once('skipifconnectfailure.inc');
 											sin(0.6), 1.00000000000001, 888888888888888)");
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt
index 83f35e5..db03aba 100644
--- a/ext/mysqli/tests/011.phpt
+++ b/ext/mysqli/tests/011.phpt
@@ -32,9 +32,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
 
diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt
index da4a48a..7cc34b0 100644
--- a/ext/mysqli/tests/012.phpt
+++ b/ext/mysqli/tests/012.phpt
@@ -31,9 +31,9 @@ require_once('skipifconnectfailure.inc');
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
 
diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt
index 5ddb496..6d75bde 100644
--- a/ext/mysqli/tests/013.phpt
+++ b/ext/mysqli/tests/013.phpt
@@ -31,10 +31,10 @@ require_once('skipifconnectfailure.inc');
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
 
 	$c = array(0,0,0,0,0,0,0,0);
-	$b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
-	mysqli_fetch($stmt);
+	$b_res= mysqli_stmt_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 	mysqli_stmt_close($stmt);
 
 	$result = mysqli_query($link, "select * from test_bind_result");
diff --git a/ext/mysqli/tests/016.phpt b/ext/mysqli/tests/016.phpt
index ce1ea83..8e1ffe6 100644
--- a/ext/mysqli/tests/016.phpt
+++ b/ext/mysqli/tests/016.phpt
@@ -18,9 +18,9 @@ require_once('skipifconnectfailure.inc');
 	if (!$stmt = mysqli_prepare($link, "SELECT @dummy"))
 		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	mysqli_bind_result($stmt, $dummy);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $dummy);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	var_dump($dummy);
 
diff --git a/ext/mysqli/tests/017.phpt b/ext/mysqli/tests/017.phpt
index a48ae5c..082202f 100644
--- a/ext/mysqli/tests/017.phpt
+++ b/ext/mysqli/tests/017.phpt
@@ -16,10 +16,10 @@ require_once('skipifconnectfailure.inc');
 	if (!$stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"))
 		printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	mysqli_bind_result($stmt, $c0, $c1, $c2);
-	mysqli_execute($stmt);
+	mysqli_stmt_bind_result($stmt, $c0, $c1, $c2);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 	mysqli_stmt_close($stmt);
 
 	$test = array($c0, $c1, $c2);
diff --git a/ext/mysqli/tests/018.phpt b/ext/mysqli/tests/018.phpt
index 8747644..d5466e2 100644
--- a/ext/mysqli/tests/018.phpt
+++ b/ext/mysqli/tests/018.phpt
@@ -18,10 +18,10 @@ require_once('skipifconnectfailure.inc');
 	if (!$stmt = mysqli_prepare($link, "SELECT @@autocommit"))
 		printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	mysqli_bind_result($stmt, $c0);
-	mysqli_execute($stmt);
+	mysqli_stmt_bind_result($stmt, $c0);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	var_dump($c0);
 
diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt
index 51cf973..5e6aac0 100644
--- a/ext/mysqli/tests/019.phpt
+++ b/ext/mysqli/tests/019.phpt
@@ -28,23 +28,23 @@ require_once('skipifconnectfailure.inc');
 	if (!$stmt = mysqli_prepare($link, "INSERT INTO insert_read(col1,col10, col11, col6) VALUES (?,?,?,?)"))
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	mysqli_bind_param($stmt, "issd", $c1, $c2, $c3, $c4);
+	mysqli_stmt_bind_param($stmt, "issd", $c1, $c2, $c3, $c4);
 
 	$c1 = 1;
 	$c2 = "foo";
 	$c3 = "foobar";
 	$c4 = 3.14;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	if (!$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 FROM insert_read"))
 		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
-	mysqli_execute($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_fetch($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
 
diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt
index 6e867d7..6512cd8 100644
--- a/ext/mysqli/tests/020.phpt
+++ b/ext/mysqli/tests/020.phpt
@@ -37,7 +37,7 @@ require_once('skipifconnectfailure.inc');
 		c7 timestamp)");
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
-	mysqli_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
+	mysqli_stmt_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
 
 	$d1 = "2002-01-02";
 	$d2 = "12:49:00";
@@ -47,15 +47,15 @@ require_once('skipifconnectfailure.inc');
 	$d6 = "2020";
 	$d7 = "1999-12-29";
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
 
-	mysqli_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
 
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/021.phpt b/ext/mysqli/tests/021.phpt
index 5dec86c..5ff58c0 100644
--- a/ext/mysqli/tests/021.phpt
+++ b/ext/mysqli/tests/021.phpt
@@ -18,16 +18,16 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
-	mysqli_bind_param($stmt, "ss", $q1, $q2);
+	mysqli_stmt_bind_param($stmt, "ss", $q1, $q2);
 	$q1 = "1234567890";
 	$q2 = "this is a test";
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2);
 
diff --git a/ext/mysqli/tests/022.phpt b/ext/mysqli/tests/022.phpt
index 8e1f017..9cb71c0 100644
--- a/ext/mysqli/tests/022.phpt
+++ b/ext/mysqli/tests/022.phpt
@@ -19,18 +19,18 @@ require_once('skipifconnectfailure.inc');
 
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
-	mysqli_bind_param($stmt, "ss", $a1, $a2);
+	mysqli_stmt_bind_param($stmt, "ss", $a1, $a2);
 
 	$a1 = "1234567890";
 	$a2 = str_repeat("A1", 32000);
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test[] = $c1;
 	$test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
diff --git a/ext/mysqli/tests/023.phpt b/ext/mysqli/tests/023.phpt
index 97c7812..2528519 100644
--- a/ext/mysqli/tests/023.phpt
+++ b/ext/mysqli/tests/023.phpt
@@ -25,7 +25,7 @@ require_once('skipifconnectfailure.inc');
 		c7 int)");
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
-	mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
+	mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
 	$c1 = -23;
 	$c2 = 35999;
 	$c3 = NULL;
@@ -34,13 +34,13 @@ require_once('skipifconnectfailure.inc');
 	$c6 = -0;
 	$c7 = 0;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/024.phpt b/ext/mysqli/tests/024.phpt
index 2cb93be..893ca0d 100644
--- a/ext/mysqli/tests/024.phpt
+++ b/ext/mysqli/tests/024.phpt
@@ -25,7 +25,7 @@ require_once('skipifconnectfailure.inc');
 		c7 smallint)");
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
-	mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
+	mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
 	$c1 = -23;
 	$c2 = 35999;
@@ -35,13 +35,13 @@ require_once('skipifconnectfailure.inc');
 	$c6 = -0;
 	$c7 = 0;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/025.phpt b/ext/mysqli/tests/025.phpt
index 84a9f67..937d624 100644
--- a/ext/mysqli/tests/025.phpt
+++ b/ext/mysqli/tests/025.phpt
@@ -25,7 +25,7 @@ require_once('skipifconnectfailure.inc');
 		c7 tinyint)");
 
 	$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)");
-	mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
+	mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
 	$c1 = -23;
 	$c2 = 300;
@@ -35,7 +35,7 @@ require_once('skipifconnectfailure.inc');
 	$c6 = 30;
 	$c7 = 0;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
@@ -43,9 +43,9 @@ require_once('skipifconnectfailure.inc');
 	$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
diff --git a/ext/mysqli/tests/026.phpt b/ext/mysqli/tests/026.phpt
index ec4baa2..47d763a 100644
--- a/ext/mysqli/tests/026.phpt
+++ b/ext/mysqli/tests/026.phpt
@@ -19,21 +19,21 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
 
 	$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
-	mysqli_bind_param($stmt, "sb", $c1, $c2);
+	mysqli_stmt_bind_param($stmt, "sb", $c1, $c2);
 
 	$c1 = "Hello World";
 
-	mysqli_send_long_data($stmt, 1, "This is the first sentence.");
-	mysqli_send_long_data($stmt, 1, " And this is the second sentence.");
-	mysqli_send_long_data($stmt, 1, " And finally this is the last sentence.");
+	mysqli_stmt_send_long_data($stmt, 1, "This is the first sentence.");
+	mysqli_stmt_send_long_data($stmt, 1, " And this is the second sentence.");
+	mysqli_stmt_send_long_data($stmt, 1, " And finally this is the last sentence.");
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
-	mysqli_bind_result($stmt, $d1, $d2);
-	mysqli_execute($stmt);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $d1, $d2);
+	mysqli_stmt_execute($stmt);
+	mysqli_stmt_fetch($stmt);
 
 	$test = array($d1,$d2);
 
diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt
index 55da0cd..31f38f7 100644
--- a/ext/mysqli/tests/042.phpt
+++ b/ext/mysqli/tests/042.phpt
@@ -25,7 +25,7 @@ require_once('skipifconnectfailure.inc');
 		c7 smallint) ENGINE=" . $engine);
 
 	$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
-	mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
+	mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
 
 	$c1 = -23;
 	$c2 = 35999;
@@ -35,7 +35,7 @@ require_once('skipifconnectfailure.inc');
 	$c6 = -0;
 	$c7 = 0;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$result = mysqli_query($link, "SELECT * FROM test_bind_fetch");
diff --git a/ext/mysqli/tests/043.phpt b/ext/mysqli/tests/043.phpt
index 5d060b9..c3a9901 100644
--- a/ext/mysqli/tests/043.phpt
+++ b/ext/mysqli/tests/043.phpt
@@ -1,5 +1,5 @@
 --TEST--
-mysqli_bind_param (UPDATE)
+mysqli_stmt_bind_param (UPDATE)
 --SKIPIF--
 <?php
 require_once('skipif.inc');
@@ -21,13 +21,13 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link, "INSERT INTO test_update VALUES ('foo', 2)");
 
 	$stmt = mysqli_prepare($link, "UPDATE test_update SET a=?,b=? WHERE b=?");
-	mysqli_bind_param($stmt, "sii", $c1, $c2, $c3);
+	mysqli_stmt_bind_param($stmt, "sii", $c1, $c2, $c3);
 
 	$c1 = "Rasmus";
 	$c2 = 1;
 	$c3 = 2;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$result = mysqli_query($link, "SELECT concat(a, ' is No. ', b) FROM test_update");
diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt
index 0b17060..d11c166 100644
--- a/ext/mysqli/tests/045.phpt
+++ b/ext/mysqli/tests/045.phpt
@@ -1,5 +1,5 @@
 --TEST--
-mysqli_bind_result (SHOW)
+mysqli_stmt_bind_result (SHOW)
 --SKIPIF--
 <?php
 	require_once('skipif.inc');
@@ -10,7 +10,7 @@ mysqli_bind_result (SHOW)
 	$link = my_mysqli_connect($host, $user, $passwd);
 
 	$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
 	if (!$stmt->field_count) {
 		printf("skip SHOW command is not supported in prepared statements.");
@@ -26,10 +26,10 @@ mysqli_bind_result (SHOW)
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 	$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_bind_result($stmt, $c1, $c2);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $c1, $c2);
+	mysqli_stmt_fetch($stmt);
 	mysqli_stmt_close($stmt);
 	if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && mysqli_get_server_version($link) < 50000) {
 		/* variables are binary */
diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt
index 18c86e3..1abc5e7 100644
--- a/ext/mysqli/tests/046.phpt
+++ b/ext/mysqli/tests/046.phpt
@@ -20,11 +20,11 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)");
 
 	$stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?");
-	mysqli_bind_param($stmt, "i", $c1);
+	mysqli_stmt_bind_param($stmt, "i", $c1);
 
 	$c1 = 2;
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	$x = mysqli_stmt_affected_rows($stmt);
 
 	mysqli_stmt_close($stmt);
diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt
index 5a86857..65c951c 100644
--- a/ext/mysqli/tests/047.phpt
+++ b/ext/mysqli/tests/047.phpt
@@ -1,5 +1,5 @@
 --TEST--
-mysqli_get_metadata
+mysqli_stmt_result_metadata
 --SKIPIF--
 <?php
 require_once('skipif.inc');
@@ -20,8 +20,8 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link, "INSERT INTO test_affected VALUES (1, 'Zak'),(2, 'Greant')");
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_affected");
-	mysqli_execute($stmt);
-	$result = mysqli_get_metadata($stmt);
+	mysqli_stmt_execute($stmt);
+	$result = mysqli_stmt_result_metadata($stmt);
 
 	echo "\n=== fetch_fields ===\n";
 	var_dump(mysqli_fetch_fields($result));
diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt
index 4e750c9..448f164 100644
--- a/ext/mysqli/tests/050.phpt
+++ b/ext/mysqli/tests/050.phpt
@@ -15,7 +15,7 @@ require_once('skipifconnectfailure.inc');
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 	$stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
 	mysqli_close($link);
 	printf("Ok\n");
diff --git a/ext/mysqli/tests/051.phpt b/ext/mysqli/tests/051.phpt
index ac85410..4a766fb 100644
--- a/ext/mysqli/tests/051.phpt
+++ b/ext/mysqli/tests/051.phpt
@@ -15,7 +15,7 @@ require_once('skipifconnectfailure.inc');
 	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
 	$stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
-	mysqli_execute($stmt1);
+	mysqli_stmt_execute($stmt1);
 
 	mysqli_close($link);
 	@mysqli_stmt_close($stmt1);
diff --git a/ext/mysqli/tests/052.phpt b/ext/mysqli/tests/052.phpt
index 89336ad..1d131f1 100644
--- a/ext/mysqli/tests/052.phpt
+++ b/ext/mysqli/tests/052.phpt
@@ -17,7 +17,7 @@ require_once('skipifconnectfailure.inc');
 	$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
 
 	mysqli_close($link);
-	@mysqli_execute($stmt2);
+	@mysqli_stmt_execute($stmt2);
 	@mysqli_stmt_close($stmt2);
 	printf("Ok\n");
 ?>
diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt
index 92f82d4..8c8b3ee 100644
--- a/ext/mysqli/tests/057.phpt
+++ b/ext/mysqli/tests/057.phpt
@@ -1,5 +1,5 @@
 --TEST--
-mysqli_get_metadata
+mysqli_stmt_result_metadata
 --SKIPIF--
 <?php
 require_once('skipif.inc');
@@ -20,7 +20,7 @@ require_once('skipifconnectfailure.inc');
 	mysqli_query($link, "INSERT INTO test_store_result VALUES (1),(2),(3)");
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
 	/* this should produce an out of sync error */
 	if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) {
@@ -31,20 +31,20 @@ require_once('skipifconnectfailure.inc');
 
 	/* now we should try mysqli_stmt_reset() */
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
-	var_dump(mysqli_execute($stmt));
+	var_dump(mysqli_stmt_execute($stmt));
 	var_dump(mysqli_stmt_reset($stmt));
 
 	var_dump($stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"));
 	if ($IS_MYSQLND && $stmt->affected_rows !== -1)
 			printf("[001] Expecting -1, got %d\n", $stmt->affected_rows);
 
-	var_dump(mysqli_execute($stmt));
+	var_dump(mysqli_stmt_execute($stmt));
 	var_dump($stmt = @mysqli_prepare($link, "SELECT * FROM test_store_result"), mysqli_error($link));
 	var_dump(mysqli_stmt_reset($stmt));
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
-	mysqli_execute($stmt);
-	$result1 = mysqli_get_metadata($stmt);
+	mysqli_stmt_execute($stmt);
+	$result1 = mysqli_stmt_result_metadata($stmt);
 	mysqli_stmt_store_result($stmt);
 
 	printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt));
diff --git a/ext/mysqli/tests/058.phpt b/ext/mysqli/tests/058.phpt
index a831261..3d2eed7 100644
--- a/ext/mysqli/tests/058.phpt
+++ b/ext/mysqli/tests/058.phpt
@@ -19,29 +19,29 @@ require_once('skipifconnectfailure.inc');
 
 	$stmt = mysqli_prepare($link, "INSERT INTO mbind VALUES (?,?)");
 
-	mysqli_bind_param($stmt, "is", $a, $b);
+	mysqli_stmt_bind_param($stmt, "is", $a, $b);
 
 	$a = 1;
 	$b = "foo";
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_bind_param($stmt, "is", $c, $d);
+	mysqli_stmt_bind_param($stmt, "is", $c, $d);
 
 	$c = 2;
 	$d = "bar";
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM mbind");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_bind_result($stmt, $e, $f);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $e, $f);
+	mysqli_stmt_fetch($stmt);
 
-	mysqli_bind_result($stmt, $g, $h);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $g, $h);
+	mysqli_stmt_fetch($stmt);
 
 	var_dump((array($e,$f,$g,$h)));
 
diff --git a/ext/mysqli/tests/059.phpt b/ext/mysqli/tests/059.phpt
index 733a3ce..e4b6a0b 100644
--- a/ext/mysqli/tests/059.phpt
+++ b/ext/mysqli/tests/059.phpt
@@ -21,20 +21,20 @@ require_once('skipifconnectfailure.inc');
 
 	$stmt = mysqli_prepare($link, "INSERT INTO mbind VALUES (?||?)");
 
-	mysqli_bind_param($stmt, "ss", $a, $b);
+	mysqli_stmt_bind_param($stmt, "ss", $a, $b);
 
 	$a = "foo";
 	$b = "bar";
 
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
 	mysqli_stmt_close($stmt);
 
 	$stmt = mysqli_prepare($link, "SELECT * FROM mbind");
-	mysqli_execute($stmt);
+	mysqli_stmt_execute($stmt);
 
-	mysqli_bind_result($stmt, $e);
-	mysqli_fetch($stmt);
+	mysqli_stmt_bind_result($stmt, $e);
+	mysqli_stmt_fetch($stmt);
 
 	var_dump($e);
 
diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt
index 172cecd..9426644 100644
--- a/ext/mysqli/tests/065.phpt
+++ b/ext/mysqli/tests/065.phpt
@@ -31,7 +31,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 		if (3 !== ($tmp = strlen($mysql->real_escape_string($esc_str))))
 			printf("[003] Expecting 3/int got %s/%s\n", gettype($tmp), $tmp);
 
-		if ('latin1' !== ($tmp = $mysql->client_encoding()))
+		if ('latin1' !== ($tmp = $mysql->character_set_name()))
 			printf("[004] Expecting latin1/string got %s/%s\n", gettype($tmp), $tmp);
 	}
 
@@ -43,7 +43,7 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 			if (2 !== ($tmp = strlen($mysql->real_escape_string($esc_str))))
 					printf("[005] Expecting 2/int got %s/%s\n", gettype($tmp), $tmp);
 
-			if ('gbk' !== ($tmp = $mysql->client_encoding()))
+			if ('gbk' !== ($tmp = $mysql->character_set_name()))
 					printf("[005] Expecting gbk/string got %s/%s\n", gettype($tmp), $tmp);;
 		}
 	}
diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt
index bcf9cb8..99c1380 100644
--- a/ext/mysqli/tests/bug35759.phpt
+++ b/ext/mysqli/tests/bug35759.phpt
@@ -18,7 +18,7 @@ require_once('skipifconnectfailure.inc');
 	while (++$i < $col_num) {
 		$create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''";
 	}
-	$create .= ")";
+	$create .= ") ENGINE=MyISAM"; // doesn't work with InnoDB, which is default in 5.5
 
 	if (!$mysql->query($create)) {
 		if (1101 == $mysql->errno) {
diff --git a/ext/mysqli/tests/bug52891.phpt b/ext/mysqli/tests/bug52891.phpt
new file mode 100644
index 0000000..463efd6
--- /dev/null
+++ b/ext/mysqli/tests/bug52891.phpt
@@ -0,0 +1,160 @@
+--TEST--
+Bug #52891 (Wrong data inserted with mysqli/mysqlnd when using bind_param,value > LONG_MAX)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+if (!$IS_MYSQLND) {
+	die("skip: test applies only to mysqlnd");
+}
+?>
+--FILE--
+<?php
+	require_once("connect.inc");
+
+	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+		printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+	}
+
+	if (!$link->query("DROP TABLE IF EXISTS tuint") ||
+		!$link->query("DROP TABLE IF EXISTS tsint")) {
+		printf("[002] [%d] %s\n", $link->errno, $link->error);
+	}
+
+	if (!$link->query("CREATE TABLE tuint(a BIGINT UNSIGNED) ENGINE=" . $engine) ||
+		!$link->query("CREATE TABLE tsint(a BIGINT) ENGINE=" . $engine)) {
+		printf("[003] [%d] %s\n", $link->errno, $link->error);
+	}
+
+
+	if (!$stmt1 = $link->prepare("INSERT INTO tuint VALUES(?)"))
+		printf("[004] [%d] %s\n", $link->errno, $link->error);
+
+	if (!$stmt2 = $link->prepare("INSERT INTO tsint VALUES(?)"))
+		printf("[005] [%d] %s\n", $link->errno, $link->error);
+
+	$param = 42;
+
+	if (!$stmt1->bind_param("i", $param))
+		printf("[006] [%d] %s\n", $stmt1->errno, $stmt1->error);
+
+	if (!$stmt2->bind_param("i", $param))
+		printf("[007] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	/* first insert normal value to force initial send of types */
+	if (!$stmt1->execute())
+		printf("[008] [%d] %s\n", $stmt1->errno, $stmt1->error);
+
+	if	(!$stmt2->execute())
+		printf("[009] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	/* now try values that don't fit in long, on 32bit, new types should be sent or 0 will be inserted */
+	$param = -4294967297;
+	if (!$stmt2->execute())
+		printf("[010] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	/* again normal value */
+	$param = 43;
+
+	if (!$stmt1->execute())
+		printf("[011] [%d] %s\n", $stmt1->errno, $stmt1->error);
+
+	if	(!$stmt2->execute())
+		printf("[012] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	/* again conversion */
+	$param = -4294967295;
+	if (!$stmt2->execute())
+		printf("[013] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	$param = 4294967295;
+	if (!$stmt1->execute())
+		printf("[014] [%d] %s\n", $stmt1->errno, $stmt1->error);
+
+	if	(!$stmt2->execute())
+		printf("[015] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	$param = 4294967297;
+	if (!$stmt1->execute())
+		printf("[016] [%d] %s\n", $stmt1->errno, $stmt1->error);
+
+	if	(!$stmt2->execute())
+		printf("[017] [%d] %s\n", $stmt2->errno, $stmt2->error);
+
+	$result = $link->query("SELECT * FROM tsint ORDER BY a ASC");
+	$result2 = $link->query("SELECT * FROM tuint ORDER BY a ASC");
+
+	echo "tsint:\n";
+	while ($row = $result->fetch_assoc()) {
+		var_dump($row);
+	}
+	echo "tuint:\n";
+	while ($row = $result2->fetch_assoc()) {
+		var_dump($row);
+	}
+
+	echo "done";
+?>
+--CLEAN--
+<?php
+require_once('connect.inc');
+
+if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+	printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+		$host, $user, $db, $port, $socket);
+}
+
+if (!mysqli_query($link, 'DROP TABLE IF EXISTS tuint')) {
+	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+}
+
+if (!mysqli_query($link, 'DROP TABLE IF EXISTS tsint')) {
+	printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+}
+
+mysqli_close($link);
+?>
+--EXPECTF--
+tsint:
+array(1) {
+  ["a"]=>
+  string(11) "-4294967297"
+}
+array(1) {
+  ["a"]=>
+  string(11) "-4294967295"
+}
+array(1) {
+  ["a"]=>
+  string(2) "42"
+}
+array(1) {
+  ["a"]=>
+  string(2) "43"
+}
+array(1) {
+  ["a"]=>
+  string(10) "4294967295"
+}
+array(1) {
+  ["a"]=>
+  string(10) "4294967297"
+}
+tuint:
+array(1) {
+  ["a"]=>
+  string(2) "42"
+}
+array(1) {
+  ["a"]=>
+  string(2) "43"
+}
+array(1) {
+  ["a"]=>
+  string(10) "4294967295"
+}
+array(1) {
+  ["a"]=>
+  string(10) "4294967297"
+}
+done
\ No newline at end of file
diff --git a/ext/mysqli/tests/bug_mysql_49406.phpt b/ext/mysqli/tests/bug_mysql_49406.phpt
new file mode 100644
index 0000000..7ed7b44
--- /dev/null
+++ b/ext/mysqli/tests/bug_mysql_49406.phpt
@@ -0,0 +1,107 @@
+--TEST--
+MySQL Bug #49406 (Binding params doesn't work when selecting a date inside a CASE-WHEN, http://bugs.mysql.com/bug.php?id=49406)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+	require_once("connect.inc");
+
+	if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
+		printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	$query = "SELECT CASE  WHEN 0 THEN CAST('2009-12-03' AS DATE)  ELSE CAST('2009-12-03' AS DATE) END";
+
+	if (!$res = $link->query($query))
+		printf("[002] [%d] %s\n", $link->errno, $link->error);
+
+	if (!$row = $res->fetch_row())
+		printf("[003] No result, [%d] %s\n", $link->errno, $link->error);
+
+	$res->free();
+
+	if ($row[0] != '2009-12-03') {
+		printf("[004] Expecting '2009-12-03' got '%s'\n", $row[0]);
+	}
+
+	if (!$stmt = $link->prepare($query))
+		printf("[005] [%d] %s\n", $link->errno, $link->error);
+
+	if (!$stmt->execute() || !$stmt->store_result())
+		printf("[006] [%d] %s\n", $stmt->errno, $stmt->error);
+
+
+	$datatypes = array(
+		MYSQLI_TYPE_TINY => "TINY",
+		MYSQLI_TYPE_SHORT => "SHORT",
+		MYSQLI_TYPE_LONG => "LONG",
+		MYSQLI_TYPE_FLOAT => "FLOAT",
+		MYSQLI_TYPE_DOUBLE => "DOUBLE",
+		MYSQLI_TYPE_TIMESTAMP => "TIMESTAMP",
+		MYSQLI_TYPE_LONGLONG => "LONGLONG",
+		MYSQLI_TYPE_INT24 => "INT24",
+		MYSQLI_TYPE_DATE => "DATE",
+		MYSQLI_TYPE_TIME => "TIME",
+		MYSQLI_TYPE_DATETIME => "DATETIME",
+		MYSQLI_TYPE_YEAR => "YEAR",
+		MYSQLI_TYPE_ENUM => "ENUM",
+		MYSQLI_TYPE_SET	=> "SET",
+		MYSQLI_TYPE_TINY_BLOB => "TINYBLOB",
+		MYSQLI_TYPE_MEDIUM_BLOB => "MEDIUMBLOB",
+		MYSQLI_TYPE_LONG_BLOB => "LONGBLOB",
+		MYSQLI_TYPE_BLOB => "BLOB",
+		MYSQLI_TYPE_VAR_STRING => "VAR_STRING",
+		MYSQLI_TYPE_STRING => "STRING",
+		MYSQLI_TYPE_NULL => "NULL",
+		MYSQLI_TYPE_NEWDATE => "NEWDATE",
+		MYSQLI_TYPE_INTERVAL => "INTERVAL",
+		MYSQLI_TYPE_GEOMETRY => "GEOMETRY",
+	);
+
+	$meta_res = $stmt->result_metadata();
+	for ($field_idx = 0; $field_idx < $meta_res->field_count; $field_idx++) {
+		$field = $meta_res->fetch_field();
+		printf("Field        : %d\n", $field_idx);
+		printf("Name         : %s\n", $field->name);
+		printf("Orgname      : %s\n", $field->orgname);
+		printf("Table        : %s\n", $field->table);
+		printf("Orgtable     : %s\n", $field->orgtable);
+		printf("Maxlength    : %d\n", $field->max_length);
+		printf("Length       : %d\n", $field->length);
+		printf("Charsetnr    : %d\n", $field->charsetnr);
+		printf("Flags        : %d\n", $field->flags);
+		printf("Type         : %d (%s)\n", $field->type, (isset($datatypes[$field->type])) ? $datatypes[$field->type] : 'unknown');
+		printf("Decimals     : %d\n", $field->decimals);
+	}
+
+	$row_stmt = null;
+	if (!$stmt->bind_result($row_stmt) || !$stmt->fetch())
+		printf("[007] [%d] %s\n", $stmt->errno, $stmt->error);
+
+	if ($row[0] != $row_stmt) {
+		printf("[008] PS and non-PS results differ, dumping data\n");
+		var_dump($row[0]);
+		var_dump($row_stmt);
+	}
+
+	$stmt->close();
+	$link->close();
+
+	echo "done";
+?>
+--EXPECTF--
+Field        : %s
+Name         : %s
+Orgname      :%s
+Table        :%s
+Orgtable     :%s
+Maxlength    : %d
+Length       : %d
+Charsetnr    : %d
+Flags        : %d
+Type         : %d (%s)
+Decimals     : %d
+done
\ No newline at end of file
diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc
index 92caa25..6c6c48b 100644
--- a/ext/mysqli/tests/connect.inc
+++ b/ext/mysqli/tests/connect.inc
@@ -20,6 +20,7 @@
 	if ($socket) {
 		ini_set('mysqli.default_socket', $socket);
 	}
+
 	/* Development setting: test experimal features and/or feature requests that never worked before? */
 	$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
 				((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
@@ -127,6 +128,100 @@
 				}
 			}
 		}
+
+		function my_get_charsets($link) {
+
+			/* Those tree are set by SET NAMES */
+			$charsets = array(
+				'client' 		=> NULL,
+				'results'		=> NULL,
+				'connection'	=> NULL,
+			);
+
+			if (!($res = mysqli_query($link, "SHOW VARIABLES LIKE '%character%'"))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+
+			$names = array();
+			while ($row = mysqli_fetch_assoc($res)) {
+				$names[$row['Variable_name']] = $row['Value'];
+			}
+			mysqli_free_result($res);
+
+			if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_client']))) ||
+				!($details = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+
+			$charsets['client'] = array(
+				'charset' 	=> $details['Charset'],
+				'desc'		=> $details['Description'],
+				'collation'	=> $details['Default collation'],
+				'maxlen'	=> $details['Maxlen'],
+				'nr'		=> NULL,
+			);
+
+			if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) ||
+				!($collation = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+			$charsets['client']['nr'] = $collation['Id'];
+
+			if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_results']))) ||
+				!($details = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+
+			$charsets['results'] = array(
+				'charset' 	=> $details['Charset'],
+				'desc'		=> $details['Description'],
+				'collation'	=> $details['Default collation'],
+				'maxlen'	=> $details['Maxlen'],
+				'nr'		=> NULL,
+			);
+
+			if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) ||
+				!($collation = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+			$charsets['results']['nr'] = $collation['Id'];
+
+
+			if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $names['character_set_connection']))) ||
+				!($details = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+
+			$charsets['connection'] = array(
+				'charset' 	=> $details['Charset'],
+				'desc'		=> $details['Description'],
+				'collation'	=> $details['Default collation'],
+				'maxlen'	=> $details['Maxlen'],
+				'nr'		=> NULL,
+			);
+
+			if (!($res = mysqli_query($link, sprintf("SHOW COLLATION LIKE '%s'", $details['Default collation']))) ||
+				!($collation = mysqli_fetch_assoc($res))) {
+				printf("[%d] %s\n", mysqli_errno($link), mysqli_error($link));
+				return $charsets;
+			}
+			mysqli_free_result($res);
+			$charsets['connection']['nr'] = $collation['Id'];
+
+			return $charsets;
+		}
+
 	} else {
 		printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n");
 	}
diff --git a/ext/mysqli/tests/mysqli_change_user_set_names.phpt b/ext/mysqli/tests/mysqli_change_user_set_names.phpt
index 362873c..3579e31 100644
--- a/ext/mysqli/tests/mysqli_change_user_set_names.phpt
+++ b/ext/mysqli/tests/mysqli_change_user_set_names.phpt
@@ -16,10 +16,10 @@ $tmp = mysqli_fetch_assoc($res);
 mysqli_free_result($res);
 $version = explode('.', $tmp['server_version']);
 if (empty($version))
-	die(sprintf("skip Cannot determine server version, need MySQL Server 4.1+ for the test!"));
+	die(sprintf("skip Cannot determine server version, we need MySQL Server 4.1+ for the test!"));
 
 if ($version[0] <= 4 && $version[1] < 1)
-	die(sprintf("ski Need MySQL Server 4.1+ for the test!"));
+	die(sprintf("skip We need MySQL Server 4.1+ for the test!"));
 ?>
 --FILE--
 <?php
diff --git a/ext/mysqli/tests/mysqli_character_set.phpt b/ext/mysqli/tests/mysqli_character_set.phpt
index 1fced9a..191a163 100644
--- a/ext/mysqli/tests/mysqli_character_set.phpt
+++ b/ext/mysqli/tests/mysqli_character_set.phpt
@@ -44,23 +44,25 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 		$charsets[] = $row;
 	mysqli_free_result($res);
 
-	foreach ($charsets as $k => $charset) {
+	foreach ($charsets as $charset) {
+		$k = $charset['Charset'];
 		/* The server currently 17.07.2007 can't handle data sent in ucs2 */
-		if ($charset['Charset'] == 'ucs2') {
+		/* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */
+		if ($charset['Charset'] == 'ucs2' || $charset['Charset'] == 'utf16' || $charset['Charset'] == 'utf32') {
 			continue;
 		}
 
 		if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
-			printf("[006 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
+			printf("[006 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
 
 		$sql = sprintf("CREATE TABLE test(id INT, label CHAR(1)) CHARACTER SET '%s' ", $charset['Charset']);
 		if (!mysqli_query($link, $sql)) {
-			printf("[007 + %d] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link));
+			printf("[007 + %s] %s [%d] %s\n", $k, $sql, mysqli_errno($link), mysqli_error($link));
 			continue;
 		}
 
 		if (!mysqli_set_charset($link, $charset['Charset'])) {
-			printf("[008 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
+			printf("[008 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
 			continue;
 		}
 
@@ -69,26 +71,26 @@ if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
 								$i, mysqli_real_escape_string($link, chr(ord("a") + $i)))))
 			{
 				var_dump($charset['Charset']);
-				printf("[009 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
+				printf("[009 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
 				continue;
 			}
 		}
 
 		if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
-			printf("[010 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
+			printf("[010 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
 
 		for ($i = 1; $i <= 3; $i++) {
 
 			if (!$tmp = mysqli_fetch_assoc($res))
-				printf("[011 + %d] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
+				printf("[011 + %s] [%d] %s\n", $k, mysqli_errno($link), mysqli_error($link));
 
 			if ($tmp['id'] != $i)
-				printf("[012 + %d] Expecting %d, got %s, [%d] %s\n", $k,
+				printf("[012 + %s] Expecting %d, got %s, [%d] %s\n", $k,
 						$i, $tmp['id'],
 						mysqli_errno($link), mysqli_error($link));
 
 			if ($tmp['label'] != chr(ord("a") + $i))
-				printf("[013 + %d] Expecting %d, got %s, [%d] %s\n", $k,
+				printf("[013 + %s] Expecting %d, got %s, [%d] %s\n", $k,
 					chr(ord("a") + $i), $tmp['label'],
 					mysqli_errno($link), mysqli_error($link));
 
diff --git a/ext/mysqli/tests/mysqli_character_set_name.phpt b/ext/mysqli/tests/mysqli_character_set_name.phpt
index 3fa997b..722faca 100644
--- a/ext/mysqli/tests/mysqli_character_set_name.phpt
+++ b/ext/mysqli/tests/mysqli_character_set_name.phpt
@@ -55,9 +55,9 @@ require_once('skipifconnectfailure.inc');
 		}
 	}
 
-	$charset2 = mysqli_client_encoding($link);
+	$charset2 = mysqli_character_set_name($link);
 	if ($charset2 !== $charset) {
-		printf("[012] Alias mysqli_client_encoding returned %s/%s, expected  %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset);
+		printf("[012] Alias mysqli_character_set_name returned %s/%s, expected  %s/%s\n", gettype($charset2), $charset2, gettype($charset), $charset);
 	}
 
 	mysqli_close($link);
@@ -66,7 +66,7 @@ require_once('skipifconnectfailure.inc');
 		printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	/* Make sure that the function alias exists */
-	if (!is_null($tmp = @mysqli_client_encoding()))
+	if (!is_null($tmp = @mysqli_character_set_name()))
 		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	print "done!";
diff --git a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
index 43a83bb..7b71940 100644
--- a/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
+++ b/ext/mysqli/tests/mysqli_character_set_name_oo.phpt
@@ -51,7 +51,7 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
 
 	$charset2 = $mysqli->character_set_name();
 	if ($charset2 !== $charset) {
-		printf("[012] Alias mysqli_client_encoding returned %s/%s, expected  %s/%s\n",
+		printf("[012] Alias mysqli_character_set_name returned %s/%s, expected  %s/%s\n",
 			gettype($charset2), $charset2, gettype($charset), $charset);
 	}
 
@@ -61,7 +61,7 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
 		printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	/* Make sure that the function alias exists */
-	if (!is_null($tmp = @$mysqli->client_encoding()))
+	if (!is_null($tmp = @$mysqli->character_set_name()))
 		printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	print "done!";
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
index c94b39d..b503d3e 100644
--- a/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
+++ b/ext/mysqli/tests/mysqli_class_mysqli_interface.phpt
@@ -63,6 +63,7 @@ require_once('skipifconnectfailure.inc');
 		/* $expected_methods['get_client_stats']	= true; */
 		$expected_methods['get_connection_stats']	= true;
 		$expected_methods['reap_async_query']	= true;
+		$expected_methods['poll'] = true;
 	} else {
 		// libmysql only
 		if (function_exists('mysqli_ssl_set'))
diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
index 910ede9..652aee2 100644
--- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
+++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt
@@ -619,6 +619,57 @@ Modifiers: 256
 Number of Parameters: 0
 Number of Required Parameters: 0
 
+Inspecting method 'poll'
+isFinal: no
+isAbstract: no
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: yes
+isConstructor: no
+isDestructor: no
+isInternal: yes
+isUserDefined: no
+returnsReference: no
+Modifiers: 257
+Number of Parameters: 5
+Number of Required Parameters: 4
+
+Inspecting parameter 'read' of method 'poll'
+isArray: yes
+allowsNull: yes
+isPassedByReference: yes
+isOptional: no
+isDefaultValueAvailable: no
+
+Inspecting parameter 'write' of method 'poll'
+isArray: yes
+allowsNull: yes
+isPassedByReference: yes
+isOptional: no
+isDefaultValueAvailable: no
+
+Inspecting parameter 'error' of method 'poll'
+isArray: yes
+allowsNull: yes
+isPassedByReference: yes
+isOptional: no
+isDefaultValueAvailable: no
+
+Inspecting parameter 'sec' of method 'poll'
+isArray: no
+allowsNull: no
+isPassedByReference: no
+isOptional: no
+isDefaultValueAvailable: no
+
+Inspecting parameter 'usec' of method 'poll'
+isArray: no
+allowsNull: no
+isPassedByReference: no
+isOptional: yes
+isDefaultValueAvailable: no
+
 Inspecting method 'prepare'
 isFinal: no
 isAbstract: no
diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt
index 418eb07..ff92160 100644
--- a/ext/mysqli/tests/mysqli_constants.phpt
+++ b/ext/mysqli/tests/mysqli_constants.phpt
@@ -84,6 +84,7 @@ require_once('skipifconnectfailure.inc');
 		"MYSQLI_REPORT_ERROR"				=> true,
 		"MYSQLI_REPORT_OFF"					=> true,
 		"MYSQLI_SET_CHARSET_NAME"			=> true,
+		"MYSQLI_SET_CHARSET_DIR"			=> true,
 		"MYSQLI_REFRESH_GRANT"				=> true,
 		"MYSQLI_REFRESH_LOG"					=> true,
 		"MYSQLI_REFRESH_TABLES"				=> true,
@@ -110,6 +111,7 @@ require_once('skipifconnectfailure.inc');
 		$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
 		$expected_constants['MYSQLI_ASYNC'] = true;
 
+		$expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true;
 	} else {
 		$version = mysqli_get_client_version();
 	}
@@ -150,6 +152,10 @@ require_once('skipifconnectfailure.inc');
 		));
 	}
 
+	if ($version > 50110 || $IS_MYSQLND) {
+		$expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
+	}
+
 	/* pretty dump test, but that is the best way to mimic mysql.c */
 	if (defined('MYSQLI_DATA_TRUNCATED'))
 		$expected_constants["MYSQLI_DATA_TRUNCATED"] = true;
diff --git a/ext/mysqli/tests/mysqli_fetch_array_large.phpt b/ext/mysqli/tests/mysqli_fetch_array_large.phpt
index 25c00ba..ae83b3f 100644
--- a/ext/mysqli/tests/mysqli_fetch_array_large.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_array_large.phpt
@@ -100,49 +100,61 @@ require_once('skipifconnectfailure.inc');
 	}
 
 
-	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
-		printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
-		$host, $user, $db, $port, $socket);
-	}
+	function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) {
 
-	if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
-			!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine)))
-		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+		$link = mysqli_init();
+		if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) {
+			printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+			return false;
+		}
 
-	$package_size = 524288;
-	$offset = 3;
-	$limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
+		if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+			!mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) {
+			printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			return false;
+		}
 
-	/* try to respect php.ini but make run time a soft limit */
-	$max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
-	set_time_limit(0);
+		$package_size = 524288;
+		$offset = 3;
+		$limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32);
 
-	do {
-		if ($package_size > $limit) {
-			printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
-			break;
-		}
+		/* try to respect php.ini but make run time a soft limit */
+		$max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30;
+		set_time_limit(0);
 
-		$start = microtime(true);
-		if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
-			printf("stop: packet size - %d\n", $package_size);
-			break;
-		}
+		do {
+			if ($package_size > $limit) {
+				printf("stop: memory limit - %s vs. %s\n", $package_size, $limit);
+				break;
+			}
 
-		$duration = microtime(true) - $start;
-		$max_runtime -= $duration;
-		if ($max_runtime < ($duration * 3)) {
-			/* likely the next iteration will not be within max_execution_time */
-			printf("stop: time limit - %2.2fs\n", $max_runtime);
-			break;
-		}
+			$start = microtime(true);
+			if (!mysqli_fetch_array_large($offset++, $link, $package_size)) {
+				printf("stop: packet size - %d\n", $package_size);
+				break;
+			}
+
+			$duration = microtime(true) - $start;
+			$max_runtime -= $duration;
+			if ($max_runtime < ($duration * 3)) {
+				/* likely the next iteration will not be within max_execution_time */
+				printf("stop: time limit - %2.2fs\n", $max_runtime);
+				break;
+			}
+
+			$package_size += $package_size;
 
-		$package_size += $package_size;
+		} while (true);
 
-	} while (true);
 
+		mysqli_close($link);
+		return true;
+	}
 
-	mysqli_close($link);
+
+	test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null);
+	test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS);
 	print "done!";
 ?>
 --CLEAN--
@@ -151,4 +163,5 @@ require_once('skipifconnectfailure.inc');
 ?>
 --EXPECTF--
 stop: %s
+stop: %s
 done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_fetch_field.phpt b/ext/mysqli/tests/mysqli_fetch_field.phpt
index e905992..4dde6c9 100644
--- a/ext/mysqli/tests/mysqli_fetch_field.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field.phpt
@@ -22,33 +22,51 @@ require_once('skipifconnectfailure.inc');
 
 	require('table.inc');
 
+	$charsets = my_get_charsets($link);
 	if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	}
 
-	while ($tmp = mysqli_fetch_field($res))
-		var_dump($tmp);
+	/* ID column, binary charset */
+	$tmp = mysqli_fetch_field($res);
 	var_dump($tmp);
 
+	/* label column, result set charset */
+	$tmp = mysqli_fetch_field($res);
+	var_dump($tmp);
+	if ($tmp->charsetnr != $charsets['results']['nr']) {
+		printf("[004] Expecting charset %s/%d got %d\n",
+			$charsets['results']['charset'],
+			$charsets['results']['nr'], $tmp->charsetnr);
+	}
+	if ($tmp->length != (1 * $charsets['results']['maxlen'])) {
+		printf("[005] Expecting length %d got %d\n",
+			$charsets['results']['maxlen'],
+			$tmp->max_length);
+	}
+
+	var_dump(mysqli_fetch_field($res));
+
 	mysqli_free_result($res);
 
 	// Read http://bugs.php.net/bug.php?id=42344 on defaults!
 	if (NULL !== ($tmp = mysqli_fetch_field($res)))
-		printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+		printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
-		printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	if (!mysqli_query($link, "CREATE TABLE test(id INT NOT NULL DEFAULT 1)"))
-		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+		printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	if (!mysqli_query($link, "INSERT INTO test(id) VALUES (2)"))
-		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	if (!$res = mysqli_query($link, "SELECT id as _default_test FROM test")) {
-		printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+		printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	}
 	var_dump(mysqli_fetch_assoc($res));
+	/* binary */
 	var_dump(mysqli_fetch_field($res));
 	mysqli_free_result($res);
 
@@ -97,11 +115,11 @@ object(stdClass)#%d (11) {
   [%u|b%"def"]=>
   %unicode|string%(0) ""
   [%u|b%"max_length"]=>
-  int(1)
+  int(%d)
   [%u|b%"length"]=>
-  int(1)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
diff --git a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
index f7dcd9b..0130f0e 100644
--- a/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_field_oo.phpt
@@ -24,22 +24,36 @@ require_once('skipifconnectfailure.inc');
 		printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
 			$host, $user, $db, $port, $socket);
 
-	if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
-		printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error);
-	}
-
 	if (!is_null($tmp = @$res->fetch_field($link)))
 		printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
-	while ($tmp = $res->fetch_field()) {
-		var_dump($tmp);
+	$charsets = my_get_charsets($link);
+
+	if (!$res = $mysqli->query("SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
+		printf("[004] [%d] %s\n", $mysqli->errno, $mysqli->error);
 	}
+
+	var_dump($res->fetch_field());
+
+	$tmp = $res->fetch_field();
 	var_dump($tmp);
+	if ($tmp->charsetnr != $charsets['results']['nr']) {
+		printf("[005] Expecting charset %s/%d got %d\n",
+			$charsets['results']['charset'],
+			$charsets['results']['nr'], $tmp->charsetnr);
+	}
+	if ($tmp->length != (1 * $charsets['results']['maxlen'])) {
+		printf("[006] Expecting length %d got %d\n",
+			$charsets['results']['maxlen'],
+			$tmp->max_length);
+	}
+
+	var_dump($res->fetch_field());
 
 	$res->free_result();
 
 	if (NULL !== ($tmp = $res->fetch_field()))
-		printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+		printf("[007] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	$mysqli->close();
 	print "done!";
@@ -85,11 +99,11 @@ object(stdClass)#%d (11) {
   [%u|b%"def"]=>
   %unicode|string%(0) ""
   [%u|b%"max_length"]=>
-  int(1)
+  int(%d)
   [%u|b%"length"]=>
-  int(1)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
diff --git a/ext/mysqli/tests/mysqli_fetch_fields.phpt b/ext/mysqli/tests/mysqli_fetch_fields.phpt
index a87956d..885c733 100644
--- a/ext/mysqli/tests/mysqli_fetch_fields.phpt
+++ b/ext/mysqli/tests/mysqli_fetch_fields.phpt
@@ -21,13 +21,31 @@ require_once('skipifconnectfailure.inc');
 		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	require('table.inc');
+	$charsets = my_get_charsets($link);
+
 	if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	}
 
 	$fields = mysqli_fetch_fields($res);
-	foreach ($fields as $k => $field)
+	foreach ($fields as $k => $field) {
 		var_dump($field);
+		switch ($k) {
+			case 1:
+				/* label column, result set charset */
+				if ($field->charsetnr != $charsets['results']['nr']) {
+					printf("[004] Expecting charset %s/%d got %d\n",
+						$charsets['results']['charset'],
+						$charsets['results']['nr'], $field->charsetnr);
+				}
+				if ($field->length != (1 * $charsets['results']['maxlen'])) {
+					printf("[005] Expecting length %d got %d\n",
+						$charsets['results']['maxlen'],
+						$field->max_length);
+				}
+				break;
+		}
+	}
 
 	mysqli_free_result($res);
 
@@ -80,9 +98,9 @@ object(stdClass)#%d (11) {
   [%u|b%"max_length"]=>
   int(1)
   [%u|b%"length"]=>
-  int(1)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt
index 58692a6..1da42c2 100644
--- a/ext/mysqli/tests/mysqli_field_seek.phpt
+++ b/ext/mysqli/tests/mysqli_field_seek.phpt
@@ -66,6 +66,8 @@ require_once('skipifconnectfailure.inc');
 		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	require('table.inc');
+	$charsets = my_get_charsets($link);
+
 	if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) {
 		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	}
@@ -75,7 +77,21 @@ require_once('skipifconnectfailure.inc');
 	var_dump(mysqli_field_seek($res, 0));
 	var_dump(mysqli_fetch_field($res));
 	var_dump(mysqli_field_seek($res, 1));
-	var_dump(mysqli_fetch_field($res));
+
+	$field = mysqli_fetch_field($res);
+	var_dump($field);
+	/* label column, result set charset */
+	if ($field->charsetnr != $charsets['results']['nr']) {
+		printf("[004] Expecting charset %s/%d got %d\n",
+			$charsets['results']['charset'],
+			$charsets['results']['nr'], $field->charsetnr);
+	}
+	if ($field->length != (1 * $charsets['results']['maxlen'])) {
+		printf("[005] Expecting length %d got %d\n",
+			$charsets['results']['maxlen'],
+			$field->max_length);
+	}
+
 	var_dump(mysqli_field_tell($res));
 	var_dump(mysqli_field_seek($res, 2));
 	var_dump(mysqli_fetch_field($res));
@@ -96,8 +112,6 @@ require_once('skipifconnectfailure.inc');
 
 	var_dump(mysqli_field_seek($res, 0));
 
-
-
 	mysqli_close($link);
 	print "done!";
 ?>
@@ -170,11 +184,11 @@ object(stdClass)#%d (11) {
   [%u|b%"def"]=>
   %unicode|string%(0) ""
   [%u|b%"max_length"]=>
-  int(0)
+  int(%d)
   [%u|b%"length"]=>
-  int(1)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt
index 7377f16..ef5ef6e 100644
--- a/ext/mysqli/tests/mysqli_get_client_stats.phpt
+++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt
@@ -63,14 +63,14 @@ mysqlnd.collect_memory_statistics=1
 		$test_counter++;
 		if (is_array($current) && is_array($expected)) {
 			if ($current[$field] <= $expected[$field]) {
-				printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
+				printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
 					$test_counter, $desc,
 					$field, $expected[$field], gettype($expected[$field]),
 					$current[$field], gettype($current[$field]));
 				}
 		} else {
 			if ($current <= $expected) {
-				printf("[%03d] %s Expecting %s = %s/%s, got %s/%s\n",
+				printf("[%03d] %s Expecting %s > %s/%s, got %s/%s\n",
 					$test_counter, $desc, $field,
 					$expected, gettype($expected),
 					$current, gettype($current));
@@ -107,6 +107,7 @@ mysqlnd.collect_memory_statistics=1
 	}
 
 	$test_counter = 6;
+
 	mysqli_get_client_stats_assert_gt('bytes_sent', $new_info, $info, $test_counter);
 	mysqli_get_client_stats_assert_gt('bytes_received', $new_info, $info, $test_counter);
 	mysqli_get_client_stats_assert_gt('packets_sent', $new_info, $info, $test_counter);
@@ -135,6 +136,10 @@ mysqlnd.collect_memory_statistics=1
 	mysqli_get_client_stats_assert_eq('connect_failure', $new_info, $info, $test_counter);
 	mysqli_get_client_stats_assert_eq('connection_reused', $new_info, $info, $test_counter);
 
+	// No data fetched so far
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $new_info, "0", $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $new_info, "0", $test_counter);
+
 	require('table.inc');
 	if (!is_array($info = mysqli_get_client_stats()) || empty($info))
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
@@ -154,11 +159,17 @@ mysqlnd.collect_memory_statistics=1
 	$expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
 	$expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + 1);
 
-
 	if (!is_array($info = mysqli_get_client_stats()) || empty($info))
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter);
+	mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter);
+
+	// real_data_* get incremeneted after mysqli_*fetch*()
+    mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, "0", $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
@@ -176,6 +187,11 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	// fetch will increment
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_buffered_from_client_normal', $info, $expected, $test_counter);
@@ -188,17 +204,21 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
 			++$test_counter, mysqli_errno($link), mysqli_error($link));
 
+
 	assert(mysqli_num_rows($res) == $num_rows);
 
 	if (!is_array($info = mysqli_get_client_stats()) || empty($info))
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+
 	$expected['rows_fetched_from_server_normal'] = (string)($expected['rows_fetched_from_server_normal'] + $num_rows);
 	$expected['rows_buffered_from_client_normal'] = (string)($expected['rows_buffered_from_client_normal'] + $num_rows);
 	$expected['buffered_sets'] = (string)($expected['buffered_sets'] + 1);
 	$expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('buffered_sets', $info, $expected, $test_counter);
@@ -213,6 +233,8 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_buffered', $info, $expected, $test_counter);
 
@@ -221,9 +243,13 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] SELECT id, label FROM test failed, [%d] %s\n",
 			++$test_counter, mysqli_errno($link), mysqli_error($link));
 
+	if (!is_array($info = mysqli_get_client_stats()) || empty($info))
+		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
+			++$test_counter, gettype($info), $info);
 
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
 
 	while ($row = mysqli_fetch_assoc($res))
 		;
@@ -238,6 +264,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
@@ -260,6 +289,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('unbuffered_sets', $info, $expected, $test_counter);
@@ -278,6 +310,8 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_normal', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_normal_unbuffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_skipped_normal', $info, $expected, $test_counter);
@@ -302,6 +336,9 @@ mysqlnd.collect_memory_statistics=1
 			++$test_counter, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 	mysqli_stmt_free_result($stmt);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+
 	$expected['rows_fetched_from_server_ps'] = (string)($expected['rows_fetched_from_server_ps'] + $num_rows);
 	$expected['result_set_queries'] = (string)($expected['result_set_queries'] + 1);
 	$expected['ps_buffered_sets'] = (string)($expected['ps_buffered_sets'] + 1);
@@ -318,6 +355,8 @@ mysqlnd.collect_memory_statistics=1
 	mysqli_get_client_stats_assert_eq('ps_buffered_sets', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_buffered_from_client_ps', $info, $expected, $test_counter);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter);
+
 	print "Testing buffered Prepared Statements... - fetching all\n";
 
 	if (!mysqli_stmt_prepare($stmt, 'SELECT id, label FROM test') ||
@@ -347,6 +386,10 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
@@ -384,6 +427,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_buffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
@@ -426,6 +472,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
@@ -458,6 +507,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_ps', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_ps'] = $info['bytes_received_real_data_ps'];
+
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_client_ps_unbuffered', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('result_set_queries', $info, $expected, $test_counter);
@@ -473,6 +525,8 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
 	mysqli_get_client_stats_assert_eq('rows_skipped_ps', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('flushed_ps_sets', $info, $expected, $test_counter);
 	mysqli_get_client_stats_assert_eq('rows_fetched_from_server_ps', $info, $expected, $test_counter);
@@ -489,6 +543,9 @@ mysqlnd.collect_memory_statistics=1
 		printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 			++$test_counter, gettype($info), $info);
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
 	//
 	// result_set_queries statistics
 	//
@@ -518,6 +575,9 @@ mysqlnd.collect_memory_statistics=1
 	mysqli_get_client_stats_assert_eq('result_set_queries', $new_info, (string)($info['result_set_queries'] + 1), $test_counter);
 	$info = $new_info;
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+
 	//
 	// non_result_set_queries - DDL
 	//
@@ -673,6 +733,7 @@ mysqlnd.collect_memory_statistics=1
 		if (!is_array($new_info = mysqli_get_client_stats()) || empty($new_info))
 			printf("[%03d] Expecting array/any_non_empty, got %s/%s\n",
 				++$test_counter, gettype($new_info), $new_info);
+
 		mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'CREATE SERVER');
 		$info = $new_info;
 
@@ -697,6 +758,9 @@ mysqlnd.collect_memory_statistics=1
 		$info = $new_info;
 	}
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
 	/*
 	We don't test the NDB ones.
 	13.1. Data Definition Statements
@@ -778,6 +842,7 @@ mysqlnd.collect_memory_statistics=1
 	mysqli_get_client_stats_assert_eq('non_result_set_queries', $new_info, (string)($info['non_result_set_queries'] + 1), $test_counter, 'TRUNCATE');
 	$info = $new_info;
 
+
 	$file = tempnam(sys_get_temp_dir(), 'mysqli_test');
 	if ($fp = fopen($file, 'w')) {
 		@fwrite($fp, '1;"a"');
@@ -794,6 +859,9 @@ mysqlnd.collect_memory_statistics=1
 		unlink($file);
 	}
 
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
+
 	/*
 	We skip those:
 	13.2. Data Manipulation Statements
@@ -842,6 +910,9 @@ mysqlnd.collect_memory_statistics=1
 
 	mysqli_close($link);
 
+	mysqli_get_client_stats_assert_gt('bytes_received_real_data_normal', $info, $expected, $test_counter);
+	$expected['bytes_received_real_data_normal'] = $info['bytes_received_real_data_normal'];
+	mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, $expected, $test_counter);
 
 	/*
 	no_index_used
@@ -887,7 +958,7 @@ if (!mysqli_query($link, "DROP SERVER IF EXISTS myself"))
 mysqli_close($link);
 ?>
 --EXPECTF--
-array(158) {
+array(160) {
   [%u|b%"bytes_sent"]=>
   %unicode|string%(1) "0"
   [%u|b%"bytes_received"]=>
@@ -1204,6 +1275,10 @@ array(158) {
   %unicode|string%(1) "0"
   [%u|b%"com_deamon"]=>
   %unicode|string%(1) "0"
+  [%u|b%"bytes_received_real_data_normal"]=>
+  %unicode|string%(1) "0"
+  [%u|b%"bytes_received_real_data_ps"]=>
+  %unicode|string%(1) "0"
 }
 Testing buffered normal...
 Testing buffered normal... - SELECT id, label FROM test
diff --git a/ext/mysqli/tests/mysqli_get_client_stats_off.phpt b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt
index 884f426..e2dff9b 100644
--- a/ext/mysqli/tests/mysqli_get_client_stats_off.phpt
+++ b/ext/mysqli/tests/mysqli_get_client_stats_off.phpt
@@ -15,16 +15,8 @@ mysqlnd.collect_memory_statistics=0
 --FILE--
 <?php
 	$before = mysqli_get_client_stats();
-
-	/*
-	NOTE: the function belongs to the mysqnd zval cache. The
-	mysqlnd zval cache was part of PHP from PHP 5.3.0(-dev) to
-	PHP 5.3.0RC3 or something. And it was turned off by default.
-	The function never returned anything meaningful in any released version of PHP.
-
-	*/
-	if (!is_array($before)) {
-		printf("[001] Expecting array, got %s.\n", gettype($before));
+	if (!is_array($before) || empty($before)) {
+		printf("[001] Expecting non-empty array, got %s.\n", gettype($before));
 		var_dump($before);
 	}
 
@@ -39,6 +31,12 @@ mysqlnd.collect_memory_statistics=0
 		var_dump($after);
 	}
 
+	foreach ($after as $k => $v)
+		if ($v != 0) {
+			printf("[003] Field %s should not have any other value but 0, got %s.\n",
+				$k, $v);
+		}
+
 	mysqli_close($link);
 	print "done!";
 ?>
diff --git a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
index 35f35a5..c7f38fa 100644
--- a/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
+++ b/ext/mysqli/tests/mysqli_insert_packet_overflow.phpt
@@ -74,8 +74,8 @@ memory_limit=256M
 	if (!mysqli_query($link, "CREATE TABLE test(col_blob LONGBLOB) ENGINE=" . $engine))
 		printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-	$query_prefix = 'INSERT INTO test(col_blob) VALUES ("';
-	$query_postfix = '")';
+	$query_prefix = "INSERT INTO test(col_blob) VALUES ('";
+	$query_postfix = "')";
 	$query_len = strlen($query_prefix) + strlen($query_postfix);
 	$com_query_len = 2;
 
diff --git a/ext/mysqli/tests/mysqli_magic_quotes.phpt b/ext/mysqli/tests/mysqli_magic_quotes.phpt
new file mode 100644
index 0000000..16848a8
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_magic_quotes.phpt
@@ -0,0 +1,128 @@
+--TEST--
+magic_quotes_runtime (DEPRECATED)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+
+if (version_compare(PHP_VERSION, '5.3.98') >= 0) {
+	die("skip: PHP 5.3 test");
+}
+?>
+--INI--
+magic_quotes_runtime=1
+--FILE--
+<?php
+	require('connect.inc');
+
+	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+
+	$query = sprintf("SELECT '%s', '%s', '%s', '%s' FROM DUAL",
+				mysqli_real_escape_string($link, "'"),
+				mysqli_real_escape_string($link, '"'),
+				mysqli_real_escape_string($link, '\0'),
+				mysqli_real_escape_string($link, '\\'));
+
+	if (!$res = mysqli_query($link, $query)) {
+		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+
+	while ($row = $res->fetch_assoc()) {
+		var_dump($row);
+	}
+
+	$res->free();
+
+	$expected = array(
+		"'" 	=> "\\'",
+		'"' 	=> "\\\"",
+		"\\0" 	=> "\\\\0",
+		"\\"	=> "\\\\",
+	);
+	$expectedBoth = array(
+		0		=> "\\'",
+		"'" 	=> "\\'",
+		1	 	=> "\\\"",
+		'"' 	=> "\\\"",
+		2	 	=> "\\\\0",
+		"\\0" 	=> "\\\\0",
+		3		=> "\\\\",
+		"\\"	=> "\\\\",
+	);
+
+	if (!$res = mysqli_query($link, $query)) {
+		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+	$row = mysqli_fetch_row($res);
+	echo "Equal:";var_dump($row === array_values($expected));
+	if ($row !== array_values($expected)) {
+		var_dump($row, array_values($expected));
+	}
+	$res->free();
+
+	if (!$res = mysqli_query($link, $query)) {
+		printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+	$row = mysqli_fetch_array($res, MYSQLI_BOTH);
+	echo "Equal:";var_dump($row === $expectedBoth);
+	if ($row !== $expectedBoth) {
+		var_dump($row, $expectedBoth);
+	}
+	$res->free();
+
+	class fetch_object {
+		public function __set($key, $value) {
+			printf(">%s< => >%s<\n", $key, $value);
+		}
+	}
+
+	if (!$res = mysqli_query($link, $query)) {
+		printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+	}
+	$obj = mysqli_fetch_object($res, "fetch_object");
+	$res->free();
+
+	if (false && $IS_MYSQLND) {
+			if (!$res = mysqli_query($link, $query)) {
+				printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			}
+			$row = @mysqli_fetch_all($res, MYSQLI_ASSOC);
+			if ($row[0] !== $expected) {
+				printf("[015] Wrong data, dumping\n");
+				var_dump($row);
+			}
+	}
+
+	$link->close();
+
+	print "done!";
+?>
+--EXPECTF--
+Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line %d
+
+Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
+array(4) {
+  ["'"]=>
+  string(2) "\'"
+  ["""]=>
+  string(2) "\""
+  ["\0"]=>
+  string(3) "\\0"
+  ["\"]=>
+  string(2) "\\"
+}
+
+Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
+Equal:bool(true)
+
+Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
+Equal:bool(true)
+
+Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
+>'< => >\'<
+>"< => >\"<
+>\0< => >\\0<
+>\< => >\\<
+done!
diff --git a/ext/mysqli/tests/mysqli_options.phpt b/ext/mysqli/tests/mysqli_options.phpt
index de23ade..2f7986d 100644
--- a/ext/mysqli/tests/mysqli_options.phpt
+++ b/ext/mysqli/tests/mysqli_options.phpt
@@ -10,30 +10,15 @@ require_once('skipifconnectfailure.inc');
 <?php
 	require_once("connect.inc");
 
-/*
-TODO: ext/mysqli might lack support for those options which are available
-with the libmysql C call mysql_options(). Not sure which of them make
-sense to have in PHP and not even sure which of them might be available
-already through other measures.
-
-	MYSQL_OPT_COMPRESS (argument: not used) --> Andrey/Ulf: bug, should be added
-	? MYSQL_OPT_NAMED_PIPE (argument: not used) ?
-	MYSQL_OPT_READ_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
-	MYSQL_OPT_RECONNECT (argument type: my_bool *) -->  Andrey/Ulf: might be security risk to have
-	MYSQL_OPT_SSL_VERIFY_SERVER_CERT (argument type: my_bool *) --> Andrey/Ulf: might be security risk to have
-	MYSQL_OPT_WRITE_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
-	MYSQL_REPORT_DATA_TRUNCATION (argument type: my_bool *) --> Andrey: bug, although truncation might only happen with libmysql not with mysqlnd
-	MYSQL_SECURE_AUTH (argument type: my_bool *) --> Ulf: let's say deprecated, no bug
-	? MYSQL_SET_CHARSET_DIR (argument type: char *) ?
-	MYSQL_SHARED_MEMORY_BASE_NAME (argument type: char *)
-*/
-
-	$valid_options = array(  MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE,
-		MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE,
-		MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_GROUP,
-		MYSQLI_READ_DEFAULT_FILE, MYSQLI_OPT_CONNECT_TIMEOUT,
-		MYSQLI_OPT_LOCAL_INFILE, MYSQLI_INIT_COMMAND,
-		MYSQLI_SET_CHARSET_NAME);
+	$valid_options = array(
+		MYSQLI_READ_DEFAULT_GROUP 			=> "MYSQLI_READ_DEFAULT_GROUP",
+		MYSQLI_READ_DEFAULT_FILE 			=> "MYSQLI_READ_DEFAUTL_FILE",
+		MYSQLI_OPT_CONNECT_TIMEOUT			=> "MYSQLI_OPT_CONNECT_TIMEOUT",
+		MYSQLI_OPT_LOCAL_INFILE				=> "MYSQLI_OPT_LOCAL_INFILE",
+		MYSQLI_INIT_COMMAND					=> "MYSQLI_INIT_COMMAND",
+		MYSQLI_SET_CHARSET_NAME				=> "MYSQLI_SET_CHARSET_NAME",
+		MYSQLI_OPT_SSL_VERIFY_SERVER_CERT 	=> "MYSQLI_OPT_SSL_VERIFY_SERVER_CERT",
+	);
 
 	if ($IS_MYSQLND && defined('MYSQLI_OPT_NET_CMD_BUFFER_SIZE'))
 		$valid_options[] = constant('MYSQLI_OPT_NET_CMD_BUFFER_SIZE');
@@ -72,28 +57,54 @@ already through other measures.
 	var_dump("MYSQLI_OPT_CONNECT_TIMEOUT",	mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
 	var_dump("MYSQLI_OPT_LOCAL_INFILE",		mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1));
 	var_dump("MYSQLI_INIT_COMMAND",			mysqli_options($link, MYSQLI_INIT_COMMAND, array('SET AUTOCOMMIT=0', 'SET AUTOCOMMIT=1')));
+
+	
+	if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+		printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+			$host, $user, $db, $port, $socket);
+
+	if (!$res = mysqli_query($link2, 'SELECT version() AS server_version'))
+		printf("[007] [%d] %s\n", mysqli_errno($link2), mysqli_error($link2));
+	$tmp = mysqli_fetch_assoc($res);
+	mysqli_free_result($res);
+	$version = explode('.', $tmp['server_version']);
+	if (empty($version))
+		printf("[008] Cannot determine server version, need MySQL Server 4.1+ for the test!\n");
+
+	if ($version[0] <= 4 && $version[1] < 1)
+		printf("[009] Need MySQL Server 4.1+ for the test!\n");
+
+	if (!$res = mysqli_query($link2, "SHOW CHARACTER SET"))
+		printf("[010] Cannot get list of available character sets, [%d] %s\n",
+			mysqli_errno($link2), mysqli_error($link2));
+
+	$charsets = array();
+	while ($row = mysqli_fetch_assoc($res))
+		$charsets[] = $row;
+	mysqli_free_result($res);
+	mysqli_close($link2);
+
+	foreach ($charsets as $charset) {
+		$k = $charset['Charset'];
+		/* The server currently 17.07.2007 can't handle data sent in ucs2 */
+		/* The server currently 16.08.2010 can't handle data sent in utf16 and utf32 */
+		if ($charset['Charset'] == 'ucs2' || $charset['Charset'] == 'utf16' || $charset['Charset'] == 'utf32') {
+			continue;
+		}
+		if (true !== mysqli_options($link, MYSQLI_SET_CHARSET_NAME, $charset['Charset'])) {
+			printf("[009] Setting charset name '%s' has failed\n", $charset['Charset']);
+		}
+	}
+
 	var_dump("MYSQLI_READ_DEFAULT_GROUP",	mysqli_options($link, MYSQLI_READ_DEFAULT_GROUP, 'extra_my.cnf'));
 	var_dump("MYSQLI_READ_DEFAULT_FILE",	mysqli_options($link, MYSQLI_READ_DEFAULT_FILE, 'extra_my.cnf'));
 	var_dump("MYSQLI_OPT_CONNECT_TIMEOUT",	mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 10));
 	var_dump("MYSQLI_OPT_LOCAL_INFILE",		mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, 1));
 	var_dump("MYSQLI_INIT_COMMAND",			mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=0'));
-	var_dump("MYSQLI_CLIENT_SSL",			mysqli_options($link, MYSQLI_CLIENT_SSL, 'not an mysqli_option'));
-
-	if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_YEARS_AS_INT') &&
-		!($tmp = mysqli_options($link, constant('MYSQLI_OPT_INT_AND_YEARS_AS_INT'), true)))
-		printf("[006] Expecting boolean/true got %s/%s\n", gettype($tmp), $tmp);
-
-	if ($IS_MYSQLND) {
-		/* Don't do this with libmysql. You may hit options not exported to PHP and cause false positives */
-		for ($flag = -10000; $flag < 10000; $flag++) {
-			if (in_array($flag, $valid_options))
-				continue;
-			if (FALSE !== ($tmp = mysqli_options($link, $flag, 'definetely not an mysqli_option'))) {
-				var_dump(array("SOME_FLAG" => $flag, "ret" => $tmp));
-			}
-		}
-	}
 
+	/* mysqli_real_connect() */
+	var_dump("MYSQLI_CLIENT_SSL",			mysqli_options($link, MYSQLI_CLIENT_SSL, 'not a mysqli_option'));
+	
 	mysqli_close($link);
 
 	echo "Link closed";
diff --git a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
new file mode 100644
index 0000000..4b0c947
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
@@ -0,0 +1,109 @@
+--TEST--
+mysqli_options() - MYSQLI_OPT_INT_AND_FLOAT_NATIVE
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+
+require_once('connect.inc');
+if (!$IS_MYSQLND)	
+	die("skip mysqlnd only test");
+?>
+--FILE--
+<?php
+	require_once("connect.inc");
+
+
+	$types = array(
+		'BIT' 			=> array('BIT(8)', 0),
+		'TINYINT'		=> array('TINYINT', 120),
+		'BOOL'			=> array('BOOL', 0),
+		'BOOLEAN'		=> array('BOOLEAN', 1),
+		'SMALLINT'		=> array('SMALLINT', 32000),
+		'MEDIUMINT'		=> array('MEDIUMINT', 999),
+		'INT'			=> array('INT', 999),
+		'BIGINT'		=> array('BIGINT', 999),
+		'FLOAT'			=> array('FLOAT', 1.3),
+		'DOUBLE'		=> array('DOUBLE', -1.3),
+	);
+
+	foreach ($types as $name => $data) {
+		$link = mysqli_init();
+		if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1)) {
+			printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+			printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+			continue;
+		}
+
+
+		if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+			printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+		
+		if (!mysqli_query($link, sprintf("CREATE TABLE test (id %s)", $data[0]))) {
+			printf("[004] TODO [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+		
+		if (!mysqli_query($link, sprintf("INSERT INTO test(id) VALUES (%f)", $data[1]))) {
+			printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		if (!$res = mysqli_query($link, "SELECT id FROM test")) {
+			printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		$row = mysqli_fetch_assoc($res);
+		mysqli_free_result($res);
+
+		if ($row['id'] !== $data[1]) {
+			printf("[007] Expecting %s - %s/%s got %s/%s\n", 
+				$name,
+				$data[1], gettype($data[1]), $row['id'], gettype($row['id']));
+		}
+		mysqli_close($link);
+
+		$link = mysqli_init();
+		if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 0)) {
+			printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+			printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+			continue;
+		}
+		
+		if (!$res = mysqli_query($link, "SELECT id FROM test")) {
+			printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+			continue;
+		}
+
+		$row = mysqli_fetch_assoc($res);
+		mysqli_free_result($res);
+
+		if (!is_string($row['id']) || ($row['id'] != $data[1])) {
+			printf("[011] Expecting %s - %s/string got %s/%s\n", 
+				$name,
+				$data[1], $row['id'], gettype($row['id']));
+		}		
+		mysqli_close($link);		
+
+	}
+	
+	print "done!";
+?>
+--CLEAN--
+<?php
+	require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
index f40965e..adc2671 100644
--- a/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt
@@ -5,9 +5,6 @@ Calling connect() on an open persistent connection to create a new persistent co
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-if (!$IS_MYSQLND)
-	die("skip mysqlnd test only");
-
 ?>
 --INI--
 mysqli.allow_persistent=1
diff --git a/ext/mysqli/tests/mysqli_pconn_disabled.phpt b/ext/mysqli/tests/mysqli_pconn_disabled.phpt
index 1fe6271..7222212 100644
--- a/ext/mysqli/tests/mysqli_pconn_disabled.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_disabled.phpt
@@ -6,9 +6,6 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 
-if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
-	die("skip: only available in mysqlnd");
-
 die("skip TODO - we need to add a user level way to check if CHANGE_USER gets called by pconnect");
 ?>
 --INI--
diff --git a/ext/mysqli/tests/mysqli_pconn_kill.phpt b/ext/mysqli/tests/mysqli_pconn_kill.phpt
index 297dd4c..f8d8d7e 100755
--- a/ext/mysqli/tests/mysqli_pconn_kill.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_kill.phpt
@@ -6,8 +6,6 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 require_once("connect.inc");
-if (!$IS_MYSQLND)
-	die("skip mysqlnd test only");
 ?>
 --INI--
 mysqli.allow_persistent=1
diff --git a/ext/mysqli/tests/mysqli_pconn_limits.phpt b/ext/mysqli/tests/mysqli_pconn_limits.phpt
index 84cd11e..ee9e1f9 100644
--- a/ext/mysqli/tests/mysqli_pconn_limits.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_limits.phpt
@@ -6,9 +6,6 @@ require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 require_once("connect.inc");
-if (!$IS_MYSQLND)
-	die("skip mysqlnd test only");
-
 ?>
 --INI--
 mysqli.allow_persistent=1
diff --git a/ext/mysqli/tests/mysqli_pconn_max_links.phpt b/ext/mysqli/tests/mysqli_pconn_max_links.phpt
index 8e75539..e87ef00 100644
--- a/ext/mysqli/tests/mysqli_pconn_max_links.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_max_links.phpt
@@ -5,14 +5,7 @@ Persistent connections and mysqli.max_links
 	require_once('skipif.inc');
 	require_once('skipifemb.inc');
 	require_once('skipifconnectfailure.inc');
-	require_once('connect.inc');
-
-	if (!$IS_MYSQLND)
-		die("skip mysqlnd only test");
-
-	// we need a second DB user to test for a possible flaw in the ext/mysql[i] code
-	if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
-		die(sprintf("skip Cannot connect [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
+	require_once('table.inc');
 
 	mysqli_query($link, 'DROP USER pcontest');
 	mysqli_query($link, 'DROP USER pcontest at localhost');
@@ -54,6 +47,17 @@ mysqli.max_persistent=2
 	require_once("connect.inc");
 	require_once('table.inc');
 
+
+	if (!mysqli_query($link, 'DROP USER pcontest') ||
+		!mysqli_query($link, 'DROP USER pcontest at localhost') ||
+		!mysqli_query($link, 'CREATE USER pcontest@"%" IDENTIFIED BY "pcontest"') ||
+		!mysqli_query($link, 'CREATE USER pcontest at localhost IDENTIFIED BY "pcontest"') ||
+		!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'%%'", $db)) ||
+		!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO pcontest@'localhost'", $db))) {
+		printf("[000] Init failed, [%d] %s\n",
+			mysqli_errno($plink), mysqli_error($plink));
+	}
+
 	if (!$plink = my_mysqli_connect('p:' . $host, 'pcontest', 'pcontest', $db, $port, $socket))
 		printf("[001] Cannot connect using the second DB user created during SKIPIF, [%d] %s\n",
 			mysqli_connect_errno(), mysqli_connect_error());
@@ -188,5 +192,5 @@ array(2) {
   %unicode|string%(1) "a"
 }
 
-Warning: my_mysqli_connect(): Too many open persistent links (%d) in %s on line %d
+Warning: %s: Too many open persistent links (%d) in %s on line %d
 done!
\ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_pconn_reuse.phpt b/ext/mysqli/tests/mysqli_pconn_reuse.phpt
index b42800a..6e210bd 100644
--- a/ext/mysqli/tests/mysqli_pconn_reuse.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_reuse.phpt
@@ -7,9 +7,6 @@ die("skip TODO - we need to add a user level way to check if CHANGE_USER gets ca
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-
-if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
-	die("skip: only available in mysqlnd");
 ?>
 --INI--
 mysqli.allow_persistent=1
diff --git a/ext/mysqli/tests/mysqli_pconn_twice.phpt b/ext/mysqli/tests/mysqli_pconn_twice.phpt
index 12800c2..5630d4e 100644
--- a/ext/mysqli/tests/mysqli_pconn_twice.phpt
+++ b/ext/mysqli/tests/mysqli_pconn_twice.phpt
@@ -5,8 +5,6 @@ Calling connect() on an open persistent connection to create a new persistent co
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-if (!$IS_MYSQLND)
-	die("skip mysqlnd test only");
 
 ?>
 --INI--
diff --git a/ext/mysqli/tests/mysqli_pconnect.phpt b/ext/mysqli/tests/mysqli_pconnect.phpt
index fbb1092..734029a 100644
--- a/ext/mysqli/tests/mysqli_pconnect.phpt
+++ b/ext/mysqli/tests/mysqli_pconnect.phpt
@@ -5,9 +5,6 @@ mysqli_pconnect()
 require_once('skipif.inc');
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
-
-if (!stristr(mysqli_get_client_info(), 'mysqlnd'))
-	die("skip: only available in mysqlnd");
 ?>
 --FILE--
 <?php
diff --git a/ext/mysqli/tests/mysqli_prepare.phpt b/ext/mysqli/tests/mysqli_prepare.phpt
index bba8274..d6d6c09 100644
--- a/ext/mysqli/tests/mysqli_prepare.phpt
+++ b/ext/mysqli/tests/mysqli_prepare.phpt
@@ -49,7 +49,7 @@ require_once('skipifconnectfailure.inc');
 		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$id = 1;
-	if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt))
+	if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt))
 		printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	mysqli_stmt_close($stmt);
 
@@ -57,7 +57,7 @@ require_once('skipifconnectfailure.inc');
 		printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$id = 2;
-	if (!mysqli_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt))
+	if (!mysqli_stmt_bind_param($stmt, 'i', $id) || !mysqli_stmt_execute($stmt))
 		printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	mysqli_stmt_close($stmt);
 
@@ -66,7 +66,7 @@ require_once('skipifconnectfailure.inc');
 
 	$id = 3;
 	$where = 2;
-	if (!mysqli_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt))
+	if (!mysqli_stmt_bind_param($stmt, 'ii', $id, $where) || !mysqli_stmt_execute($stmt))
 		printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	mysqli_stmt_close($stmt);
 
@@ -74,7 +74,7 @@ require_once('skipifconnectfailure.inc');
 		printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$where = 3;
-	if (!mysqli_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt))
+	if (!mysqli_stmt_bind_param($stmt, 'i', $where) || !mysqli_stmt_execute($stmt))
 		printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	mysqli_stmt_close($stmt);
 
@@ -82,7 +82,7 @@ require_once('skipifconnectfailure.inc');
 		printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
 	$testvar = 'testvar';
-	if (!mysqli_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt))
+	if (!mysqli_stmt_bind_param($stmt, 's', $testvar) || !mysqli_stmt_execute($stmt))
 		printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 	mysqli_stmt_close($stmt);
 
diff --git a/ext/mysqli/tests/mysqli_set_charset.phpt b/ext/mysqli/tests/mysqli_set_charset.phpt
index 4f4aaa5..4cd6e6e 100644
--- a/ext/mysqli/tests/mysqli_set_charset.phpt
+++ b/ext/mysqli/tests/mysqli_set_charset.phpt
@@ -102,7 +102,7 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
 		printf("[016] Cannot get list of character sets\n");
 
 	while ($tmp = mysqli_fetch_assoc($res)) {
-		if ('ucs2' == $tmp['Charset'])
+		if ('ucs2' == $tmp['Charset'] || 'utf16' == $tmp['Charset'] || 'utf32' == $tmp['Charset'])
 			continue;
 
 		/* Uncomment to see where it hangs - var_dump($tmp); flush(); */
diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
index 82e0121..c2ddd21 100644
--- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
@@ -92,6 +92,9 @@ require_once('skipifconnectfailure.inc');
 	$stmt = mysqli_stmt_init($link);
 	$stmt->prepare("SELECT label FROM test");
 	$stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1);
+	$res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH);
+	if ($res !== 1)
+		printf("[007.1] max_length should be 1, got %s\n", $res);
 	$stmt->execute();
 	$stmt->store_result();
 	$res = $stmt->result_metadata();
@@ -109,6 +112,9 @@ require_once('skipifconnectfailure.inc');
 	$stmt = mysqli_stmt_init($link);
 	$stmt->prepare("SELECT label FROM test");
 	$stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 0);
+	$res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH);
+	if ($res !== 0)
+		printf("[008.1] max_length should be 0, got %s\n", $res);
 	$stmt->execute();
 	$stmt->store_result();
 	$res = $stmt->result_metadata();
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
index 33ef317..7104578 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt
@@ -379,7 +379,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_bind_param()))
+	if (!is_null($tmp = @mysqli_stmt_bind_param()))
 			printf("[021] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 	print "done!";
 ?>
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt
index e1e3a92..03d1590 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_param_check_param_no_change.phpt
@@ -9,6 +9,7 @@ require_once('skipifconnectfailure.inc');
 --FILE--
 <?php
 	require('table.inc');
+	$link->set_charset('latin1');
 
 	class foo {
 	  // @var $bar string
diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
index 5b7da34..26b39d5 100644
--- a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt
@@ -296,7 +296,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_bind_result()))
+	if (!is_null($tmp = @mysqli_stmt_bind_result()))
 		printf("[3000] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	$stmt = mysqli_stmt_init($link);
diff --git a/ext/mysqli/tests/mysqli_stmt_fetch.phpt b/ext/mysqli/tests/mysqli_stmt_fetch.phpt
index fca5100..7598ffe 100644
--- a/ext/mysqli/tests/mysqli_stmt_fetch.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_fetch.phpt
@@ -80,7 +80,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_fetch()))
+	if (!is_null($tmp = @mysqli_stmt_fetch()))
 		printf("[017] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	print "done!";
diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt
index 1a2dba4..23d045a 100644
--- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata_fetch_field.phpt
@@ -12,26 +12,44 @@ if (!function_exists('mysqli_stmt_get_result'))
 --FILE--
 <?php
 	require('table.inc');
+	$charsets = my_get_charsets($link);
 
 	if (!($stmt = mysqli_stmt_init($link)) ||
 		!mysqli_stmt_prepare($stmt, "SELECT id, label, id + 1 as _id,  concat(label, '_') ___label FROM test ORDER BY id ASC LIMIT 3") ||
 		!mysqli_stmt_execute($stmt))
-		printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+		printf("[001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 
 	if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) {
-		printf("[007] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
+		printf("[002] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
 			gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 	}
 
 	if (!is_object($res_meta = mysqli_stmt_result_metadata($stmt)) ||
 		'mysqli_result' != get_class($res_meta)) {
-		printf("[008] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
+		printf("[003] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
 			gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 	}
 
-	$fields = array();
-	while ($info = $res->fetch_field()) {
-		var_dump($info);
+	$i = 0;
+	while ($field = $res->fetch_field()) {
+		var_dump($field);
+		$i++;
+		if (2 == $i) {
+			/*
+			Label column, result set charset.
+			All of the following columns are "too hot" - too server dependent
+			*/
+			if ($field->charsetnr != $charsets['results']['nr']) {
+				printf("[004] Expecting charset %s/%d got %d\n",
+					$charsets['results']['charset'],
+					$charsets['results']['nr'], $field->charsetnr);
+			}
+			if ($field->length != (1 * $charsets['results']['maxlen'])) {
+				printf("[005] Expecting length %d got %d\n",
+					$charsets['results']['maxlen'],
+					$field->max_length);
+			}
+		}
 	}
 
 	mysqli_stmt_close($stmt);
@@ -79,11 +97,11 @@ object(stdClass)#%d (11) {
   [%u|b%"def"]=>
   %unicode|string%(0) ""
   [%u|b%"max_length"]=>
-  int(1)
+  int(%d)
   [%u|b%"length"]=>
-  int(1)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
@@ -127,11 +145,11 @@ object(stdClass)#%d (11) {
   [%u|b%"def"]=>
   %unicode|string%(0) ""
   [%u|b%"max_length"]=>
-  int(2)
+  int(%d)
   [%u|b%"length"]=>
-  int(2)
+  int(%d)
   [%u|b%"charsetnr"]=>
-  int(8)
+  int(%d)
   [%u|b%"flags"]=>
   int(0)
   [%u|b%"type"]=>
diff --git a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
index 28ee64f..0a21bb5 100644
--- a/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_num_rows.phpt
@@ -27,17 +27,17 @@ require_once('skipifconnectfailure.inc');
 	function func_test_mysqli_stmt_num_rows($stmt, $query, $expected, $offset) {
 
 		if (!mysqli_stmt_prepare($stmt, $query)) {
-			printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt));
+			printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 			return false;
 		}
 
 		if (!mysqli_stmt_execute($stmt)) {
-			printf("[%03d] [%d] %s\n", $offset + 1, mysqli_errno($stmt), mysqli_error($stmt));
+			printf("[%03d] [%d] %s\n", $offset + 1, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 			return false;
 		}
 
 		if (!mysqli_stmt_store_result($stmt)) {
-			printf("[%03d] [%d] %s\n", $offset + 2, mysqli_errno($stmt), mysqli_error($stmt));
+			printf("[%03d] [%d] %s\n", $offset + 2, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
 			return false;
 		}
 
diff --git a/ext/mysqli/tests/mysqli_stmt_param_count.phpt b/ext/mysqli/tests/mysqli_stmt_param_count.phpt
index 84bcfd9..3526956 100644
--- a/ext/mysqli/tests/mysqli_stmt_param_count.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_param_count.phpt
@@ -55,7 +55,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_param_count()))
+	if (!is_null($tmp = @mysqli_stmt_param_count()))
 		printf("[041] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	print "done!";
diff --git a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
index faccdf9..f9fd3cf 100644
--- a/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_result_metadata.phpt
@@ -87,7 +87,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_get_metadata()))
+	if (!is_null($tmp = @mysqli_stmt_result_metadata()))
 		printf("[018] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	mysqli_close($link);
diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
index 1a6a3d7..7e2f860 100644
--- a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
+++ b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt
@@ -120,7 +120,7 @@ require_once('skipifconnectfailure.inc');
 
 	/* Check that the function alias exists. It's a deprecated function,
 	but we have not announce the removal so far, therefore we need to check for it */
-	if (!is_null($tmp = @mysqli_send_long_data()))
+	if (!is_null($tmp = @mysqli_stmt_send_long_data()))
 		printf("[023] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
 
 	mysqli_close($link);
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index 4a23e10..fad2bce 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config9.m4 298023 2010-04-15 11:01:30Z andrey $
+dnl $Id: config9.m4 304973 2010-10-28 13:46:54Z andrey $
 dnl config.m4 for mysqlnd driver
 
 
@@ -27,13 +27,10 @@ if test "$PHP_MYSQLND_ENABLED" = "yes"; then
   dnl Windows uses config.w32 thus this code is safe for now
 
   if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then
-    AC_DEFINE([MYSQLND_COMPRESSION_ENABLED], 1, [Enable compressed protocol support])
-    if test "$PHP_ZLIB_DIR" != "no"; then
+    if test -z "$PHP_ZLIB_DIR"; then
+      AC_DEFINE([MYSQLND_COMPRESSION_ENABLED], 1, [Enable compressed protocol support])
       PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR, MYSQLND_SHARED_LIBADD)
       MYSQLND_LIBS="$MYSQLND_LIBS -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz"
-    else
-      PHP_ADD_LIBRARY(z,, MYSQLND_SHARED_LIBADD)
-      MYSQLND_LIBS="$MYSQLND_LIBS -lz"
     fi
   fi
   AC_DEFINE([MYSQLND_SSL_SUPPORTED], 1, [Enable SSL support])
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index d0f2c1c..430db40 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd.c 300635 2010-06-21 15:32:26Z andrey $ */
+/* $Id: mysqlnd.c 306008 2010-12-06 13:50:51Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -282,7 +282,7 @@ MYSQLND_METHOD(mysqlnd_conn, simple_command_handle_response)(MYSQLND * conn, enu
 			MYSQLND_PACKET_EOF * ok_response = conn->protocol->m.get_eof_packet(conn->protocol, FALSE TSRMLS_CC);
 			if (!ok_response) {
 				SET_OOM_ERROR(conn->error_info);
-				break;			
+				break;
 			}
 			if (FAIL == (ret = PACKET_READ(ok_response, conn))) {
 				SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE,
@@ -399,25 +399,6 @@ MYSQLND_METHOD(mysqlnd_conn, set_server_option)(MYSQLND * const conn, enum_mysql
 /* }}} */
 
 
-/* {{{ _mysqlnd_restart_psession */
-PHPAPI void _mysqlnd_restart_psession(MYSQLND * conn TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_restart_psession");
-	conn->m->restart_psession(conn TSRMLS_CC);
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
-
-/* {{{ _mysqlnd_end_psession */
-PHPAPI void _mysqlnd_end_psession(MYSQLND * conn TSRMLS_DC)
-{
-	DBG_ENTER("_mysqlnd_end_psession");
-	conn->m->end_psession(conn TSRMLS_CC);
-	DBG_VOID_RETURN;
-}
-/* }}} */
-
 /* {{{ mysqlnd_conn::restart_psession */
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_conn, restart_psession)(MYSQLND * conn TSRMLS_DC)
@@ -481,7 +462,7 @@ mysqlnd_connect_run_authentication(
 	if (options->charset_name && (charset = mysqlnd_find_charset_name(options->charset_name))) {
 		auth_packet->charset_no	= charset->nr;
 	} else {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		auth_packet->charset_no	= 200;/* utf8 - swedish collation, check mysqlnd_charset.c */
 #else
 		auth_packet->charset_no	= greet_packet->charset_no;
@@ -498,7 +479,7 @@ mysqlnd_connect_run_authentication(
 		goto err;
 	}
 	memcpy(auth_packet->server_scramble_buf, greet_packet->scramble_buf, SCRAMBLE_LENGTH);
-	
+
 	if (!PACKET_WRITE(auth_packet, conn)) {
 		CONN_SET_STATE(conn, CONN_QUIT_SENT);
 		SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
@@ -515,7 +496,7 @@ mysqlnd_connect_run_authentication(
 		if (FAIL == conn->net->m.enable_ssl(conn->net TSRMLS_CC)) {
 			goto err;
 		}
-		
+
 		auth_packet->send_half_packet = FALSE;
 		if (!PACKET_WRITE(auth_packet, conn)) {
 			CONN_SET_STATE(conn, CONN_QUIT_SENT);
@@ -550,7 +531,7 @@ mysqlnd_connect_run_authentication(
 err:
 	PACKET_FREE(auth_packet);
 	PACKET_FREE(ok_packet);
-	DBG_RETURN(ret);	
+	DBG_RETURN(ret);
 }
 /* }}} */
 
@@ -568,7 +549,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
 						 const char *passwd, unsigned int passwd_len,
 						 const char *db, unsigned int db_len,
 						 unsigned int port,
-						 const char *socket,
+						 const char * socket_or_pipe,
 						 unsigned int mysql_flags
 						 TSRMLS_DC)
 {
@@ -636,11 +617,11 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
 		int transport_len;
 #ifndef PHP_WIN32
 		if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) {
-			DBG_INF_FMT("socket=%s", socket? socket:"n/a");
-			if (!socket) {
-				socket = "/tmp/mysql.sock";
+			DBG_INF_FMT("socket=%s", socket_or_pipe? socket_or_pipe:"n/a");
+			if (!socket_or_pipe) {
+				socket_or_pipe = "/tmp/mysql.sock";
 			}
-			transport_len = spprintf(&transport, 0, "unix://%s", socket);
+			transport_len = spprintf(&transport, 0, "unix://%s", socket_or_pipe);
 			unix_socket = TRUE;
 		} else
 #endif
@@ -714,6 +695,10 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
 	if (mysql_flags & CLIENT_COMPRESS) {
 		mysql_flags &= ~CLIENT_COMPRESS;
 	}
+#else
+	if (conn->net->options.flags & MYSQLND_NET_FLAG_USE_COMPRESSION) {
+		mysql_flags |= CLIENT_COMPRESS;
+	}
 #endif
 #ifndef MYSQLND_SSL_SUPPORTED
 	if (mysql_flags & CLIENT_SSL) {
@@ -769,21 +754,21 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
 				spprintf(&p, 0, "%s via TCP/IP", conn->host);
 				if (!p) {
 					SET_OOM_ERROR(conn->error_info);
-					goto err; /* OOM */		
+					goto err; /* OOM */
 				}
 				conn->host_info =  mnd_pestrdup(p, conn->persistent);
 				efree(p); /* allocated by spprintf */
 				if (!conn->host_info) {
 					SET_OOM_ERROR(conn->error_info);
-					goto err; /* OOM */		
+					goto err; /* OOM */
 				}
 			}
 		} else {
-			conn->unix_socket	= mnd_pestrdup(socket, conn->persistent);
+			conn->unix_socket	= mnd_pestrdup(socket_or_pipe, conn->persistent);
 			conn->host_info		= mnd_pestrdup("Localhost via UNIX socket", conn->persistent);
 			if (!conn->unix_socket || !conn->host_info) {
 				SET_OOM_ERROR(conn->error_info);
-				goto err; /* OOM */			
+				goto err; /* OOM */
 			}
 			conn->unix_socket_len = strlen(conn->unix_socket);
 		}
@@ -799,7 +784,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
 
 		mysqlnd_local_infile_default(conn);
 
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		{
 			unsigned int as_unicode = 1;
 			conn->m->set_client_option(conn, MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, (char *)&as_unicode TSRMLS_CC);
@@ -865,7 +850,7 @@ PHPAPI MYSQLND * mysqlnd_connect(MYSQLND * conn,
 						 const char *passwd, unsigned int passwd_len,
 						 const char *db, unsigned int db_len,
 						 unsigned int port,
-						 const char *socket,
+						 const char *socket_or_pipe,
 						 unsigned int mysql_flags
 						 TSRMLS_DC)
 {
@@ -883,7 +868,7 @@ PHPAPI MYSQLND * mysqlnd_connect(MYSQLND * conn,
 		}
 	}
 
-	ret = conn->m->connect(conn, host, user, passwd, passwd_len, db, db_len, port, socket, mysql_flags TSRMLS_CC);
+	ret = conn->m->connect(conn, host, user, passwd, passwd_len, db, db_len, port, socket_or_pipe, mysql_flags TSRMLS_CC);
 
 	if (ret == FAIL) {
 		if (self_alloced) {
@@ -1188,11 +1173,11 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND * conn, const char *table, con
 									   FALSE, TRUE TSRMLS_CC)) {
 		DBG_RETURN(NULL);
 	}
-	
+
 	/*
 	   Prepare for the worst case.
 	   MyISAM goes to 2500 BIT columns, double it for safety.
-	 */
+	*/
 	result = conn->m->result_init(5000, conn->persistent TSRMLS_CC);
 	if (!result) {
 		DBG_RETURN(NULL);
@@ -1211,7 +1196,7 @@ MYSQLND_METHOD(mysqlnd_conn, list_fields)(MYSQLND * conn, const char *table, con
 		/* OOM */
 		SET_OOM_ERROR(conn->error_info);
 		result->m.free_result(result, TRUE TSRMLS_CC);
-		DBG_RETURN(NULL);	
+		DBG_RETURN(NULL);
 	}
 	result->unbuf->eof_reached = TRUE;
 
@@ -1287,20 +1272,19 @@ MYSQLND_METHOD(mysqlnd_conn, sqlstate)(const MYSQLND * const conn TSRMLS_DC)
 PHPAPI ulong mysqlnd_old_escape_string(char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_old_escape_string");
-	DBG_RETURN(mysqlnd_cset_escape_slashes(mysqlnd_find_charset_name("latin1"),
-										   newstr, escapestr, escapestr_len TSRMLS_CC));
+	DBG_RETURN(mysqlnd_cset_escape_slashes(mysqlnd_find_charset_name("latin1"), newstr, escapestr, escapestr_len TSRMLS_CC));
 }
 /* }}} */
 
 /* {{{ mysqlnd_conn::ssl_set */
-void
+static enum_func_status
 MYSQLND_METHOD(mysqlnd_conn, ssl_set)(MYSQLND * const conn, const char * key, const char * const cert, const char * const ca, const char * const capath, const char * const cipher TSRMLS_DC)
 {
-	conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_KEY, key TSRMLS_CC);
-	conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CERT, cert TSRMLS_CC);
-	conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CA, ca TSRMLS_CC);
-	conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CAPATH, capath TSRMLS_CC);
-	conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CIPHER, cipher TSRMLS_CC);
+	return (PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_KEY, key TSRMLS_CC) &&
+		PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CERT, cert TSRMLS_CC) &&
+		PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CA, ca TSRMLS_CC) &&
+		PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CAPATH, capath TSRMLS_CC) &&
+		PASS == conn->net->m.set_client_option(conn->net, MYSQLND_OPT_SSL_CIPHER, cipher TSRMLS_CC)) ? PASS : FAIL;
 }
 /* }}} */
 
@@ -1384,14 +1368,14 @@ MYSQLND_METHOD(mysqlnd_conn, ping)(MYSQLND * const conn TSRMLS_DC)
 /* }}} */
 
 
-/* {{{ mysqlnd_conn::stat */
+/* {{{ mysqlnd_conn::statistic */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_conn, stat)(MYSQLND * conn, char **message, unsigned int * message_len TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_conn, statistic)(MYSQLND * conn, char **message, unsigned int * message_len TSRMLS_DC)
 {
 	enum_func_status ret;
 	MYSQLND_PACKET_STATS * stats_header;
 
-	DBG_ENTER("mysqlnd_conn::stat");
+	DBG_ENTER("mysqlnd_conn::statistic");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
 
 	ret = conn->m->simple_command(conn, COM_STATISTICS, NULL, 0, PROT_LAST, FALSE, TRUE TSRMLS_CC);
@@ -1438,8 +1422,7 @@ MYSQLND_METHOD(mysqlnd_conn, kill)(MYSQLND * conn, unsigned int pid TSRMLS_DC)
 		  a protocol of giving back -1. Thus we have to follow it :(
 		*/
 		SET_ERROR_AFF_ROWS(conn);
-	} else if (PASS == (ret = conn->m->simple_command(conn, COM_PROCESS_KILL, buff,
-													 4, PROT_LAST, FALSE, TRUE TSRMLS_CC))) {
+	} else if (PASS == (ret = conn->m->simple_command(conn, COM_PROCESS_KILL, buff, 4, PROT_LAST, FALSE, TRUE TSRMLS_CC))) {
 		CONN_SET_STATE(conn, CONN_QUIT_SENT);
 	}
 	DBG_RETURN(ret);
@@ -1577,13 +1560,13 @@ MYSQLND_METHOD(mysqlnd_conn, close)(MYSQLND * conn, enum_connection_close_type c
 		STAT_CLOSE_IMPLICIT,
 		STAT_CLOSE_DISCONNECT
 	};
-	enum_mysqlnd_collected_stats stat = close_type_to_stat_map[close_type];
+	enum_mysqlnd_collected_stats statistic = close_type_to_stat_map[close_type];
 
 	DBG_ENTER("mysqlnd_conn::close");
 	DBG_INF_FMT("conn=%llu", conn->thread_id);
 
 	if (conn->state >= CONN_READY) {
-		MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
+		MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
 		MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_CONNECTIONS);
 		if (conn->persistent) {
 			MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS);
@@ -1954,7 +1937,7 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 		int2store(p, conn->charset->nr);
 		p+=2;
 	}
-	
+
 	if (PASS != conn->m->simple_command(conn, COM_CHANGE_USER, buffer, p - buffer,
 									   PROT_LAST /* we will handle the OK packet*/,
 									   silent, TRUE TSRMLS_CC)) {
@@ -1983,20 +1966,24 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 				PACKET_FREE(redundant_error_packet);
 				DBG_INF_FMT("Server is %u, buggy, sends two ERR messages", mysqlnd_get_server_version(conn));
 			} else {
-				SET_OOM_ERROR(conn->error_info);			
+				SET_OOM_ERROR(conn->error_info);
 			}
 		}
 	}
 	if (ret == PASS) {
+		char * tmp = NULL;
+		/* if we get conn->user as parameter and then we first free it, then estrndup it, we will crash */
+		tmp = mnd_pestrndup(user, user_len, conn->persistent);
 		if (conn->user) {
 			mnd_pefree(conn->user, conn->persistent);
 		}
-		conn->user = mnd_pestrndup(user, user_len, conn->persistent);
+		conn->user = tmp;
 
+		tmp = mnd_pestrdup(passwd, conn->persistent);
 		if (conn->passwd) {
 			mnd_pefree(conn->passwd, conn->persistent);
 		}
-		conn->passwd = mnd_pestrdup(passwd, conn->persistent);
+		conn->passwd = tmp;
 
 		if (conn->last_message) {
 			mnd_pefree(conn->last_message, conn->persistent);
@@ -2010,7 +1997,7 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
 	} else if (ret == FAIL && chg_user_resp->server_asked_323_auth == TRUE) {
 		/* old authentication with new server  !*/
 		DBG_ERR(mysqlnd_old_passwd);
-		SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);	
+		SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
 	}
 end:
 	PACKET_FREE(chg_user_resp);
@@ -2036,9 +2023,7 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 	DBG_ENTER("mysqlnd_conn::set_client_option");
 	DBG_INF_FMT("conn=%llu option=%u", conn->thread_id, option);
 	switch (option) {
-#ifdef WHEN_SUPPORTED_BY_MYSQLI
 		case MYSQL_OPT_COMPRESS:
-#endif
 #ifdef WHEN_SUPPORTED_BY_MYSQLI
 		case MYSQL_OPT_READ_TIMEOUT:
 		case MYSQL_OPT_WRITE_TIMEOUT:
@@ -2054,7 +2039,7 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 		case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
 			ret = conn->net->m.set_client_option(conn->net, option, value TSRMLS_CC);
 			break;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
 			conn->options.numeric_and_datetime_as_unicode = *(unsigned int*) value;
 			break;
@@ -2116,10 +2101,17 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 			DBG_INF_FMT("charset=%s", conn->options.charset_name);
 			break;
 		}
+		case MYSQL_OPT_NAMED_PIPE:
+			conn->options.protocol = MYSQL_PROTOCOL_PIPE;
+			break;
+		case MYSQL_OPT_PROTOCOL:
+			if (*(unsigned int*) value < MYSQL_PROTOCOL_LAST) {
+				conn->options.protocol = *(unsigned int*) value;
+			}
+			break;
 #ifdef WHEN_SUPPORTED_BY_MYSQLI
 		case MYSQL_SET_CHARSET_DIR:
 		case MYSQL_OPT_RECONNECT:
-		case MYSQL_OPT_PROTOCOL:
 			/* we don't need external character sets, all character sets are
 			   compiled in. For compatibility we just ignore this setting.
 			   Same for protocol, we don't support old protocol */
@@ -2131,7 +2123,6 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
 #endif
 
 #ifdef WHEN_SUPPORTED_BY_MYSQLI
-		case MYSQL_OPT_NAMED_PIPE:
 		case MYSQL_SHARED_MEMORY_BASE_NAME:
 		case MYSQL_OPT_USE_RESULT:
 		case MYSQL_SECURE_AUTH:
@@ -2178,7 +2169,7 @@ MYSQLND_METHOD(mysqlnd_conn, use_result)(MYSQLND * const conn TSRMLS_DC)
 		conn->current_result->m.free_result(conn->current_result, TRUE TSRMLS_CC);
 	}
 	conn->current_result = NULL;
-	
+
 	DBG_RETURN(result);
 }
 /* }}} */
@@ -2209,7 +2200,7 @@ MYSQLND_METHOD(mysqlnd_conn, store_result)(MYSQLND * const conn TSRMLS_DC)
 
 	result = conn->current_result->m.store_result(conn->current_result, conn, FALSE TSRMLS_CC);
 	if (!result) {
-		conn->current_result->m.free_result(conn->current_result, TRUE TSRMLS_CC);	
+		conn->current_result->m.free_result(conn->current_result, TRUE TSRMLS_CC);
 	}
 	conn->current_result = NULL;
 	DBG_RETURN(result);
@@ -2269,7 +2260,7 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_conn)
 
 	MYSQLND_METHOD(mysqlnd_conn, get_server_version),
 	MYSQLND_METHOD(mysqlnd_conn, get_server_info),
-	MYSQLND_METHOD(mysqlnd_conn, stat),
+	MYSQLND_METHOD(mysqlnd_conn, statistic),
 	MYSQLND_METHOD(mysqlnd_conn, get_host_info),
 	MYSQLND_METHOD(mysqlnd_conn, get_proto_info),
 	MYSQLND_METHOD(mysqlnd_conn, info),
@@ -2328,10 +2319,11 @@ MYSQLND_METHOD(mysqlnd_conn, init)(MYSQLND * conn TSRMLS_DC)
 PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC)
 {
 	size_t alloc_size = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
-	MYSQLND *ret = mnd_pecalloc(1, alloc_size, persistent);
+	MYSQLND *ret;
 
 	DBG_ENTER("mysqlnd_init");
 	DBG_INF_FMT("persistent=%u", persistent);
+	ret = mnd_pecalloc(1, alloc_size, persistent);
 	if (!ret) {
 		DBG_RETURN(NULL);
 	}
diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h
index 2db4c6d..032057f 100644
--- a/ext/mysqlnd/mysqlnd.h
+++ b/ext/mysqlnd/mysqlnd.h
@@ -17,12 +17,12 @@
   |          Ulf Wendel <uwendel at mysql.com>                              |
   +----------------------------------------------------------------------+
 */
-/* $Id: mysqlnd.h 300533 2010-06-17 16:56:48Z pajoye $ */
+/* $Id: mysqlnd.h 304625 2010-10-22 14:34:33Z andrey $ */
 
 #ifndef MYSQLND_H
 #define MYSQLND_H
 
-#define MYSQLND_VERSION "mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $"
+#define MYSQLND_VERSION "mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $"
 #define MYSQLND_VERSION_ID 50007
 
 /* This forces inlining of some accessor functions */
@@ -44,7 +44,7 @@
 #define MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND 1
 #endif
 
-#if PHP_DEBUG && !defined(PHP_WIN32)
+#if PHP_DEBUG
 #define MYSQLND_DBG_ENABLED 1
 #else
 #define MYSQLND_DBG_ENABLED 0
@@ -85,10 +85,8 @@ PHPAPI struct st_mysqlnd_stmt_methods * mysqlnd_stmt_get_methods();
 PHPAPI void mysqlnd_stmt_set_methods(struct st_mysqlnd_stmt_methods *methods);
 
 
-#define mysqlnd_restart_psession(conn) _mysqlnd_restart_psession((conn) TSRMLS_CC)
-PHPAPI void _mysqlnd_restart_psession(MYSQLND * conn TSRMLS_DC);
-#define mysqlnd_end_psession(conn) _mysqlnd_end_psession((conn) TSRMLS_CC)
-PHPAPI void _mysqlnd_end_psession(MYSQLND *conn TSRMLS_DC);
+#define mysqlnd_restart_psession(conn)	(conn)->m->restart_psession((conn) TSRMLS_CC)
+#define mysqlnd_end_psession(conn)		(conn)->m->end_psession((conn) TSRMLS_CC)
 PHPAPI void mysqlnd_minfo_print_hash(zval *values);
 #define mysqlnd_thread_safe()	TRUE
 
@@ -104,7 +102,7 @@ PHPAPI MYSQLND * mysqlnd_connect(MYSQLND *conn,
 						  const char *passwd, unsigned int passwd_len,
 						  const char *db, unsigned int db_len,
 						  unsigned int port,
-						  const char *socket,
+						  const char *socket_or_pipe,
 						  unsigned int mysql_flags
 						  TSRMLS_DC);
 
@@ -286,7 +284,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
 	long			debug_realloc_fail_threshold;
 ZEND_END_MODULE_GLOBALS(mysqlnd)
 
-PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd);
+PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd)
 
 #ifdef ZTS
 #define MYSQLND_G(v) TSRMG(mysqlnd_globals_id, zend_mysqlnd_globals *, v)
diff --git a/ext/mysqlnd/mysqlnd_block_alloc.c b/ext/mysqlnd/mysqlnd_block_alloc.c
index 1288e76..c89b377 100644
--- a/ext/mysqlnd/mysqlnd_block_alloc.c
+++ b/ext/mysqlnd/mysqlnd_block_alloc.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_block_alloc.c 298917 2010-05-03 17:07:18Z andrey $ */
+/* $Id: mysqlnd_block_alloc.c 303734 2010-09-23 16:03:22Z andrey $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -104,7 +104,6 @@ mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL_CHUNK * chunk, unsigned int siz
 			DBG_RETURN(FAIL);
 		}
 		chunk->ptr = new_ptr;
-		
 	}
 	DBG_RETURN(PASS);
 }
diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c
index d8a2c5a..1e058fa 100644
--- a/ext/mysqlnd/mysqlnd_charset.c
+++ b/ext/mysqlnd/mysqlnd_charset.c
@@ -24,6 +24,44 @@
 #include "mysqlnd_debug.h"
 
 /* {{{ utf8 functions */
+static unsigned int check_mb_utf8mb3_sequence(const char *start, const char *end)
+{
+	zend_uchar	c;
+
+	if (start >= end) {
+		return 0;
+	}
+
+	c = (zend_uchar) start[0];
+
+	if (c < 0x80) {
+		return 1;		/* single byte character */
+	}
+	if (c < 0xC2) {
+		return 0;		/* invalid mb character */
+	}
+	if (c < 0xE0) {
+		if (start + 2 > end) {
+			return 0;	/* too small */
+		}
+		if (!(((zend_uchar)start[1] ^ 0x80) < 0x40)) {
+			return 0;
+		}
+		return 2;
+	}
+	if (c < 0xF0) {
+		if (start + 3 > end) {
+			return 0;	/* too small */
+		}
+		if (!(((zend_uchar)start[1] ^ 0x80) < 0x40 && ((zend_uchar)start[2] ^ 0x80) < 0x40 &&
+			(c >= 0xE1 || (zend_uchar)start[1] >= 0xA0))) {
+			return 0;	/* invalid utf8 character */
+		}
+		return 3;
+	}
+	return 0;
+}
+
 
 static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
 {
@@ -60,16 +98,57 @@ static unsigned int check_mb_utf8_sequence(const char *start, const char *end)
 		}
 		return 3;
 	}
+	if (c < 0xF5) {
+		if (start + 4 > end) { /* We need 4 characters */
+			return 0;	/* too small */
+		}
+
+		/*
+		  UTF-8 quick four-byte mask:
+		  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+		  Encoding allows to encode U+00010000..U+001FFFFF
+
+		  The maximum character defined in the Unicode standard is U+0010FFFF.
+		  Higher characters U+00110000..U+001FFFFF are not used.
+
+		  11110000.10010000.10xxxxxx.10xxxxxx == F0.90.80.80 == U+00010000 (min)
+		  11110100.10001111.10111111.10111111 == F4.8F.BF.BF == U+0010FFFF (max)
+
+		  Valid codes:
+		  [F0][90..BF][80..BF][80..BF]
+		  [F1][80..BF][80..BF][80..BF]
+		  [F2][80..BF][80..BF][80..BF]
+		  [F3][80..BF][80..BF][80..BF]
+		  [F4][80..8F][80..BF][80..BF]
+		*/
+
+		if (!((start[1] ^ 0x80) < 0x40 &&
+			(start[2] ^ 0x80) < 0x40 &&
+			(start[3] ^ 0x80) < 0x40 &&
+				(c >= 0xf1 || start[1] >= 0x90) &&
+				(c <= 0xf3 || start[1] <= 0x8F)))
+		{
+			return 0;	/* invalid utf8 character */
+		}
+		return 4;
+	}
 	return 0;
 }
 
+static unsigned int check_mb_utf8mb3_valid(const char *start, const char *end)
+{
+	unsigned int len = check_mb_utf8mb3_sequence(start, end);
+	return (len > 1)? len:0;
+}
+
 static unsigned int check_mb_utf8_valid(const char *start, const char *end)
 {
 	unsigned int len = check_mb_utf8_sequence(start, end);
 	return (len > 1)? len:0;
 }
 
-static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
+
+static unsigned int mysqlnd_mbcharlen_utf8mb3(unsigned int utf8)
 {
 	if (utf8 < 0x80) {
 		return 1;		/* single byte character */
@@ -83,8 +162,27 @@ static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
 	if (utf8 < 0xF0) {
 		return 3;		/* triple byte character */
 	}
-	/* We still don't support characters out of the BMP */
+	return 0;
+}
+
 
+static unsigned int mysqlnd_mbcharlen_utf8(unsigned int utf8)
+{
+	if (utf8 < 0x80) {
+		return 1;		/* single byte character */
+	}
+	if (utf8 < 0xC2) {
+		return 0;		/* invalid multibyte header */
+	}
+	if (utf8 < 0xE0) {
+		return 2;		/* double byte character */
+	}
+	if (utf8 < 0xF0) {
+		return 3;		/* triple byte character */
+	}
+	if (utf8 < 0xF8) {
+		return 4;		/* four byte character */
+	}
 	return 0;
 }
 /* }}} */
@@ -292,186 +390,60 @@ static unsigned int mysqlnd_mbcharlen_ujis(unsigned int ujis)
 
 
 
-/* {{{ mysqlnd_charsets */
-const MYSQLND_CHARSET mysqlnd_charsets[] =
+/* {{{ utf16 functions */
+#define UTF16_HIGH_HEAD(x)  ((((zend_uchar) (x)) & 0xFC) == 0xD8)
+#define UTF16_LOW_HEAD(x)   ((((zend_uchar) (x)) & 0xFC) == 0xDC)
+
+static unsigned int check_mb_utf16(const char *start, const char *end)
 {
-	{   1, "big5","big5_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
-	{   3, "dec8", "dec8_swedisch_ci", 1, 1, "", NULL, NULL},
-	{   4, "cp850", "cp850_general_ci", 1, 1, "", NULL, NULL},
-	{   6, "hp8", "hp8_english_ci", 1, 1, "", NULL, NULL},
-	{   7, "koi8r", "koi8r_general_ci", 1, 1, "", NULL, NULL},
-	{   8, "latin1", "latin1_swedish_ci", 1, 1, "", NULL, NULL},
-	{   9, "latin2", "latin2_general_ci", 1, 1, "", NULL, NULL},
-	{  10, "swe7", "swe7_swedish_ci", 1, 1, "", NULL, NULL},
-	{  11, "ascii", "ascii_general_ci", 1, 1, "", NULL, NULL},
-	{  12, "ujis", "ujis_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
-	{  13, "sjis", "sjis_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
-	{  16, "hebrew", "hebrew_general_ci", 1, 1, "", NULL, NULL},
-	{  18, "tis620", "tis620_thai_ci", 1, 1, "", NULL, NULL},
-	{  19, "euckr", "euckr_korean_ci", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
-	{  22, "koi8u", "koi8u_general_ci", 1, 1, "", NULL, NULL},
-	{  24, "gb2312", "gb2312_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
-	{  25, "greek", "greek_general_ci", 1, 1, "", NULL, NULL},
-	{  26, "cp1250", "cp1250_general_ci", 1, 1, "", NULL, NULL},
-	{  28, "gbk", "gbk_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
-	{  30, "latin5", "latin5_turkish_ci", 1, 1, "", NULL, NULL},
-	{  32, "armscii8", "armscii8_general_ci", 1, 1, "", NULL, NULL},
-	{  33, "utf8", "utf8_general_ci", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-	{  35, "ucs2", "ucs2_general_ci", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{  36, "cp866", "cp866_general_ci", 1, 1, "", NULL, NULL},
-	{  37, "keybcs2", "keybcs2_general_ci", 1, 1, "", NULL, NULL},
-	{  38, "macce", "macce_general_ci", 1, 1, "", NULL, NULL},
-	{  39, "macroman", "macroman_general_ci", 1, 1, "", NULL, NULL},
-	{  40, "cp852", "cp852_general_ci", 1, 1, "", NULL, NULL},
-	{  41, "latin7", "latin7_general_ci", 1, 1, "", NULL, NULL},
-	{  51, "cp1251", "cp1251_general_ci", 1, 1, "", NULL, NULL},
-	{  57, "cp1256", "cp1256_general_ci", 1, 1, "", NULL, NULL},
-	{  59, "cp1257", "cp1257_general_ci", 1, 1, "", NULL, NULL},
-	{  63, "binary", "binary", 1, 1, "", NULL, NULL},
-	{  92, "geostd8", "geostd8_general_ci", 1, 1, "", NULL, NULL},
-	{  95, "cp932", "cp932_japanese_ci", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
-	{  97, "eucjpms", "eucjpms_japanese_ci", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
-	{   2, "latin2", "latin2_czech_cs", 1, 1, "", NULL, NULL},
-	{   5, "latin1", "latin1_german_ci", 1, 1, "", NULL, NULL},
-	{  14, "cp1251", "cp1251_bulgarian_ci", 1, 1, "", NULL, NULL},
-	{  15, "latin1", "latin1_danish_ci", 1, 1, "", NULL, NULL},
-	{  17, "filename", "filename", 1, 5, "", NULL, NULL},
-	{  20, "latin7", "latin7_estonian_cs", 1, 1, "", NULL, NULL},
-	{  21, "latin2", "latin2_hungarian_ci", 1, 1, "", NULL, NULL},
-	{  23, "cp1251", "cp1251_ukrainian_ci", 1, 1, "", NULL, NULL},
-	{  27, "latin2", "latin2_croatian_ci", 1, 1, "", NULL, NULL},
-	{  29, "cp1257", "cp1257_lithunian_ci", 1, 1, "", NULL, NULL},
-	{  31, "latin1", "latin1_german2_ci", 1, 1, "", NULL, NULL},
-	{  34, "cp1250", "cp1250_czech_cs", 1, 1, "", NULL, NULL},
-	{  42, "latin7", "latin7_general_cs", 1, 1, "", NULL, NULL},
-	{  43, "macce", "macce_bin", 1, 1, "", NULL, NULL},
-	{  44, "cp1250", "cp1250_croatian_ci", 1, 1, "", NULL, NULL},
-	{  47, "latin1", "latin1_bin", 1, 1, "", NULL, NULL},
-	{  48, "latin1", "latin1_general_ci", 1, 1, "", NULL, NULL},
-	{  49, "latin1", "latin1_general_cs", 1, 1, "", NULL, NULL},
-	{  50, "cp1251", "cp1251_bin", 1, 1, "", NULL, NULL},
-	{  52, "cp1251", "cp1251_general_cs", 1, 1, "", NULL, NULL},
-	{  53, "macroman", "macroman_bin", 1, 1, "", NULL, NULL},
-	{  58, "cp1257", "cp1257_bin", 1, 1, "", NULL, NULL},
-	{  60, "armascii8", "armascii8_bin", 1, 1, "", NULL, NULL},
-	{  65, "ascii", "ascii_bin", 1, 1, "", NULL, NULL},
-	{  66, "cp1250", "cp1250_bin", 1, 1, "", NULL, NULL},
-	{  67, "cp1256", "cp1256_bin", 1, 1, "", NULL, NULL},
-	{  68, "cp866", "cp866_bin", 1, 1, "", NULL, NULL},
-	{  69, "dec8", "dec8_bin", 1, 1, "", NULL, NULL},
-	{  70, "greek", "greek_bin", 1, 1, "", NULL, NULL},
-	{  71, "hebew", "hebrew_bin", 1, 1, "", NULL, NULL},
-	{  72, "hp8", "hp8_bin", 1, 1, "", NULL, NULL},
-	{  73, "keybcs2", "keybcs2_bin", 1, 1, "", NULL, NULL},
-	{  74, "koi8r", "koi8r_bin", 1, 1, "", NULL, NULL},
-	{  75, "koi8u", "koi8u_bin", 1, 1, "", NULL, NULL},
-	{  77, "latin2", "latin2_bin", 1, 1, "", NULL, NULL},
-	{  78, "latin5", "latin5_bin", 1, 1, "", NULL, NULL},
-	{  79, "latin7", "latin7_bin", 1, 1, "", NULL, NULL},
-	{  80, "cp850", "cp850_bin", 1, 1, "", NULL, NULL},
-	{  81, "cp852", "cp852_bin", 1, 1, "", NULL, NULL},
-	{  82, "swe7", "swe7_bin", 1, 1, "", NULL, NULL},
-	{  93, "geostd8", "geostd8_bin", 1, 1, "", NULL, NULL},
-	{  83, "utf8", "utf8_bin", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-	{  84, "big5", "big5_bin", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
-	{  85, "euckr", "euckr_bin", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
-	{  86, "gb2312", "gb2312_bin", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
-	{  87, "gbk", "gbk_bin", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
-	{  88, "sjis", "sjis_bin", 1, 2, "", mysqlnd_mbcharlen_sjis, check_mb_sjis},
-	{  89, "tis620", "tis620_bin", 1, 1, "", NULL, NULL},
-	{  90, "ucs2", "ucs2_bin", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{  91, "ujis", "ujis_bin", 1, 3, "", mysqlnd_mbcharlen_ujis, check_mb_ujis},
-	{  94, "latin1", "latin1_spanish_ci", 1, 1, "", NULL, NULL},
-	{  96, "cp932", "cp932_bin", 1, 2, "", mysqlnd_mbcharlen_cp932, check_mb_cp932},
-	{  99, "cp1250", "cp1250_polish_ci", 1, 1, "", NULL, NULL},
-	{  98, "eucjpms", "eucjpms_bin", 1, 3, "", mysqlnd_mbcharlen_eucjpms, check_mb_eucjpms},
-	{ 128, "ucs2", "ucs2_unicode_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 129, "ucs2", "ucs2_icelandic_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 130, "ucs2", "ucs2_latvian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 131, "ucs2", "ucs2_romanian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 132, "ucs2", "ucs2_slovenian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 133, "ucs2", "ucs2_polish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 134, "ucs2", "ucs2_estonian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 135, "ucs2", "ucs2_spanish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 136, "ucs2", "ucs2_swedish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 137, "ucs2", "ucs2_turkish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 138, "ucs2", "ucs2_czech_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 139, "ucs2", "ucs2_danish_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 140, "ucs2", "ucs2_lithunian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 141, "ucs2", "ucs2_slovak_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 142, "ucs2", "ucs2_spanish2_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 143, "ucs2", "ucs2_roman_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 144, "ucs2", "ucs2_persian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 145, "ucs2", "ucs2_esperanto_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 146, "ucs2", "ucs2_hungarian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 147, "ucs2", "ucs2_sinhala_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 192, "utf8", "utf8_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 193, "utf8", "utf8_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 194, "utf8", "utf8_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-	{ 195, "utf8", "utf8_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 196, "utf8", "utf8_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 197, "utf8", "utf8_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 198, "utf8", "utf8_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 119, "utf8", "utf8_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 200, "utf8", "utf8_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 201, "utf8", "utf8_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 202, "utf8", "utf8_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 203, "utf8", "utf8_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 204, "utf8", "utf8_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 205, "utf8", "utf8_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 206, "utf8", "utf8_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 207, "utf8", "utf8_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 208, "utf8", "utf8_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 209, "utf8", "utf8_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 210, "utf8", "utf8_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 192, "utf8mb3", "utf8mb3_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 193, "utf8mb3", "utf8mb3_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 194, "utf8mb3", "utf8mb3_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-	{ 195, "utf8mb3", "utf8mb3_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 196, "utf8mb3", "utf8mb3_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 197, "utf8mb3", "utf8mb3_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 198, "utf8mb3", "utf8mb3_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 119, "utf8mb3", "utf8mb3_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 200, "utf8mb3", "utf8mb3_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 201, "utf8mb3", "utf8mb3_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 202, "utf8mb3", "utf8mb3_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 203, "utf8mb3", "utf8mb3_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 204, "utf8mb3", "utf8mb3_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 205, "utf8mb3", "utf8mb3_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 206, "utf8mb3", "utf8mb3_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 207, "utf8mb3", "utf8mb3_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 208, "utf8mb3", "utf8mb3_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 209, "utf8mb3", "utf8mb3_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 210, "utf8mb3", "utf8mb3_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 211, "utf8mb3", "utf8mb3_sinhala_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 224, "utf8", "utf8_unicode_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 225, "utf8", "utf8_icelandic_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 226, "utf8", "utf8_latvian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 227, "utf8", "utf8_romanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 228, "utf8", "utf8_slovenian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 229, "utf8", "utf8_polish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 230, "utf8", "utf8_estonian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 231, "utf8", "utf8_spanish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 232, "utf8", "utf8_swedish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 233, "utf8", "utf8_turkish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 234, "utf8", "utf8_czech_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 235, "utf8", "utf8_danish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 236, "utf8", "utf8_lithuanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 237, "utf8", "utf8_slovak_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 238, "utf8", "utf8_spanish2_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 239, "utf8", "utf8_roman_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 240, "utf8", "utf8_persian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 241, "utf8", "utf8_esperanto_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 242, "utf8", "utf8_hungarian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 243, "utf8", "utf8_sinhala_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 254, "utf8mb3", "utf8mb3_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{   0, NULL, NULL, 0, 0, NULL, NULL, NULL}
-};
+	if (start + 2 > end) {
+		return 0;
+	}
+
+	if (UTF16_HIGH_HEAD(*start)) {
+		return (start + 4 <= end) && UTF16_LOW_HEAD(start[2]) ? 4 : 0;
+	}
+
+	if (UTF16_LOW_HEAD(*start)) {
+		return 0;
+	}
+	return 2;
+}
+
+
+static uint mysqlnd_mbcharlen_utf16(unsigned int utf16)
+{
+  return UTF16_HIGH_HEAD(utf16) ? 4 : 2;
+}
 /* }}} */
 
 
+/* {{{ utf32 functions */
+static uint
+check_mb_utf32(const char *start __attribute((unused)), const char *end __attribute((unused)))
+{
+	return 4;
+}
+
+
+static uint
+mysqlnd_mbcharlen_utf32(unsigned int utf32 __attribute((unused)))
+{
+	return 4;
+}
+/* }}} */
+
+/*
+  The server compiles sometimes the full utf-8 (the mb4) as utf8m4, and the old as utf8,
+  for BC reasons. Sometimes, utf8mb4 is just utf8 but the old charsets are utf8mb3.
+  Change easily now, with a macro, could be made compilastion dependable.
+*/
+
+#define UTF8_MB4 "utf8mb4"
+#define UTF8_MB3 "utf8"
+
 /* {{{ mysqlnd_charsets */
-const MYSQLND_CHARSET mysqlnd_charsets60[] =
+const MYSQLND_CHARSET mysqlnd_charsets[] =
 {
 	{   1, "big5","big5_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
 	{   3, "dec8", "dec8_swedisch_ci", 1, 1, "", NULL, NULL},
@@ -494,7 +466,7 @@ const MYSQLND_CHARSET mysqlnd_charsets60[] =
 	{  28, "gbk", "gbk_chinese_ci", 1, 2, "", mysqlnd_mbcharlen_gbk, check_mb_gbk},
 	{  30, "latin5", "latin5_turkish_ci", 1, 1, "", NULL, NULL},
 	{  32, "armscii8", "armscii8_general_ci", 1, 1, "", NULL, NULL},
-	{  33, "utf8", "utf8_general_ci", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+	{  33, UTF8_MB3, UTF8_MB3"_general_ci", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8mb3,  check_mb_utf8mb3_valid},
 	{  35, "ucs2", "ucs2_general_ci", 2, 2, "UCS-2 Unicode", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
 	{  36, "cp866", "cp866_general_ci", 1, 1, "", NULL, NULL},
 	{  37, "keybcs2", "keybcs2_general_ci", 1, 1, "", NULL, NULL},
@@ -524,14 +496,22 @@ const MYSQLND_CHARSET mysqlnd_charsets60[] =
 	{  42, "latin7", "latin7_general_cs", 1, 1, "", NULL, NULL},
 	{  43, "macce", "macce_bin", 1, 1, "", NULL, NULL},
 	{  44, "cp1250", "cp1250_croatian_ci", 1, 1, "", NULL, NULL},
+	{  45, UTF8_MB4, UTF8_MB4"_general_ci", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+	{  46, UTF8_MB4, UTF8_MB4"_bin", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
 	{  47, "latin1", "latin1_bin", 1, 1, "", NULL, NULL},
 	{  48, "latin1", "latin1_general_ci", 1, 1, "", NULL, NULL},
 	{  49, "latin1", "latin1_general_cs", 1, 1, "", NULL, NULL},
 	{  50, "cp1251", "cp1251_bin", 1, 1, "", NULL, NULL},
 	{  52, "cp1251", "cp1251_general_cs", 1, 1, "", NULL, NULL},
 	{  53, "macroman", "macroman_bin", 1, 1, "", NULL, NULL},
+	{  54, "utf16", "utf16_general_ci", 2, 4, "UTF-16 Unicode", mysqlnd_mbcharlen_utf16, check_mb_utf16},
+	{  55, "utf16", "utf16_bin", 2, 4, "UTF-16 Unicode", mysqlnd_mbcharlen_utf16, check_mb_utf16},
 	{  58, "cp1257", "cp1257_bin", 1, 1, "", NULL, NULL},
+#ifdef USED_TO_BE_SO_BEFORE_MYSQL_5_5
 	{  60, "armascii8", "armascii8_bin", 1, 1, "", NULL, NULL},
+#endif
+	{  60, "utf32", "utf32_general_ci", 4, 4, "UTF-32 Unicode", mysqlnd_mbcharlen_utf32, check_mb_utf32},
+	{  61, "utf32", "utf32_bin", 4, 4, "UTF-32 Unicode", mysqlnd_mbcharlen_utf32, check_mb_utf32},
 	{  65, "ascii", "ascii_bin", 1, 1, "", NULL, NULL},
 	{  66, "cp1250", "cp1250_bin", 1, 1, "", NULL, NULL},
 	{  67, "cp1256", "cp1256_bin", 1, 1, "", NULL, NULL},
@@ -550,7 +530,7 @@ const MYSQLND_CHARSET mysqlnd_charsets60[] =
 	{  81, "cp852", "cp852_bin", 1, 1, "", NULL, NULL},
 	{  82, "swe7", "swe7_bin", 1, 1, "", NULL, NULL},
 	{  93, "geostd8", "geostd8_bin", 1, 1, "", NULL, NULL},
-	{  83, "utf8", "utf8_bin", 1, 2, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+	{  83, UTF8_MB3, UTF8_MB3"_bin", 1, 3, "UTF-8 Unicode", mysqlnd_mbcharlen_utf8mb3,  check_mb_utf8mb3_valid},
 	{  84, "big5", "big5_bin", 1, 2, "", mysqlnd_mbcharlen_big5, check_mb_big5},
 	{  85, "euckr", "euckr_bin", 1, 2, "", mysqlnd_mbcharlen_euckr, check_mb_euckr},
 	{  86, "gb2312", "gb2312_bin", 1, 2, "", mysqlnd_mbcharlen_gb2312, check_mb_gb2312},
@@ -583,47 +563,52 @@ const MYSQLND_CHARSET mysqlnd_charsets60[] =
 	{ 145, "ucs2", "ucs2_esperanto_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
 	{ 146, "ucs2", "ucs2_hungarian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
 	{ 147, "ucs2", "ucs2_sinhala_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2},
-	{ 192, "utf8mb3", "utf8mb3_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 193, "utf8mb3", "utf8mb3_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 194, "utf8mb3", "utf8mb3_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-	{ 195, "utf8mb3", "utf8mb3_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 196, "utf8mb3", "utf8mb3_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 197, "utf8mb3", "utf8mb3_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 198, "utf8mb3", "utf8mb3_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 119, "utf8mb3", "utf8mb3_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 200, "utf8mb3", "utf8mb3_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 201, "utf8mb3", "utf8mb3_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 202, "utf8mb3", "utf8mb3_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 203, "utf8mb3", "utf8mb3_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 204, "utf8mb3", "utf8mb3_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid },
-	{ 205, "utf8mb3", "utf8mb3_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 206, "utf8mb3", "utf8mb3_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 207, "utf8mb3", "utf8mb3_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 208, "utf8mb3", "utf8mb3_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 209, "utf8mb3", "utf8mb3_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 210, "utf8mb3", "utf8mb3_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 211, "utf8mb3", "utf8mb3_sinhala_ci", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 224, "utf8", "utf8_unicode_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 225, "utf8", "utf8_icelandic_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 226, "utf8", "utf8_latvian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 227, "utf8", "utf8_romanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 228, "utf8", "utf8_slovenian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 229, "utf8", "utf8_polish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 230, "utf8", "utf8_estonian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 231, "utf8", "utf8_spanish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 232, "utf8", "utf8_swedish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 233, "utf8", "utf8_turkish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 234, "utf8", "utf8_czech_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 235, "utf8", "utf8_danish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 236, "utf8", "utf8_lithuanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 237, "utf8", "utf8_slovak_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 238, "utf8", "utf8_spanish2_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 239, "utf8", "utf8_roman_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 240, "utf8", "utf8_persian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 241, "utf8", "utf8_esperanto_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 242, "utf8", "utf8_hungarian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 243, "utf8", "utf8_sinhala_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
-	{ 254, "utf8mb3", "utf8mb3_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 149, "ucs2", "ucs2_croatian_ci", 2, 2, "", mysqlnd_mbcharlen_ucs2, check_mb_ucs2}, /* MDB */
+
+	{ 192, UTF8_MB3, UTF8_MB3"_general_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 193, UTF8_MB3, UTF8_MB3"_icelandic_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 194, UTF8_MB3, UTF8_MB3"_latvian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3,  check_mb_utf8mb3_valid},
+	{ 195, UTF8_MB3, UTF8_MB3"_romanian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 196, UTF8_MB3, UTF8_MB3"_slovenian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 197, UTF8_MB3, UTF8_MB3"_polish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 198, UTF8_MB3, UTF8_MB3"_estonian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 119, UTF8_MB3, UTF8_MB3"_spanish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 200, UTF8_MB3, UTF8_MB3"_swedish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 201, UTF8_MB3, UTF8_MB3"_turkish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 202, UTF8_MB3, UTF8_MB3"_czech_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 203, UTF8_MB3, UTF8_MB3"_danish_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid },
+	{ 204, UTF8_MB3, UTF8_MB3"_lithunian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid },
+	{ 205, UTF8_MB3, UTF8_MB3"_slovak_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 206, UTF8_MB3, UTF8_MB3"_spanish2_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 207, UTF8_MB3, UTF8_MB3"_roman_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 208, UTF8_MB3, UTF8_MB3"_persian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 209, UTF8_MB3, UTF8_MB3"_esperanto_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 210, UTF8_MB3, UTF8_MB3"_hungarian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 211, UTF8_MB3, UTF8_MB3"_sinhala_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid},
+	{ 213, UTF8_MB3, UTF8_MB3"_croatian_ci", 1, 3, "", mysqlnd_mbcharlen_utf8mb3, check_mb_utf8mb3_valid}, /*MDB*/
+
+	{ 224, UTF8_MB4, UTF8_MB4"_unicode_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 225, UTF8_MB4, UTF8_MB4"_icelandic_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 226, UTF8_MB4, UTF8_MB4"_latvian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 227, UTF8_MB4, UTF8_MB4"_romanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 228, UTF8_MB4, UTF8_MB4"_slovenian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 229, UTF8_MB4, UTF8_MB4"_polish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 230, UTF8_MB4, UTF8_MB4"_estonian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 231, UTF8_MB4, UTF8_MB4"_spanish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 232, UTF8_MB4, UTF8_MB4"_swedish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 233, UTF8_MB4, UTF8_MB4"_turkish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 234, UTF8_MB4, UTF8_MB4"_czech_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 235, UTF8_MB4, UTF8_MB4"_danish_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 236, UTF8_MB4, UTF8_MB4"_lithuanian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 237, UTF8_MB4, UTF8_MB4"_slovak_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 238, UTF8_MB4, UTF8_MB4"_spanish2_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 239, UTF8_MB4, UTF8_MB4"_roman_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 240, UTF8_MB4, UTF8_MB4"_persian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 241, UTF8_MB4, UTF8_MB4"_esperanto_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 242, UTF8_MB4, UTF8_MB4"_hungarian_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+	{ 243, UTF8_MB4, UTF8_MB4"_sinhala_ci", 1, 4, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
+
+	{ 254, UTF8_MB3, UTF8_MB3"_general_cs", 1, 3, "", mysqlnd_mbcharlen_utf8, check_mb_utf8_valid},
 	{   0, NULL, NULL, 0, 0, NULL, NULL, NULL}
 };
 /* }}} */
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index 575efac..692c81e 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.c 300635 2010-06-21 15:32:26Z andrey $ */
+/* $Id: mysqlnd_debug.c 305389 2010-11-15 23:46:21Z pajoye $ */
 
 #include "php.h"
 #include "mysqlnd.h"
@@ -36,16 +36,6 @@ static const char * const mysqlnd_debug_default_trace_file = "/tmp/mysqlnd.trace
 #define MYSQLND_ZTS(self)
 #endif
 
-#define MYSQLND_DEBUG_DUMP_TIME				1
-#define MYSQLND_DEBUG_DUMP_TRACE			2
-#define MYSQLND_DEBUG_DUMP_PID				4
-#define MYSQLND_DEBUG_DUMP_LINE				8
-#define MYSQLND_DEBUG_DUMP_FILE				16
-#define MYSQLND_DEBUG_DUMP_LEVEL			32
-#define MYSQLND_DEBUG_APPEND				64
-#define MYSQLND_DEBUG_FLUSH					128
-#define MYSQLND_DEBUG_TRACE_MEMORY_CALLS	256
-
 static const char mysqlnd_emalloc_name[]	= "_mysqlnd_emalloc";
 static const char mysqlnd_pemalloc_name[]	= "_mysqlnd_pemalloc";
 static const char mysqlnd_ecalloc_name[]	= "_mysqlnd_ecalloc";
@@ -81,6 +71,7 @@ const char * mysqlnd_debug_std_no_trace_funcs[] =
 	NULL /* must be always last */
 };
 
+
 /* {{{ mysqlnd_debug::open */
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_debug, open)(MYSQLND_DEBUG * self, zend_bool reopen)
@@ -287,7 +278,6 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self,
 								flags & MYSQLND_DEBUG_DUMP_LEVEL? level_buffer:"",
 								pipe_buffer, type? type:"", buffer);
 	efree(buffer);
-
 	ret = php_stream_write(self->stream, message_line, message_line_len)? PASS:FAIL;
 	efree(message_line); /* allocated by spprintf */
 
@@ -301,7 +291,7 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self,
 
 
 /* FALSE - The DBG_ calls won't be traced, TRUE - will be traced */
-/* {{{ mysqlnd_res_meta::func_enter */
+/* {{{ mysqlnd_debug::func_enter */
 static zend_bool
 MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self,
 										  unsigned int line, const char * const file,
@@ -319,6 +309,12 @@ MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self,
 		while (*p) {
 			if (*p == func_name) {
 				zend_stack_push(&self->call_stack, "", sizeof(""));
+#ifndef MYSQLND_PROFILING_DISABLED
+				if (self->flags & MYSQLND_DEBUG_PROFILE_CALLS) {
+					uint64_t some_time = 0;
+					zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time));
+				}
+#endif
 				return FALSE;
 			}
 			p++;
@@ -326,6 +322,12 @@ MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self,
 	}
 
 	zend_stack_push(&self->call_stack, func_name, func_name_len + 1);
+#ifndef MYSQLND_PROFILING_DISABLED
+	if (self->flags & MYSQLND_DEBUG_PROFILE_CALLS) {
+		uint64_t some_time = 0;
+		zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time));
+	}
+#endif
 
 	if (zend_hash_num_elements(&self->not_filtered_functions) &&
 		0 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1))
@@ -338,12 +340,34 @@ MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self,
 }
 /* }}} */
 
+#ifndef MYSQLND_PROFILING_DISABLED
+struct st_mysqlnd_dbg_function_profile {
+	uint64_t calls;
+	uint64_t min_own;
+	uint64_t max_own;
+	uint64_t avg_own;
+	uint64_t own_underporm_calls;
+	uint64_t min_in_calls;
+	uint64_t max_in_calls;
+	uint64_t avg_in_calls;
+	uint64_t in_calls_underporm_calls;
+	uint64_t min_total;
+	uint64_t max_total;
+	uint64_t avg_total;	
+	uint64_t total_underporm_calls;
+};
+#define PROFILE_UNDERPERFORM_THRESHOLD 10
+#endif
 
-/* {{{ mysqlnd_res_meta::func_leave */
+/* {{{ mysqlnd_debug::func_leave */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file)
+MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, uint64_t call_time)
 {
 	char *func_name;
+	uint64_t * parent_non_own_time_ptr = NULL, * mine_non_own_time_ptr = NULL;
+	uint64_t mine_non_own_time = 0;
+	zend_bool profile_calls = self->flags & MYSQLND_DEBUG_PROFILE_CALLS? TRUE:FALSE;
+
 	if ((self->flags & MYSQLND_DEBUG_DUMP_TRACE) == 0 || self->file_name == NULL) {
 		return PASS;
 	}
@@ -353,12 +377,92 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin
 
 	zend_stack_top(&self->call_stack, (void **)&func_name);
 
+#ifndef MYSQLND_PROFILING_DISABLED
+	if (profile_calls) {
+		zend_stack_top(&self->call_time_stack, (void **)&mine_non_own_time_ptr);
+		mine_non_own_time = *mine_non_own_time_ptr;
+		zend_stack_del_top(&self->call_time_stack); /* callee - removing ourselves */
+	}
+#endif
+
 	if (func_name[0] == '\0') {
 		; /* don't log that function */
 	} else if (!zend_hash_num_elements(&self->not_filtered_functions) ||
 			   1 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1))
 	{
-		self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s", func_name);
+#ifndef MYSQLND_PROFILING_DISABLED
+		if (FALSE == profile_calls) {
+#endif
+			self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s", func_name);
+
+#ifndef MYSQLND_PROFILING_DISABLED
+		} else {
+			struct st_mysqlnd_dbg_function_profile f_profile_stack = {0};
+			struct st_mysqlnd_dbg_function_profile * f_profile = NULL;
+			uint64_t own_time = call_time - mine_non_own_time;
+			uint func_name_len = strlen(func_name);
+
+			self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s (total=%u own=%u in_calls=%u)",
+						func_name, (unsigned int) call_time, (unsigned int) own_time, (unsigned int) mine_non_own_time
+					);
+
+			if (SUCCESS == zend_hash_find(&self->function_profiles, func_name, func_name_len + 1, (void **) &f_profile)) {
+				/* found */
+					if (f_profile) {
+					if (mine_non_own_time < f_profile->min_in_calls) {
+						f_profile->min_in_calls = mine_non_own_time;
+					} else if (mine_non_own_time > f_profile->max_in_calls) {
+						f_profile->max_in_calls = mine_non_own_time;
+					}
+					f_profile->avg_in_calls = (f_profile->avg_in_calls * f_profile->calls + mine_non_own_time) / (f_profile->calls + 1);
+
+					if (own_time < f_profile->min_own) {
+						f_profile->min_own = own_time;
+					} else if (own_time > f_profile->max_own) {
+						f_profile->max_own = own_time;
+					}
+					f_profile->avg_own = (f_profile->avg_own * f_profile->calls + own_time) / (f_profile->calls + 1);
+
+					if (call_time < f_profile->min_total) {
+						f_profile->min_total = call_time;
+					} else if (call_time > f_profile->max_total) {
+						f_profile->max_total = call_time;
+					}
+					f_profile->avg_total = (f_profile->avg_total * f_profile->calls + call_time) / (f_profile->calls + 1);
+
+					++f_profile->calls;
+					if (f_profile->calls > PROFILE_UNDERPERFORM_THRESHOLD) {
+						if (f_profile->avg_in_calls < mine_non_own_time) {
+							f_profile->in_calls_underporm_calls++;
+						}
+						if (f_profile->avg_own < own_time) {
+							f_profile->own_underporm_calls++;
+						}
+						if (f_profile->avg_total < call_time) {
+							f_profile->total_underporm_calls++;
+						}
+					}
+				}
+			} else {
+				/* add */
+				f_profile = &f_profile_stack;
+				f_profile->min_in_calls = f_profile->max_in_calls = f_profile->avg_in_calls = mine_non_own_time;
+				f_profile->min_total = f_profile->max_total = f_profile->avg_total = call_time;
+				f_profile->min_own = f_profile->max_own = f_profile->avg_own = own_time;
+				f_profile->calls = 1;
+				zend_hash_add(&self->function_profiles, func_name, func_name_len+1, f_profile, sizeof(struct st_mysqlnd_dbg_function_profile), NULL);
+			}
+			if ((uint) zend_stack_count(&self->call_time_stack)) {
+				uint64_t parent_non_own_time = 0;
+
+				zend_stack_top(&self->call_time_stack, (void **)&parent_non_own_time_ptr);
+				parent_non_own_time = *parent_non_own_time_ptr;
+				parent_non_own_time += call_time;
+				zend_stack_del_top(&self->call_time_stack); /* the caller */
+				zend_stack_push(&self->call_time_stack, &parent_non_own_time, sizeof(parent_non_own_time)); /* add back the caller */
+			}
+		}
+#endif
 	}
 
 	return zend_stack_del_top(&self->call_stack) == SUCCESS? PASS:FAIL;
@@ -366,15 +470,57 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin
 /* }}} */
 
 
-/* {{{ mysqlnd_res_meta::close */
+/* {{{ mysqlnd_debug::close */
 static enum_func_status
 MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self)
 {
 	MYSQLND_ZTS(self);
 	if (self->stream) {
+#ifndef MYSQLND_PROFILING_DISABLED
+		if (!(self->flags & MYSQLND_DEBUG_FLUSH) && (self->flags & MYSQLND_DEBUG_PROFILE_CALLS)) {
+			struct st_mysqlnd_dbg_function_profile * f_profile;
+			HashPosition pos_values;
+
+			self->m->log_va(self, __LINE__, __FILE__, 0, "info : ",	
+					"number of functions: %d", zend_hash_num_elements(&self->function_profiles));
+			zend_hash_internal_pointer_reset_ex(&self->function_profiles, &pos_values);
+			while (zend_hash_get_current_data_ex(&self->function_profiles, (void **) &f_profile, &pos_values) == SUCCESS) {
+				char	*string_key = NULL;
+				uint	string_key_len;
+				ulong	num_key;
+
+				zend_hash_get_current_key_ex(&self->function_profiles, &string_key, &string_key_len, &num_key, 0, &pos_values);
+
+				self->m->log_va(self, __LINE__, __FILE__, -1, "info : ",
+						"%-40s\tcalls=%5llu  own_slow=%5llu  in_calls_slow=%5llu  total_slow=%5llu"
+						"   min_own=%5llu  max_own=%7llu  avg_own=%7llu   "
+						"   min_in_calls=%5llu  max_in_calls=%7llu  avg_in_calls=%7llu"
+						"   min_total=%5llu  max_total=%7llu  avg_total=%7llu"
+						,string_key
+						,(uint64_t) f_profile->calls
+						,(uint64_t) f_profile->own_underporm_calls
+						,(uint64_t) f_profile->in_calls_underporm_calls
+						,(uint64_t) f_profile->total_underporm_calls
+						
+						,(uint64_t) f_profile->min_own
+						,(uint64_t) f_profile->max_own
+						,(uint64_t) f_profile->avg_own
+						,(uint64_t) f_profile->min_in_calls
+						,(uint64_t) f_profile->max_in_calls
+						,(uint64_t) f_profile->avg_in_calls
+						,(uint64_t) f_profile->min_total
+						,(uint64_t) f_profile->max_total
+						,(uint64_t) f_profile->avg_total
+						);
+				zend_hash_move_forward_ex(&self->function_profiles, &pos_values);
+			}
+		}
+#endif	
+
 		php_stream_free(self->stream, PHP_STREAM_FREE_CLOSE);
 		self->stream = NULL;
 	}
+	/* no DBG_RETURN please */
 	return PASS;
 }
 /* }}} */
@@ -389,7 +535,9 @@ MYSQLND_METHOD(mysqlnd_debug, free)(MYSQLND_DEBUG * self)
 		self->file_name = NULL;
 	}
 	zend_stack_destroy(&self->call_stack);
+	zend_stack_destroy(&self->call_time_stack);
 	zend_hash_destroy(&self->not_filtered_functions);
+	zend_hash_destroy(&self->function_profiles);
 	efree(self);
 	return PASS;
 }
@@ -433,6 +581,11 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const
 				}
 				if (i + 1 < mode_len && mode[i+1] == ',') {
 					unsigned int j = i + 2;
+#ifdef PHP_WIN32
+					if (i+4 < mode_len && mode[i+3] == ':' && (mode[i+4] == '\\' || mode[i+5] == '/')) {
+						j = i + 5;
+					}
+#endif
 					while (j < mode_len) {
 						if (mode[j] == ':') {
 							break;
@@ -562,6 +715,10 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const
 				self->flags |= MYSQLND_DEBUG_TRACE_MEMORY_CALLS;
 				state = PARSER_WAIT_COLON;
 				break;
+			case 'x': /* mysqlnd extension - profile calls */
+				self->flags |= MYSQLND_DEBUG_PROFILE_CALLS;
+				state = PARSER_WAIT_COLON;
+				break;				
 			default:
 				if (state == PARSER_WAIT_MODIFIER) {
 #if 0
@@ -588,7 +745,6 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const
 }
 /* }}} */
 
-
 MYSQLND_CLASS_METHODS_START(mysqlnd_debug)
 	MYSQLND_METHOD(mysqlnd_debug, open),
 	MYSQLND_METHOD(mysqlnd_debug, set_mode),
@@ -601,7 +757,6 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_debug)
 MYSQLND_CLASS_METHODS_END;
 
 
-
 /* {{{ mysqlnd_debug_init */
 PHPAPI MYSQLND_DEBUG *
 mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC)
@@ -613,11 +768,13 @@ mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC)
 	ret->nest_level_limit = 0;
 	ret->pid = getpid();
 	zend_stack_init(&ret->call_stack);
+	zend_stack_init(&ret->call_time_stack);
 	zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0);
+	zend_hash_init(&ret->function_profiles, 0, NULL, NULL, 0);
 
 	ret->m = & mysqlnd_mysqlnd_debug_methods;
 	ret->skip_functions = skip_functions;
-	
+
 	return ret;
 }
 /* }}} */
@@ -634,12 +791,15 @@ PHPAPI void _mysqlnd_debug(const char * mode TSRMLS_DC)
 			return;
 		}
 	}
-	
+
 	dbg->m->close(dbg);
 	dbg->m->set_mode(dbg, mode);
 	while (zend_stack_count(&dbg->call_stack)) {
 		zend_stack_del_top(&dbg->call_stack);
 	}
+	while (zend_stack_count(&dbg->call_time_stack)) {
+		zend_stack_del_top(&dbg->call_time_stack);
+	}
 #endif
 }
 /* }}} */
@@ -650,7 +810,7 @@ PHPAPI void _mysqlnd_debug(const char * mode TSRMLS_DC)
 #define __zend_filename "/unknown/unknown"
 #define __zend_lineno   0
 #endif
-	
+
 #define REAL_SIZE(s) (collect_memory_statistics? (s) + sizeof(size_t) : (s))
 #define REAL_PTR(p) (collect_memory_statistics && (p)? (((char *)(p)) - sizeof(size_t)) : (p))
 #define FAKE_PTR(p) (collect_memory_statistics && (p)? (((char *)(p)) + sizeof(size_t)) : (p))
@@ -1092,7 +1252,9 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME
 }
 /* }}} */
 
-#if MYSQLND_DEBUG_MEMORY
+#define MYSQLND_DEBUG_MEMORY 1
+
+#if MYSQLND_DEBUG_MEMORY == 0
 
 /* {{{ mysqlnd_zend_mm_emalloc */
 static void * mysqlnd_zend_mm_emalloc(size_t size MYSQLND_MEM_D)
@@ -1208,8 +1370,6 @@ static char * mysqlnd_zend_mm_pestrdup(const char * const ptr, zend_bool persist
 #endif
 
 
-#define MYSQLND_DEBUG_MEMORY 1
-
 PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator = 
 {
 #if MYSQLND_DEBUG_MEMORY
@@ -1249,7 +1409,7 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
 
 /* Follows code borrowed from zend_builtin_functions.c because the functions there are static */
 
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 /* {{{ gettraceasstring() macros */
 #define TRACE_APPEND_CHR(chr)                                            \
 	*str = (char*)erealloc(*str, *len + 1 + 1);                          \
@@ -1593,14 +1753,14 @@ static int mysqlnd_build_trace_args(zval **arg TSRMLS_DC, int num_args, va_list
 		case IS_OBJECT: {
 			char *class_name;
 			zend_uint class_name_len;
-			int dup;
+			int dupl;
 
 			TRACE_APPEND_STR("Object(");
 
-			dup = zend_get_object_classname(*arg, &class_name, &class_name_len TSRMLS_CC);
+			dupl = zend_get_object_classname(*arg, &class_name, &class_name_len TSRMLS_CC);
 
 			TRACE_APPEND_STRL(class_name, class_name_len);
-			if(!dup) {
+			if (!dupl) {
 				efree(class_name);
 			}
 
diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h
index f79a896..4c6197d 100644
--- a/ext/mysqlnd/mysqlnd_debug.h
+++ b/ext/mysqlnd/mysqlnd_debug.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_debug.h 299755 2010-05-25 21:54:21Z andrey $ */
+/* $Id: mysqlnd_debug.h 305878 2010-12-01 10:16:51Z andrey $ */
 
 #ifndef MYSQLND_DEBUG_H
 #define MYSQLND_DEBUG_H
@@ -27,17 +27,17 @@
 
 struct st_mysqlnd_debug_methods
 {
-	enum_func_status (*open)(MYSQLND_DEBUG *self, zend_bool reopen);
-	void			 (*set_mode)(MYSQLND_DEBUG *self, const char * const mode);
-	enum_func_status (*log)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
+	enum_func_status (*open)(MYSQLND_DEBUG * self, zend_bool reopen);
+	void			 (*set_mode)(MYSQLND_DEBUG * self, const char * const mode);
+	enum_func_status (*log)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
 							unsigned int level, const char * type, const char *message);
-	enum_func_status (*log_va)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
+	enum_func_status (*log_va)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
 							   unsigned int level, const char * type, const char *format, ...);
-	zend_bool (*func_enter)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
+	zend_bool (*func_enter)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
 							const char * const func_name, unsigned int func_name_len);
-	enum_func_status (*func_leave)(MYSQLND_DEBUG *self, unsigned int line, const char * const file);
-	enum_func_status (*close)(MYSQLND_DEBUG *self);
-	enum_func_status (*free_handle)(MYSQLND_DEBUG *self);
+	enum_func_status (*func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, uint64_t call_time);
+	enum_func_status (*close)(MYSQLND_DEBUG * self);
+	enum_func_status (*free_handle)(MYSQLND_DEBUG * self);
 };
 
 
@@ -52,7 +52,9 @@ struct st_mysqlnd_debug
 	int pid;
 	char * file_name;
 	zend_stack call_stack;
+	zend_stack call_time_stack;	
 	HashTable not_filtered_functions;
+	HashTable function_profiles;
 	struct st_mysqlnd_debug_methods *m;
 	const char ** skip_functions;
 };
@@ -63,15 +65,66 @@ PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[] TSRMLS_D
 
 PHPAPI char *	mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC);
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
+#ifdef PHP_WIN32
+#include "win32/time.h"
+#elif defined(NETWARE)
+#include <sys/timeval.h>
+#include <sys/time.h>
+#else
+#include <sys/time.h>
+#endif
+
+#ifndef MYSQLND_PROFILING_DISABLED
+#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp)	((tp.tv_sec * 1000000LL)+ tp.tv_usec)
+#define DBG_PROFILE_START_TIME()		gettimeofday(&__dbg_prof_tp, NULL); __dbg_prof_start = DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp);
+#define DBG_PROFILE_END_TIME(duration)	gettimeofday(&__dbg_prof_tp, NULL); (duration) = (DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp) - __dbg_prof_start);
+#else
+#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp)
+#define DBG_PROFILE_START_TIME()
+#define DBG_PROFILE_END_TIME(duration)
+#endif
+
 #define DBG_INF_EX(dbg_obj, msg)		do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0)
 #define DBG_ERR_EX(dbg_obj, msg)		do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0)
 #define DBG_INF_FMT_EX(dbg_obj, ...)	do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0)
 #define DBG_ERR_FMT_EX(dbg_obj, ...)	do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0)
 
-#define DBG_ENTER_EX(dbg_obj, func_name) zend_bool dbg_skip_trace = TRUE; if ((dbg_obj)) dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name));
-#define DBG_RETURN_EX(dbg_obj, value)	do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return (value); } while (0)
-#define DBG_VOID_RETURN_EX(dbg_obj)		do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return; } while (0)
+#define DBG_ENTER_EX(dbg_obj, func_name) \
+					struct timeval __dbg_prof_tp = {0}; \
+					uint64_t __dbg_prof_start = 0; /* initialization is needed */ \
+					zend_bool dbg_skip_trace = TRUE; \
+					if ((dbg_obj)) { \
+						dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name)); \
+					} \
+					do { \
+						if ((dbg_obj) && (dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
+							DBG_PROFILE_START_TIME(); \
+						} \
+					} while (0); 
+
+#define DBG_RETURN_EX(dbg_obj, value)	\
+			do {\
+				if ((dbg_obj)) { \
+					uint64_t this_call_duration = 0; \
+					if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
+						DBG_PROFILE_END_TIME(this_call_duration); \
+					} \
+					(dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
+				} \
+				return (value);\
+			} while (0)
+#define DBG_VOID_RETURN_EX(dbg_obj)	\
+			do {\
+				if ((dbg_obj)) { \
+					uint64_t this_call_duration = 0; \
+					if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
+						DBG_PROFILE_END_TIME(this_call_duration); \
+					} \
+					(dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
+				} \
+				return;\
+			} while (0)
 
 #else
 static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {}
@@ -82,7 +135,7 @@ static inline void DBG_ENTER_EX(MYSQLND_DEBUG * dbg_obj, const char * const func
 #define DBG_RETURN_EX(dbg_obj, value) return (value)
 #define DBG_VOID_RETURN_EX(dbg_obj) return
 
-#endif
+#endif /* defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400)) */
 
 #if MYSQLND_DBG_ENABLED == 1
 
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index dbc938b..209caf2 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_enum_n_def.h 298650 2010-04-27 11:02:51Z andrey $ */
+/* $Id: mysqlnd_enum_n_def.h 305904 2010-12-02 13:59:56Z andrey $ */
 #ifndef MYSQLND_ENUM_N_DEF_H
 #define MYSQLND_ENUM_N_DEF_H
 
@@ -63,7 +63,8 @@
 #define SERVER_STATUS_LAST_ROW_SENT				128
 #define SERVER_STATUS_DB_DROPPED				256 /* A database was dropped */
 #define SERVER_STATUS_NO_BACKSLASH_ESCAPES		512
-#define SERVER_QUERY_WAS_SLOW					1024
+#define SERVER_QUERY_WAS_SLOW					2048
+#define SERVER_PS_OUT_PARAMS            		4096
 
 #define MYSQLND_NO_DATA			100
 #define MYSQLND_DATA_TRUNCATED	101
@@ -94,24 +95,27 @@
 
 #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
 
+
+#define MYSQLND_NET_FLAG_USE_COMPRESSION 1
+
 typedef enum mysqlnd_extension
 {
 	MYSQLND_MYSQL = 0,
-	MYSQLND_MYSQLI,
+	MYSQLND_MYSQLI
 } enum_mysqlnd_extension;
 
 enum
 {
 	MYSQLND_FETCH_ASSOC = 1,
 	MYSQLND_FETCH_NUM = 2,
-	MYSQLND_FETCH_BOTH = 1|2,
+	MYSQLND_FETCH_BOTH = 1|2
 };
 
 /* Follow libmysql convention */
 typedef enum func_status
 {
 	PASS = 0,
-	FAIL = 1,
+	FAIL = 1
 } enum_func_status;
 
 typedef enum mysqlnd_query_type
@@ -152,7 +156,7 @@ typedef enum mysqlnd_option
 	MYSQL_REPORT_DATA_TRUNCATION,
 	MYSQL_OPT_RECONNECT,
 	MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 	MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE = 200,
 #endif
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
@@ -168,6 +172,15 @@ typedef enum mysqlnd_option
 	MYSQLND_OPT_SSL_PASSPHRASE = 209
 } enum_mysqlnd_option;
 
+typedef enum mysqlnd_protocol_type
+{
+	MYSQL_PROTOCOL_DEFAULT = 0,
+	MYSQL_PROTOCOL_TCP,		/* all, supported */
+	MYSQL_PROTOCOL_SOCKET,	/* unix, supported */
+	MYSQL_PROTOCOL_PIPE,	/* win32, not-supported */
+	MYSQL_PROTOCOL_MEMORY,	/* win32, not-supported */
+	MYSQL_PROTOCOL_LAST
+} enum_mysqlnd_protocol_type;
 
 typedef enum mysqlnd_field_types
 {
@@ -284,7 +297,7 @@ typedef enum mysqlnd_connection_state
 	CONN_SENDING_LOAD_DATA,
 	CONN_FETCHING_DATA,
 	CONN_NEXT_RESULT_PENDING,
-	CONN_QUIT_SENT, /* object is "destroyed" at this stage */
+	CONN_QUIT_SENT /* object is "destroyed" at this stage */
 } enum_mysqlnd_connection_state;
 
 
@@ -295,7 +308,7 @@ typedef enum mysqlnd_stmt_state
 	MYSQLND_STMT_EXECUTED,
 	MYSQLND_STMT_WAITING_USE_OR_STORE,
 	MYSQLND_STMT_USE_OR_STORE_CALLED,
-	MYSQLND_STMT_USER_FETCHING, /* fetch_row_buff or fetch_row_unbuf */
+	MYSQLND_STMT_USER_FETCHING /* fetch_row_buff or fetch_row_unbuf */
 } enum_mysqlnd_stmt_state;
 
 
@@ -490,6 +503,8 @@ typedef enum mysqlnd_collected_stats
 	STAT_COM_SET_OPTION,
 	STAT_COM_STMT_FETCH,
 	STAT_COM_DAEMON,
+	STAT_BYTES_RECEIVED_PURE_DATA_TEXT,
+	STAT_BYTES_RECEIVED_PURE_DATA_PS,
 	STAT_LAST /* Should be always the last */
 } enum_mysqlnd_collected_stats;
 
@@ -508,7 +523,7 @@ enum mysqlnd_packet_type
 	PROT_STATS_PACKET,
 	PROT_PREPARE_RESP_PACKET,
 	PROT_CHG_USER_RESP_PACKET,
-	PROT_LAST, /* should always be last */
+	PROT_LAST /* should always be last */
 };
 
 
diff --git a/ext/mysqlnd/mysqlnd_loaddata.c b/ext/mysqlnd/mysqlnd_loaddata.c
index 1885cbc..4623898 100644
--- a/ext/mysqlnd/mysqlnd_loaddata.c
+++ b/ext/mysqlnd/mysqlnd_loaddata.c
@@ -57,7 +57,7 @@ int mysqlnd_local_infile_init(void **ptr, char *filename, void **userdata TSRMLS
 	if (!info) {
 		DBG_RETURN(1);
 	}
-	
+
 	*ptr = info;
 
 	/* check open_basedir */
@@ -173,7 +173,7 @@ static const char *lost_conn = "Lost connection to MySQL server during LOAD DATA
 enum_func_status
 mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_warning TSRMLS_DC)
 {
-	char				*buf;
+	char				*buf = NULL;
 	char				empty_packet[MYSQLND_HEADER_SIZE];
 	enum_func_status	result = FAIL;
 	unsigned int		buflen = 4096;
@@ -244,7 +244,9 @@ infile_error:
 	}
 
 	(*conn->infile.local_infile_end)(info TSRMLS_CC);
-	mnd_efree(buf);
+	if (buf) {
+		mnd_efree(buf);
+	}
 	DBG_INF_FMT("%s", result == PASS? "PASS":"FAIL");
 	DBG_RETURN(result);
 }
diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c
index 207fa53..b6ee73d 100644
--- a/ext/mysqlnd/mysqlnd_net.c
+++ b/ext/mysqlnd/mysqlnd_net.c
@@ -41,14 +41,13 @@
 
 /* {{{ mysqlnd_set_sock_no_delay */
 static int
-mysqlnd_set_sock_no_delay(php_stream * stream)
+mysqlnd_set_sock_no_delay(php_stream * stream TSRMLS_DC)
 {
 
 	int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
 	int ret = SUCCESS;
 	int flag = 1;
 	int result = setsockopt(socketd, IPPROTO_TCP,  TCP_NODELAY, (char *) &flag, sizeof(int));
-	TSRMLS_FETCH();
 
 	DBG_ENTER("mysqlnd_set_sock_no_delay");
 
@@ -184,7 +183,7 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem
 
 	if (!memcmp(scheme, "tcp://", sizeof("tcp://") - 1)) {
 		/* TCP -> Set TCP_NODELAY */
-		mysqlnd_set_sock_no_delay(net->stream);
+		mysqlnd_set_sock_no_delay(net->stream TSRMLS_CC);
 	}
 
 	{
@@ -665,10 +664,8 @@ MYSQLND_METHOD(mysqlnd_net, set_client_option)(MYSQLND_NET * const net, enum mys
 			net->options.timeout_write = *(unsigned int*) value;
 			break;
 #endif
-#ifdef WHEN_SUPPORTED_BY_MYSQLI
 		case MYSQL_OPT_COMPRESS:
-#endif
-			/* currently not supported. Todo!! */
+			net->options.flags |= MYSQLND_NET_FLAG_USE_COMPRESSION;
 			break;
 		default:
 			DBG_RETURN(FAIL);
diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h
index 532c719..b947915 100644
--- a/ext/mysqlnd/mysqlnd_portability.h
+++ b/ext/mysqlnd/mysqlnd_portability.h
@@ -12,6 +12,8 @@ This file is public domain and comes with NO WARRANTY of any kind */
 #ifndef MYSQLND_PORTABILITY_H
 #define MYSQLND_PORTABILITY_H
 
+
+
 /* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */
 #define STRUCT_OFFSET(t, f)   ((size_t)(char *)&((t *)0)->f)
 
@@ -479,20 +481,18 @@ typedef union {
    short/long to/from some place in memory V should be a (not
    register) variable, M is a pointer to byte */
 
-#ifdef WORDS_BIGENDIAN
+#ifndef float8get
 
+#ifdef WORDS_BIGENDIAN
 #define float8get(V,M)		memcpy((char*) &(V),(char*)  (M), sizeof(double))
 #define float8store(T,V)	memcpy((char*)  (T),(char*) &(V), sizeof(double))
-
 #else
-
-#ifndef float8get
 #define float8get(V,M)    memcpy((char*) &(V),(char*) (M),sizeof(double))
 #define float8store(T,V)  memcpy((char*) (T),(char*) &(V),sizeof(double))
-#endif /* float8get */
-
 #endif /* WORDS_BIGENDIAN */
 
+#endif /* float8get */
+
 #endif /* MYSQLND_PORTABILITY_H */
 
 
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h
index e555222..eab65b7 100644
--- a/ext/mysqlnd/mysqlnd_priv.h
+++ b/ext/mysqlnd/mysqlnd_priv.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_priv.h 298781 2010-04-29 15:49:51Z andrey $ */
+/* $Id: mysqlnd_priv.h 304984 2010-10-29 15:02:39Z andrey $ */
 
 #ifndef MYSQLND_PRIV_H
 #define MYSQLND_PRIV_H
@@ -33,6 +33,12 @@
 #define Z_DELREF_PP(ppz)			Z_DELREF_P(*(ppz))
 #endif
 
+#if PHP_MAJOR_VERSION >= 6
+#define MYSQLND_UNICODE 1
+#else
+#define MYSQLND_UNICODE 0
+#endif
+
 #ifdef ZTS
 #include "TSRM.h"
 #endif
@@ -45,24 +51,33 @@
 #define MYSQLND_CLASS_METHODS_START(class)	struct st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
 #define MYSQLND_CLASS_METHODS_END			}
 
-#if PHP_MAJOR_VERSION < 6
+#if MYSQLND_UNICODE
 #define mysqlnd_array_init(arg, field_count) \
 { \
 	ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
-	zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
+	zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
 	Z_TYPE_P(arg) = IS_ARRAY;\
 }
 #else
 #define mysqlnd_array_init(arg, field_count) \
 { \
 	ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
-	zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
+	zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
 	Z_TYPE_P(arg) = IS_ARRAY;\
 }
 #endif
 
 
-
+#define MYSQLND_DEBUG_DUMP_TIME				1
+#define MYSQLND_DEBUG_DUMP_TRACE			2
+#define MYSQLND_DEBUG_DUMP_PID				4
+#define MYSQLND_DEBUG_DUMP_LINE				8
+#define MYSQLND_DEBUG_DUMP_FILE				16
+#define MYSQLND_DEBUG_DUMP_LEVEL			32
+#define MYSQLND_DEBUG_APPEND				64
+#define MYSQLND_DEBUG_FLUSH					128
+#define MYSQLND_DEBUG_TRACE_MEMORY_CALLS	256
+#define MYSQLND_DEBUG_PROFILE_CALLS			512
 
 
 /* Client Error codes */
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index fa8be3e..b332d3d 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps.c 300735 2010-06-24 19:52:13Z andrey $ */
+/* $Id: mysqlnd_ps.c 306051 2010-12-07 11:13:55Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -52,8 +52,6 @@ enum_func_status mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param,
 static void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt TSRMLS_DC);
 static void mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const stmt, unsigned int param_no TSRMLS_DC);
 
-static void mysqlnd_internal_free_stmt_content(MYSQLND_STMT * const stmt TSRMLS_DC);
-
 /* {{{ mysqlnd_stmt::store_result */
 static MYSQLND_RES *
 MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s TSRMLS_DC)
@@ -175,7 +173,7 @@ MYSQLND_METHOD(mysqlnd_stmt, get_result)(MYSQLND_STMT * const s TSRMLS_DC)
 		}
 
 		if ((result = result->m.store_result(result, conn, TRUE TSRMLS_CC))) {
-			stmt->upsert_status.affected_rows = result->stored_data->row_count;	
+			stmt->upsert_status.affected_rows = result->stored_data->row_count;
 			stmt->state = MYSQLND_STMT_PREPARED;
 			result->type = MYSQLND_RES_PS_BUF;
 		} else {
@@ -227,10 +225,15 @@ MYSQLND_METHOD(mysqlnd_stmt, next_result)(MYSQLND_STMT * s TSRMLS_DC)
 		DBG_RETURN(FAIL);
 	}
 
-	/* Free space for next result */
-	mysqlnd_internal_free_stmt_content(s TSRMLS_CC);
+	DBG_INF_FMT("server_status=%u cursor=%u", stmt->upsert_status.server_status, stmt->upsert_status.server_status & SERVER_STATUS_CURSOR_EXISTS);
+	DBG_INF_FMT("server_status=%u cursor=%u", conn->upsert_status.server_status, conn->upsert_status.server_status & SERVER_STATUS_CURSOR_EXISTS);
 
-	DBG_RETURN(s->m->parse_execute_response(s TSRMLS_CC));
+	/* Free space for next result */
+	s->m->free_stmt_content(s TSRMLS_CC);
+	{
+		enum_func_status ret = s->m->parse_execute_response(s TSRMLS_CC);
+		DBG_RETURN(ret);
+	}
 }
 /* }}} */
 
@@ -290,7 +293,7 @@ mysqlnd_stmt_read_prepare_response(MYSQLND_STMT * s TSRMLS_DC)
 	if (!prepare_resp) {
 		SET_OOM_ERROR(stmt->error_info);
 		SET_OOM_ERROR(stmt->conn->error_info);
-		goto done;	
+		goto done;
 	}
 
 	if (FAIL == PACKET_READ(prepare_resp, stmt->conn)) {
@@ -435,13 +438,19 @@ MYSQLND_METHOD(mysqlnd_stmt, prepare)(MYSQLND_STMT * const s, const char * const
 	}
 
 	if (stmt_to_prepare != stmt) {
-		/* Free old buffers, binding and resources on server */
-		s->m->net_close(s, TRUE TSRMLS_CC);
-
-		memcpy(stmt, stmt_to_prepare, sizeof(MYSQLND_STMT_DATA));
-
-		/* Now we will have a clean new statement object */
-		mnd_pefree(stmt_to_prepare, stmt_to_prepare->persistent);
+		/* swap */
+		size_t real_size = sizeof(MYSQLND_STMT) + mysqlnd_plugin_count() * sizeof(void *);
+		char * tmp_swap = mnd_malloc(real_size);
+		memcpy(tmp_swap, s, real_size);
+		memcpy(s, s_to_prepare, real_size);
+		memcpy(s_to_prepare, tmp_swap, real_size);
+		mnd_free(tmp_swap);
+		{
+			MYSQLND_STMT_DATA * tmp_swap_data = stmt_to_prepare;
+			stmt_to_prepare = stmt;
+			stmt = tmp_swap_data;
+		}
+		s_to_prepare->m->dtor(s_to_prepare, TRUE TSRMLS_CC);
 	}
 	stmt->state = MYSQLND_STMT_PREPARED;
 	DBG_INF("PASS");
@@ -482,10 +491,17 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s TSRMLS_DC)
 			/* close the statement here, the connection has been closed */
 		}
 		stmt->state = MYSQLND_STMT_PREPARED;
+		stmt->send_types_to_server = 1;
 	} else {
+		/*
+		  stmt->send_types_to_server has already been set to 0 in
+		  mysqlnd_stmt_execute_generate_request / mysqlnd_stmt_execute_store_params
+		  In case there is a situation in which binding was done for integer and the
+		  value is > LONG_MAX or < LONG_MIN, there is string conversion and we have
+		  to resend the types. Next execution will also need to resend the type.
+		*/
 		SET_EMPTY_ERROR(stmt->error_info);
 		SET_EMPTY_ERROR(stmt->conn->error_info);
-		stmt->send_types_to_server = 0;
 		stmt->upsert_status = conn->upsert_status;
 		stmt->state = MYSQLND_STMT_EXECUTED;
 		if (conn->last_query_type == QUERY_UPSERT || conn->last_query_type == QUERY_LOAD_LOCAL) {
@@ -545,6 +561,15 @@ mysqlnd_stmt_execute_parse_response(MYSQLND_STMT * const s TSRMLS_DC)
 			}
 		}
 	}
+/* #ifndef MYSQLND_DONT_SKIP_OUT_PARAMS_RESULTSET */
+#if A0
+	if (stmt->upsert_status.server_status & SERVER_PS_OUT_PARAMS) {
+		s->m->free_stmt_content(s TSRMLS_CC);
+		DBG_INF("PS OUT Variable RSet, skipping");
+		/* OUT params result set. Skip for now to retain compatibility */
+		ret = mysqlnd_stmt_execute_parse_response(s TSRMLS_CC);
+	}
+#endif
 
 	DBG_INF(ret == PASS? "PASS":"FAIL");
 	DBG_RETURN(ret);
@@ -572,7 +597,7 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s TSRMLS_DC)
 
 	SET_ERROR_AFF_ROWS(stmt);
 	SET_ERROR_AFF_ROWS(stmt->conn);
-	
+
 	if (stmt->result && stmt->state >= MYSQLND_STMT_PREPARED && stmt->field_count) {
 		/*
 		  We don need to copy the data from the buffers which we will clean.
@@ -690,6 +715,8 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MYSQLND_STMT * const s TSRMLS_DC)
 
 	ret = s->m->parse_execute_response(s TSRMLS_CC);
 
+	DBG_INF_FMT("server_status=%u cursor=%u", stmt->upsert_status.server_status, stmt->upsert_status.server_status & SERVER_STATUS_CURSOR_EXISTS);
+
 	if (ret == PASS && conn->last_query_type == QUERY_UPSERT && stmt->upsert_status.affected_rows) {
 		MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats, STAT_ROWS_AFFECTED_PS, stmt->upsert_status.affected_rows);
 	}
@@ -869,7 +896,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 					if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data)) ) {
 						if (
 							(Z_TYPE_P(data) == IS_STRING
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 							|| Z_TYPE_P(data) == IS_UNICODE
 #endif
 							)
@@ -904,7 +931,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
 			stmt->error_info = row_packet->error_info; 
 		}
 		CONN_SET_STATE(result->conn, CONN_READY);
-		result->unbuf->eof_reached = TRUE; /* so next time we won't get an error */	
+		result->unbuf->eof_reached = TRUE; /* so next time we won't get an error */
 	} else if (row_packet->eof) {
 		DBG_INF("EOF");
 		/* Mark the connection as usable again */
@@ -1059,7 +1086,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
 								Z_TYPE_P(data), Z_REFCOUNT_P(stmt->result_bind[i].zv));
 					if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data))) {
 						if ((Z_TYPE_P(data) == IS_STRING
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 							|| Z_TYPE_P(data) == IS_UNICODE
 #endif
 							)
@@ -1258,7 +1285,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
 	MYSQLND * conn;
 	zend_uchar *cmd_buf;
 	enum php_mysqlnd_server_command cmd = COM_STMT_SEND_LONG_DATA;
-	
+
 	DBG_ENTER("mysqlnd_stmt::send_long_data");
 	if (!stmt || !stmt->conn) {
 		DBG_RETURN(FAIL);
@@ -1313,16 +1340,15 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
 			memcpy(cmd_buf + STMT_ID_LENGTH + 2, data, length);
 
 			/* COM_STMT_SEND_LONG_DATA doesn't send an OK packet*/
-			ret = conn->m->simple_command(conn, cmd, (char *)cmd_buf, packet_len,
-										 PROT_LAST , FALSE, TRUE TSRMLS_CC);
+			ret = conn->m->simple_command(conn, cmd, (char *)cmd_buf, packet_len, PROT_LAST , FALSE, TRUE TSRMLS_CC);
 			mnd_efree(cmd_buf);
 			if (FAIL == ret) {
 				stmt->error_info = conn->error_info;
 			}
 		} else {
 			ret = FAIL;
-			SET_OOM_ERROR(stmt->error_info);			
-			SET_OOM_ERROR(conn->error_info);			
+			SET_OOM_ERROR(stmt->error_info);
+			SET_OOM_ERROR(conn->error_info);
 		}
 		/*
 		  Cover protocol error: COM_STMT_SEND_LONG_DATA was designed to be quick and not
@@ -1467,7 +1493,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const s, unsigne
 				DBG_RETURN(FAIL);
 			}
 		}
-		
+
 		/* Prevent from freeing */
 		/* Don't update is_ref, or we will leak during conversion */
 		Z_ADDREF_P(zv);
@@ -1482,7 +1508,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_one_parameter)(MYSQLND_STMT * const s, unsigne
 		}
 		stmt->param_bind[param_no].zv = zv;
 		stmt->param_bind[param_no].type = type;
-		
+
 		stmt->send_types_to_server = 1;
 	}
 	DBG_INF("PASS");
@@ -1805,7 +1831,7 @@ MYSQLND_METHOD(mysqlnd_stmt, result_metadata)(MYSQLND_STMT * const s TSRMLS_DC)
 	if (result) {
 		result->m.free_result(result, TRUE TSRMLS_CC);
 	}
-	DBG_RETURN(NULL);	
+	DBG_RETURN(NULL);
 }
 /* }}} */
 
@@ -1817,39 +1843,42 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
 									   const void * const value TSRMLS_DC)
 {
 	MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
-	unsigned long val = *(unsigned long *) value;
 	DBG_ENTER("mysqlnd_stmt::attr_set");
 	if (!stmt) {
 		DBG_RETURN(FAIL);
 	}
-	DBG_INF_FMT("stmt=%lu attr_type=%u value=%lu", stmt->stmt_id, attr_type, val);
+	DBG_INF_FMT("stmt=%lu attr_type=%u", stmt->stmt_id, attr_type);
 
 	switch (attr_type) {
-		case STMT_ATTR_UPDATE_MAX_LENGTH:
+		case STMT_ATTR_UPDATE_MAX_LENGTH:{
+			zend_uchar bval = *(zend_uchar *) value;
 			/*
 			  XXX : libmysql uses my_bool, but mysqli uses ulong as storage on the stack
 			  and mysqlnd won't be used out of the scope of PHP -> use ulong.
 			*/
-			stmt->update_max_length = val? TRUE:FALSE;
+			stmt->update_max_length = bval? TRUE:FALSE;
 			break;
+		}
 		case STMT_ATTR_CURSOR_TYPE: {
-			if (val > (unsigned long) CURSOR_TYPE_READ_ONLY) {
+			unsigned int ival = *(unsigned int *) value;
+			if (ival > (unsigned long) CURSOR_TYPE_READ_ONLY) {
 				SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
 				DBG_INF("FAIL");
 				DBG_RETURN(FAIL);
 			}
-			stmt->flags = val;
+			stmt->flags = ival;
 			break;
 		}
 		case STMT_ATTR_PREFETCH_ROWS: {
-			if (val == 0) {
-				val = MYSQLND_DEFAULT_PREFETCH_ROWS;
-			} else if (val > 1) {
+			unsigned int ival = *(unsigned int *) value;
+			if (ival == 0) {
+				ival = MYSQLND_DEFAULT_PREFETCH_ROWS;
+			} else if (ival > 1) {
 				SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
 				DBG_INF("FAIL");
 				DBG_RETURN(FAIL);
 			}
-			stmt->prefetch_rows = val;
+			stmt->prefetch_rows = ival;
 			break;
 		}
 		default:
@@ -2056,12 +2085,12 @@ mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const s, unsigned int param
 /* }}} */
 
 
-/* {{{ mysqlnd_internal_free_stmt_content */
+/* {{{ mysqlnd_stmt::free_stmt_content */
 static void
-mysqlnd_internal_free_stmt_content(MYSQLND_STMT * const s TSRMLS_DC)
+MYSQLND_METHOD(mysqlnd_stmt, free_stmt_content)(MYSQLND_STMT * const s TSRMLS_DC)
 {
 	MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
-	DBG_ENTER("mysqlnd_internal_free_stmt_content");
+	DBG_ENTER("mysqlnd_stmt::free_stmt_content");
 	if (!stmt) {
 		DBG_VOID_RETURN;
 	}
@@ -2112,7 +2141,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const s, zend_boo
 	MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
 	MYSQLND * conn;
 	zend_uchar cmd_buf[STMT_ID_LENGTH /* statement id */];
-	enum_mysqlnd_collected_stats stat = STAT_LAST;
+	enum_mysqlnd_collected_stats statistic = STAT_LAST;
 
 	DBG_ENTER("mysqlnd_stmt::net_close");
 	if (!stmt || !stmt->conn) {
@@ -2163,16 +2192,16 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const s, zend_boo
 	}
 	switch (stmt->execute_count) {
 		case 0:
-			stat = STAT_PS_PREPARED_NEVER_EXECUTED;
+			statistic = STAT_PS_PREPARED_NEVER_EXECUTED;
 			break;
 		case 1:
-			stat = STAT_PS_PREPARED_ONCE_USED;
+			statistic = STAT_PS_PREPARED_ONCE_USED;
 			break;
 		default:
 			break;
 	}
-	if (stat != STAT_LAST) {
-		MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
+	if (statistic != STAT_LAST) {
+		MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
 	}
 
 	if (stmt->execute_cmd_buffer.buffer) {
@@ -2180,7 +2209,7 @@ MYSQLND_METHOD_PRIVATE(mysqlnd_stmt, net_close)(MYSQLND_STMT * const s, zend_boo
 		stmt->execute_cmd_buffer.buffer = NULL;
 	}
 
-	mysqlnd_internal_free_stmt_content(s TSRMLS_CC);
+	s->m->free_stmt_content(s TSRMLS_CC);
 
 	if (stmt->conn) {
 		stmt->conn->m->free_reference(stmt->conn TSRMLS_CC);
@@ -2196,7 +2225,7 @@ static enum_func_status
 MYSQLND_METHOD(mysqlnd_stmt, dtor)(MYSQLND_STMT * const s, zend_bool implicit TSRMLS_DC)
 {
 	MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
-	enum_func_status ret;
+	enum_func_status ret = FAIL;
 	zend_bool persistent = s->persistent;
 
 	DBG_ENTER("mysqlnd_stmt::dtor");
@@ -2318,7 +2347,8 @@ MYSQLND_CLASS_METHODS_START(mysqlnd_stmt)
 	MYSQLND_METHOD(mysqlnd_stmt, free_result_bind),
 	MYSQLND_METHOD(mysqlnd_stmt, server_status),
 	mysqlnd_stmt_execute_generate_request,
-	mysqlnd_stmt_execute_parse_response
+	mysqlnd_stmt_execute_parse_response,
+	MYSQLND_METHOD(mysqlnd_stmt, free_stmt_content)
 MYSQLND_CLASS_METHODS_END;
 
 
@@ -2360,7 +2390,7 @@ MYSQLND_STMT * _mysqlnd_stmt_init(MYSQLND * const conn TSRMLS_DC)
 
 		DBG_RETURN(ret);
 	} while (0);
-	
+
 	SET_OOM_ERROR(conn->error_info);
 	if (ret) {
 		ret->m->dtor(ret, TRUE TSRMLS_CC);
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index 9256763..7e15f2e 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_ps_codec.c 300735 2010-06-24 19:52:13Z andrey $ */
+/* $Id: mysqlnd_ps_codec.c 304131 2010-10-06 06:08:55Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -84,7 +84,7 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
 #endif /* #if SIZEOF_LONG==4 */
 		{
 			if (byte_count < 8 || uval <= L64(9223372036854775807)) {
-				ZVAL_LONG(zv, uval);
+				ZVAL_LONG(zv, (long) uval); /* the cast is safe, we are in the range */
 			} else {
 				DBG_INF("stringify");
 				tmp_len = sprintf((char *)&tmp, MYSQLND_LLU_SPEC, uval);
@@ -112,12 +112,12 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
 		} else
 #endif /* SIZEOF */
 		{
-			ZVAL_LONG(zv, lval);
+			ZVAL_LONG(zv, (long) lval); /* the cast is safe, we are in the range */
 		}
 	}
 
 	if (tmp_len) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		if (as_unicode) {
 			DBG_INF("stringify");
 			ZVAL_UTF8_STRINGL(zv, tmp, tmp_len, ZSTR_DUPLICATE);
@@ -231,7 +231,7 @@ void ps_fetch_time(zval *zv, const MYSQLND_FIELD * const field,
 {
 	struct st_mysqlnd_time t;
 	unsigned int length; /* First byte encodes the length*/
-	char *to;
+	char * value;
 	DBG_ENTER("ps_fetch_time");
 
 	if ((length = php_mysqlnd_net_field_length(row))) {
@@ -262,17 +262,17 @@ void ps_fetch_time(zval *zv, const MYSQLND_FIELD * const field,
 	  QQ : How to make this unicode without copying two times the buffer -
 	  Unicode equivalent of spprintf?
 	*/
-	length = spprintf(&to, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second);
+	length = spprintf(&value, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second);
 
-	DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+	DBG_INF_FMT("%s", value);
+#if MYSQLND_UNICODE
 	if (!as_unicode) {
 #endif
-		ZVAL_STRINGL(zv, to, length, 1);
-		efree(to);  /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+		ZVAL_STRINGL(zv, value, length, 1);
+		efree(value);  /* allocated by spprintf */
+#if MYSQLND_UNICODE
 	} else {
-		ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
+		ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE);
 	}
 #endif
 	DBG_VOID_RETURN;
@@ -288,7 +288,7 @@ void ps_fetch_date(zval *zv, const MYSQLND_FIELD * const field,
 {
 	struct st_mysqlnd_time t = {0};
 	unsigned int length; /* First byte encodes the length*/
-	char *to;
+	char * value;
 	DBG_ENTER("ps_fetch_date");
 
 	if ((length = php_mysqlnd_net_field_length(row))) {
@@ -313,17 +313,17 @@ void ps_fetch_date(zval *zv, const MYSQLND_FIELD * const field,
 	  QQ : How to make this unicode without copying two times the buffer -
 	  Unicode equivalent of spprintf?
 	*/
-	length = spprintf(&to, 0, "%04u-%02u-%02u", t.year, t.month, t.day);
+	length = spprintf(&value, 0, "%04u-%02u-%02u", t.year, t.month, t.day);
 
-	DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+	DBG_INF_FMT("%s", value);
+#if MYSQLND_UNICODE
 	if (!as_unicode) {
 #endif
-		ZVAL_STRINGL(zv, to, length, 1);
-		efree(to); /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+		ZVAL_STRINGL(zv, value, length, 1);
+		efree(value); /* allocated by spprintf */
+#if MYSQLND_UNICODE
 	} else {
-		ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
+		ZVAL_UTF8_STRINGL(zv, value, length, ZSTR_AUTOFREE);
 	}
 #endif
 	DBG_VOID_RETURN;
@@ -339,7 +339,7 @@ void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * const field,
 {
 	struct st_mysqlnd_time t;
 	unsigned int length; /* First byte encodes the length*/
-	char *to;
+	char * value;
 	DBG_ENTER("ps_fetch_datetime");
 
 	if ((length = php_mysqlnd_net_field_length(row))) {
@@ -371,16 +371,16 @@ void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * const field,
 	  QQ : How to make this unicode without copying two times the buffer -
 	  Unicode equivalent of spprintf?
 	*/
-	length = spprintf(&to, 0, "%04u-%02u-%02u %02u:%02u:%02u",
+	length = spprintf(&value, 0, "%04u-%02u-%02u %02u:%02u:%02u",
 					  t.year, t.month, t.day, t.hour, t.minute, t.second);
 
-	DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+	DBG_INF_FMT("%s", value);
+#if MYSQLND_UNICODE
 	if (!as_unicode) {
 #endif
-		ZVAL_STRINGL(zv, to, length, 1);
-		efree(to); /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+		ZVAL_STRINGL(zv, value, length, 1);
+		efree(value); /* allocated by spprintf */
+#if MYSQLND_UNICODE
 	} else {
 		ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
 	}
@@ -403,10 +403,7 @@ void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field,
 	unsigned long length = php_mysqlnd_net_field_length(row);
 	DBG_ENTER("ps_fetch_string");
 	DBG_INF_FMT("len = %lu", length);
-#if PHP_MAJOR_VERSION < 6
-	DBG_INF("copying from the row buffer");
-	ZVAL_STRINGL(zv, (char *)*row, length, 1);
-#else
+#if MYSQLND_UNICODE
 	if (field->charsetnr == MYSQLND_BINARY_CHARSET_NR) {
 		DBG_INF("Binary charset");
 		ZVAL_STRINGL(zv, (char *)*row, length, 1);
@@ -414,6 +411,9 @@ void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field,
 		DBG_INF_FMT("copying from the row buffer");
 		ZVAL_UTF8_STRINGL(zv, (char*)*row, length, ZSTR_DUPLICATE);
 	}
+#else
+	DBG_INF("copying from the row buffer");
+	ZVAL_STRINGL(zv, (char *)*row, length, 1);
 #endif
 
 	(*row) += length;
@@ -482,7 +482,7 @@ void _mysqlnd_init_ps_fetch_subsystem()
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DOUBLE].pack_len	= 8;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DOUBLE].php_type	= IS_DOUBLE;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DOUBLE].can_ret_as_str_in_uni	= TRUE;
-	
+
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIME].func		= ps_fetch_time;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIME].pack_len	= MYSQLND_PS_SKIP_RESULT_W_LEN;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIME].php_type	= IS_STRING;
@@ -493,11 +493,11 @@ void _mysqlnd_init_ps_fetch_subsystem()
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DATE].php_type	= IS_STRING;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DATE].can_ret_as_str_in_uni	= TRUE;
 
-	mysqlnd_ps_fetch_functions[MYSQL_TYPE_NEWDATE].func		= ps_fetch_date;
+	mysqlnd_ps_fetch_functions[MYSQL_TYPE_NEWDATE].func		= ps_fetch_string;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_NEWDATE].pack_len	= MYSQLND_PS_SKIP_RESULT_W_LEN;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_NEWDATE].php_type	= IS_STRING;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_NEWDATE].can_ret_as_str_in_uni	= TRUE;
-	
+
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DATETIME].func	= ps_fetch_datetime;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DATETIME].pack_len= MYSQLND_PS_SKIP_RESULT_W_LEN;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_DATETIME].php_type= IS_STRING;
@@ -507,7 +507,7 @@ void _mysqlnd_init_ps_fetch_subsystem()
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIMESTAMP].pack_len= MYSQLND_PS_SKIP_RESULT_W_LEN;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIMESTAMP].php_type= IS_STRING;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIMESTAMP].can_ret_as_str_in_uni	= TRUE;
-	
+
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].func	= ps_fetch_string;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].pack_len= MYSQLND_PS_SKIP_RESULT_STR;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].php_type = IS_STRING;
@@ -519,7 +519,7 @@ void _mysqlnd_init_ps_fetch_subsystem()
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_BLOB].php_type	= IS_STRING;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_BLOB].is_possibly_blob = TRUE;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_BLOB].can_ret_as_str_in_uni	= TRUE;
-	
+
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_MEDIUM_BLOB].func		= ps_fetch_string;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_MEDIUM_BLOB].pack_len	= MYSQLND_PS_SKIP_RESULT_STR;
 	mysqlnd_ps_fetch_functions[MYSQL_TYPE_MEDIUM_BLOB].php_type	= IS_STRING;
@@ -608,12 +608,47 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 	size_t data_size = 0;
 	zval **copies = NULL;/* if there are different types */
 	enum_func_status ret = FAIL;
+	int resend_types_next_time = 0;
 
 	DBG_ENTER("mysqlnd_stmt_execute_store_params");
 
 /* 1. Store type information */
-	if (stmt->send_types_to_server) {
+	/*
+	  check if need to send the types even if stmt->send_types_to_server is 0. This is because
+	  if we send "i" (42) then the type will be int and the server will expect int. However, if next
+	  time we try to send > LONG_MAX, the conversion to string will send a string and the server
+	  won't expect it and interpret the value as 0. Thus we need to resend the types, if any such values
+	  occur, and force resend for the next execution.
+	*/
+	for (i = 0; i < stmt->param_count; i++) {
+		if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_NULL &&
+			(stmt->param_bind[i].type == MYSQL_TYPE_LONG || stmt->param_bind[i].type == MYSQL_TYPE_LONGLONG))
+		{
+			/* always copy the var, because we do many conversions */
+			if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG &&
+				PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i TSRMLS_CC))
+			{
+				SET_OOM_ERROR(stmt->error_info);
+				goto end;
+			}
+			/*
+			  if it doesn't fit in a long send it as a string.
+			  Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
+			*/
+			if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
+				zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+				convert_to_double_ex(&tmp_data);
+				if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
+					stmt->send_types_to_server = resend_types_next_time = 1;
+				}
+			}
+		}
+	}
 
+	int1store(*p, stmt->send_types_to_server); 
+	(*p)++;
+
+	if (stmt->send_types_to_server) {
 		/* 2 bytes per type, and leave 20 bytes for future use */
 		if (left < ((stmt->param_count * 2) + 20)) {
 			unsigned int offset = *p - *buf;
@@ -626,21 +661,46 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 			}
 			memcpy(tmp_buf, *buf, offset);
 			*buf = tmp_buf;
-			
+
 			/* Update our pos pointer */
 			*p = *buf + offset;
 		}
 		for (i = 0; i < stmt->param_count; i++) {
+			short current_type = stmt->param_bind[i].type;
 			/* our types are not unsigned */
 #if SIZEOF_LONG==8  
-			if (stmt->param_bind[i].type == MYSQL_TYPE_LONG) {
-				stmt->param_bind[i].type = MYSQL_TYPE_LONGLONG;
+			if (current_type == MYSQL_TYPE_LONG) {
+				current_type = MYSQL_TYPE_LONGLONG;
 			}
 #endif
-			int2store(*p, stmt->param_bind[i].type);
+			if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_NULL && (current_type == MYSQL_TYPE_LONG || current_type == MYSQL_TYPE_LONGLONG)) {
+				/*
+				  if it doesn't fit in a long send it as a string.
+				  Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
+				*/
+				if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
+					zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+
+					convert_to_double_ex(&tmp_data);
+					if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
+						convert_to_string_ex(&tmp_data);
+						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.
+						  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.
+						*/
+					} else {
+						convert_to_long_ex(&tmp_data);
+					}
+				}
+			}
+			int2store(*p, current_type);
 			*p+= 2;
 		}
 	}
+	stmt->send_types_to_server = resend_types_next_time;
 
 /* 2. Store data */
 	/* 2.1 Calculate how much space we need */
@@ -654,9 +714,11 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 		for (j = i + 1; j < stmt->param_count; j++) {
 			if (stmt->param_bind[j].zv == the_var) {
 				/* Double binding of the same zval, make a copy */
-				if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) {
-					SET_OOM_ERROR(stmt->error_info);
-					goto end;
+				if (!copies || !copies[i]) {
+					if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) {
+						SET_OOM_ERROR(stmt->error_info);
+						goto end;
+					}
 				}
 				break; 
 			}
@@ -674,23 +736,25 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 					}
 				}
 				break;
-#if SIZEOF_LONG==8  
 			case MYSQL_TYPE_LONGLONG:
+				{
+					zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+					if (Z_TYPE_P(tmp_data) == IS_STRING) {
+						goto use_string;
+					}
+					convert_to_long_ex(&tmp_data);
+				}
 				data_size += 8;
-#elif SIZEOF_LONG==4
+				break;
 			case MYSQL_TYPE_LONG:
-				data_size += 4;
-#else
-#error "Should not happen"
-#endif
-				if (Z_TYPE_P(the_var) != IS_LONG) {
-					if (!copies || !copies[i]) {
-						if (PASS != mysqlnd_stmt_copy_it(&copies, the_var, stmt->param_count, i TSRMLS_CC)) {
-							SET_OOM_ERROR(stmt->error_info);
-							goto end;
-						}
+				{
+					zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+					if (Z_TYPE_P(tmp_data) == IS_STRING) {
+						goto use_string;
 					}
+					convert_to_long_ex(&tmp_data);
 				}
+				data_size += 4;
 				break;
 			case MYSQL_TYPE_LONG_BLOB:
 				if (!(stmt->param_bind[i].flags & MYSQLND_PARAM_BIND_BLOB_USED)) {
@@ -703,11 +767,12 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 				}
 				break;
 			case MYSQL_TYPE_VAR_STRING:
+use_string:
 				data_size += 8; /* max 8 bytes for size */
-#if PHP_MAJOR_VERSION < 6
-				if (Z_TYPE_P(the_var) != IS_STRING)
-#elif PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 				if (Z_TYPE_P(the_var) != IS_STRING || Z_TYPE_P(the_var) == IS_UNICODE)
+#else
+				if (Z_TYPE_P(the_var) != IS_STRING)
 #endif
 				{
 					if (!copies || !copies[i]) {
@@ -717,7 +782,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 						}
 					}
 					the_var = copies[i];
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 					if (Z_TYPE_P(the_var) == IS_UNICODE) {
 						zval_unicode_to_string_ex(the_var, UG(utf8_conv) TSRMLS_CC);
 					}
@@ -727,7 +792,6 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 				data_size += Z_STRLEN_P(the_var);
 				break;
 		}
-
 	}
 
 	/* 2.2 Enlarge the buffer, if needed */
@@ -757,7 +821,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 
 	/* 2.3 Store the actual data */
 	for (i = 0; i < stmt->param_count; i++) {
-		zval *data = copies && copies[i]? copies[i]: stmt->param_bind[i].zv;
+		zval *data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
 		/* Handle long data */
 		if (stmt->param_bind[i].zv && Z_TYPE_P(data) == IS_NULL) {
 			(*buf + null_byte_offset)[i/8] |= (zend_uchar) (1 << (i & 7));
@@ -768,21 +832,22 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 					float8store(*p, Z_DVAL_P(data));
 					(*p) += 8;
 					break;
-#if SIZEOF_LONG==8  
 				case MYSQL_TYPE_LONGLONG:
-					convert_to_long_ex(&data);
+					if (Z_TYPE_P(data) == IS_STRING) {
+						goto send_string;
+					}
+					/* data has alreade been converted to long */
 					int8store(*p, Z_LVAL_P(data));
 					(*p) += 8;
 					break;
-#elif SIZEOF_LONG==4
 				case MYSQL_TYPE_LONG:
-					convert_to_long_ex(&data);
+					if (Z_TYPE_P(data) == IS_STRING) {
+						goto send_string;
+					}
+					/* data has alreade been converted to long */
 					int4store(*p, Z_LVAL_P(data));
 					(*p) += 4;
 					break;
-#else
-#error "Should not happen"
-#endif
 				case MYSQL_TYPE_LONG_BLOB:
 					if (stmt->param_bind[i].flags & MYSQLND_PARAM_BIND_BLOB_USED) {
 						stmt->param_bind[i].flags &= ~MYSQLND_PARAM_BIND_BLOB_USED;
@@ -791,7 +856,9 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
 						*p = php_mysqlnd_net_store_length(*p, 0);
 					}
 					break;
-				case MYSQL_TYPE_VAR_STRING:{
+				case MYSQL_TYPE_VAR_STRING:
+send_string:
+					{
 						unsigned int len = Z_STRLEN_P(data);
 						/* to is after p. The latter hasn't been moved */
 						*p = php_mysqlnd_net_store_length(*p, len);
@@ -855,10 +922,6 @@ mysqlnd_stmt_execute_generate_request(MYSQLND_STMT * const s, zend_uchar ** requ
 	memset(p, 0, null_count);
 	p += null_count;
 
-
-	int1store(p, stmt->send_types_to_server); 
-	p++;
-
 	ret = mysqlnd_stmt_execute_store_params(s, &cmd_buffer, &p, &cmd_buffer_length, null_byte_offset TSRMLS_CC);
 
 	*free_buffer = (cmd_buffer != stmt->execute_cmd_buffer.buffer);
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 645c819..1d0106e 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result.c 301234 2010-07-13 13:02:00Z andrey $ */
+/* $Id: mysqlnd_result.c 304183 2010-10-07 13:49:00Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_wireprotocol.h"
@@ -42,14 +42,14 @@ MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest)(MYSQLND_RES * const resu
 	zval **data_cursor = result->stored_data? result->stored_data->data:NULL;
 	zval **data_begin = result->stored_data? result->stored_data->data:NULL;
 	unsigned int field_count = result->meta? result->meta->field_count : 0;
-	unsigned int row_count = result->stored_data? result->stored_data->row_count:0;
+	uint64_t row_count = result->stored_data? result->stored_data->row_count:0;
 	enum_func_status ret = PASS;
 	DBG_ENTER("mysqlnd_res::initialize_result_set_rest");
 
 	if (!data_cursor || row_count == result->stored_data->initialized_rows) {
 		DBG_RETURN(ret);
 	}
-	while ((data_cursor - data_begin) < (row_count * field_count)) {
+	while ((data_cursor - data_begin) < (int)(row_count * field_count)) {
 		if (NULL == data_cursor[0]) {
 			enum_func_status rc = result->m.row_decoder(
 									result->stored_data->row_buffers[(data_cursor - data_begin) / field_count],
@@ -86,19 +86,23 @@ MYSQLND_METHOD(mysqlnd_res, initialize_result_set_rest)(MYSQLND_RES * const resu
 /* }}} */
 
 
-
 /* {{{ mysqlnd_palloc_zval_ptr_dtor */
+static
 void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bool * copy_ctor_called TSRMLS_DC)
 {
 	DBG_ENTER("mysqlnd_palloc_zval_ptr_dtor");
-	*copy_ctor_called = FALSE;
-
+	if (!zv || !*zv) {
+		*copy_ctor_called = FALSE;
+		DBG_ERR_FMT("zv was NULL");
+		DBG_VOID_RETURN;
+	}
 	/*
 	  This zval is not from the cache block.
 	  Thus the refcount is -1 than of a zval from the cache,
 	  because the zvals from the cache are owned by it.
 	*/
 	if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) {
+		*copy_ctor_called = FALSE;
 		; /* do nothing, zval_ptr_dtor will do the job*/
 	} else if (Z_REFCOUNT_PP(zv) > 1) {
 		/*
@@ -120,6 +124,12 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, enum_mysqlnd_res_type type, zend_bo
 		}
 		*copy_ctor_called = TRUE;
 	} else {
+		/*
+		  noone but us point to this, so we can safely ZVAL_NULL the zval,
+		  so Zend does not try to free what the zval points to - which is
+		  in result set buffers
+		*/
+		*copy_ctor_called = FALSE;
 		if (Z_TYPE_PP(zv) == IS_STRING) {
 			ZVAL_NULL(*zv);
 		}
@@ -152,18 +162,16 @@ MYSQLND_METHOD(mysqlnd_res, unbuffered_free_last_data)(MYSQLND_RES * result TSRM
 		for (i = 0; i < result->field_count; i++) {
 			mysqlnd_palloc_zval_ptr_dtor(&(unbuf->last_row_data[i]), result->type, &copy_ctor_called TSRMLS_CC);
 			if (copy_ctor_called) {
-				ctor_called_count++;
+				++ctor_called_count;
 			}
 		}
 		DBG_INF_FMT("copy_ctor_called_count=%u", ctor_called_count);
 		/* By using value3 macros we hold a mutex only once, there is no value2 */
-		MYSQLND_INC_CONN_STATISTIC_W_VALUE3(global_stats,
+		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(global_stats,
 											STAT_COPY_ON_WRITE_PERFORMED,
 											ctor_called_count,
 											STAT_COPY_ON_WRITE_SAVED,
-											result->field_count - ctor_called_count,
-											STAT_COPY_ON_WRITE_PERFORMED, 0);
-		
+											result->field_count - ctor_called_count);
 		/* Free last row's zvals */
 		mnd_efree(unbuf->last_row_data);
 		unbuf->last_row_data = NULL;
@@ -186,31 +194,37 @@ MYSQLND_METHOD(mysqlnd_res, free_buffered_data)(MYSQLND_RES * result TSRMLS_DC)
 {
 	MYSQLND_RES_BUFFERED *set = result->stored_data;
 	unsigned int field_count = result->field_count;
-	int row;
+	int64_t row;
 
 	DBG_ENTER("mysqlnd_res::free_buffered_data");
 	DBG_INF_FMT("Freeing "MYSQLND_LLU_SPEC" row(s)", set->row_count);
 
 	DBG_INF("Freeing data & row_buffer");
 	if (set->data) {
+		unsigned int copy_on_write_performed = 0;
+		unsigned int copy_on_write_saved = 0;
 
 		DBG_INF_FMT("before: real_usage=%lu  usage=%lu", zend_memory_usage(TRUE TSRMLS_CC), zend_memory_usage(FALSE TSRMLS_CC));
 		for (row = set->row_count - 1; row >= 0; row--) {
 			zval **current_row = set->data + row * field_count;
 			MYSQLND_MEMORY_POOL_CHUNK *current_buffer = set->row_buffers[row];
-			int col;
+			int64_t col;
 
-			for (col = field_count - 1; col >= 0; --col) {
-				zend_bool copy_ctor_called;
-				if (current_row == NULL || current_row[0] == NULL) {
-					break;/* row that was never initialized */
-				}
-			mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), result->type, &copy_ctor_called TSRMLS_CC);
+			if (current_row != NULL) {
+				for (col = field_count - 1; col >= 0; --col) {
+					if (current_row[col]) {
+						zend_bool copy_ctor_called;
+						mysqlnd_palloc_zval_ptr_dtor(&(current_row[col]), result->type, &copy_ctor_called TSRMLS_CC);
 #if MYSQLND_DEBUG_MEMORY
-				DBG_INF_FMT("Copy_ctor_called=%u", copy_ctor_called);
+						DBG_INF_FMT("Copy_ctor_called=%u", copy_ctor_called);
 #endif
-				MYSQLND_INC_GLOBAL_STATISTIC(copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED:
-														   STAT_COPY_ON_WRITE_SAVED);
+						if (copy_ctor_called) {
+							++copy_on_write_performed;
+						} else {
+							++copy_on_write_saved;
+						}
+					}
+				}
 			}
 #if MYSQLND_DEBUG_MEMORY
 			DBG_INF("Freeing current_row & current_buffer");
@@ -218,6 +232,8 @@ MYSQLND_METHOD(mysqlnd_res, free_buffered_data)(MYSQLND_RES * result TSRMLS_DC)
 			current_buffer->free_chunk(current_buffer TSRMLS_CC);
 		}
 
+		MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_COPY_ON_WRITE_PERFORMED, copy_on_write_performed,
+											  STAT_COPY_ON_WRITE_SAVED, copy_on_write_saved);
 		mnd_pefree(set->data, set->persistent);
 		set->data = NULL;
 	}
@@ -376,7 +392,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 		if (!rset_header) {
 			SET_OOM_ERROR(conn->error_info);
 			ret = FAIL;
-			break;		
+			break;
 		}
 
 		SET_ERROR_AFF_ROWS(conn);
@@ -443,7 +459,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 				break;
 			default: do {			/* Result set */
 				MYSQLND_RES * result;
-				enum_mysqlnd_collected_stats stat = STAT_LAST;
+				enum_mysqlnd_collected_stats statistic = STAT_LAST;
 
 				DBG_INF("Result set pending");
 				SET_EMPTY_MESSAGE(conn->last_message, conn->last_message_len, conn->persistent);
@@ -489,7 +505,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 					ret = FAIL;
 					break;
 				}
-				
+
 				if (FAIL == (ret = result->m.read_result_metadata(result, conn TSRMLS_CC))) {
 					/* For PS, we leave them in Prepared state */
 					if (!stmt && conn->current_result) {
@@ -505,7 +521,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 				if (!fields_eof) {
 					SET_OOM_ERROR(conn->error_info);
 					ret = FAIL;
-					break;				
+					break;
 				}
 				if (FAIL == (ret = PACKET_READ(fields_eof, conn))) {
 					DBG_ERR("Error ocurred while reading the EOF packet");
@@ -532,11 +548,11 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 					*/
 					conn->upsert_status.server_status = fields_eof->server_status;
 					if (fields_eof->server_status & SERVER_QUERY_NO_GOOD_INDEX_USED) {
-						stat = STAT_BAD_INDEX_USED;
+						statistic = STAT_BAD_INDEX_USED;
 					} else if (fields_eof->server_status & SERVER_QUERY_NO_INDEX_USED) {
-						stat = STAT_NO_INDEX_USED;
+						statistic = STAT_NO_INDEX_USED;
 					} else if (fields_eof->server_status & SERVER_QUERY_WAS_SLOW) {
-						stat = STAT_QUERY_WAS_SLOW;
+						statistic = STAT_QUERY_WAS_SLOW;
 					}
 					if (to_log) {
 #if A0
@@ -545,7 +561,7 @@ mysqlnd_query_read_result_set_header(MYSQLND *conn, MYSQLND_STMT * s TSRMLS_DC)
 						efree(backtrace);
 #endif
 					}
-					MYSQLND_INC_CONN_STATISTIC(conn->stats, stat);
+					MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
 				}
 			} while (0);
 			PACKET_FREE(fields_eof);
@@ -663,7 +679,7 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES * result TSRMLS_DC)
 
 		if (!row_packet->skip_extraction) {
 			MYSQLND_FIELD *field = result->meta->fields;
-			struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys;
+			struct mysqlnd_field_hash_key * hash_key = result->meta->zend_hash_keys;
 
 			enum_func_status rc = result->m.row_decoder(result->unbuf->last_row_buffer,
 										  result->unbuf->last_row_data,
@@ -679,7 +695,7 @@ mysqlnd_fetch_row_unbuffered_c(MYSQLND_RES * result TSRMLS_DC)
 
 			retrow = mnd_malloc(result->field_count * sizeof(char *));
 			if (retrow) {
-				for (i = 0; i < field_count; i++, field++, zend_hash_key++) {
+				for (i = 0; i < field_count; i++, field++, hash_key++) {
 					zval *data = result->unbuf->last_row_data[i];
 					unsigned int len;
 
@@ -778,7 +794,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla
 		if (!row_packet->skip_extraction) {
 			HashTable *row_ht = Z_ARRVAL_P(row);
 			MYSQLND_FIELD *field = result->meta->fields;
-			struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys;
+			struct mysqlnd_field_hash_key * hash_key = result->meta->zend_hash_keys;
 			unsigned int i, field_count = result->field_count;
 			unsigned long *lengths = result->lengths;
 
@@ -793,7 +809,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla
 			if (PASS != rc) {
 				DBG_RETURN(FAIL);
 			}
-			for (i = 0; i < field_count; i++, field++, zend_hash_key++) {
+			for (i = 0; i < field_count; i++, field++, hash_key++) {
 				zval *data = result->unbuf->last_row_data[i];
 				unsigned int len = (Z_TYPE_P(data) == IS_NULL)? 0:Z_STRLEN_P(data);
 
@@ -814,23 +830,23 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla
 					  hashing of the column name, which is not needed as it can be precomputed.
 					*/
 					Z_ADDREF_P(data);
-					if (zend_hash_key->is_numeric == FALSE) {
-#if PHP_MAJOR_VERSION >= 6
+					if (hash_key->is_numeric == FALSE) {
+#if MYSQLND_UNICODE
 						zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
-												 zend_hash_key->ustr,
-												 zend_hash_key->ulen + 1,
-												 zend_hash_key->key,
+												 hash_key->ustr,
+												 hash_key->ulen + 1,
+												 hash_key->key,
 												 (void *) &data, sizeof(zval *), NULL);
 #else
 						zend_hash_quick_update(Z_ARRVAL_P(row),
 											   field->name,
 											   field->name_length + 1,
-											   zend_hash_key->key,
+											   hash_key->key,
 											   (void *) &data, sizeof(zval *), NULL);
 #endif
 					} else {
 						zend_hash_index_update(Z_ARRVAL_P(row),
-											   zend_hash_key->key,
+											   hash_key->key,
 											   (void *) &data, sizeof(zval *), NULL);
 					}
 				}
@@ -946,7 +962,7 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES * result TSRMLS_DC)
 	{
 		zval **current_row = set->data_cursor;
 		MYSQLND_FIELD *field = result->meta->fields;
-		struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys;
+		struct mysqlnd_field_hash_key * hash_key = result->meta->zend_hash_keys;
 		unsigned int i;
 
 		if (NULL == current_row[0]) {
@@ -983,7 +999,7 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES * result TSRMLS_DC)
 
 		ret = mnd_malloc(result->field_count * sizeof(char *));
 		if (ret) {
-			for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) {
+			for (i = 0; i < result->field_count; i++, field++, hash_key++) {
 				zval *data = current_row[i];
 
 				if (Z_TYPE_P(data) != IS_NULL) {
@@ -1022,7 +1038,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags
 	{
 		zval **current_row = set->data_cursor;
 		MYSQLND_FIELD *field = result->meta->fields;
-		struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys;
+		struct mysqlnd_field_hash_key * hash_key = result->meta->zend_hash_keys;
 
 		if (NULL == current_row[0]) {
 			uint64_t row_num = (set->data_cursor - set->data) / result->meta->field_count;
@@ -1053,7 +1069,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags
 			}
 		}
 
-		for (i = 0; i < result->field_count; i++, field++, zend_hash_key++) {
+		for (i = 0; i < result->field_count; i++, field++, hash_key++) {
 			zval *data = current_row[i];
 
 			if (flags & MYSQLND_FETCH_NUM) {
@@ -1069,23 +1085,23 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags
 				  hashing of the column name, which is not needed as it can be precomputed.
 				*/
 				Z_ADDREF_P(data);
-				if (zend_hash_key->is_numeric == FALSE) {
-#if PHP_MAJOR_VERSION >= 6
+				if (hash_key->is_numeric == FALSE) {
+#if MYSQLND_UNICODE
 					zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
-											 zend_hash_key->ustr,
-											 zend_hash_key->ulen + 1,
-											 zend_hash_key->key,
+											 hash_key->ustr,
+											 hash_key->ulen + 1,
+											 hash_key->key,
 											 (void *) &data, sizeof(zval *), NULL);
 #else
 					zend_hash_quick_update(Z_ARRVAL_P(row),
 										   field->name,
 										   field->name_length + 1,
-										   zend_hash_key->key,
+										   hash_key->key,
 										   (void *) &data, sizeof(zval *), NULL);
 #endif
 				} else {
 					zend_hash_index_update(Z_ARRVAL_P(row),
-										   zend_hash_key->key,
+										   hash_key->key,
 										   (void *) &data, sizeof(zval *), NULL);
 				}
 			}
@@ -1128,14 +1144,14 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQL
 	if (!set) {
 		SET_OOM_ERROR(conn->error_info);
 		ret = FAIL;
-		goto end;	
+		goto end;
 	}
 	if (free_rows) {
-		set->row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache);
+		set->row_buffers = mnd_pemalloc((size_t)(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)), to_cache);
 		if (!set->row_buffers) {
 			SET_OOM_ERROR(conn->error_info);
 			ret = FAIL;
-			goto end;	
+			goto end;
 		}
 	}
 	set->persistent	= to_cache;
@@ -1149,7 +1165,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQL
 	if (!row_packet) {
 		SET_OOM_ERROR(conn->error_info);
 		ret = FAIL;
-		goto end;	
+		goto end;
 	}
 	row_packet->result_set_memory_pool = result->result_set_memory_pool;
 	row_packet->field_count = meta->field_count;
@@ -1165,8 +1181,15 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQL
 			uint64_t total_allocated_rows = free_rows = next_extend = next_extend * 11 / 10; /* extend with 10% */
 			MYSQLND_MEMORY_POOL_CHUNK ** new_row_buffers;
 			total_allocated_rows += set->row_count;
+
+			/* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */
+			if (total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *) > SIZE_MAX) {
+				SET_OOM_ERROR(conn->error_info);
+				ret = FAIL;
+				goto end;
+			}
 			new_row_buffers = mnd_perealloc(set->row_buffers,
-											total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *),
+											(size_t)(total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)),
 											set->persistent);
 			if (!new_row_buffers) {
 				SET_OOM_ERROR(conn->error_info);
@@ -1193,14 +1216,20 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQL
 	}
 	/* Overflow ? */
 	if (set->row_count) {
+		/* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */
+		if (set->row_count * meta->field_count * sizeof(zval *) > SIZE_MAX) {
+			SET_OOM_ERROR(conn->error_info);
+			ret = FAIL;
+			goto end;
+		}
 		/* if pecalloc is used valgrind barks gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux) */
-		set->data = mnd_pemalloc(set->row_count * meta->field_count * sizeof(zval *), to_cache);
+		set->data = mnd_pemalloc((size_t)(set->row_count * meta->field_count * sizeof(zval *)), to_cache);
 		if (!set->data) {
 			SET_OOM_ERROR(conn->error_info);
 			ret = FAIL;
 			goto end;
 		}
-		memset(set->data, 0, set->row_count * meta->field_count * sizeof(zval *));
+		memset(set->data, 0, (size_t)(set->row_count * meta->field_count * sizeof(zval *)));
 	}
 
 	MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn->stats,
@@ -1215,8 +1244,14 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND * const conn, MYSQL
 	}
 	/* save some memory */
 	if (free_rows) {
+		/* don't try to allocate more than possible - mnd_XXalloc expects size_t, and it can have narrower range than uint64_t */
+		if (set->row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *) > SIZE_MAX) {
+			SET_OOM_ERROR(conn->error_info);
+			ret = FAIL;
+			goto end;
+		}
 		set->row_buffers = mnd_perealloc(set->row_buffers,
-										 set->row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *),
+										 (size_t) (set->row_count * sizeof(MYSQLND_MEMORY_POOL_CHUNK *)),
 										 set->persistent);
 	}
 
@@ -1277,7 +1312,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result)(MYSQLND_RES * result,
 		if (result->stored_data) {
 			conn->error_info = result->stored_data->error_info;
 		} else {
-			SET_OOM_ERROR(conn->error_info);		
+			SET_OOM_ERROR(conn->error_info);
 		}
 		DBG_RETURN(NULL);
 	}
@@ -1310,9 +1345,7 @@ MYSQLND_METHOD(mysqlnd_res, skip_result)(MYSQLND_RES * const result TSRMLS_DC)
 									result->type == MYSQLND_RES_NORMAL? STAT_FLUSHED_NORMAL_SETS:
 																		STAT_FLUSHED_PS_SETS);
 
-		while ((PASS == result->m.fetch_row(result, NULL, 0, &fetched_anything TSRMLS_CC)) &&
-			   fetched_anything == TRUE)
-		{
+		while ((PASS == result->m.fetch_row(result, NULL, 0, &fetched_anything TSRMLS_CC)) && fetched_anything == TRUE) {
 			/* do nothing */;
 		}
 	}
@@ -1491,6 +1524,9 @@ MYSQLND_METHOD(mysqlnd_res, field_tell)(const MYSQLND_RES * const result TSRMLS_
 /* }}} */
 
 
+/* for php_addslashes */
+#include "ext/standard/php_string.h"
+
 /* {{{ mysqlnd_res::fetch_into */
 static void
 MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, unsigned int flags,
@@ -1525,7 +1561,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, unsigned int flags
 				break;
 			default:exit(0);
 		}
-	}
+	} 
 	/*
 	  return_value is IS_NULL for no more data and an array for data. Thus it's ok
 	  to return here.
@@ -1567,8 +1603,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags,
 	DBG_ENTER("mysqlnd_res::fetch_all");
 	DBG_INF_FMT("flags=%u", flags);
 
-	/* mysqlnd_res::fetch_all works with buffered resultsets only */
-	if (result->unbuf || (!result->unbuf && !set)) {
+	if ((!result->unbuf && !set)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "fetch_all can be used only with buffered sets");
 		if (result->conn) {
 			SET_CLIENT_ERROR(result->conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "fetch_all can be used only with buffered sets");
@@ -1577,19 +1612,18 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags,
 		DBG_VOID_RETURN;
 	}
 
-	mysqlnd_array_init(return_value, (unsigned int) set->row_count);
+	/* 4 is a magic value. The cast is safe, if larger then the array will be later extended - no big deal :) */
+	mysqlnd_array_init(return_value, set? (unsigned int) set->row_count : 4); 
 
-	if (!set->row_count || !set->data_cursor || set->data_cursor >= set->data + set->row_count) {
-		DBG_VOID_RETURN;
-	}	
-
-	while (set->data_cursor &&
-		   (set->data_cursor - set->data) < (set->row_count * result->meta->field_count))
-	{
+	do {
 		MAKE_STD_ZVAL(row);
 		mysqlnd_fetch_into(result, flags, row, MYSQLND_MYSQLI);
+		if (Z_TYPE_P(row) != IS_ARRAY) {
+			zval_ptr_dtor(&row);
+			break;
+		}
 		add_index_zval(return_value, i++, row);
-	}
+	} while (1);
 
 	DBG_VOID_RETURN;
 }
@@ -1627,7 +1661,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES * result, unsigned int
 		zend_hash_move_forward(Z_ARRVAL(row));
 		zend_hash_get_current_data(Z_ARRVAL(row), (void **)&entry);
 	}
-	
+
 	zend_hash_get_current_data(Z_ARRVAL(row), (void **)&entry);
 
 	*return_value = **entry;
@@ -1686,7 +1720,7 @@ mysqlnd_result_init(unsigned int field_count, zend_bool persistent TSRMLS_DC)
 
 	DBG_ENTER("mysqlnd_result_init");
 	DBG_INF_FMT("field_count=%u", field_count);
-	
+
 	if (!ret) {
 		DBG_RETURN(NULL);
 	}
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index a3897bc..b15fb10 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_result_meta.c 300635 2010-06-21 15:32:26Z andrey $ */
+/* $Id: mysqlnd_result_meta.c 304066 2010-10-05 08:29:54Z uw $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
@@ -52,16 +52,16 @@ php_mysqlnd_free_field_metadata(MYSQLND_FIELD *meta, zend_bool persistent TSRMLS
   and modified for the needs of mysqlnd.
 */
 static zend_bool
-mysqlnd_is_key_numeric(char *key, size_t length, long *idx)
+mysqlnd_is_key_numeric(const char * key, size_t length, long *idx)
 {
-	register char * tmp = key;
+	register const char * tmp = key;
 
 	if (*tmp=='-') {
 		tmp++;
 	}
 	if ((*tmp>='0' && *tmp<='9')) {
 		do { /* possibly a numeric index */
-			char *end=key+length-1;
+			const char *end=key+length-1;
 
 			if (*tmp++=='0' && length>2) { /* don't accept numbers with leading zeros */
 				break;
@@ -92,7 +92,7 @@ mysqlnd_is_key_numeric(char *key, size_t length, long *idx)
 /* }}} */
 
 
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 /* {{{ mysqlnd_unicode_is_key_numeric */
 static zend_bool
 mysqlnd_unicode_is_key_numeric(UChar *key, size_t length, long *idx)
@@ -142,7 +142,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 {
 	unsigned int i = 0;
 	MYSQLND_PACKET_RES_FIELD * field_packet;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 	UChar *ustr;
 	int ulen;
 #endif
@@ -175,7 +175,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 			PACKET_FREE(field_packet);
 			DBG_RETURN(FAIL);
 		}
-		
+
 		if (field_packet->stupid_list_fields_eof == TRUE) {
 			meta->field_count = i;
 			break;
@@ -224,10 +224,9 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
 					meta->bit_fields_total_len += 3;/* 120 */
 					break;
 			}
-			
 		}
 
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen,
 							   meta->fields[i].name,
 							   meta->fields[i].name_length TSRMLS_CC);
@@ -284,7 +283,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA * meta TSRMLS_DC)
 
 	if (meta->zend_hash_keys) {
 		DBG_INF("Freeing zend_hash_keys");
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		if (UG(unicode)) {
 			for (i = 0; i < meta->field_count; i++) {
 				if (meta->zend_hash_keys[i].ustr.v) {
@@ -380,7 +379,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co
 			/* copy the trailing \0 too */
 			memcpy(new_fields[i].def, orig_fields[i].def, orig_fields[i].def_length + 1);
 		}
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		if (new_meta->zend_hash_keys[i].ustr.u) {
 			new_meta->zend_hash_keys[i].ustr.u =
 					eustrndup(new_meta->zend_hash_keys[i].ustr.u, new_meta->zend_hash_keys[i].ulen);
@@ -455,7 +454,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, field_tell)(const MYSQLND_RES_METADATA * const
 /* }}} */
 
 
-static 
+static
 MYSQLND_CLASS_METHODS_START(mysqlnd_res_meta)
 	MYSQLND_METHOD(mysqlnd_res_meta, fetch_field),
 	MYSQLND_METHOD(mysqlnd_res_meta, fetch_field_direct),
@@ -475,7 +474,7 @@ mysqlnd_result_meta_init(unsigned int field_count, zend_bool persistent TSRMLS_D
 	MYSQLND_RES_METADATA *ret = mnd_pecalloc(1, alloc_size, persistent);
 	DBG_ENTER("mysqlnd_result_meta_init");
 	DBG_INF_FMT("persistent=%u", persistent);
-	
+
 	do {
 		if (!ret) {
 			break;
diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c
index 6557e23..d918132 100644
--- a/ext/mysqlnd/mysqlnd_statistics.c
+++ b/ext/mysqlnd/mysqlnd_statistics.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_statistics.c 298217 2010-04-20 13:50:34Z felipe $ */
+/* $Id: mysqlnd_statistics.c 305109 2010-11-05 20:07:34Z andrey $ */
 #include "php.h"
 #include "mysqlnd.h"
 #include "mysqlnd_priv.h"
@@ -190,7 +190,9 @@ const MYSQLND_STRING mysqlnd_stats_values_names[STAT_LAST] =
 	{ STR_W_LEN("com_stmt_reset") },
 	{ STR_W_LEN("com_stmt_set_option") },
 	{ STR_W_LEN("com_stmt_fetch") },
-	{ STR_W_LEN("com_deamon") }
+	{ STR_W_LEN("com_deamon") },
+	{ STR_W_LEN("bytes_received_real_data_normal") },
+	{ STR_W_LEN("bytes_received_real_data_ps") }
 };
 /* }}} */
 
@@ -203,14 +205,14 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING
 
 	mysqlnd_array_init(return_value, stats->count);
 	for (i = 0; i < stats->count; i++) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		UChar *ustr, *tstr;
 		int ulen, tlen;
 #endif
 		char tmp[25];
-		
+
 		sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 		zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, names[i].s, names[i].l + 1 TSRMLS_CC);
 		zend_string_to_unicode(UG(utf8_conv), &tstr, &tlen, tmp, strlen(tmp) + 1 TSRMLS_CC);
 		add_u_assoc_unicode_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen, tstr, 1);
@@ -274,14 +276,14 @@ mysqlnd_stats_end(MYSQLND_STATS * stats)
 
 /* {{{ mysqlnd_stats_set_trigger */
 PHPAPI mysqlnd_stat_trigger
-mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger TSRMLS_DC)
+mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats statistic, mysqlnd_stat_trigger trigger TSRMLS_DC)
 {
 	mysqlnd_stat_trigger ret = NULL;
 	DBG_ENTER("mysqlnd_stats_set_trigger");
 	if (stats) {
 		MYSQLND_STATS_LOCK(stats);
-		ret = stats->triggers[stat];
-		stats->triggers[stat] = trigger;
+		ret = stats->triggers[statistic];
+		stats->triggers[statistic] = trigger;
 		MYSQLND_STATS_UNLOCK(stats);
 	}
 	DBG_RETURN(ret);
diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h
index 3fffe5f..b54db35 100644
--- a/ext/mysqlnd/mysqlnd_statistics.h
+++ b/ext/mysqlnd/mysqlnd_statistics.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_statistics.h 298318 2010-04-22 13:03:44Z andrey $ */
+/* $Id: mysqlnd_statistics.h 303734 2010-09-23 16:03:22Z andrey $ */
 
 #ifndef MYSQLND_STATISTICS_H
 #define MYSQLND_STATISTICS_H
@@ -64,7 +64,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
 			MYSQLND_STAT_CALL_TRIGGER((stats), (statistic), (value)); \
 			MYSQLND_STATS_UNLOCK(_p_s); \
 	}
-	
+
 #define MYSQLND_DEC_STATISTIC(enabler, stats, statistic) \
  { \
 	enum_mysqlnd_collected_stats _s = (statistic);\
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index f229d95..5aa486f 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_structs.h 300735 2010-06-24 19:52:13Z andrey $ */
+/* $Id: mysqlnd_structs.h 304112 2010-10-05 16:27:49Z andrey $ */
 
 #ifndef MYSQLND_STRUCTS_H
 #define MYSQLND_STRUCTS_H
@@ -44,7 +44,7 @@ struct st_mysqlnd_memory_pool
 
 struct st_mysqlnd_memory_pool_chunk
 {
-	uint64_t			app;
+	size_t				app;
 	MYSQLND_MEMORY_POOL	*pool;
 	zend_uchar			*ptr;
 	unsigned int		size;
@@ -161,7 +161,8 @@ typedef struct st_mysqlnd_options
 	char		* unused3;
 	char		* unused4;
 	char		* unused5;
-	zend_bool	unused6;
+
+	enum_mysqlnd_protocol_type protocol;
 
 	char 		*charset_name;
 	/* maximum allowed packet size for communication */
@@ -190,6 +191,7 @@ typedef struct st_mysqlnd_net_options
 	char		*ssl_cipher;
 	char		*ssl_passphrase;
 	zend_bool	ssl_verify_peer;
+	uint64_t	flags;
 } MYSQLND_NET_OPTIONS;
 
 
@@ -335,7 +337,7 @@ struct st_mysqlnd_protocol_methods
 
 
 typedef enum_func_status	(*func_mysqlnd_conn__init)(MYSQLND * conn TSRMLS_DC);
-typedef enum_func_status	(*func_mysqlnd_conn__connect)(MYSQLND *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, unsigned int mysql_flags TSRMLS_DC);
+typedef enum_func_status	(*func_mysqlnd_conn__connect)(MYSQLND *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__escape_string)(const MYSQLND * const conn, char *newstr, const char *escapestr, size_t escapestr_len TSRMLS_DC);
 typedef enum_func_status	(*func_mysqlnd_conn__set_charset)(MYSQLND * const conn, const char * const charset TSRMLS_DC);
 typedef enum_func_status	(*func_mysqlnd_conn__query)(MYSQLND *conn, const char *query, unsigned int query_len TSRMLS_DC);
@@ -400,7 +402,7 @@ typedef enum_func_status	(*func_mysqlnd_conn__restart_psession)(MYSQLND *conn TS
 typedef enum_func_status	(*func_mysqlnd_conn__end_psession)(MYSQLND *conn TSRMLS_DC);
 typedef enum_func_status	(*func_mysqlnd_conn__send_close)(MYSQLND * conn TSRMLS_DC);
 
-typedef void				(*func_mysqlnd_conn__ssl_set)(MYSQLND * const conn, const char * key, const char * const cert, const char * const ca, const char * const capath, const char * const cipher TSRMLS_DC);
+typedef enum_func_status    (*func_mysqlnd_conn__ssl_set)(MYSQLND * const conn, const char * key, const char * const cert, const char * const ca, const char * const capath, const char * const cipher TSRMLS_DC);
 
 typedef MYSQLND_RES * 		(*func_mysqlnd_conn__result_init)(unsigned int field_count, zend_bool persistent TSRMLS_DC);
 
@@ -625,6 +627,7 @@ typedef	void 				(*func_mysqlnd_stmt__free_result_bind)(MYSQLND_STMT * const stm
 typedef unsigned int		(*func_mysqlnd_stmt__server_status)(const MYSQLND_STMT * const stmt TSRMLS_DC);
 typedef enum_func_status 	(*func_mysqlnd_stmt__generate_execute_request)(MYSQLND_STMT * const s, zend_uchar ** request, size_t *request_len, zend_bool * free_buffer TSRMLS_DC);
 typedef enum_func_status	(*func_mysqlnd_stmt__parse_execute_response)(MYSQLND_STMT * const s TSRMLS_DC);
+typedef void 				(*func_mysqlnd_stmt__free_stmt_content)(MYSQLND_STMT * const s TSRMLS_DC);
 
 struct st_mysqlnd_stmt_methods
 {
@@ -676,6 +679,8 @@ struct st_mysqlnd_stmt_methods
 
 	func_mysqlnd_stmt__generate_execute_request generate_execute_request;
 	func_mysqlnd_stmt__parse_execute_response parse_execute_response;
+
+	func_mysqlnd_stmt__free_stmt_content free_stmt_content;
 };
 
 
@@ -788,7 +793,7 @@ struct mysqlnd_field_hash_key
 {
 	zend_bool		is_numeric;
 	unsigned long	key;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 	zstr			ustr;
 	unsigned int	ulen;
 #endif
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index ba31984..810a793 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -243,7 +243,7 @@ php_mysqlnd_read_error_from_line(zend_uchar *buf, size_t buf_len,
 			}
 		}
 		if ((buf_len - (p - buf)) > 0) {
-			error_msg_len = MIN((buf_len - (p - buf)), error_buf_len - 1);
+			error_msg_len = MIN((int)((buf_len - (p - buf))), (int) (error_buf_len - 1));
 			memcpy(error, p, error_msg_len);
 		}
 	}
@@ -391,14 +391,14 @@ premature_end:
 
 /* {{{ php_mysqlnd_greet_free_mem */
 static
-void php_mysqlnd_greet_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_greet_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_GREET *p= (MYSQLND_PACKET_GREET *) _packet;
 	if (p->server_version) {
 		efree(p->server_version);
 		p->server_version = NULL;
 	}
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 }
@@ -508,9 +508,9 @@ size_t php_mysqlnd_auth_write(void *_packet, MYSQLND * conn TSRMLS_DC)
 
 /* {{{ php_mysqlnd_auth_free_mem */
 static
-void php_mysqlnd_auth_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_auth_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
-	if (!alloca) {
+	if (!stack_allocation) {
 		MYSQLND_PACKET_AUTH * p = (MYSQLND_PACKET_AUTH *) _packet;
 		mnd_pefree(p, p->header.persistent);
 	}
@@ -591,14 +591,14 @@ premature_end:
 
 /* {{{ php_mysqlnd_ok_free_mem */
 static void
-php_mysqlnd_ok_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+php_mysqlnd_ok_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_OK *p= (MYSQLND_PACKET_OK *) _packet;
 	if (p->message) {
 		mnd_efree(p->message);
 		p->message = NULL;
 	}
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 }
@@ -674,9 +674,9 @@ premature_end:
 
 /* {{{ php_mysqlnd_eof_free_mem */
 static
-void php_mysqlnd_eof_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_eof_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(_packet, ((MYSQLND_PACKET_EOF *)_packet)->header.persistent);
 	}
 }
@@ -748,9 +748,9 @@ end:
 
 /* {{{ php_mysqlnd_cmd_free_mem */
 static
-void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_cmd_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
-	if (!alloca) {
+	if (!stack_allocation) {
 		MYSQLND_PACKET_COMMAND * p = (MYSQLND_PACKET_COMMAND *) _packet;
 		mnd_pefree(p, p->header.persistent);
 	}
@@ -864,7 +864,7 @@ premature_end:
 
 /* {{{ php_mysqlnd_rset_header_free_mem */
 static
-void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_RSET_HEADER *p= (MYSQLND_PACKET_RSET_HEADER *) _packet;
 	DBG_ENTER("php_mysqlnd_rset_header_free_mem");
@@ -872,7 +872,7 @@ void php_mysqlnd_rset_header_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 		mnd_efree(p->info_or_local_file);
 		p->info_or_local_file = NULL;
 	}
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 	DBG_VOID_RETURN;
@@ -1091,11 +1091,11 @@ premature_end:
 
 /* {{{ php_mysqlnd_rset_field_free_mem */
 static
-void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_RES_FIELD *p= (MYSQLND_PACKET_RES_FIELD *) _packet;
 	/* p->metadata was passed to us as temporal buffer */
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 }
@@ -1106,7 +1106,7 @@ void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 static enum_func_status
 php_mysqlnd_read_row_ex(MYSQLND * conn, MYSQLND_MEMORY_POOL * result_set_memory_pool,
 						MYSQLND_MEMORY_POOL_CHUNK **buffer,
-						uint64_t *data_size, zend_bool persistent_alloc,
+						size_t *data_size, zend_bool persistent_alloc,
 						unsigned int prealloc_more_bytes TSRMLS_DC)
 {
 	enum_func_status ret = PASS;
@@ -1201,23 +1201,29 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv
 
 	DBG_ENTER("php_mysqlnd_rowp_read_binary_protocol");
 
-	end_field = (current_field = start_field = fields) + field_count;
-	if (!current_field) {
+	if (!fields) {
 		DBG_RETURN(FAIL);
 	}
 
+	end_field = (start_field = fields) + field_count;
+
 	/* skip the first byte, not EODATA_MARKER -> 0x0, status */
 	p++;
 	null_ptr= p;
 	p += (field_count + 9)/8;	/* skip null bits */
 	bit	= 4;					/* first 2 bits are reserved */
 
-	for (i = 0; current_field < end_field; current_field++, i++) {
+	for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
 		DBG_INF("Directly creating zval");
 		MAKE_STD_ZVAL(*current_field);
 		if (!*current_field) {
 			DBG_RETURN(FAIL);
 		}
+	}
+
+	for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
+		enum_mysqlnd_collected_stats statistic;
+		zend_uchar * orig_p = p;
 
 		DBG_INF_FMT("Into zval=%p decoding column %u [%s.%s.%s] type=%u field->flags&unsigned=%u flags=%u is_bit=%u as_unicode=%u",
 			*current_field, i,
@@ -1226,13 +1232,12 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv
 		if (*null_ptr & bit) {
 			DBG_INF("It's null");
 			ZVAL_NULL(*current_field);
-			MYSQLND_INC_CONN_STATISTIC(stats, STAT_BINARY_TYPE_FETCHED_NULL);
+			statistic = STAT_BINARY_TYPE_FETCHED_NULL;
 		} else {
 			enum_mysqlnd_field_types type = fields_metadata[i].type;
 			mysqlnd_ps_fetch_functions[type].func(*current_field, &fields_metadata[i], 0, &p, as_unicode TSRMLS_CC);
 
 			if (MYSQLND_G(collect_statistics)) {
-				enum_mysqlnd_collected_stats statistic;
 				switch (fields_metadata[i].type) {
 					case MYSQL_TYPE_DECIMAL:	statistic = STAT_BINARY_TYPE_FETCHED_DECIMAL; break;
 					case MYSQL_TYPE_TINY:		statistic = STAT_BINARY_TYPE_FETCHED_INT8; break;
@@ -1263,9 +1268,13 @@ php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zv
 					case MYSQL_TYPE_GEOMETRY:	statistic = STAT_BINARY_TYPE_FETCHED_GEOMETRY; break;
 					default: statistic = STAT_BINARY_TYPE_FETCHED_OTHER; break;
 				}
-				MYSQLND_INC_CONN_STATISTIC(stats, statistic);
 			}
 		}
+		MYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1,
+										STAT_BYTES_RECEIVED_PURE_DATA_PS,
+										(Z_TYPE_PP(current_field) == IS_STRING)?
+											Z_STRLEN_PP(current_field) : (p - orig_p));
+
 		if (!((bit<<=1) & 255)) {
 			bit = 1;	/* to the following byte */
 			null_ptr++;
@@ -1294,22 +1303,25 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 
 	DBG_ENTER("php_mysqlnd_rowp_read_text_protocol");
 
-	end_field = (current_field = start_field = fields) + field_count;
-	if (!current_field) {
+	if (!fields) {
 		DBG_RETURN(FAIL);
 	}
 
-	for (i = 0; current_field < end_field; current_field++, i++) {
-		/* Don't reverse the order. It is significant!*/
-		zend_uchar *this_field_len_pos = p;
-		/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */
-		unsigned long len = php_mysqlnd_net_field_length(&p);
+	end_field = (start_field = fields) + field_count;
 
+	for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
 		DBG_INF("Directly creating zval");
 		MAKE_STD_ZVAL(*current_field);
 		if (!*current_field) {
 			DBG_RETURN(FAIL);
 		}
+	}
+
+	for (i = 0, current_field = start_field; current_field < end_field; current_field++, i++) {
+		/* Don't reverse the order. It is significant!*/
+		zend_uchar *this_field_len_pos = p;
+		/* php_mysqlnd_net_field_length() call should be after *this_field_len_pos = p; */
+		unsigned long len = php_mysqlnd_net_field_length(&p);
 
 		if (current_field > start_field && last_field_was_string) {
 			/*
@@ -1332,7 +1344,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 			ZVAL_NULL(*current_field);
 			last_field_was_string = FALSE;
 		} else {
-#if PHP_MAJOR_VERSION >= 6 || defined(MYSQLND_STRING_TO_INT_CONVERSION)
+#if MYSQLND_UNICODE || defined(MYSQLND_STRING_TO_INT_CONVERSION)
 			struct st_mysqlnd_perm_bind perm_bind =
 					mysqlnd_ps_fetch_functions[fields_metadata[i].type];
 #endif
@@ -1368,9 +1380,8 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 					case MYSQL_TYPE_GEOMETRY:	statistic = STAT_TEXT_TYPE_FETCHED_GEOMETRY; break;
 					default: statistic = STAT_TEXT_TYPE_FETCHED_OTHER; break;
 				}
-				MYSQLND_INC_CONN_STATISTIC(stats, statistic);
+				MYSQLND_INC_CONN_STATISTIC_W_VALUE2(stats, statistic, 1, STAT_BYTES_RECEIVED_PURE_DATA_TEXT, len);
 			}
-
 #ifdef MYSQLND_STRING_TO_INT_CONVERSION
 			if (as_int_or_float && perm_bind.php_type == IS_LONG) {
 				zend_uchar save = *(p + len);
@@ -1384,7 +1395,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 #else
 						_atoi64((char *) p);
 #endif
-					ZVAL_LONG(*current_field, v);
+					ZVAL_LONG(*current_field, (long) v); /* the cast is safe */
 				} else {
 					uint64_t v =
 #ifndef PHP_WIN32
@@ -1406,7 +1417,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 					{
 						ZVAL_STRINGL(*current_field, (char *)p, len, 0);
 					} else {
-						ZVAL_LONG(*current_field, (int64_t)v);
+						ZVAL_LONG(*current_field, (long) v); /* the cast is safe */
 					}
 				}
 				*(p + len) = save;
@@ -1437,7 +1448,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 				p -= len;
 				if (Z_TYPE_PP(current_field) == IS_LONG) {
 					bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_PP(current_field));
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 					if (as_unicode) {
 						ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
 					} else
@@ -1450,7 +1461,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 					bit_area += Z_STRLEN_PP(current_field);
 					*bit_area++ = '\0';
 					zval_dtor(*current_field);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 					if (as_unicode) {
 						ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
 					} else
@@ -1464,7 +1475,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
 				  the buffers are not referenced - everything is copied.
 				*/
 			} else
-#if PHP_MAJOR_VERSION < 6
+#if MYSQLND_UNICODE == 0
 			{
 				ZVAL_STRINGL(*current_field, (char *)p, len, 0);
 			}
@@ -1519,7 +1530,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 	size_t old_chunk_size = net->stream->chunk_size;
 	MYSQLND_PACKET_ROW *packet= (MYSQLND_PACKET_ROW *) _packet;
 	size_t post_alloc_for_bit_fields = 0;
-	uint64_t data_size = 0;
+	size_t data_size = 0;
 
 	DBG_ENTER("php_mysqlnd_rowp_read");
 
@@ -1606,7 +1617,7 @@ end:
 
 /* {{{ php_mysqlnd_rowp_free_mem */
 static void
-php_mysqlnd_rowp_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+php_mysqlnd_rowp_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_ROW *p;
 
@@ -1616,7 +1627,7 @@ php_mysqlnd_rowp_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 		p->row_buffer->free_chunk(p->row_buffer TSRMLS_CC);
 		p->row_buffer = NULL;
 	}
-	DBG_INF_FMT("alloca=%u persistent=%u", (int)alloca, (int)p->header.persistent);
+	DBG_INF_FMT("stack_allocation=%u persistent=%u", (int)stack_allocation, (int)p->header.persistent);
 	/*
 	  Don't free packet->fields :
 	  - normal queries -> store_result() | fetch_row_unbuffered() will transfer
@@ -1624,7 +1635,7 @@ php_mysqlnd_rowp_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
 	  - PS will pass in it the bound variables, we have to use them! and of course
 	    not free the array. As it is passed to us, we should not clean it ourselves.
 	*/
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 	DBG_VOID_RETURN;
@@ -1656,14 +1667,14 @@ php_mysqlnd_stats_read(void *_packet, MYSQLND *conn TSRMLS_DC)
 
 /* {{{ php_mysqlnd_stats_free_mem */
 static
-void php_mysqlnd_stats_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+void php_mysqlnd_stats_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_STATS *p= (MYSQLND_PACKET_STATS *) _packet;
 	if (p->message) {
 		mnd_efree(p->message);
 		p->message = NULL;
 	}
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 }
@@ -1752,10 +1763,10 @@ premature_end:
 
 /* {{{ php_mysqlnd_prepare_free_mem */
 static void
-php_mysqlnd_prepare_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+php_mysqlnd_prepare_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
 	MYSQLND_PACKET_PREPARE_RESPONSE *p= (MYSQLND_PACKET_PREPARE_RESPONSE *) _packet;
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(p, p->header.persistent);
 	}
 }
@@ -1815,9 +1826,9 @@ premature_end:
 
 /* {{{ php_mysqlnd_chg_user_free_mem */
 static void
-php_mysqlnd_chg_user_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
+php_mysqlnd_chg_user_free_mem(void *_packet, zend_bool stack_allocation TSRMLS_DC)
 {
-	if (!alloca) {
+	if (!stack_allocation) {
 		mnd_pefree(_packet, ((MYSQLND_PACKET_CHG_USER_RESPONSE *)_packet)->header.persistent);
 	}
 }
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.h b/ext/mysqlnd/mysqlnd_wireprotocol.h
index 8d862fc..7fee850 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.h
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysqlnd_wireprotocol.h 299998 2010-05-31 17:57:03Z andrey $ */
+/* $Id: mysqlnd_wireprotocol.h 304116 2010-10-05 17:20:00Z andrey $ */
 
 #ifndef MYSQLND_WIREPROTOCOL_H
 #define MYSQLND_WIREPROTOCOL_H
@@ -53,7 +53,7 @@ typedef struct st_mysqlnd_packet_methods {
 	size_t				struct_size;
 	enum_func_status	(*read_from_net)(void *packet, MYSQLND *conn TSRMLS_DC);
 	size_t				(*write_to_net)(void *packet, MYSQLND *conn TSRMLS_DC);
-	void				(*free_mem)(void *packet, zend_bool alloca TSRMLS_DC);
+	void				(*free_mem)(void *packet, zend_bool stack_allocation TSRMLS_DC);
 } mysqlnd_packet_methods;
 
 
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index 6bfbe2e..e1ddcba 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_mysqlnd.c 300352 2010-06-10 12:24:03Z andrey $ */
+/* $Id: php_mysqlnd.c 304974 2010-10-28 14:07:36Z andrey $ */
 #include "php.h"
 #include "php_ini.h"
 #include "mysqlnd.h"
@@ -37,7 +37,7 @@ static zend_function_entry mysqlnd_functions[] = {
 
 
 /* {{{ mysqlnd_minfo_print_hash */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
 PHPAPI void mysqlnd_minfo_print_hash(zval *values)
 {
 	zval **values_entry;
@@ -122,6 +122,8 @@ PHP_MINFO_FUNCTION(mysqlnd)
 	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");
+
+	php_info_print_table_row(2, "Tracing", MYSQLND_G(debug)? MYSQLND_G(debug):"n/a");
 	php_info_print_table_end();
 
 	/* Print client stats */
@@ -136,7 +138,7 @@ PHP_MINFO_FUNCTION(mysqlnd)
 /* }}} */
 
 
-PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd);
+PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd)
 
 
 /* {{{ PHP_GINIT_FUNCTION
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 841c824..41ced89 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -26,7 +26,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8.c 300752 2010-06-25 21:09:13Z sixd $ */
+/* $Id: oci8.c 305257 2010-11-10 18:59:56Z sixd $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1040,6 +1040,12 @@ static void php_oci_init_global_handles(TSRMLS_D)
 #else
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and " PHP_OCI8_LIB_PATH_MSG " are set and point to the right directories");
 #endif
+		if (OCI_G(env)
+			&& OCIErrorGet(OCI_G(env), (ub4)1, NULL, &ora_error_code, tmp_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ENV) == OCI_SUCCESS
+  			&& *tmp_buf) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tmp_buf);
+		}
+		
 		OCI_G(env) = NULL;
 		OCI_G(err) = NULL;
 		return;
@@ -1293,7 +1299,7 @@ PHP_MINFO_FUNCTION(oci)
 	php_info_print_table_start();
 	php_info_print_table_row(2, "OCI8 Support", "enabled");
 	php_info_print_table_row(2, "Version", PHP_OCI8_VERSION);
-	php_info_print_table_row(2, "Revision", "$Revision: 300752 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 305257 $");
 
 	snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent));
 	php_info_print_table_row(2, "Active Persistent Connections", buf);
@@ -2701,20 +2707,6 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
 	if (OCI_G(errcode) != OCI_SUCCESS) {
 		php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
 		iserror = 1;
-		goto exit_create_spool;
-	}
-
-	/* Set the session pool's timeout to the oci8.persistent_timeout param */
-	if (OCI_G(persistent_timeout)) {
-		ub4 timeout = OCI_G(persistent_timeout);
-
-		PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) session_pool->poolh, (ub4) OCI_HTYPE_SPOOL, (void *) &timeout, (ub4) sizeof(timeout), (ub4) OCI_ATTR_SPOOL_TIMEOUT, OCI_G(err)));
-
-		if (OCI_G(errcode) != OCI_SUCCESS) {
-			php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
-			iserror = 1;
-			goto exit_create_spool;
-		}
 	}
 
 exit_create_spool:
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index a104046..793490c 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_interface.c 293180 2010-01-06 18:58:16Z sixd $ */
+/* $Id: oci8_interface.c 305578 2010-11-20 01:29:03Z sixd $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -242,7 +242,12 @@ PHP_FUNCTION(oci_lob_import)
 			return;
 		}	
 	}
-	
+
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;  
+	}
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
@@ -662,7 +667,7 @@ PHP_FUNCTION(oci_lob_erase)
 			RETURN_FALSE;
 		}
 	}
-	
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
@@ -894,7 +899,12 @@ PHP_FUNCTION(oci_lob_export)
 			RETURN_FALSE;
 		}
 	}
-	
+
+	if (strlen(filename) != filename_len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
+		RETURN_FALSE;  
+	}
+
 	if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
 		RETURN_FALSE;
@@ -918,7 +928,7 @@ PHP_FUNCTION(oci_lob_export)
 		/* nothing to write, fail silently */
 		RETURN_FALSE;
 	}
-	
+
 	if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
@@ -1666,8 +1676,8 @@ PHP_FUNCTION(oci_num_fields)
 }
 /* }}} */
 
-/* {{{ proto resource oci_parse(resource connection, string query)
-   Parse a query and return a statement */
+/* {{{ proto resource oci_parse(resource connection, string statement)
+   Parse a SQL or PL/SQL statement and return a statement resource */
 PHP_FUNCTION(oci_parse)
 {
 	zval *z_connection;
@@ -1719,7 +1729,7 @@ PHP_FUNCTION(oci_set_client_identifier)
 	zval *z_connection;
 	php_oci_connection *connection;
 	char *client_id;
-	long client_id_len;
+	int client_id_len;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_len) == FAILURE) {
 		return;
@@ -1744,7 +1754,7 @@ PHP_FUNCTION(oci_set_edition)
 {
 #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
 	char *edition;
-	long edition_len;
+	int edition_len;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &edition, &edition_len) == FAILURE) {
 		return;
@@ -1777,7 +1787,7 @@ PHP_FUNCTION(oci_set_module_name)
 	zval *z_connection;
 	php_oci_connection *connection;
 	char *module;
-	long module_len;
+	int module_len;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_len) == FAILURE) {
 		return;
@@ -1808,7 +1818,7 @@ PHP_FUNCTION(oci_set_action)
 	zval *z_connection;
 	php_oci_connection *connection;
 	char *action;
-	long action_len;
+	int action_len;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_len) == FAILURE) {
 		return;
@@ -1839,7 +1849,7 @@ PHP_FUNCTION(oci_set_client_info)
 	zval *z_connection;
 	php_oci_connection *connection;
 	char *client_info;
-	long client_info_len;
+	int client_info_len;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_len) == FAILURE) {
 		return;
diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml
index 8e0f36d..7f87705 100644
--- a/ext/oci8/package.xml
+++ b/ext/oci8/package.xml
@@ -33,23 +33,20 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <active>no</active>
  </lead>
 
- <date>2010-06-25</date>
+ <date>2010-11-16</date>
  <time>15:00:00</time>
 
  <version>
-  <release>1.4.2</release>
-  <api>1.4.2</api>
+  <release>1.4.5</release>
+  <api>1.4.5</api>
  </version>
  <stability>
-  <release>stable</release>
+  <release>devel</release>
   <api>stable</api>
  </stability>
  <license uri="http://www.php.net/license">PHP</license>
  <notes>
-    Fixed bug #51691 (Unnecessary realloc causes crashes in PHP trunk tests with interned strings)
-    Fixed bug #51291 (oci_error doesn't report last error when called two times)
-    Fixed bug #51577 (Uninitialized memory reference with oci_bind_array_by_name)
-    Fixed bug #52186 (phpinfo() shows 10.1 or 11.1 when installed with ORACLE_HOME 10.2 or 11.2)
+    Protect against null bytes in LOB filenames (http://news.php.net/php.internals/50202)
  </notes>
  <contents>
   <dir name="/">
@@ -186,6 +183,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <file name="connect_scope_try5.phpt" role="test" />
     <file name="connect_scope_try6.phpt" role="test" />
     <file name="connect_with_charset_001.phpt" role="test" />
+    <file name="connect_without_oracle_home_11.phpt" role="test" />
+    <file name="connect_without_oracle_home_old_11.phpt" role="test" />
     <file name="connect_without_oracle_home_old.phpt" role="test" />
     <file name="connect_without_oracle_home.phpt" role="test" />
     <file name="create_table.inc" role="test" />
@@ -308,6 +307,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <file name="lob_temp1.phpt" role="test" />
     <file name="lob_temp.phpt" role="test" />
     <file name="minfo.phpt" role="test" />
+    <file name="null_byte_1.phpt" role="test" />
+    <file name="null_byte_2.phpt" role="test" />
     <file name="num.phpt" role="test" />
     <file name="oci8safemode.phpt" role="test" />
     <file name="oci_execute_segfault.phpt" role="test" />
@@ -381,6 +382,57 @@ http://pear.php.net/dtd/package-2.0.xsd">
 
 <release>
  <version>
+  <release>1.4.4</release>
+  <api>1.4.4</api>
+ </version>
+ <stability>
+  <release>stable</release>
+  <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+    Fixed bug #53284 (Valgrind warnings in oci_set_* functions)
+    Enhancement - improve startup failure error messages
+ </notes>
+</release>
+
+<release>
+ <version>
+  <release>1.4.3</release>
+  <api>1.4.3</api>
+ </version>
+ <stability>
+  <release>stable</release>
+  <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+    Fixed bug #51610 (Using oci_connect causes PHP to take a long time to exit). Requires Oracle 11.2.0.2 client libraries (or Oracle bug fix 9891199) for this patch to have an effect.
+ </notes>
+</release>
+
+<release>
+ <version>
+  <release>1.4.2</release>
+  <api>1.4.2</api>
+ </version>
+ <stability>
+  <release>stable</release>
+  <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+    Fixed bug #52186 (phpinfo() shows 10.1 or 11.1 when installed with ORACLE_HOME 10.2 or 11.2)
+    Fixed bug #51691 (Unnecessary realloc causes crashes in PHP trunk tests with interned strings)
+    Fixed bug #51577 (Uninitialized memory reference with oci_bind_array_by_name)
+    Fixed bug #51291 (oci_error doesn't report last error when called two times)
+
+    OCI8 1.4.2 is included in PHP 5.3.3
+ </notes>
+</release>
+
+<release>
+ <version>
   <release>1.4.1</release>
   <api>1.4.1</api>
  </version>
diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h
index d4b90ff..1598850 100644
--- a/ext/oci8/php_oci8.h
+++ b/ext/oci8/php_oci8.h
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_oci8.h 300753 2010-06-25 21:18:09Z sixd $ */
+/* $Id: php_oci8.h 305896 2010-12-01 23:30:28Z sixd $ */
 
 #if HAVE_OCI8
 # ifndef PHP_OCI8_H
@@ -46,7 +46,7 @@
  */
 #undef PHP_OCI8_VERSION
 #endif
-#define PHP_OCI8_VERSION "1.4.2"
+#define PHP_OCI8_VERSION "1.4.5"
 
 extern zend_module_entry oci8_module_entry;
 #define phpext_oci8_ptr &oci8_module_entry
diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt
index 71cccbf..24ab1fc 100644
--- a/ext/oci8/tests/bind_char_1.phpt
+++ b/ext/oci8/tests/bind_char_1.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
-
 require(dirname(__FILE__).'/connect.inc');
 
 // Initialization
diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt
index 6c7dbaf..fa2e547 100644
--- a/ext/oci8/tests/bind_char_2.phpt
+++ b/ext/oci8/tests/bind_char_2.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
-
 require(dirname(__FILE__).'/connect.inc');
 
 // Initialization
diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt
index 8d4e95f..052981a 100644
--- a/ext/oci8/tests/bind_char_3.phpt
+++ b/ext/oci8/tests/bind_char_3.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
-
 require(dirname(__FILE__).'/connect.inc');
 
 // Initialization
diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt
index 40221b2..fd38d90 100644
--- a/ext/oci8/tests/bind_char_4.phpt
+++ b/ext/oci8/tests/bind_char_4.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff on the undefined cases with a 32bit 11.2.0.1 DB
-
 // Same test as bind_char_3 but the PL/SQL function uses VARCHAR2 instead of CHAR
 
 require(dirname(__FILE__).'/connect.inc');
diff --git a/ext/oci8/tests/bug27303_1.phpt b/ext/oci8/tests/bug27303_1.phpt
index 82c2d6f..6d49196 100644
--- a/ext/oci8/tests/bug27303_1.phpt
+++ b/ext/oci8/tests/bug27303_1.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 19gR2 or 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff with a 32bit 11.2.0.1 DB
-
 require dirname(__FILE__).'/connect.inc';
 	
 $create_st = array();
diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt
index 44b9ce6..3d0c087 100644
--- a/ext/oci8/tests/bug27303_2.phpt
+++ b/ext/oci8/tests/bug27303_2.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 database");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff with a 32bit 11.2.0.1 DB
-
 require dirname(__FILE__).'/connect.inc';
 	
 $create_st = array();
diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt
index 3c35c65..20dec54 100644
--- a/ext/oci8/tests/bug27303_4.phpt
+++ b/ext/oci8/tests/bug27303_4.phpt
@@ -8,14 +8,19 @@ $sv = oci_server_version($c);
 $sv = preg_match('/Release 1[01]\.2\./', $sv, $matches);
 if ($sv !== 1) {
 	die ("skip expected output only valid when using Oracle 10gR2 or 11gR2 databases");
+} else {
+    ob_start();
+    phpinfo(INFO_MODULES);
+    $phpinfo = ob_get_clean();
+    $iv = preg_match('/Oracle .*Version => 1[1]\./', $phpinfo);
+    if ($iv != 1) {
+        die ("skip test expected to work only with Oracle 11g or greater version of client");
+    }
 }
 ?>
 --FILE--
 <?php
 
-// Note: expected output is valid for 32bit clients to 32bit 10gR2 XE or 11.2.0.1 64bit DBs.
-// It will diff with a 32bit 11.2.0.1 DB
-
 require dirname(__FILE__).'/connect.inc';
 	
 $create_st = array();
diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt
index 42cbde8..e14fb93 100644
--- a/ext/oci8/tests/connect_without_oracle_home.phpt
+++ b/ext/oci8/tests/connect_without_oracle_home.phpt
@@ -10,6 +10,10 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo);
 if ($ov !== 1) {
 	die ("skip Test only valid when OCI8 is built with an ORACLE_HOME");
 }
+$iv = preg_match('/Oracle .*Version => (10\.2)/', $phpinfo);
+if ($iv != 1) {
+    die ("skip tests a feature that works only with Oracle 10gR2");
+}
 ?>
 --ENV--
 ORACLE_HOME=""
diff --git a/ext/oci8/tests/connect_without_oracle_home_11.phpt b/ext/oci8/tests/connect_without_oracle_home_11.phpt
new file mode 100644
index 0000000..be99a8b
--- /dev/null
+++ b/ext/oci8/tests/connect_without_oracle_home_11.phpt
@@ -0,0 +1,41 @@
+--TEST--
+oci_connect() without ORACLE_HOME set (OCIServerAttach() segfaults)
+--SKIPIF--
+<?php 
+if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo);
+if ($ov != 1) {
+	die ("skip Test only valid when OCI8 is built with an ORACLE_HOME");
+}
+$iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+if ($iv != 1) {
+        die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+}
+?>
+--ENV--
+ORACLE_HOME=""
+--FILE--
+<?php
+
+require dirname(__FILE__)."/details.inc";
+
+if (!empty($dbase)) {
+	var_dump(oci_connect($user, $password, $dbase));
+}
+else {
+	var_dump(oci_connect($user, $password));
+}
+	
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d
+
+Warning: oci_connect(): Error while trying to retrieve text for error ORA-01804
+ in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/oci8/tests/connect_without_oracle_home_old.phpt b/ext/oci8/tests/connect_without_oracle_home_old.phpt
index 82d8ae4..602d55f 100644
--- a/ext/oci8/tests/connect_without_oracle_home_old.phpt
+++ b/ext/oci8/tests/connect_without_oracle_home_old.phpt
@@ -10,6 +10,10 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo);
 if ($ov !== 1) {
 	die ("skip Test only valid when OCI8 is built with an ORACLE_HOME");
 }
+$iv = preg_match('/Oracle .*Version => (10\.2)/', $phpinfo);
+if ($iv != 1) {
+    die ("skip tests a feature that works only with Oracle 10gR2");
+}
 ?>
 --ENV--
 ORACLE_HOME=""
diff --git a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt
new file mode 100644
index 0000000..9bb42e7
--- /dev/null
+++ b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt
@@ -0,0 +1,41 @@
+--TEST--
+ocilogon() without ORACLE_HOME set (OCIServerAttach() segfaults)
+--SKIPIF--
+<?php 
+if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo);
+if ($ov !== 1) {
+	die ("skip Test only valid when OCI8 is built with an ORACLE_HOME");
+}
+$iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+if ($iv != 1) {
+    die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+}
+?>
+--ENV--
+ORACLE_HOME=""
+--FILE--
+<?php
+
+require dirname(__FILE__)."/details.inc";
+
+if (!empty($dbase)) {
+	var_dump(ocilogon($user, $password, $dbase));
+}
+else {
+	var_dump(ocilogon($user, $password));
+}
+	
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: ocilogon(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and %s are set and point to the right directories in %s on line %d
+
+Warning: ocilogon(): Error while trying to retrieve text for error ORA-01804
+ in %sconnect_without_oracle_home_old_11.php on line %d
+bool(false)
+===DONE===
diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt
index 49e3d4c..fe96e6e 100644
--- a/ext/oci8/tests/debug.phpt
+++ b/ext/oci8/tests/debug.phpt
@@ -1,16 +1,7 @@
 --TEST--
 oci_internal_debug()
 --SKIPIF--
-<?php 
-if (!extension_loaded('oci8')) die("skip no oci8 extension"); 
-ob_start();
-phpinfo(INFO_MODULES);
-$phpinfo = ob_get_clean();
-$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
-if ($iv !== 1) {
-   	die ("skip expected output only valid when using Oracle 11gR2+ client libraries");
-}
-?>
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
 --FILE--
 <?php
 
@@ -27,45 +18,8 @@ else {
 	
 echo "Done\n";
 
+oci_internal_debug(false);
+
 ?>
---EXPECTF--
-OCI8 DEBUG: OCINlsEnvironmentVariableGet at (%s:%d) 
-OCI8 DEBUG L1: Got NO cached connection at (%s:%d) 
-OCI8 DEBUG: OCIEnvNlsCreate at (%s:%d) 
-OCI8 DEBUG: OCIHandleAlloc at (%s:%d) 
-OCI8 DEBUG: OCIHandleAlloc at (%s:%d) 
-OCI8 DEBUG: OCIHandleAlloc at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG: OCISessionPoolCreate at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG L1: create_spool: (%s:%d) 
-OCI8 DEBUG L1: using shared pool: (%s:%d) 
-OCI8 DEBUG: OCIHandleAlloc at (%s:%d) 
-OCI8 DEBUG: OCIHandleAlloc at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG: OCIAttrGet at (%s:%d) 
-OCI8 DEBUG: OCIAttrGet at (%s:%d) 
-OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (%s:%d) 
-OCI8 DEBUG: OCISessionGet at (%s:%d) 
-OCI8 DEBUG: OCIAttrGet at (%s:%d) 
-OCI8 DEBUG: OCIAttrGet at (%s:%d) 
-OCI8 DEBUG: OCIContextGetValue at (%s:%d) 
-OCI8 DEBUG: OCIContextGetValue at (%s:%d) 
-OCI8 DEBUG: OCIMemoryAlloc at (%s:%d) 
-OCI8 DEBUG: OCIContextSetValue at (%s:%d) 
-OCI8 DEBUG: OCIAttrSet at (%s:%d) 
-OCI8 DEBUG L1: New Non-Persistent Connection address: (%s) at (%s:%d) 
-OCI8 DEBUG L1: num_persistent=(%s:%d) 
-OCI8 DEBUG: OCISessionRelease at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-Done
-OCI8 DEBUG: OCISessionPoolDestroy at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d) 
-OCI8 DEBUG: OCIHandleFree at (%s:%d)
+--EXPECTREGEX--
+^OCI8 DEBUG: .*Done$
diff --git a/ext/oci8/tests/null_byte_1.phpt b/ext/oci8/tests/null_byte_1.phpt
new file mode 100644
index 0000000..1439bd5
--- /dev/null
+++ b/ext/oci8/tests/null_byte_1.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Protect against null bytes in LOB filenames (http://news.php.net/php.internals/50202)
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--INI--
+display_errors = On
+error_reporting = E_WARNING
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Run Test
+
+echo "Test 1: Import\n";
+
+$lob = oci_new_descriptor($c, OCI_D_LOB);
+$r = $lob->savefile("/tmp/abc\0def");
+var_dump($r);
+
+echo "Test 2: Export\n";
+
+$r = $lob->export("/tmp/abc\0def");
+var_dump($r);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1: Import
+
+Warning: OCI-Lob::savefile(): Filename cannot contain null bytes in %snull_byte_1.php on line %d
+bool(false)
+Test 2: Export
+
+Warning: OCI-Lob::export(): Filename cannot contain null bytes in %snull_byte_1.php on line %d
+bool(false)
+===DONE===
diff --git a/ext/oci8/tests/null_byte_2.phpt b/ext/oci8/tests/null_byte_2.phpt
new file mode 100644
index 0000000..b4c9b61
--- /dev/null
+++ b/ext/oci8/tests/null_byte_2.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Null bytes in SQL statements
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+--INI--
+display_errors = On
+error_reporting = E_WARNING
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+// Run Test
+
+echo "Test 1: Valid use of a null byte\n";
+
+$s = oci_parse($c, "select * \0from dual");
+oci_execute($s);
+oci_fetch_all($s, $res);
+var_dump($res);
+
+echo "Test 2: Invalid use of a null byte\n";
+
+$s = oci_parse($c, "select * from du\0al");
+oci_execute($s);
+
+echo "Test 3: Using a null byte in a bind variable name\n";
+
+$s = oci_parse($c, "select * from dual where :bv = 1");
+$bv = 1;
+oci_bind_by_name($s, ":bv\0:bv", $bv);
+oci_execute($s);
+ 
+echo "Test 4: Using a null byte in a bind variable value causing WHERE clause to fail\n";
+
+$s = oci_parse($c, "select * from dual where :bv = 'abc'");
+$bv = 'abc\0abc';
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+oci_fetch_all($s, $res);
+var_dump($res);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test 1: Valid use of a null byte
+array(1) {
+  ["DUMMY"]=>
+  array(1) {
+    [0]=>
+    string(1) "X"
+  }
+}
+Test 2: Invalid use of a null byte
+
+Warning: oci_execute(): ORA-00942: %s in %snull_byte_2.php on line %d
+Test 3: Using a null byte in a bind variable name
+
+Warning: oci_bind_by_name(): ORA-01036: %s in %snull_byte_2.php on line %d
+
+Warning: oci_execute(): ORA-01008: %s in %snull_byte_2.php on line %d
+Test 4: Using a null byte in a bind variable value causing WHERE clause to fail
+array(1) {
+  ["DUMMY"]=>
+  array(0) {
+  }
+}
+===DONE===
diff --git a/ext/oci8/tests/oci8safemode.phpt b/ext/oci8/tests/oci8safemode.phpt
index 1c62f36..02e180e 100644
--- a/ext/oci8/tests/oci8safemode.phpt
+++ b/ext/oci8/tests/oci8safemode.phpt
@@ -15,7 +15,7 @@ $r = oci_password_change($c, "hr", "hrpwd", "hrpwd");
 echo "Done\n";
 ?>
 --EXPECTF--
-%sarning:%sDirective 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+%s: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Warning: oci_connect(): Privileged connect is disabled in Safe Mode in %s on line %d
 
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 9214540..756c3b3 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_odbc.c 296467 2010-03-20 18:19:16Z felipe $ */
+/* $Id: php_odbc.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1262,11 +1262,19 @@ PHP_FUNCTION(odbc_execute)
 
 		zend_hash_internal_pointer_reset(Z_ARRVAL_P(pv_param_arr));
 		params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0);
+		for(i = 0; i < result->numparams; i++) {
+			params[i].fp = -1;
+		}
 		
 		for(i = 1; i <= result->numparams; i++) {
 			if (zend_hash_get_current_data(Z_ARRVAL_P(pv_param_arr), (void **) &tmp) == FAILURE) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error getting parameter");
 				SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
+				for (i = 0; i < result->numparams; i++) {
+					if (params[i].fp != -1) {
+						close(params[i].fp);
+					}
+				}
 				efree(params);
 				RETURN_FALSE;
 			}
@@ -1276,13 +1284,29 @@ PHP_FUNCTION(odbc_execute)
 			if (Z_TYPE_PP(tmp) != IS_STRING) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING,"Error converting parameter");
 				SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
+				for (i = 0; i < result->numparams; i++) {
+					if (params[i].fp != -1) {
+						close(params[i].fp);
+					}
+				}
 				efree(params);
 				RETURN_FALSE;
 			}
 			
-			SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision, &scale, &nullable);
+			rc = SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision, &scale, &nullable);
 			params[i-1].vallen = Z_STRLEN_PP(tmp);
 			params[i-1].fp = -1;
+			if (rc == SQL_ERROR) {
+				odbc_sql_error(result->conn_ptr, result->stmt, "SQLDescribeParameter");	
+				SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
+				for (i = 0; i < result->numparams; i++) {
+					if (params[i].fp != -1) {
+						close(params[i].fp);
+					}
+				}
+				efree(params);
+				RETURN_FALSE;
+			}
 
 			if (IS_SQL_BINARY(sqltype)) {
 				ctype = SQL_C_BINARY;
@@ -1293,8 +1317,11 @@ PHP_FUNCTION(odbc_execute)
 			if (Z_STRLEN_PP(tmp) > 2 &&
 				Z_STRVAL_PP(tmp)[0] == '\'' &&
 				Z_STRVAL_PP(tmp)[Z_STRLEN_PP(tmp) - 1] == '\'') {
+				if (strlen(tmp) != Z_STRLEN_PP(tmp)) {
+					RETURN_FALSE;
+				}
+
 				filename = estrndup(&Z_STRVAL_PP(tmp)[1], Z_STRLEN_PP(tmp) - 2);
-				filename[strlen(filename)] = '\0';
 
 				/* Check for safe mode. */
 				if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
@@ -1306,6 +1333,12 @@ PHP_FUNCTION(odbc_execute)
 				/* Check the basedir */
 				if (php_check_open_basedir(filename TSRMLS_CC)) {
 					efree(filename);
+					SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
+					for (i = 0; i < result->numparams; i++) {
+						if (params[i].fp != -1) {
+							close(params[i].fp);
+						}
+					}
 					efree(params);
 					RETURN_FALSE;
 				}
@@ -1313,7 +1346,7 @@ PHP_FUNCTION(odbc_execute)
 				if ((params[i-1].fp = open(filename,O_RDONLY)) == -1) {
 					php_error_docref(NULL TSRMLS_CC, E_WARNING,"Can't open file %s", filename);
 					SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
-					for(i = 0; i < result->numparams; i++) {
+					for (i = 0; i < result->numparams; i++) {
 						if (params[i].fp != -1) {
 							close(params[i].fp);
 						}
@@ -1344,6 +1377,17 @@ PHP_FUNCTION(odbc_execute)
 									  Z_STRVAL_PP(tmp), 0,
 									  &params[i-1].vallen);
 			}
+			if (rc == SQL_ERROR) {
+				odbc_sql_error(result->conn_ptr, result->stmt, "SQLBindParameter");	
+				SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
+				for (i = 0; i < result->numparams; i++) {
+					if (params[i].fp != -1) {
+						close(params[i].fp);
+					}
+				}
+				efree(params);
+				RETURN_FALSE;
+			}
 			zend_hash_move_forward(Z_ARRVAL_P(pv_param_arr));
 		}
 	}
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index af968c8..ce36bd2 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: openssl.c 300764 2010-06-26 16:03:39Z felipe $ */
+/* $Id: openssl.c 305902 2010-12-02 11:37:43Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -702,7 +702,7 @@ static time_t asn1_time_to_time_t(ASN1_UTCTIME * timestr TSRMLS_DC) /* {{{ */
 #if OPENSSL_VERSION_NUMBER >= 0x10000002L
 static inline int php_openssl_config_check_syntax(const char * section_label, const char * config_filename, const char * section, LHASH_OF(CONF_VALUE) * config TSRMLS_DC) /* {{{ */
 #else
-static inline int php_openssl_config_check_syntax(const char * section_label, const char * config_filename, const char * section, LHASH * config TSRMLS_DC) /* {{{ */
+static inline int php_openssl_config_check_syntax(const char * section_label, const char * config_filename, const char * section, LHASH * config TSRMLS_DC)
 #endif
 {
 	X509V3_CTX ctx;
@@ -868,10 +868,7 @@ static int php_openssl_load_rand_file(const char * file, int *egdsocket, int *se
 
 	*egdsocket = 0;
 	*seeded = 0;
-	
-#ifdef WINDOWS
-	RAND_screen();
-#endif
+
 	if (file == NULL) {
 		file = RAND_file_name(buffer, sizeof(buffer));
 	} else if (RAND_egd(file) > 0) {
@@ -1771,6 +1768,10 @@ PHP_FUNCTION(openssl_pkcs12_export_to_file)
 		return;
 
 	RETVAL_FALSE;
+
+	if (strlen(filename) != filename_len) {
+		return;
+	}
 	
 	cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
 	if (cert == NULL) {
@@ -2117,7 +2118,8 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z
 		if (attribs) {
 			zend_hash_internal_pointer_reset_ex(HASH_OF(attribs), &hpos);
 			while(zend_hash_get_current_data_ex(HASH_OF(attribs), (void**)&item, &hpos) == SUCCESS) {
-				char * strindex; uint strindexlen;
+				char *strindex = NULL;
+				uint strindexlen;
 				ulong intindex;
 
 				zend_hash_get_current_key_ex(HASH_OF(attribs), &strindex, &strindexlen, &intindex, 0, &hpos);
@@ -2218,6 +2220,10 @@ PHP_FUNCTION(openssl_csr_export_to_file)
 	}
 	RETVAL_FALSE;
 
+	if (strlen(filename) != filename_len) {
+		return;
+	}
+
 	csr = php_openssl_csr_from_zval(&zcsr, 0, &csr_resource TSRMLS_CC);
 	if (csr == NULL) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get CSR from parameter 1");
@@ -3002,6 +3008,10 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
 	}
 	RETVAL_FALSE;
 
+	if (strlen(filename) != filename_len) {
+		return;
+	}
+
 	key = php_openssl_evp_from_zval(zpkey, 0, passphrase, 0, &key_resource TSRMLS_CC);
 
 	if (key == NULL) {
@@ -3394,7 +3404,14 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
 				&outfilename, &outfilename_len, &zrecipcerts, &zheaders, &flags, &cipherid) == FAILURE)
 		return;
 
-	
+	if (strlen(infilename) != infilename_len) {
+		return;
+	}
+
+	if (strlen(outfilename) != outfilename_len) {
+		return;
+	}
+
 	if (php_openssl_safe_mode_chk(infilename TSRMLS_CC) || php_openssl_safe_mode_chk(outfilename TSRMLS_CC)) {
 		return;
 	}
@@ -3526,14 +3543,22 @@ PHP_FUNCTION(openssl_pkcs7_sign)
 	char * outfilename;	int outfilename_len;
 	char * extracertsfilename = NULL; int extracertsfilename_len;
 
+	RETVAL_FALSE;
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssZZa!|ls",
 				&infilename, &infilename_len, &outfilename, &outfilename_len,
 				&zcert, &zprivkey, &zheaders, &flags, &extracertsfilename,
 				&extracertsfilename_len) == FAILURE) {
 		return;
 	}
-	
-	RETVAL_FALSE;
+
+	if (strlen(infilename) != infilename_len) {
+		return;
+	}
+
+	if (strlen(outfilename) != outfilename_len) {
+		return;
+	}
 
 	if (extracertsfilename) {
 		others = load_all_certs_from_file(extracertsfilename);
@@ -3630,12 +3655,20 @@ PHP_FUNCTION(openssl_pkcs7_decrypt)
 	char * infilename;	int infilename_len;
 	char * outfilename;	int outfilename_len;
 
+	RETVAL_FALSE;
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssZ|Z", &infilename, &infilename_len,
 				&outfilename, &outfilename_len, &recipcert, &recipkey) == FAILURE) {
 		return;
 	}
 
-	RETVAL_FALSE;
+	if (strlen(infilename) != infilename_len) {
+		return;
+	}
+
+	if (strlen(outfilename) != outfilename_len) {
+		return;
+	}
 
 	cert = php_openssl_x509_from_zval(recipcert, 0, &certresval TSRMLS_CC);
 	if (cert == NULL) {
@@ -4638,7 +4671,7 @@ PHP_FUNCTION(openssl_encrypt)
 {
 	zend_bool raw_output = 0;
 	char *data, *method, *password, *iv = "";
-	int data_len, method_len, password_len, iv_len = 0;
+	int data_len, method_len, password_len, iv_len = 0, max_iv_len;
 	const EVP_CIPHER *cipher_type;
 	EVP_CIPHER_CTX cipher_ctx;
 	int i, outlen, keylen;
@@ -4663,10 +4696,11 @@ PHP_FUNCTION(openssl_encrypt)
 		key = (unsigned char*)password;
 	}
 
-	if (iv_len <= 0) {
+	max_iv_len = EVP_CIPHER_iv_length(cipher_type);
+	if (iv_len <= 0 && max_iv_len > 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Using an empty Initialization Vector (iv) is potentially insecure and not recommended");
 	}
-	free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type) TSRMLS_CC);
+	free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);
 
 	outlen = data_len + EVP_CIPHER_block_size(cipher_type);
 	outbuf = emalloc(outlen + 1);
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index 74a54d8..135a9b0 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: xp_ssl.c 300617 2010-06-20 16:33:16Z pajoye $ */
+/* $Id: xp_ssl.c 303839 2010-09-29 01:25:35Z felipe $ */
 
 #include "php.h"
 #include "ext/standard/file.h"
@@ -502,7 +502,6 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
 										zend_list_insert(mycert,
 											php_openssl_get_x509_list_id()));
 								add_next_index_zval(arr, zcert);
-								FREE_ZVAL(zcert);
 							}
 
 						} else {
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 458e1ad..09ccd77 100755
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: pcntl.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: pcntl.c 305020 2010-11-01 22:43:59Z lbarnaud $ */
 
 #define PCNTL_DEBUG 0
 
@@ -44,6 +44,8 @@
 #include <sys/resource.h>
 #endif
 
+#include <errno.h>
+
 ZEND_DECLARE_MODULE_GLOBALS(pcntl)
 static PHP_GINIT_FUNCTION(pcntl);
 
@@ -134,6 +136,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_setpriority, 0, 0, 1)
 	ZEND_ARG_INFO(0, process_identifier)
 ZEND_END_ARG_INFO()
 #endif
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pcntl_strerror, 0, 0, 1)
+        ZEND_ARG_INFO(0, errno)
+ZEND_END_ARG_INFO()
 /* }}} */
 
 const zend_function_entry pcntl_functions[] = {
@@ -150,6 +156,9 @@ const zend_function_entry pcntl_functions[] = {
 	PHP_FE(pcntl_wstopsig,		arginfo_pcntl_wstopsig)
 	PHP_FE(pcntl_exec,			arginfo_pcntl_exec)
 	PHP_FE(pcntl_alarm,			arginfo_pcntl_alarm)
+	PHP_FE(pcntl_get_last_error,	arginfo_pcntl_void)
+	PHP_FALIAS(pcntl_errno, pcntl_get_last_error,	NULL)
+	PHP_FE(pcntl_strerror,		arginfo_pcntl_strerror)
 #ifdef HAVE_GETPRIORITY
 	PHP_FE(pcntl_getpriority,	arginfo_pcntl_getpriority)
 #endif
@@ -407,6 +416,73 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
 	/* }}} */
 }
 
+static void php_pcntl_register_errno_constants(INIT_FUNC_ARGS)
+{
+#ifdef EINTR
+	REGISTER_PCNTL_ERRNO_CONSTANT(EINTR);
+#endif
+#ifdef ECHILD
+	REGISTER_PCNTL_ERRNO_CONSTANT(ECHILD);
+#endif
+#ifdef EINVAL
+	REGISTER_PCNTL_ERRNO_CONSTANT(EINVAL);
+#endif
+#ifdef EAGAIN
+	REGISTER_PCNTL_ERRNO_CONSTANT(EAGAIN);
+#endif
+#ifdef ESRCH
+	REGISTER_PCNTL_ERRNO_CONSTANT(ESRCH);
+#endif
+#ifdef EACCES
+	REGISTER_PCNTL_ERRNO_CONSTANT(EACCES);
+#endif
+#ifdef EPERM
+	REGISTER_PCNTL_ERRNO_CONSTANT(EPERM);
+#endif
+#ifdef ENOMEM
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENOMEM);
+#endif
+#ifdef E2BIG
+	REGISTER_PCNTL_ERRNO_CONSTANT(E2BIG);
+#endif
+#ifdef EFAULT
+	REGISTER_PCNTL_ERRNO_CONSTANT(EFAULT);
+#endif
+#ifdef EIO
+	REGISTER_PCNTL_ERRNO_CONSTANT(EIO);
+#endif
+#ifdef EISDIR
+	REGISTER_PCNTL_ERRNO_CONSTANT(EISDIR);
+#endif
+#ifdef ELIBBAD
+	REGISTER_PCNTL_ERRNO_CONSTANT(ELIBBAD);
+#endif
+#ifdef ELOOP
+	REGISTER_PCNTL_ERRNO_CONSTANT(ELOOP);
+#endif
+#ifdef EMFILE
+	REGISTER_PCNTL_ERRNO_CONSTANT(EMFILE);
+#endif
+#ifdef ENAMETOOLONG
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENAMETOOLONG);
+#endif
+#ifdef ENFILE
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENFILE);
+#endif
+#ifdef ENOENT
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENOENT);
+#endif
+#ifdef ENOEXEC
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENOEXEC);
+#endif
+#ifdef ENOTDIR
+	REGISTER_PCNTL_ERRNO_CONSTANT(ENOTDIR);
+#endif
+#ifdef ETXTBSY
+	REGISTER_PCNTL_ERRNO_CONSTANT(ETXTBSY);
+#endif
+}
+
 static PHP_GINIT_FUNCTION(pcntl)
 { 
 	memset(pcntl_globals, 0, sizeof(*pcntl_globals));
@@ -422,6 +498,7 @@ PHP_RINIT_FUNCTION(pcntl)
 PHP_MINIT_FUNCTION(pcntl)
 {
 	php_register_signal_constants(INIT_FUNC_ARGS_PASSTHRU);
+	php_pcntl_register_errno_constants(INIT_FUNC_ARGS_PASSTHRU);
 	php_add_tick_function(pcntl_signal_dispatch);
 
 	return SUCCESS;
@@ -467,6 +544,7 @@ PHP_FUNCTION(pcntl_fork)
 
 	id = fork();
 	if (id == -1) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d", errno);
 	}
 	
@@ -505,6 +583,10 @@ PHP_FUNCTION(pcntl_waitpid)
 
 	child_id = waitpid((pid_t) pid, &status, options);
 
+	if (child_id < 0) {
+		PCNTL_G(last_error) = errno;
+	}
+
 	Z_LVAL_P(z_status) = status;
 
 	RETURN_LONG((long) child_id);
@@ -536,6 +618,10 @@ PHP_FUNCTION(pcntl_wait)
 #else
 	child_id = wait(&status);
 #endif
+	if (child_id < 0) {
+		PCNTL_G(last_error) = errno;
+	}
+
 	Z_LVAL_P(z_status) = status;
 
 	RETURN_LONG((long) child_id);
@@ -729,6 +815,7 @@ PHP_FUNCTION(pcntl_exec)
 		*(pair) = NULL;
 
 		if (execve(path, argv, envp) == -1) {
+			PCNTL_G(last_error) = errno;
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno));
 		}
 	
@@ -738,6 +825,7 @@ PHP_FUNCTION(pcntl_exec)
 	} else {
 
 		if (execv(path, argv) == -1) {
+			PCNTL_G(last_error) = errno;
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occured: (errno %d) %s", errno, strerror(errno));
 		}
 	}
@@ -780,6 +868,7 @@ PHP_FUNCTION(pcntl_signal)
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for handle argument specified");
 		}
 		if (php_signal(signo, (Sigfunc *) Z_LVAL_P(handle), (int) restart_syscalls) == SIG_ERR) {
+			PCNTL_G(last_error) = errno;
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error assigning signal");
 			RETURN_FALSE;
 		}
@@ -787,6 +876,7 @@ 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);
 		efree(func_name);
 		RETURN_FALSE;
@@ -797,7 +887,8 @@ PHP_FUNCTION(pcntl_signal)
 	zend_hash_index_update(&PCNTL_G(php_signal_table), signo, (void **) &handle, sizeof(zval *), (void **) &dest_handle);
 	if (dest_handle) zval_add_ref(dest_handle);
 	
-	if (php_signal(signo, pcntl_signal_handler, (int) restart_syscalls) == SIG_ERR) {
+	if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == SIG_ERR) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error assigning signal");
 		RETURN_FALSE;
 	}
@@ -829,6 +920,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
 	}
 
 	if (sigemptyset(&set) != 0 || sigemptyset(&oldset) != 0) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 		RETURN_FALSE;
 	}
@@ -842,6 +934,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
 		}
 		signo = Z_LVAL_PP(user_signo);
 		if (sigaddset(&set, signo) != 0) {
+			PCNTL_G(last_error) = errno;
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 			RETURN_FALSE;
 		}
@@ -849,6 +942,7 @@ PHP_FUNCTION(pcntl_sigprocmask)
 	}
 
 	if (sigprocmask(how, &set, &oldset) != 0) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 		RETURN_FALSE;
 	}
@@ -895,6 +989,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
 	}
 
 	if (sigemptyset(&set) != 0) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 		RETURN_FALSE;
 	}
@@ -908,6 +1003,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
 		}
 		signo = Z_LVAL_PP(user_signo);
 		if (sigaddset(&set, signo) != 0) {
+			PCNTL_G(last_error) = errno;
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 			RETURN_FALSE;
 		}
@@ -922,6 +1018,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
 		signo = sigwaitinfo(&set, &siginfo);
 	}
 	if (signo == -1 && errno != EAGAIN) {
+		PCNTL_G(last_error) = errno;
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 	}
 
@@ -1015,6 +1112,7 @@ PHP_FUNCTION(pcntl_getpriority)
 	pri = getpriority(who, pid);
 
 	if (errno) {
+		PCNTL_G(last_error) = errno;
 		switch (errno) {
 			case ESRCH:
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d: No process was located using the given parameters", errno);
@@ -1048,6 +1146,7 @@ PHP_FUNCTION(pcntl_setpriority)
 	}
 
 	if (setpriority(who, pid, pri)) {
+		PCNTL_G(last_error) = errno;
 		switch (errno) {
 			case ESRCH:
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d: No process was located using the given parameters", errno);
@@ -1073,6 +1172,28 @@ PHP_FUNCTION(pcntl_setpriority)
 /* }}} */
 #endif
 
+/* {{{ proto int pcntl_get_last_error(void)
+   Retrieve the error number set by the last pcntl function which failed. */
+PHP_FUNCTION(pcntl_get_last_error)
+{
+        RETURN_LONG(PCNTL_G(last_error));
+}
+/* }}} */
+
+/* {{{ proto string pcntl_strerror(int errno)
+   Retrieve the system error message associated with the given errno. */
+PHP_FUNCTION(pcntl_strerror)
+{
+        long error;
+
+        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &error) == FAILURE) {
+                RETURN_FALSE;
+        }
+
+        RETURN_STRING(strerror(error), 1);
+}
+/* }}} */
+
 /* Our custom signal handler that calls the appropriate php_function */
 static void pcntl_signal_handler(int signo)
 {
@@ -1103,11 +1224,19 @@ void pcntl_signal_dispatch()
 {
 	zval *param, **handle, *retval;
 	struct php_pcntl_pending_signal *queue, *next;
+	sigset_t mask;
+	sigset_t old_mask;
 	TSRMLS_FETCH();
+		
+	/* Mask all signals */
+	sigfillset(&mask);
+	sigprocmask(SIG_BLOCK, &mask, &old_mask);
 
 	/* Bail if the queue is empty or if we are already playing the queue*/
-	if (! PCNTL_G(head) || PCNTL_G(processing_signal_queue))
+	if (! PCNTL_G(head) || PCNTL_G(processing_signal_queue)) {
+		sigprocmask(SIG_SETMASK, &old_mask, NULL);
 		return;
+	}
 
 	/* Prevent reentrant handler calls */
 	PCNTL_G(processing_signal_queue) = 1;
@@ -1139,6 +1268,9 @@ void pcntl_signal_dispatch()
 
 	/* Re-enable queue */
 	PCNTL_G(processing_signal_queue) = 0;
+	
+	/* return signal mask to previous state */
+	sigprocmask(SIG_SETMASK, &old_mask, NULL);
 }
 
 
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index 8b7a1f1..8d48f9c 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcntl.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_pcntl.h 305016 2010-11-01 20:22:23Z lbarnaud $ */
 
 #ifndef PHP_PCNTL_H
 #define PHP_PCNTL_H
@@ -42,6 +42,8 @@ PHP_FUNCTION(pcntl_wtermsig);
 PHP_FUNCTION(pcntl_wstopsig);
 PHP_FUNCTION(pcntl_signal);
 PHP_FUNCTION(pcntl_signal_dispatch);
+PHP_FUNCTION(pcntl_get_last_error);
+PHP_FUNCTION(pcntl_strerror);
 #ifdef HAVE_SIGPROCMASK
 PHP_FUNCTION(pcntl_sigprocmask);
 #endif
@@ -66,6 +68,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)
 	HashTable php_signal_table;
 	int processing_signal_queue;
 	struct php_pcntl_pending_signal *head, *tail, *spares;
+	int last_error;
 ZEND_END_MODULE_GLOBALS(pcntl)
 
 #ifdef ZTS
@@ -74,6 +77,8 @@ ZEND_END_MODULE_GLOBALS(pcntl)
 #define PCNTL_G(v)	(pcntl_globals.v)
 #endif
 
+#define REGISTER_PCNTL_ERRNO_CONSTANT(name) REGISTER_LONG_CONSTANT("PCNTL_" #name, name, CONST_CS | CONST_PERSISTENT)
+
 #endif	/* PHP_PCNTL_H */
 
 
diff --git a/ext/pcntl/php_signal.c b/ext/pcntl/php_signal.c
index c025296..95eb08d 100644
--- a/ext/pcntl/php_signal.c
+++ b/ext/pcntl/php_signal.c
@@ -16,17 +16,21 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_signal.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_signal.c 305020 2010-11-01 22:43:59Z lbarnaud $ */
 
 #include "php_signal.h"
 
 /* php_signal using sigaction is derrived from Advanced Programing
  * in the Unix Environment by W. Richard Stevens p 298. */
-Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
+Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
 {
 	struct sigaction act,oact;
 	act.sa_handler = func;
-	sigemptyset(&act.sa_mask);
+	if (mask_all) {
+		sigfillset(&act.sa_mask);
+	} else {
+		sigemptyset(&act.sa_mask);
+	}
 	act.sa_flags = 0;
 	if (signo == SIGALRM || (! restart)) {
 #ifdef SA_INTERRUPT
@@ -43,6 +47,11 @@ Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
 	return oact.sa_handler;
 }
 
+Sigfunc *php_signal(int signo, Sigfunc *func, int restart)
+{
+	return php_signal4(signo, func, restart, 0);
+}
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/ext/pcntl/php_signal.h b/ext/pcntl/php_signal.h
index e97cf08..1fbe6ed 100644
--- a/ext/pcntl/php_signal.h
+++ b/ext/pcntl/php_signal.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_signal.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_signal.h 305020 2010-11-01 22:43:59Z lbarnaud $ */
 
 #include <signal.h>
 #ifndef PHP_SIGNAL_H
@@ -31,5 +31,6 @@
 
 typedef void Sigfunc(int);
 Sigfunc *php_signal(int signo, Sigfunc *func, int restart);
+Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all);
 
 #endif
diff --git a/ext/pcntl/tests/pcntl_get_last_error.phpt b/ext/pcntl/tests/pcntl_get_last_error.phpt
new file mode 100644
index 0000000..4ed66c9
--- /dev/null
+++ b/ext/pcntl/tests/pcntl_get_last_error.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test pcntl_get_last_error()
+--SKIPIF--
+<?php
+	if (!extension_loaded("pcntl")) print "skip"; 
+?>
+--FILE--
+<?php 
+var_dump(pcntl_get_last_error());
+$pid = pcntl_wait($status);
+var_dump($pid);
+var_dump(pcntl_get_last_error() == PCNTL_ECHILD);
+?>
+--EXPECT--
+int(0)
+int(-1)
+bool(true)
diff --git a/ext/pcre/pcrelib/ChangeLog b/ext/pcre/pcrelib/ChangeLog
index 9e833ee..b2fef0d 100644
--- a/ext/pcre/pcrelib/ChangeLog
+++ b/ext/pcre/pcrelib/ChangeLog
@@ -1,6 +1,101 @@
 ChangeLog for PCRE
 ------------------
 
+Version 8.10 25-Jun-2010
+------------------------
+
+1.  Added support for (*MARK:ARG) and for ARG additions to PRUNE, SKIP, and
+    THEN.
+
+2.  (*ACCEPT) was not working when inside an atomic group.
+
+3.  Inside a character class, \B is treated as a literal by default, but
+    faulted if PCRE_EXTRA is set. This mimics Perl's behaviour (the -w option
+    causes the error). The code is unchanged, but I tidied the documentation.
+
+4.  Inside a character class, PCRE always treated \R and \X as literals,
+    whereas Perl faults them if its -w option is set. I have changed PCRE so
+    that it faults them when PCRE_EXTRA is set.
+
+5.  Added support for \N, which always matches any character other than
+    newline. (It is the same as "." when PCRE_DOTALL is not set.)
+
+6.  When compiling pcregrep with newer versions of gcc which may have
+    FORTIFY_SOURCE set, several warnings "ignoring return value of 'fwrite',
+    declared with attribute warn_unused_result" were given. Just casting the
+    result to (void) does not stop the warnings; a more elaborate fudge is
+    needed. I've used a macro to implement this.
+
+7.  Minor change to pcretest.c to avoid a compiler warning.
+
+8.  Added four artifical Unicode properties to help with an option to make
+    \s etc use properties (see next item). The new properties are: Xan
+    (alphanumeric), Xsp (Perl space), Xps (POSIX space), and Xwd (word).
+
+9.  Added PCRE_UCP to make \b, \d, \s, \w, and certain POSIX character classes
+    use Unicode properties. (*UCP) at the start of a pattern can be used to set
+    this option. Modified pcretest to add /W to test this facility. Added
+    REG_UCP to make it available via the POSIX interface.
+
+10. Added --line-buffered to pcregrep.
+
+11. In UTF-8 mode, if a pattern that was compiled with PCRE_CASELESS was
+    studied, and the match started with a letter with a code point greater than
+    127 whose first byte was different to the first byte of the other case of
+    the letter, the other case of this starting letter was not recognized
+    (#976).
+
+12. If a pattern that was studied started with a repeated Unicode property
+    test, for example, \p{Nd}+, there was the theoretical possibility of
+    setting up an incorrect bitmap of starting bytes, but fortunately it could
+    not have actually happened in practice until change 8 above was made (it
+    added property types that matched character-matching opcodes).
+
+13. pcre_study() now recognizes \h, \v, and \R when constructing a bit map of
+    possible starting bytes for non-anchored patterns.
+
+14. Extended the "auto-possessify" feature of pcre_compile(). It now recognizes
+    \R, and also a number of cases that involve Unicode properties, both
+    explicit and implicit when PCRE_UCP is set.
+
+15. If a repeated Unicode property match (e.g. \p{Lu}*) was used with non-UTF-8
+    input, it could crash or give wrong results if characters with values
+    greater than 0xc0 were present in the subject string. (Detail: it assumed
+    UTF-8 input when processing these items.)
+
+16. Added a lot of (int) casts to avoid compiler warnings in systems where
+    size_t is 64-bit (#991).
+
+17. Added a check for running out of memory when PCRE is compiled with
+    --disable-stack-for-recursion (#990).
+
+18. If the last data line in a file for pcretest does not have a newline on
+    the end, a newline was missing in the output.
+
+19. The default pcre_chartables.c file recognizes only ASCII characters (values
+    less than 128) in its various bitmaps. However, there is a facility for
+    generating tables according to the current locale when PCRE is compiled. It
+    turns out that in some environments, 0x85 and 0xa0, which are Unicode space
+    characters, are recognized by isspace() and therefore were getting set in
+    these tables, and indeed these tables seem to approximate to ISO 8859. This
+    caused a problem in UTF-8 mode when pcre_study() was used to create a list
+    of bytes that can start a match. For \s, it was including 0x85 and 0xa0,
+    which of course cannot start UTF-8 characters. I have changed the code so
+    that only real ASCII characters (less than 128) and the correct starting
+    bytes for UTF-8 encodings are set for characters greater than 127 when in
+    UTF-8 mode. (When PCRE_UCP is set - see 9 above - the code is different
+    altogether.)
+
+20. Added the /T option to pcretest so as to be able to run tests with non-
+    standard character tables, thus making it possible to include the tests
+    used for 19 above in the standard set of tests.
+
+21. A pattern such as (?&t)(?#()(?(DEFINE)(?<t>a)) which has a forward
+    reference to a subpattern the other side of a comment that contains an
+    opening parenthesis caused either an internal compiling error, or a
+    reference to the wrong subpattern.
+
+
 Version 8.02 19-Mar-2010
 ------------------------
 
diff --git a/ext/pcre/pcrelib/NEWS b/ext/pcre/pcrelib/NEWS
index 835d03d..4f21e0b 100644
--- a/ext/pcre/pcrelib/NEWS
+++ b/ext/pcre/pcrelib/NEWS
@@ -1,6 +1,17 @@
 News about PCRE releases
 ------------------------
 
+Release 8.10 25-Jun-2010
+------------------------
+
+There are two major additions: support for (*MARK) and friends, and the option
+PCRE_UCP, which changes the behaviour of \b, \d, \s, and \w (and their
+opposites) so that they make use of Unicode properties. There are also a number
+of lesser new features, and several bugs have been fixed. A new option,
+--line-buffered, has been added to pcregrep, for use when it is connected to
+pipes.
+
+
 Release 8.02 19-Mar-2010
 ------------------------
 
diff --git a/ext/pcre/pcrelib/NON-UNIX-USE b/ext/pcre/pcrelib/NON-UNIX-USE
index 69668cb..8619b58 100644
--- a/ext/pcre/pcrelib/NON-UNIX-USE
+++ b/ext/pcre/pcrelib/NON-UNIX-USE
@@ -188,9 +188,9 @@ significantly slower when this is done. There is more about stack usage in the
 LINKING PROGRAMS IN WINDOWS ENVIRONMENTS
 
 If you want to statically link a program against a PCRE library in the form of
-a non-dll .a file, you must define PCRE_STATIC before including pcre.h,
-otherwise the pcre_malloc() and pcre_free() exported functions will be declared
-__declspec(dllimport), with unwanted results.
+a non-dll .a file, you must define PCRE_STATIC before including pcre.h or
+pcrecpp.h, otherwise the pcre_malloc() and pcre_free() exported functions will
+be declared __declspec(dllimport), with unwanted results.
 
 
 CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
@@ -497,5 +497,5 @@ build.log file in the root of the package also.
 
 
 =========================
-Last Updated: 19 January 2010
+Last Updated: 26 May 2010
 ****
diff --git a/ext/pcre/pcrelib/config.h b/ext/pcre/pcrelib/config.h
index 34d16a4..43bfa44 100644
--- a/ext/pcre/pcrelib/config.h
+++ b/ext/pcre/pcrelib/config.h
@@ -1,5 +1,10 @@
 
 #include <php_compat.h>
+
+#ifndef PHP_WIN32
+# include <php_config.h>
+#endif
+
 #undef PACKAGE_NAME
 #undef PACKAGE_VERSION
 #undef PACKAGE_TARNAME
@@ -18,6 +23,8 @@
 # define PCRE_EXP_DATA_DEFN	__attribute__ ((visibility("default")))
 #endif
 
+/* Exclude these below definitions when building within PHP */
+#ifndef ZEND_API
 
 /* config.h.  Generated from config.h.in by configure.  */
 /* config.h.in.  Generated from configure.ac by autoheader.  */
@@ -189,6 +196,9 @@ them both to 0; an emulation function will be used. */
 /* Define to 1 if you have `_strtoi64'. */
 /* #undef HAVE__STRTOI64 */
 
+/* Exclude these above definitions when building within PHP */
+#endif
+
 /* The value of LINK_SIZE determines the number of bytes used to store links
    as offsets within the compiled regex. The default is 2, which allows for
    compiled patterns up to 64K long. This covers the vast majority of cases.
@@ -271,13 +281,16 @@ them both to 0; an emulation function will be used. */
 #define PACKAGE_NAME "PCRE"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "PCRE 8.02"
+#define PACKAGE_STRING "PCRE 8.10"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "pcre"
 
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "8.02"
+#define PACKAGE_VERSION "8.10"
 
 
 /* If you are compiling for a system other than a Unix-like system or
@@ -333,7 +346,7 @@ them both to 0; an emulation function will be used. */
 
 /* Version number of package */
 #ifndef VERSION
-#define VERSION "8.02"
+#define VERSION "8.10"
 #endif
 
 /* Define to empty if `const' does not conform to ANSI C. */
diff --git a/ext/pcre/pcrelib/doc/pcre.txt b/ext/pcre/pcrelib/doc/pcre.txt
index aedf853..5f65871 100644
--- a/ext/pcre/pcrelib/doc/pcre.txt
+++ b/ext/pcre/pcrelib/doc/pcre.txt
@@ -26,8 +26,8 @@ INTRODUCTION
        give better JavaScript compatibility.
 
        The  current implementation of PCRE corresponds approximately with Perl
-       5.10, including support for UTF-8 encoded strings and  Unicode  general
-       category  properties.  However,  UTF-8  and  Unicode  support has to be
+       5.10/5.11, including support for UTF-8 encoded strings and Unicode gen-
+       eral  category properties. However, UTF-8 and Unicode support has to be
        explicitly enabled; it is not the default. The  Unicode  tables  corre-
        spond to Unicode release 5.2.0.
 
@@ -222,21 +222,25 @@ UTF-8 AND UNICODE PROPERTY SUPPORT
        not available in the alternative matching function, pcre_dfa_exec().
 
        6.  The  character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly
-       test characters of any code value, but the characters that PCRE  recog-
-       nizes  as  digits,  spaces,  or  word characters remain the same set as
-       before, all with values less than 256. This remains true even when PCRE
-       includes  Unicode  property support, because to do otherwise would slow
-       down PCRE in many common cases. If you really want to test for a  wider
-       sense  of,  say,  "digit",  you must use Unicode property tests such as
-       \p{Nd}. Note that this also applies to \b, because  it  is  defined  in
-       terms of \w and \W.
+       test characters of any code value, but, by default, the characters that
+       PCRE  recognizes  as digits, spaces, or word characters remain the same
+       set as before, all with values less than 256. This  remains  true  even
+       when  PCRE  is built to include Unicode property support, because to do
+       otherwise would slow down PCRE in many common  cases.  Note  that  this
+       also applies to \b, because it is defined in terms of \w and \W. If you
+       really want to test for a wider sense of, say,  "digit",  you  can  use
+       explicit  Unicode property tests such as \p{Nd}.  Alternatively, if you
+       set the PCRE_UCP option, the way that the  character  escapes  work  is
+       changed  so that Unicode properties are used to determine which charac-
+       ters match. There are more details in the section on generic  character
+       types in the pcrepattern documentation.
 
        7.  Similarly,  characters that match the POSIX named character classes
-       are all low-valued characters.
+       are all low-valued characters, unless the PCRE_UCP option is set.
 
        8. However, the Perl 5.10 horizontal and vertical  whitespace  matching
        escapes (\h, \H, \v, and \V) do match all the appropriate Unicode char-
-       acters.
+       acters, whether or not PCRE_UCP is set.
 
        9. Case-insensitive matching applies only to  characters  whose  values
        are  less than 128, unless PCRE is built with Unicode property support.
@@ -263,7 +267,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 01 March 2010
+       Last updated: 12 May 2010
        Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -902,6 +906,12 @@ PCRE API OVERVIEW
        bers for the library.  Applications can use these  to  include  support
        for different releases of PCRE.
 
+       In a Windows environment, if you want to statically link an application
+       program against a non-dll pcre.a  file,  you  must  define  PCRE_STATIC
+       before  including  pcre.h or pcrecpp.h, because otherwise the pcre_mal-
+       loc()   and   pcre_free()   exported   functions   will   be   declared
+       __declspec(dllimport), with unwanted results.
+
        The   functions   pcre_compile(),  pcre_compile2(),  pcre_study(),  and
        pcre_exec() are used for compiling and matching regular expressions  in
        a  Perl-compatible  manner. A sample program that demonstrates the sim-
@@ -1281,48 +1291,49 @@ COMPILING A PATTERN
        letter that has no special meaning  causes  an  error,  thus  reserving
        these  combinations  for  future  expansion.  By default, as in Perl, a
        backslash followed by a letter with no special meaning is treated as  a
-       literal.  (Perl can, however, be persuaded to give a warning for this.)
-       There are at present no other features controlled by  this  option.  It
-       can also be set by a (?X) option setting within a pattern.
+       literal. (Perl can, however, be persuaded to give an error for this, by
+       running it with the -w option.) There are at present no other  features
+       controlled  by this option. It can also be set by a (?X) option setting
+       within a pattern.
 
          PCRE_FIRSTLINE
 
-       If  this  option  is  set,  an  unanchored pattern is required to match
-       before or at the first  newline  in  the  subject  string,  though  the
+       If this option is set, an  unanchored  pattern  is  required  to  match
+       before  or  at  the  first  newline  in  the subject string, though the
        matched text may continue over the newline.
 
          PCRE_JAVASCRIPT_COMPAT
 
        If this option is set, PCRE's behaviour is changed in some ways so that
-       it is compatible with JavaScript rather than Perl. The changes  are  as
+       it  is  compatible with JavaScript rather than Perl. The changes are as
        follows:
 
-       (1)  A  lone  closing square bracket in a pattern causes a compile-time
-       error, because this is illegal in JavaScript (by default it is  treated
+       (1) A lone closing square bracket in a pattern  causes  a  compile-time
+       error,  because this is illegal in JavaScript (by default it is treated
        as a data character). Thus, the pattern AB]CD becomes illegal when this
        option is set.
 
-       (2) At run time, a back reference to an unset subpattern group  matches
-       an  empty  string (by default this causes the current matching alterna-
-       tive to fail). A pattern such as (\1)(a) succeeds when this  option  is
-       set  (assuming  it can find an "a" in the subject), whereas it fails by
+       (2)  At run time, a back reference to an unset subpattern group matches
+       an empty string (by default this causes the current  matching  alterna-
+       tive  to  fail). A pattern such as (\1)(a) succeeds when this option is
+       set (assuming it can find an "a" in the subject), whereas it  fails  by
        default, for Perl compatibility.
 
          PCRE_MULTILINE
 
-       By default, PCRE treats the subject string as consisting  of  a  single
-       line  of characters (even if it actually contains newlines). The "start
-       of line" metacharacter (^) matches only at the  start  of  the  string,
-       while  the  "end  of line" metacharacter ($) matches only at the end of
+       By  default,  PCRE  treats the subject string as consisting of a single
+       line of characters (even if it actually contains newlines). The  "start
+       of  line"  metacharacter  (^)  matches only at the start of the string,
+       while the "end of line" metacharacter ($) matches only at  the  end  of
        the string, or before a terminating newline (unless PCRE_DOLLAR_ENDONLY
        is set). This is the same as Perl.
 
-       When  PCRE_MULTILINE  it  is set, the "start of line" and "end of line"
-       constructs match immediately following or immediately  before  internal
-       newlines  in  the  subject string, respectively, as well as at the very
-       start and end. This is equivalent to Perl's /m option, and  it  can  be
+       When PCRE_MULTILINE it is set, the "start of line" and  "end  of  line"
+       constructs  match  immediately following or immediately before internal
+       newlines in the subject string, respectively, as well as  at  the  very
+       start  and  end.  This is equivalent to Perl's /m option, and it can be
        changed within a pattern by a (?m) option setting. If there are no new-
-       lines in a subject string, or no occurrences of ^ or $  in  a  pattern,
+       lines  in  a  subject string, or no occurrences of ^ or $ in a pattern,
        setting PCRE_MULTILINE has no effect.
 
          PCRE_NEWLINE_CR
@@ -1331,32 +1342,32 @@ COMPILING A PATTERN
          PCRE_NEWLINE_ANYCRLF
          PCRE_NEWLINE_ANY
 
-       These  options  override the default newline definition that was chosen
-       when PCRE was built. Setting the first or the second specifies  that  a
-       newline  is  indicated  by a single character (CR or LF, respectively).
-       Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by  the
-       two-character  CRLF  sequence.  Setting  PCRE_NEWLINE_ANYCRLF specifies
+       These options override the default newline definition that  was  chosen
+       when  PCRE  was built. Setting the first or the second specifies that a
+       newline is indicated by a single character (CR  or  LF,  respectively).
+       Setting  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the
+       two-character CRLF  sequence.  Setting  PCRE_NEWLINE_ANYCRLF  specifies
        that any of the three preceding sequences should be recognized. Setting
-       PCRE_NEWLINE_ANY  specifies that any Unicode newline sequence should be
+       PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should  be
        recognized. The Unicode newline sequences are the three just mentioned,
-       plus  the  single  characters  VT (vertical tab, U+000B), FF (formfeed,
-       U+000C), NEL (next line, U+0085), LS (line separator, U+2028),  and  PS
-       (paragraph  separator,  U+2029).  The  last  two are recognized only in
+       plus the single characters VT (vertical  tab,  U+000B),  FF  (formfeed,
+       U+000C),  NEL  (next line, U+0085), LS (line separator, U+2028), and PS
+       (paragraph separator, U+2029). The last  two  are  recognized  only  in
        UTF-8 mode.
 
-       The newline setting in the  options  word  uses  three  bits  that  are
+       The  newline  setting  in  the  options  word  uses three bits that are
        treated as a number, giving eight possibilities. Currently only six are
-       used (default plus the five values above). This means that if  you  set
-       more  than one newline option, the combination may or may not be sensi-
+       used  (default  plus the five values above). This means that if you set
+       more than one newline option, the combination may or may not be  sensi-
        ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to
-       PCRE_NEWLINE_CRLF,  but other combinations may yield unused numbers and
+       PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers  and
        cause an error.
 
-       The only time that a line break is specially recognized when  compiling
-       a  pattern  is  if  PCRE_EXTENDED  is set, and an unescaped # outside a
-       character class is encountered. This indicates  a  comment  that  lasts
-       until  after the next line break sequence. In other circumstances, line
-       break  sequences  are  treated  as  literal  data,   except   that   in
+       The  only time that a line break is specially recognized when compiling
+       a pattern is if PCRE_EXTENDED is set, and  an  unescaped  #  outside  a
+       character  class  is  encountered.  This indicates a comment that lasts
+       until after the next line break sequence. In other circumstances,  line
+       break   sequences   are   treated  as  literal  data,  except  that  in
        PCRE_EXTENDED mode, both CR and LF are treated as whitespace characters
        and are therefore ignored.
 
@@ -1366,46 +1377,56 @@ COMPILING A PATTERN
          PCRE_NO_AUTO_CAPTURE
 
        If this option is set, it disables the use of numbered capturing paren-
-       theses in the pattern. Any opening parenthesis that is not followed  by
-       ?  behaves as if it were followed by ?: but named parentheses can still
-       be used for capturing (and they acquire  numbers  in  the  usual  way).
+       theses  in the pattern. Any opening parenthesis that is not followed by
+       ? behaves as if it were followed by ?: but named parentheses can  still
+       be  used  for  capturing  (and  they acquire numbers in the usual way).
        There is no equivalent of this option in Perl.
 
+         PCRE_UCP
+
+       This option changes the way PCRE processes \b, \d, \s, \w, and some  of
+       the POSIX character classes. By default, only ASCII characters are rec-
+       ognized, but if PCRE_UCP is set, Unicode properties are used instead to
+       classify  characters.  More details are given in the section on generic
+       character types in the pcrepattern page. If you set PCRE_UCP,  matching
+       one  of the items it affects takes much longer. The option is available
+       only if PCRE has been compiled with Unicode property support.
+
          PCRE_UNGREEDY
 
-       This  option  inverts  the "greediness" of the quantifiers so that they
-       are not greedy by default, but become greedy if followed by "?". It  is
-       not  compatible  with Perl. It can also be set by a (?U) option setting
+       This option inverts the "greediness" of the quantifiers  so  that  they
+       are  not greedy by default, but become greedy if followed by "?". It is
+       not compatible with Perl. It can also be set by a (?U)  option  setting
        within the pattern.
 
          PCRE_UTF8
 
-       This option causes PCRE to regard both the pattern and the  subject  as
-       strings  of  UTF-8 characters instead of single-byte character strings.
-       However, it is available only when PCRE is built to include UTF-8  sup-
-       port.  If not, the use of this option provokes an error. Details of how
-       this option changes the behaviour of PCRE are given in the  section  on
+       This  option  causes PCRE to regard both the pattern and the subject as
+       strings of UTF-8 characters instead of single-byte  character  strings.
+       However,  it is available only when PCRE is built to include UTF-8 sup-
+       port. If not, the use of this option provokes an error. Details of  how
+       this  option  changes the behaviour of PCRE are given in the section on
        UTF-8 support in the main pcre page.
 
          PCRE_NO_UTF8_CHECK
 
        When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
-       automatically checked. There is a  discussion  about  the  validity  of
-       UTF-8  strings  in  the main pcre page. If an invalid UTF-8 sequence of
-       bytes is found, pcre_compile() returns an error. If  you  already  know
+       automatically  checked.  There  is  a  discussion about the validity of
+       UTF-8 strings in the main pcre page. If an invalid  UTF-8  sequence  of
+       bytes  is  found,  pcre_compile() returns an error. If you already know
        that your pattern is valid, and you want to skip this check for perfor-
-       mance reasons, you can set the PCRE_NO_UTF8_CHECK option.  When  it  is
-       set,  the  effect  of  passing  an invalid UTF-8 string as a pattern is
-       undefined. It may cause your program to crash. Note  that  this  option
-       can  also be passed to pcre_exec() and pcre_dfa_exec(), to suppress the
+       mance  reasons,  you  can set the PCRE_NO_UTF8_CHECK option. When it is
+       set, the effect of passing an invalid UTF-8  string  as  a  pattern  is
+       undefined.  It  may  cause your program to crash. Note that this option
+       can also be passed to pcre_exec() and pcre_dfa_exec(), to suppress  the
        UTF-8 validity checking of subject strings.
 
 
 COMPILATION ERROR CODES
 
-       The following table lists the error  codes  than  may  be  returned  by
-       pcre_compile2(),  along with the error messages that may be returned by
-       both compiling functions. As PCRE has developed, some error codes  have
+       The  following  table  lists  the  error  codes than may be returned by
+       pcre_compile2(), along with the error messages that may be returned  by
+       both  compiling functions. As PCRE has developed, some error codes have
        fallen out of use. To avoid confusion, they have not been re-used.
 
           0  no error
@@ -1461,20 +1482,24 @@ COMPILATION ERROR CODES
          50  [this code is not in use]
          51  octal value is greater than \377 (not in UTF-8 mode)
          52  internal error: overran compiling workspace
-         53   internal  error:  previously-checked  referenced  subpattern not
-       found
+         53  internal error: previously-checked referenced subpattern
+               not found
          54  DEFINE group contains more than one branch
          55  repeating a DEFINE group is not allowed
          56  inconsistent NEWLINE options
          57  \g is not followed by a braced, angle-bracketed, or quoted
                name/number or by a plain number
          58  a numbered reference must not be zero
-         59  (*VERB) with an argument is not supported
+         59  an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)
          60  (*VERB) not recognized
          61  number is too big
          62  subpattern name expected
          63  digit expected after (?+
          64  ] is an invalid data character in JavaScript compatibility mode
+         65  different names for subpatterns of the same number are
+               not allowed
+         66  (*MARK) must have an argument
+         67  this version of PCRE is not compiled with PCRE_UCP support
 
        The numbers 32 and 10000 in errors 48 and 49  are  defaults;  different
        values may be used if the limits were changed when PCRE was built.
@@ -1534,59 +1559,68 @@ STUDYING A PATTERN
        bytes  is  created. This speeds up finding a position in the subject at
        which to start matching.
 
+       The two optimizations just described can be  disabled  by  setting  the
+       PCRE_NO_START_OPTIMIZE    option    when    calling    pcre_exec()   or
+       pcre_dfa_exec(). You might want to do this  if  your  pattern  contains
+       callouts,  or  make  use of (*MARK), and you make use of these in cases
+       where matching fails.  See  the  discussion  of  PCRE_NO_START_OPTIMIZE
+       below.
+
 
 LOCALE SUPPORT
 
-       PCRE handles caseless matching, and determines whether  characters  are
-       letters,  digits, or whatever, by reference to a set of tables, indexed
-       by character value. When running in UTF-8 mode, this  applies  only  to
-       characters  with  codes  less than 128. Higher-valued codes never match
-       escapes such as \w or \d, but can be tested with \p if  PCRE  is  built
-       with  Unicode  character property support. The use of locales with Uni-
-       code is discouraged. If you are handling characters with codes  greater
-       than  128, you should either use UTF-8 and Unicode, or use locales, but
-       not try to mix the two.
-
-       PCRE contains an internal set of tables that are used  when  the  final
-       argument  of  pcre_compile()  is  NULL.  These  are sufficient for many
+       PCRE  handles  caseless matching, and determines whether characters are
+       letters, digits, or whatever, by reference to a set of tables,  indexed
+       by  character  value.  When running in UTF-8 mode, this applies only to
+       characters with codes less than 128. By  default,  higher-valued  codes
+       never match escapes such as \w or \d, but they can be tested with \p if
+       PCRE is built with Unicode character property  support.  Alternatively,
+       the  PCRE_UCP  option  can  be  set at compile time; this causes \w and
+       friends to use Unicode property support instead of built-in tables. The
+       use of locales with Unicode is discouraged. If you are handling charac-
+       ters with codes greater than 128, you should either use UTF-8 and  Uni-
+       code, or use locales, but not try to mix the two.
+
+       PCRE  contains  an  internal set of tables that are used when the final
+       argument of pcre_compile() is  NULL.  These  are  sufficient  for  many
        applications.  Normally, the internal tables recognize only ASCII char-
        acters. However, when PCRE is built, it is possible to cause the inter-
        nal tables to be rebuilt in the default "C" locale of the local system,
        which may cause them to be different.
 
-       The  internal tables can always be overridden by tables supplied by the
+       The internal tables can always be overridden by tables supplied by  the
        application that calls PCRE. These may be created in a different locale
-       from  the  default.  As more and more applications change to using Uni-
+       from the default. As more and more applications change  to  using  Uni-
        code, the need for this locale support is expected to die away.
 
-       External tables are built by calling  the  pcre_maketables()  function,
-       which  has no arguments, in the relevant locale. The result can then be
-       passed to pcre_compile() or pcre_exec()  as  often  as  necessary.  For
-       example,  to  build  and use tables that are appropriate for the French
-       locale (where accented characters with  values  greater  than  128  are
+       External  tables  are  built by calling the pcre_maketables() function,
+       which has no arguments, in the relevant locale. The result can then  be
+       passed  to  pcre_compile()  or  pcre_exec()  as often as necessary. For
+       example, to build and use tables that are appropriate  for  the  French
+       locale  (where  accented  characters  with  values greater than 128 are
        treated as letters), the following code could be used:
 
          setlocale(LC_CTYPE, "fr_FR");
          tables = pcre_maketables();
          re = pcre_compile(..., tables);
 
-       The  locale  name "fr_FR" is used on Linux and other Unix-like systems;
+       The locale name "fr_FR" is used on Linux and other  Unix-like  systems;
        if you are using Windows, the name for the French locale is "french".
 
-       When pcre_maketables() runs, the tables are built  in  memory  that  is
-       obtained  via  pcre_malloc. It is the caller's responsibility to ensure
-       that the memory containing the tables remains available for as long  as
+       When  pcre_maketables()  runs,  the  tables are built in memory that is
+       obtained via pcre_malloc. It is the caller's responsibility  to  ensure
+       that  the memory containing the tables remains available for as long as
        it is needed.
 
        The pointer that is passed to pcre_compile() is saved with the compiled
-       pattern, and the same tables are used via this pointer by  pcre_study()
+       pattern,  and the same tables are used via this pointer by pcre_study()
        and normally also by pcre_exec(). Thus, by default, for any single pat-
        tern, compilation, studying and matching all happen in the same locale,
        but different patterns can be compiled in different locales.
 
-       It  is  possible to pass a table pointer or NULL (indicating the use of
-       the internal tables) to pcre_exec(). Although  not  intended  for  this
-       purpose,  this facility could be used to match a pattern in a different
+       It is possible to pass a table pointer or NULL (indicating the  use  of
+       the  internal  tables)  to  pcre_exec(). Although not intended for this
+       purpose, this facility could be used to match a pattern in a  different
        locale from the one in which it was compiled. Passing table pointers at
        run time is discussed below in the section on matching a pattern.
 
@@ -1596,15 +1630,15 @@ INFORMATION ABOUT A PATTERN
        int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
             int what, void *where);
 
-       The  pcre_fullinfo() function returns information about a compiled pat-
+       The pcre_fullinfo() function returns information about a compiled  pat-
        tern. It replaces the obsolete pcre_info() function, which is neverthe-
        less retained for backwards compability (and is documented below).
 
-       The  first  argument  for  pcre_fullinfo() is a pointer to the compiled
-       pattern. The second argument is the result of pcre_study(), or NULL  if
-       the  pattern  was not studied. The third argument specifies which piece
-       of information is required, and the fourth argument is a pointer  to  a
-       variable  to  receive  the  data. The yield of the function is zero for
+       The first argument for pcre_fullinfo() is a  pointer  to  the  compiled
+       pattern.  The second argument is the result of pcre_study(), or NULL if
+       the pattern was not studied. The third argument specifies  which  piece
+       of  information  is required, and the fourth argument is a pointer to a
+       variable to receive the data. The yield of the  function  is  zero  for
        success, or one of the following negative numbers:
 
          PCRE_ERROR_NULL       the argument code was NULL
@@ -1612,9 +1646,9 @@ INFORMATION ABOUT A PATTERN
          PCRE_ERROR_BADMAGIC   the "magic number" was not found
          PCRE_ERROR_BADOPTION  the value of what was invalid
 
-       The "magic number" is placed at the start of each compiled  pattern  as
-       an  simple check against passing an arbitrary memory pointer. Here is a
-       typical call of pcre_fullinfo(), to obtain the length of  the  compiled
+       The  "magic  number" is placed at the start of each compiled pattern as
+       an simple check against passing an arbitrary memory pointer. Here is  a
+       typical  call  of pcre_fullinfo(), to obtain the length of the compiled
        pattern:
 
          int rc;
@@ -1625,131 +1659,131 @@ INFORMATION ABOUT A PATTERN
            PCRE_INFO_SIZE,   /* what is required */
            &length);         /* where to put the data */
 
-       The  possible  values for the third argument are defined in pcre.h, and
+       The possible values for the third argument are defined in  pcre.h,  and
        are as follows:
 
          PCRE_INFO_BACKREFMAX
 
-       Return the number of the highest back reference  in  the  pattern.  The
-       fourth  argument  should  point to an int variable. Zero is returned if
+       Return  the  number  of  the highest back reference in the pattern. The
+       fourth argument should point to an int variable. Zero  is  returned  if
        there are no back references.
 
          PCRE_INFO_CAPTURECOUNT
 
-       Return the number of capturing subpatterns in the pattern.  The  fourth
+       Return  the  number of capturing subpatterns in the pattern. The fourth
        argument should point to an int variable.
 
          PCRE_INFO_DEFAULT_TABLES
 
-       Return  a pointer to the internal default character tables within PCRE.
-       The fourth argument should point to an unsigned char *  variable.  This
+       Return a pointer to the internal default character tables within  PCRE.
+       The  fourth  argument should point to an unsigned char * variable. This
        information call is provided for internal use by the pcre_study() func-
-       tion. External callers can cause PCRE to use  its  internal  tables  by
+       tion.  External  callers  can  cause PCRE to use its internal tables by
        passing a NULL table pointer.
 
          PCRE_INFO_FIRSTBYTE
 
-       Return  information  about  the first byte of any matched string, for a
-       non-anchored pattern. The fourth argument should point to an int  vari-
-       able.  (This option used to be called PCRE_INFO_FIRSTCHAR; the old name
+       Return information about the first byte of any matched  string,  for  a
+       non-anchored  pattern. The fourth argument should point to an int vari-
+       able. (This option used to be called PCRE_INFO_FIRSTCHAR; the old  name
        is still recognized for backwards compatibility.)
 
-       If there is a fixed first byte, for example, from  a  pattern  such  as
+       If  there  is  a  fixed first byte, for example, from a pattern such as
        (cat|cow|coyote), its value is returned. Otherwise, if either
 
-       (a)  the pattern was compiled with the PCRE_MULTILINE option, and every
+       (a) the pattern was compiled with the PCRE_MULTILINE option, and  every
        branch starts with "^", or
 
        (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not
        set (if it were set, the pattern would be anchored),
 
-       -1  is  returned, indicating that the pattern matches only at the start
-       of a subject string or after any newline within the  string.  Otherwise
+       -1 is returned, indicating that the pattern matches only at  the  start
+       of  a  subject string or after any newline within the string. Otherwise
        -2 is returned. For anchored patterns, -2 is returned.
 
          PCRE_INFO_FIRSTTABLE
 
-       If  the pattern was studied, and this resulted in the construction of a
+       If the pattern was studied, and this resulted in the construction of  a
        256-bit table indicating a fixed set of bytes for the first byte in any
-       matching  string, a pointer to the table is returned. Otherwise NULL is
-       returned. The fourth argument should point to an unsigned char *  vari-
+       matching string, a pointer to the table is returned. Otherwise NULL  is
+       returned.  The fourth argument should point to an unsigned char * vari-
        able.
 
          PCRE_INFO_HASCRORLF
 
-       Return  1  if  the  pattern  contains any explicit matches for CR or LF
-       characters, otherwise 0. The fourth argument should  point  to  an  int
-       variable.  An explicit match is either a literal CR or LF character, or
+       Return 1 if the pattern contains any explicit  matches  for  CR  or  LF
+       characters,  otherwise  0.  The  fourth argument should point to an int
+       variable. An explicit match is either a literal CR or LF character,  or
        \r or \n.
 
          PCRE_INFO_JCHANGED
 
-       Return 1 if the (?J) or (?-J) option setting is used  in  the  pattern,
-       otherwise  0. The fourth argument should point to an int variable. (?J)
+       Return  1  if  the (?J) or (?-J) option setting is used in the pattern,
+       otherwise 0. The fourth argument should point to an int variable.  (?J)
        and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
 
          PCRE_INFO_LASTLITERAL
 
-       Return the value of the rightmost literal byte that must exist  in  any
-       matched  string,  other  than  at  its  start,  if such a byte has been
+       Return  the  value of the rightmost literal byte that must exist in any
+       matched string, other than at its  start,  if  such  a  byte  has  been
        recorded. The fourth argument should point to an int variable. If there
-       is  no such byte, -1 is returned. For anchored patterns, a last literal
-       byte is recorded only if it follows something of variable  length.  For
+       is no such byte, -1 is returned. For anchored patterns, a last  literal
+       byte  is  recorded only if it follows something of variable length. For
        example, for the pattern /^a\d+z\d+/ the returned value is "z", but for
        /^a\dz\d/ the returned value is -1.
 
          PCRE_INFO_MINLENGTH
 
-       If the pattern was studied and a minimum length  for  matching  subject
-       strings  was  computed,  its  value is returned. Otherwise the returned
-       value is -1. The value is a number of characters, not bytes  (this  may
-       be  relevant in UTF-8 mode). The fourth argument should point to an int
-       variable. A non-negative value is a lower bound to the  length  of  any
-       matching  string.  There  may not be any strings of that length that do
+       If  the  pattern  was studied and a minimum length for matching subject
+       strings was computed, its value is  returned.  Otherwise  the  returned
+       value  is  -1. The value is a number of characters, not bytes (this may
+       be relevant in UTF-8 mode). The fourth argument should point to an  int
+       variable.  A  non-negative  value is a lower bound to the length of any
+       matching string. There may not be any strings of that  length  that  do
        actually match, but every string that does match is at least that long.
 
          PCRE_INFO_NAMECOUNT
          PCRE_INFO_NAMEENTRYSIZE
          PCRE_INFO_NAMETABLE
 
-       PCRE supports the use of named as well as numbered capturing  parenthe-
-       ses.  The names are just an additional way of identifying the parenthe-
+       PCRE  supports the use of named as well as numbered capturing parenthe-
+       ses. The names are just an additional way of identifying the  parenthe-
        ses, which still acquire numbers. Several convenience functions such as
-       pcre_get_named_substring()  are  provided  for extracting captured sub-
-       strings by name. It is also possible to extract the data  directly,  by
-       first  converting  the  name to a number in order to access the correct
+       pcre_get_named_substring() are provided for  extracting  captured  sub-
+       strings  by  name. It is also possible to extract the data directly, by
+       first converting the name to a number in order to  access  the  correct
        pointers in the output vector (described with pcre_exec() below). To do
-       the  conversion,  you  need  to  use  the  name-to-number map, which is
+       the conversion, you need  to  use  the  name-to-number  map,  which  is
        described by these three values.
 
        The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT
        gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size
-       of each entry; both of these  return  an  int  value.  The  entry  size
-       depends  on the length of the longest name. PCRE_INFO_NAMETABLE returns
-       a pointer to the first entry of the table  (a  pointer  to  char).  The
+       of  each  entry;  both  of  these  return  an int value. The entry size
+       depends on the length of the longest name. PCRE_INFO_NAMETABLE  returns
+       a  pointer  to  the  first  entry of the table (a pointer to char). The
        first two bytes of each entry are the number of the capturing parenthe-
-       sis, most significant byte first. The rest of the entry is  the  corre-
+       sis,  most  significant byte first. The rest of the entry is the corre-
        sponding name, zero terminated.
 
-       The  names are in alphabetical order. Duplicate names may appear if (?|
+       The names are in alphabetical order. Duplicate names may appear if  (?|
        is used to create multiple groups with the same number, as described in
-       the  section  on  duplicate subpattern numbers in the pcrepattern page.
-       Duplicate names for subpatterns with different  numbers  are  permitted
-       only  if  PCRE_DUPNAMES  is  set. In all cases of duplicate names, they
-       appear in the table in the order in which they were found in  the  pat-
-       tern.  In  the  absence  of (?| this is the order of increasing number;
+       the section on duplicate subpattern numbers in  the  pcrepattern  page.
+       Duplicate  names  for  subpatterns with different numbers are permitted
+       only if PCRE_DUPNAMES is set. In all cases  of  duplicate  names,  they
+       appear  in  the table in the order in which they were found in the pat-
+       tern. In the absence of (?| this is the  order  of  increasing  number;
        when (?| is used this is not necessarily the case because later subpat-
        terns may have lower numbers.
 
-       As  a  simple  example of the name/number table, consider the following
-       pattern (assume PCRE_EXTENDED is set, so white space -  including  new-
+       As a simple example of the name/number table,  consider  the  following
+       pattern  (assume  PCRE_EXTENDED is set, so white space - including new-
        lines - is ignored):
 
          (?<date> (?<year>(\d\d)?\d\d) -
          (?<month>\d\d) - (?<day>\d\d) )
 
-       There  are  four  named subpatterns, so the table has four entries, and
-       each entry in the table is eight bytes long. The table is  as  follows,
+       There are four named subpatterns, so the table has  four  entries,  and
+       each  entry  in the table is eight bytes long. The table is as follows,
        with non-printing bytes shows in hexadecimal, and undefined bytes shown
        as ??:
 
@@ -1758,31 +1792,31 @@ INFORMATION ABOUT A PATTERN
          00 04 m  o  n  t  h  00
          00 02 y  e  a  r  00 ??
 
-       When writing code to extract data  from  named  subpatterns  using  the
-       name-to-number  map,  remember that the length of the entries is likely
+       When  writing  code  to  extract  data from named subpatterns using the
+       name-to-number map, remember that the length of the entries  is  likely
        to be different for each compiled pattern.
 
          PCRE_INFO_OKPARTIAL
 
-       Return 1  if  the  pattern  can  be  used  for  partial  matching  with
-       pcre_exec(),  otherwise  0.  The fourth argument should point to an int
-       variable. From  release  8.00,  this  always  returns  1,  because  the
-       restrictions  that  previously  applied  to  partial matching have been
-       lifted. The pcrepartial documentation gives details of  partial  match-
+       Return  1  if  the  pattern  can  be  used  for  partial  matching with
+       pcre_exec(), otherwise 0. The fourth argument should point  to  an  int
+       variable.  From  release  8.00,  this  always  returns  1,  because the
+       restrictions that previously applied  to  partial  matching  have  been
+       lifted.  The  pcrepartial documentation gives details of partial match-
        ing.
 
          PCRE_INFO_OPTIONS
 
-       Return  a  copy of the options with which the pattern was compiled. The
-       fourth argument should point to an unsigned long  int  variable.  These
+       Return a copy of the options with which the pattern was  compiled.  The
+       fourth  argument  should  point to an unsigned long int variable. These
        option bits are those specified in the call to pcre_compile(), modified
        by any top-level option settings at the start of the pattern itself. In
-       other  words,  they are the options that will be in force when matching
-       starts. For example, if the pattern /(?im)abc(?-i)d/ is  compiled  with
-       the  PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE,
+       other words, they are the options that will be in force  when  matching
+       starts.  For  example, if the pattern /(?im)abc(?-i)d/ is compiled with
+       the PCRE_EXTENDED option, the result is PCRE_CASELESS,  PCRE_MULTILINE,
        and PCRE_EXTENDED.
 
-       A pattern is automatically anchored by PCRE if  all  of  its  top-level
+       A  pattern  is  automatically  anchored by PCRE if all of its top-level
        alternatives begin with one of the following:
 
          ^     unless PCRE_MULTILINE is set
@@ -1796,7 +1830,7 @@ INFORMATION ABOUT A PATTERN
 
          PCRE_INFO_SIZE
 
-       Return the size of the compiled pattern, that is, the  value  that  was
+       Return  the  size  of the compiled pattern, that is, the value that was
        passed as the argument to pcre_malloc() when PCRE was getting memory in
        which to place the compiled data. The fourth argument should point to a
        size_t variable.
@@ -1804,10 +1838,10 @@ INFORMATION ABOUT A PATTERN
          PCRE_INFO_STUDYSIZE
 
        Return the size of the data block pointed to by the study_data field in
-       a pcre_extra block. That is,  it  is  the  value  that  was  passed  to
+       a  pcre_extra  block.  That  is,  it  is  the  value that was passed to
        pcre_malloc() when PCRE was getting memory into which to place the data
-       created by pcre_study(). If pcre_extra is NULL, or there  is  no  study
-       data,  zero  is  returned. The fourth argument should point to a size_t
+       created  by  pcre_study().  If pcre_extra is NULL, or there is no study
+       data, zero is returned. The fourth argument should point  to  a  size_t
        variable.
 
 
@@ -1815,21 +1849,21 @@ OBSOLETE INFO FUNCTION
 
        int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
 
-       The pcre_info() function is now obsolete because its interface  is  too
-       restrictive  to return all the available data about a compiled pattern.
-       New  programs  should  use  pcre_fullinfo()  instead.  The   yield   of
-       pcre_info()  is the number of capturing subpatterns, or one of the fol-
+       The  pcre_info()  function is now obsolete because its interface is too
+       restrictive to return all the available data about a compiled  pattern.
+       New   programs   should  use  pcre_fullinfo()  instead.  The  yield  of
+       pcre_info() is the number of capturing subpatterns, or one of the  fol-
        lowing negative numbers:
 
          PCRE_ERROR_NULL       the argument code was NULL
          PCRE_ERROR_BADMAGIC   the "magic number" was not found
 
-       If the optptr argument is not NULL, a copy of the  options  with  which
-       the  pattern  was  compiled  is placed in the integer it points to (see
+       If  the  optptr  argument is not NULL, a copy of the options with which
+       the pattern was compiled is placed in the integer  it  points  to  (see
        PCRE_INFO_OPTIONS above).
 
-       If the pattern is not anchored and the  firstcharptr  argument  is  not
-       NULL,  it is used to pass back information about the first character of
+       If  the  pattern  is  not anchored and the firstcharptr argument is not
+       NULL, it is used to pass back information about the first character  of
        any matched string (see PCRE_INFO_FIRSTBYTE above).
 
 
@@ -1837,21 +1871,21 @@ REFERENCE COUNTS
 
        int pcre_refcount(pcre *code, int adjust);
 
-       The pcre_refcount() function is used to maintain a reference  count  in
+       The  pcre_refcount()  function is used to maintain a reference count in
        the data block that contains a compiled pattern. It is provided for the
-       benefit of applications that  operate  in  an  object-oriented  manner,
+       benefit  of  applications  that  operate  in an object-oriented manner,
        where different parts of the application may be using the same compiled
        pattern, but you want to free the block when they are all done.
 
        When a pattern is compiled, the reference count field is initialized to
-       zero.   It is changed only by calling this function, whose action is to
-       add the adjust value (which may be positive or  negative)  to  it.  The
+       zero.  It is changed only by calling this function, whose action is  to
+       add  the  adjust  value  (which may be positive or negative) to it. The
        yield of the function is the new value. However, the value of the count
-       is constrained to lie between 0 and 65535, inclusive. If the new  value
+       is  constrained to lie between 0 and 65535, inclusive. If the new value
        is outside these limits, it is forced to the appropriate limit value.
 
-       Except  when it is zero, the reference count is not correctly preserved
-       if a pattern is compiled on one host and then  transferred  to  a  host
+       Except when it is zero, the reference count is not correctly  preserved
+       if  a  pattern  is  compiled on one host and then transferred to a host
        whose byte-order is different. (This seems a highly unlikely scenario.)
 
 
@@ -1861,18 +1895,18 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
             const char *subject, int length, int startoffset,
             int options, int *ovector, int ovecsize);
 
-       The  function pcre_exec() is called to match a subject string against a
-       compiled pattern, which is passed in the code argument. If the  pattern
-       was  studied,  the  result  of  the study should be passed in the extra
-       argument. This function is the main matching facility of  the  library,
+       The function pcre_exec() is called to match a subject string against  a
+       compiled  pattern, which is passed in the code argument. If the pattern
+       was studied, the result of the study should  be  passed  in  the  extra
+       argument.  This  function is the main matching facility of the library,
        and it operates in a Perl-like manner. For specialist use there is also
-       an alternative matching function, which is described below in the  sec-
+       an  alternative matching function, which is described below in the sec-
        tion about the pcre_dfa_exec() function.
 
-       In  most applications, the pattern will have been compiled (and option-
-       ally studied) in the same process that calls pcre_exec().  However,  it
+       In most applications, the pattern will have been compiled (and  option-
+       ally  studied)  in the same process that calls pcre_exec(). However, it
        is possible to save compiled patterns and study data, and then use them
-       later in different processes, possibly even on different hosts.  For  a
+       later  in  different processes, possibly even on different hosts. For a
        discussion about this, see the pcreprecompile documentation.
 
        Here is an example of a simple call to pcre_exec():
@@ -1891,10 +1925,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
 
    Extra data for pcre_exec()
 
-       If  the  extra argument is not NULL, it must point to a pcre_extra data
-       block. The pcre_study() function returns such a block (when it  doesn't
-       return  NULL), but you can also create one for yourself, and pass addi-
-       tional information in it. The pcre_extra block contains  the  following
+       If the extra argument is not NULL, it must point to a  pcre_extra  data
+       block.  The pcre_study() function returns such a block (when it doesn't
+       return NULL), but you can also create one for yourself, and pass  addi-
+       tional  information  in it. The pcre_extra block contains the following
        fields (not necessarily in this order):
 
          unsigned long int flags;
@@ -1903,8 +1937,9 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          unsigned long int match_limit_recursion;
          void *callout_data;
          const unsigned char *tables;
+         unsigned char **mark;
 
-       The  flags  field  is a bitmap that specifies which of the other fields
+       The flags field is a bitmap that specifies which of  the  other  fields
        are set. The flag bits are:
 
          PCRE_EXTRA_STUDY_DATA
@@ -1912,85 +1947,98 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          PCRE_EXTRA_MATCH_LIMIT_RECURSION
          PCRE_EXTRA_CALLOUT_DATA
          PCRE_EXTRA_TABLES
+         PCRE_EXTRA_MARK
 
-       Other flag bits should be set to zero. The study_data field is  set  in
-       the  pcre_extra  block  that is returned by pcre_study(), together with
+       Other  flag  bits should be set to zero. The study_data field is set in
+       the pcre_extra block that is returned by  pcre_study(),  together  with
        the appropriate flag bit. You should not set this yourself, but you may
-       add  to  the  block by setting the other fields and their corresponding
+       add to the block by setting the other fields  and  their  corresponding
        flag bits.
 
        The match_limit field provides a means of preventing PCRE from using up
-       a  vast amount of resources when running patterns that are not going to
-       match, but which have a very large number  of  possibilities  in  their
-       search  trees. The classic example is a pattern that uses nested unlim-
+       a vast amount of resources when running patterns that are not going  to
+       match,  but  which  have  a very large number of possibilities in their
+       search trees. The classic example is a pattern that uses nested  unlim-
        ited repeats.
 
-       Internally, PCRE uses a function called match() which it calls  repeat-
-       edly  (sometimes  recursively). The limit set by match_limit is imposed
-       on the number of times this function is called during  a  match,  which
-       has  the  effect  of  limiting the amount of backtracking that can take
+       Internally,  PCRE uses a function called match() which it calls repeat-
+       edly (sometimes recursively). The limit set by match_limit  is  imposed
+       on  the  number  of times this function is called during a match, which
+       has the effect of limiting the amount of  backtracking  that  can  take
        place. For patterns that are not anchored, the count restarts from zero
        for each position in the subject string.
 
-       The  default  value  for  the  limit can be set when PCRE is built; the
-       default default is 10 million, which handles all but the  most  extreme
-       cases.  You  can  override  the  default by suppling pcre_exec() with a
-       pcre_extra    block    in    which    match_limit    is    set,     and
-       PCRE_EXTRA_MATCH_LIMIT  is  set  in  the  flags  field. If the limit is
+       The default value for the limit can be set  when  PCRE  is  built;  the
+       default  default  is 10 million, which handles all but the most extreme
+       cases. You can override the default  by  suppling  pcre_exec()  with  a
+       pcre_extra     block    in    which    match_limit    is    set,    and
+       PCRE_EXTRA_MATCH_LIMIT is set in the  flags  field.  If  the  limit  is
        exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
 
-       The match_limit_recursion field is similar to match_limit, but  instead
+       The  match_limit_recursion field is similar to match_limit, but instead
        of limiting the total number of times that match() is called, it limits
-       the depth of recursion. The recursion depth is a  smaller  number  than
-       the  total number of calls, because not all calls to match() are recur-
+       the  depth  of  recursion. The recursion depth is a smaller number than
+       the total number of calls, because not all calls to match() are  recur-
        sive.  This limit is of use only if it is set smaller than match_limit.
 
-       Limiting the recursion depth limits the amount of  stack  that  can  be
+       Limiting  the  recursion  depth  limits the amount of stack that can be
        used, or, when PCRE has been compiled to use memory on the heap instead
        of the stack, the amount of heap memory that can be used.
 
-       The default value for match_limit_recursion can be  set  when  PCRE  is
-       built;  the  default  default  is  the  same  value  as the default for
-       match_limit. You can override the default by suppling pcre_exec()  with
-       a   pcre_extra   block  in  which  match_limit_recursion  is  set,  and
-       PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in  the  flags  field.  If  the
+       The  default  value  for  match_limit_recursion can be set when PCRE is
+       built; the default default  is  the  same  value  as  the  default  for
+       match_limit.  You can override the default by suppling pcre_exec() with
+       a  pcre_extra  block  in  which  match_limit_recursion  is   set,   and
+       PCRE_EXTRA_MATCH_LIMIT_RECURSION  is  set  in  the  flags field. If the
        limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
 
-       The  callout_data  field is used in conjunction with the "callout" fea-
+       The callout_data field is used in conjunction with the  "callout"  fea-
        ture, and is described in the pcrecallout documentation.
 
-       The tables field  is  used  to  pass  a  character  tables  pointer  to
-       pcre_exec();  this overrides the value that is stored with the compiled
-       pattern. A non-NULL value is stored with the compiled pattern  only  if
-       custom  tables  were  supplied to pcre_compile() via its tableptr argu-
+       The  tables  field  is  used  to  pass  a  character  tables pointer to
+       pcre_exec(); this overrides the value that is stored with the  compiled
+       pattern.  A  non-NULL value is stored with the compiled pattern only if
+       custom tables were supplied to pcre_compile() via  its  tableptr  argu-
        ment.  If NULL is passed to pcre_exec() using this mechanism, it forces
-       PCRE's  internal  tables  to be used. This facility is helpful when re-
-       using patterns that have been saved after compiling  with  an  external
-       set  of  tables,  because  the  external tables might be at a different
-       address when pcre_exec() is called. See the  pcreprecompile  documenta-
+       PCRE's internal tables to be used. This facility is  helpful  when  re-
+       using  patterns  that  have been saved after compiling with an external
+       set of tables, because the external tables  might  be  at  a  different
+       address  when  pcre_exec() is called. See the pcreprecompile documenta-
        tion for a discussion of saving compiled patterns for later use.
 
+       If PCRE_EXTRA_MARK is set in the flags field, the mark  field  must  be
+       set  to  point  to a char * variable. If the pattern contains any back-
+       tracking control verbs such as (*MARK:NAME), and the execution ends  up
+       with  a  name  to  pass back, a pointer to the name string (zero termi-
+       nated) is placed in the variable pointed to  by  the  mark  field.  The
+       names  are  within  the  compiled pattern; if you wish to retain such a
+       name you must copy it before freeing the memory of a compiled  pattern.
+       If  there  is no name to pass back, the variable pointed to by the mark
+       field set to NULL. For details of the backtracking control  verbs,  see
+       the section entitled "Backtracking control" in the pcrepattern documen-
+       tation.
+
    Option bits for pcre_exec()
 
-       The  unused  bits of the options argument for pcre_exec() must be zero.
-       The only bits that may  be  set  are  PCRE_ANCHORED,  PCRE_NEWLINE_xxx,
-       PCRE_NOTBOL,    PCRE_NOTEOL,    PCRE_NOTEMPTY,   PCRE_NOTEMPTY_ATSTART,
-       PCRE_NO_START_OPTIMIZE,  PCRE_NO_UTF8_CHECK,   PCRE_PARTIAL_SOFT,   and
+       The unused bits of the options argument for pcre_exec() must  be  zero.
+       The  only  bits  that  may  be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
+       PCRE_NOTBOL,   PCRE_NOTEOL,    PCRE_NOTEMPTY,    PCRE_NOTEMPTY_ATSTART,
+       PCRE_NO_START_OPTIMIZE,   PCRE_NO_UTF8_CHECK,   PCRE_PARTIAL_SOFT,  and
        PCRE_PARTIAL_HARD.
 
          PCRE_ANCHORED
 
-       The  PCRE_ANCHORED  option  limits pcre_exec() to matching at the first
-       matching position. If a pattern was  compiled  with  PCRE_ANCHORED,  or
-       turned  out to be anchored by virtue of its contents, it cannot be made
+       The PCRE_ANCHORED option limits pcre_exec() to matching  at  the  first
+       matching  position.  If  a  pattern was compiled with PCRE_ANCHORED, or
+       turned out to be anchored by virtue of its contents, it cannot be  made
        unachored at matching time.
 
          PCRE_BSR_ANYCRLF
          PCRE_BSR_UNICODE
 
        These options (which are mutually exclusive) control what the \R escape
-       sequence  matches.  The choice is either to match only CR, LF, or CRLF,
-       or to match any Unicode newline sequence. These  options  override  the
+       sequence matches. The choice is either to match only CR, LF,  or  CRLF,
+       or  to  match  any Unicode newline sequence. These options override the
        choice that was made or defaulted when the pattern was compiled.
 
          PCRE_NEWLINE_CR
@@ -1999,94 +2047,129 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
          PCRE_NEWLINE_ANYCRLF
          PCRE_NEWLINE_ANY
 
-       These  options  override  the  newline  definition  that  was chosen or
-       defaulted when the pattern was compiled. For details, see the  descrip-
-       tion  of  pcre_compile()  above.  During  matching,  the newline choice
-       affects the behaviour of the dot, circumflex,  and  dollar  metacharac-
-       ters.  It may also alter the way the match position is advanced after a
+       These options override  the  newline  definition  that  was  chosen  or
+       defaulted  when the pattern was compiled. For details, see the descrip-
+       tion of pcre_compile()  above.  During  matching,  the  newline  choice
+       affects  the  behaviour  of the dot, circumflex, and dollar metacharac-
+       ters. It may also alter the way the match position is advanced after  a
        match failure for an unanchored pattern.
 
-       When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF,  or  PCRE_NEWLINE_ANY  is
-       set,  and a match attempt for an unanchored pattern fails when the cur-
-       rent position is at a  CRLF  sequence,  and  the  pattern  contains  no
-       explicit  matches  for  CR  or  LF  characters,  the  match position is
+       When  PCRE_NEWLINE_CRLF,  PCRE_NEWLINE_ANYCRLF,  or PCRE_NEWLINE_ANY is
+       set, and a match attempt for an unanchored pattern fails when the  cur-
+       rent  position  is  at  a  CRLF  sequence,  and the pattern contains no
+       explicit matches for  CR  or  LF  characters,  the  match  position  is
        advanced by two characters instead of one, in other words, to after the
        CRLF.
 
        The above rule is a compromise that makes the most common cases work as
-       expected. For example, if the  pattern  is  .+A  (and  the  PCRE_DOTALL
+       expected.  For  example,  if  the  pattern  is .+A (and the PCRE_DOTALL
        option is not set), it does not match the string "\r\nA" because, after
-       failing at the start, it skips both the CR and the LF before  retrying.
-       However,  the  pattern  [\r\n]A does match that string, because it con-
+       failing  at the start, it skips both the CR and the LF before retrying.
+       However, the pattern [\r\n]A does match that string,  because  it  con-
        tains an explicit CR or LF reference, and so advances only by one char-
        acter after the first failure.
 
        An explicit match for CR of LF is either a literal appearance of one of
-       those characters, or one of the \r or  \n  escape  sequences.  Implicit
-       matches  such  as [^X] do not count, nor does \s (which includes CR and
+       those  characters,  or  one  of the \r or \n escape sequences. Implicit
+       matches such as [^X] do not count, nor does \s (which includes  CR  and
        LF in the characters that it matches).
 
-       Notwithstanding the above, anomalous effects may still occur when  CRLF
+       Notwithstanding  the above, anomalous effects may still occur when CRLF
        is a valid newline sequence and explicit \r or \n escapes appear in the
        pattern.
 
          PCRE_NOTBOL
 
        This option specifies that first character of the subject string is not
-       the  beginning  of  a  line, so the circumflex metacharacter should not
-       match before it. Setting this without PCRE_MULTILINE (at compile  time)
-       causes  circumflex  never to match. This option affects only the behav-
+       the beginning of a line, so the  circumflex  metacharacter  should  not
+       match  before it. Setting this without PCRE_MULTILINE (at compile time)
+       causes circumflex never to match. This option affects only  the  behav-
        iour of the circumflex metacharacter. It does not affect \A.
 
          PCRE_NOTEOL
 
        This option specifies that the end of the subject string is not the end
-       of  a line, so the dollar metacharacter should not match it nor (except
-       in multiline mode) a newline immediately before it. Setting this  with-
+       of a line, so the dollar metacharacter should not match it nor  (except
+       in  multiline mode) a newline immediately before it. Setting this with-
        out PCRE_MULTILINE (at compile time) causes dollar never to match. This
-       option affects only the behaviour of the dollar metacharacter. It  does
+       option  affects only the behaviour of the dollar metacharacter. It does
        not affect \Z or \z.
 
          PCRE_NOTEMPTY
 
        An empty string is not considered to be a valid match if this option is
-       set. If there are alternatives in the pattern, they are tried.  If  all
-       the  alternatives  match  the empty string, the entire match fails. For
+       set.  If  there are alternatives in the pattern, they are tried. If all
+       the alternatives match the empty string, the entire  match  fails.  For
        example, if the pattern
 
          a?b?
 
-       is applied to a string not beginning with "a" or  "b",  it  matches  an
-       empty  string at the start of the subject. With PCRE_NOTEMPTY set, this
+       is  applied  to  a  string not beginning with "a" or "b", it matches an
+       empty string at the start of the subject. With PCRE_NOTEMPTY set,  this
        match is not valid, so PCRE searches further into the string for occur-
        rences of "a" or "b".
 
          PCRE_NOTEMPTY_ATSTART
 
-       This  is  like PCRE_NOTEMPTY, except that an empty string match that is
-       not at the start of  the  subject  is  permitted.  If  the  pattern  is
+       This is like PCRE_NOTEMPTY, except that an empty string match  that  is
+       not  at  the  start  of  the  subject  is  permitted. If the pattern is
        anchored, such a match can occur only if the pattern contains \K.
 
-       Perl     has    no    direct    equivalent    of    PCRE_NOTEMPTY    or
-       PCRE_NOTEMPTY_ATSTART, but it does make a special  case  of  a  pattern
-       match  of  the empty string within its split() function, and when using
-       the /g modifier. It is  possible  to  emulate  Perl's  behaviour  after
+       Perl    has    no    direct    equivalent    of    PCRE_NOTEMPTY     or
+       PCRE_NOTEMPTY_ATSTART,  but  it  does  make a special case of a pattern
+       match of the empty string within its split() function, and  when  using
+       the  /g  modifier.  It  is  possible  to emulate Perl's behaviour after
        matching a null string by first trying the match again at the same off-
-       set with PCRE_NOTEMPTY_ATSTART and  PCRE_ANCHORED,  and  then  if  that
+       set  with  PCRE_NOTEMPTY_ATSTART  and  PCRE_ANCHORED,  and then if that
        fails, by advancing the starting offset (see below) and trying an ordi-
-       nary match again. There is some code that demonstrates how to  do  this
+       nary  match  again. There is some code that demonstrates how to do this
        in the pcredemo sample program.
 
          PCRE_NO_START_OPTIMIZE
 
-       There  are a number of optimizations that pcre_exec() uses at the start
-       of a match, in order to speed up the process. For  example,  if  it  is
-       known  that  a  match must start with a specific character, it searches
-       the subject for that character, and fails immediately if it cannot find
-       it,  without actually running the main matching function. When callouts
-       are in use, these optimizations can cause  them  to  be  skipped.  This
-       option  disables  the  "start-up" optimizations, causing performance to
-       suffer, but ensuring that the callouts do occur.
+       There are a number of optimizations that pcre_exec() uses at the  start
+       of  a  match,  in  order to speed up the process. For example, if it is
+       known that an unanchored match must start with a specific character, it
+       searches  the  subject  for that character, and fails immediately if it
+       cannot find it, without actually running the  main  matching  function.
+       This means that a special item such as (*COMMIT) at the start of a pat-
+       tern is not considered until after a suitable starting  point  for  the
+       match  has been found. When callouts or (*MARK) items are in use, these
+       "start-up" optimizations can cause them to be skipped if the pattern is
+       never  actually  used.  The start-up optimizations are in effect a pre-
+       scan of the subject that takes place before the pattern is run.
+
+       The PCRE_NO_START_OPTIMIZE option disables the start-up  optimizations,
+       possibly  causing  performance  to  suffer,  but ensuring that in cases
+       where the result is "no match", the callouts do occur, and  that  items
+       such as (*COMMIT) and (*MARK) are considered at every possible starting
+       position in the subject  string.   Setting  PCRE_NO_START_OPTIMIZE  can
+       change the outcome of a matching operation.  Consider the pattern
+
+         (*COMMIT)ABC
+
+       When  this  is  compiled, PCRE records the fact that a match must start
+       with the character "A". Suppose the subject  string  is  "DEFABC".  The
+       start-up  optimization  scans along the subject, finds "A" and runs the
+       first match attempt from there. The (*COMMIT) item means that the  pat-
+       tern  must  match the current starting position, which in this case, it
+       does. However, if the same match  is  run  with  PCRE_NO_START_OPTIMIZE
+       set,  the  initial  scan  along the subject string does not happen. The
+       first match attempt is run starting  from  "D"  and  when  this  fails,
+       (*COMMIT)  prevents  any  further  matches  being tried, so the overall
+       result is "no match". If the pattern is studied,  more  start-up  opti-
+       mizations  may  be  used. For example, a minimum length for the subject
+       may be recorded. Consider the pattern
+
+         (*MARK:A)(X|Y)
+
+       The minimum length for a match is one  character.  If  the  subject  is
+       "ABC",  there  will  be  attempts  to  match "ABC", "BC", "C", and then
+       finally an empty string.  If the pattern is studied, the final  attempt
+       does  not take place, because PCRE knows that the subject is too short,
+       and so the (*MARK) is never encountered.  In this  case,  studying  the
+       pattern  does  not  affect the overall match result, which is still "no
+       match", but it does affect the auxiliary information that is returned.
 
          PCRE_NO_UTF8_CHECK
 
@@ -2273,6 +2356,10 @@ MATCHING A PATTERN: THE TRADITIONAL FUNCTION
        purpose.  If the call via pcre_malloc() fails, this error is given. The
        memory is automatically freed at the end of matching.
 
+       This error is also given if pcre_stack_malloc() fails  in  pcre_exec().
+       This  can happen only when PCRE has been compiled with --disable-stack-
+       for-recursion.
+
          PCRE_ERROR_NOSUBSTRING    (-7)
 
        This error is used by the pcre_copy_substring(),  pcre_get_substring(),
@@ -2584,49 +2671,50 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
        The unused bits of the options argument  for  pcre_dfa_exec()  must  be
        zero.  The  only  bits  that  may  be  set are PCRE_ANCHORED, PCRE_NEW-
        LINE_xxx,        PCRE_NOTBOL,        PCRE_NOTEOL,        PCRE_NOTEMPTY,
-       PCRE_NOTEMPTY_ATSTART, PCRE_NO_UTF8_CHECK, PCRE_PARTIAL_HARD, PCRE_PAR-
-       TIAL_SOFT, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All  but  the  last
-       four  of  these  are  exactly  the  same  as  for pcre_exec(), so their
+       PCRE_NOTEMPTY_ATSTART,       PCRE_NO_UTF8_CHECK,      PCRE_BSR_ANYCRLF,
+       PCRE_BSR_UNICODE, PCRE_NO_START_OPTIMIZE, PCRE_PARTIAL_HARD,  PCRE_PAR-
+       TIAL_SOFT,  PCRE_DFA_SHORTEST,  and PCRE_DFA_RESTART.  All but the last
+       four of these are  exactly  the  same  as  for  pcre_exec(),  so  their
        description is not repeated here.
 
          PCRE_PARTIAL_HARD
          PCRE_PARTIAL_SOFT
 
-       These have the same general effect as they do for pcre_exec(), but  the
-       details  are  slightly  different.  When  PCRE_PARTIAL_HARD  is set for
-       pcre_dfa_exec(), it returns PCRE_ERROR_PARTIAL if the end of  the  sub-
-       ject  is  reached  and there is still at least one matching possibility
+       These  have the same general effect as they do for pcre_exec(), but the
+       details are slightly  different.  When  PCRE_PARTIAL_HARD  is  set  for
+       pcre_dfa_exec(),  it  returns PCRE_ERROR_PARTIAL if the end of the sub-
+       ject is reached and there is still at least  one  matching  possibility
        that requires additional characters. This happens even if some complete
        matches have also been found. When PCRE_PARTIAL_SOFT is set, the return
        code PCRE_ERROR_NOMATCH is converted into PCRE_ERROR_PARTIAL if the end
-       of  the  subject  is  reached, there have been no complete matches, but
-       there is still at least one matching possibility. The  portion  of  the
-       string  that  was inspected when the longest partial match was found is
+       of the subject is reached, there have been  no  complete  matches,  but
+       there  is  still  at least one matching possibility. The portion of the
+       string that was inspected when the longest partial match was  found  is
        set as the first matching string in both cases.
 
          PCRE_DFA_SHORTEST
 
-       Setting the PCRE_DFA_SHORTEST option causes the matching  algorithm  to
+       Setting  the  PCRE_DFA_SHORTEST option causes the matching algorithm to
        stop as soon as it has found one match. Because of the way the alterna-
-       tive algorithm works, this is necessarily the shortest  possible  match
+       tive  algorithm  works, this is necessarily the shortest possible match
        at the first possible matching point in the subject string.
 
          PCRE_DFA_RESTART
 
        When pcre_dfa_exec() returns a partial match, it is possible to call it
-       again, with additional subject characters, and have  it  continue  with
-       the  same match. The PCRE_DFA_RESTART option requests this action; when
-       it is set, the workspace and wscount options must  reference  the  same
-       vector  as  before  because data about the match so far is left in them
+       again,  with  additional  subject characters, and have it continue with
+       the same match. The PCRE_DFA_RESTART option requests this action;  when
+       it  is  set,  the workspace and wscount options must reference the same
+       vector as before because data about the match so far is  left  in  them
        after a partial match. There is more discussion of this facility in the
        pcrepartial documentation.
 
    Successful returns from pcre_dfa_exec()
 
-       When  pcre_dfa_exec()  succeeds, it may have matched more than one sub-
+       When pcre_dfa_exec() succeeds, it may have matched more than  one  sub-
        string in the subject. Note, however, that all the matches from one run
-       of  the  function  start  at the same point in the subject. The shorter
-       matches are all initial substrings of the longer matches. For  example,
+       of the function start at the same point in  the  subject.  The  shorter
+       matches  are all initial substrings of the longer matches. For example,
        if the pattern
 
          <.*>
@@ -2641,61 +2729,61 @@ MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
          <something> <something else>
          <something> <something else> <something further>
 
-       On  success,  the  yield of the function is a number greater than zero,
-       which is the number of matched substrings.  The  substrings  themselves
-       are  returned  in  ovector. Each string uses two elements; the first is
-       the offset to the start, and the second is the offset to  the  end.  In
-       fact,  all  the  strings  have the same start offset. (Space could have
-       been saved by giving this only once, but it was decided to retain  some
-       compatibility  with  the  way pcre_exec() returns data, even though the
+       On success, the yield of the function is a number  greater  than  zero,
+       which  is  the  number of matched substrings. The substrings themselves
+       are returned in ovector. Each string uses two elements;  the  first  is
+       the  offset  to  the start, and the second is the offset to the end. In
+       fact, all the strings have the same start  offset.  (Space  could  have
+       been  saved by giving this only once, but it was decided to retain some
+       compatibility with the way pcre_exec() returns data,  even  though  the
        meaning of the strings is different.)
 
        The strings are returned in reverse order of length; that is, the long-
-       est  matching  string is given first. If there were too many matches to
-       fit into ovector, the yield of the function is zero, and the vector  is
+       est matching string is given first. If there were too many  matches  to
+       fit  into ovector, the yield of the function is zero, and the vector is
        filled with the longest matches.
 
    Error returns from pcre_dfa_exec()
 
-       The  pcre_dfa_exec()  function returns a negative number when it fails.
-       Many of the errors are the same  as  for  pcre_exec(),  and  these  are
-       described  above.   There are in addition the following errors that are
+       The pcre_dfa_exec() function returns a negative number when  it  fails.
+       Many  of  the  errors  are  the  same as for pcre_exec(), and these are
+       described above.  There are in addition the following errors  that  are
        specific to pcre_dfa_exec():
 
          PCRE_ERROR_DFA_UITEM      (-16)
 
-       This return is given if pcre_dfa_exec() encounters an item in the  pat-
-       tern  that  it  does not support, for instance, the use of \C or a back
+       This  return is given if pcre_dfa_exec() encounters an item in the pat-
+       tern that it does not support, for instance, the use of \C  or  a  back
        reference.
 
          PCRE_ERROR_DFA_UCOND      (-17)
 
-       This return is given if pcre_dfa_exec()  encounters  a  condition  item
-       that  uses  a back reference for the condition, or a test for recursion
+       This  return  is  given  if pcre_dfa_exec() encounters a condition item
+       that uses a back reference for the condition, or a test  for  recursion
        in a specific group. These are not supported.
 
          PCRE_ERROR_DFA_UMLIMIT    (-18)
 
-       This return is given if pcre_dfa_exec() is called with an  extra  block
+       This  return  is given if pcre_dfa_exec() is called with an extra block
        that contains a setting of the match_limit field. This is not supported
        (it is meaningless).
 
          PCRE_ERROR_DFA_WSSIZE     (-19)
 
-       This return is given if  pcre_dfa_exec()  runs  out  of  space  in  the
+       This  return  is  given  if  pcre_dfa_exec()  runs  out of space in the
        workspace vector.
 
          PCRE_ERROR_DFA_RECURSE    (-20)
 
-       When  a  recursive subpattern is processed, the matching function calls
-       itself recursively, using private vectors for  ovector  and  workspace.
-       This  error  is  given  if  the output vector is not large enough. This
+       When a recursive subpattern is processed, the matching  function  calls
+       itself  recursively,  using  private vectors for ovector and workspace.
+       This error is given if the output vector  is  not  large  enough.  This
        should be extremely rare, as a vector of size 1000 is used.
 
 
 SEE ALSO
 
-       pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3),  pcrepar-
+       pcrebuild(3),  pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-
        tial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
 
 
@@ -2708,8 +2796,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 03 October 2009
-       Copyright (c) 1997-2009 University of Cambridge.
+       Last updated: 21 June 2010
+       Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -2905,7 +2993,7 @@ DIFFERENCES BETWEEN PCRE AND PERL
 
        This  document describes the differences in the ways that PCRE and Perl
        handle regular expressions. The differences  described  here  are  with
-       respect to Perl 5.10.
+       respect to Perl 5.10/5.11.
 
        1.  PCRE has only a subset of Perl's UTF-8 and Unicode support. Details
        of what it does have are given in the section on UTF-8 support  in  the
@@ -2976,11 +3064,7 @@ DIFFERENCES BETWEEN PCRE AND PERL
        matching "aba" against the  pattern  /^(a(b)?)+$/  in  Perl  leaves  $2
        unset, but in PCRE it is set to "b".
 
-       11.  PCRE  does  support  Perl  5.10's  backtracking  verbs  (*ACCEPT),
-       (*FAIL), (*F), (*COMMIT), (*PRUNE), (*SKIP), and (*THEN), but  only  in
-       the forms without an argument. PCRE does not support (*MARK).
-
-       12.  PCRE's handling of duplicate subpattern numbers and duplicate sub-
+       11.  PCRE's handling of duplicate subpattern numbers and duplicate sub-
        pattern names is not as general as Perl's. This is a consequence of the
        fact the PCRE works internally just with numbers, using an external ta-
        ble to translate between numbers and names. In  particular,  a  pattern
@@ -2991,7 +3075,7 @@ DIFFERENCES BETWEEN PCRE AND PERL
        turing subpattern number 1. To avoid this confusing situation, an error
        is given at compile time.
 
-       13. PCRE provides some extensions to the Perl regular expression facil-
+       12. PCRE provides some extensions to the Perl regular expression facil-
        ities.   Perl  5.10  includes new features that are not in earlier ver-
        sions of Perl, some of which (such as named parentheses) have  been  in
        PCRE for some time. This list is with respect to Perl 5.10:
@@ -3046,8 +3130,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 04 October 2009
-       Copyright (c) 1997-2009 University of Cambridge.
+       Last updated: 12 May 2010
+       Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -3089,6 +3173,16 @@ PCRE REGULAR EXPRESSION DETAILS
        below.  There  is  also  a  summary of UTF-8 features in the section on
        UTF-8 support in the main pcre page.
 
+       Another special sequence that may appear at the start of a  pattern  or
+       in combination with (*UTF8) is:
+
+         (*UCP)
+
+       This  has  the  same  effect  as setting the PCRE_UCP option: it causes
+       sequences such as \d and \w to  use  Unicode  properties  to  determine
+       character types, instead of recognizing only characters with codes less
+       than 128 via a lookup table.
+
        The remainder of this document discusses the  patterns  that  are  sup-
        ported  by  PCRE when its main matching function, pcre_exec(), is used.
        From  release  6.0,   PCRE   offers   a   second   matching   function,
@@ -3129,11 +3223,13 @@ NEWLINE CONVENTIONS
        and that they must be in upper case.  If  more  than  one  of  them  is
        present, the last one is used.
 
-       The  newline  convention  does  not  affect what the \R escape sequence
-       matches. By default, this is any Unicode  newline  sequence,  for  Perl
-       compatibility.  However, this can be changed; see the description of \R
-       in the section entitled "Newline sequences" below. A change of \R  set-
-       ting can be combined with a change of newline convention.
+       The  newline convention affects the interpretation of the dot metachar-
+       acter when PCRE_DOTALL is not set, and also the behaviour of  \N.  How-
+       ever,  it  does  not  affect  what  the  \R escape sequence matches. By
+       default, this is any Unicode newline sequence, for Perl  compatibility.
+       However,  this can be changed; see the description of \R in the section
+       entitled "Newline sequences" below. A change of \R setting can be  com-
+       bined with a change of newline convention.
 
 
 CHARACTERS AND METACHARACTERS
@@ -3315,9 +3411,11 @@ BACKSLASH
        All the sequences that define a single character value can be used both
        inside  and  outside character classes. In addition, inside a character
        class, the sequence \b is interpreted as the backspace  character  (hex
-       08),  and the sequences \R and \X are interpreted as the characters "R"
-       and "X", respectively. Outside a character class, these sequences  have
-       different meanings (see below).
+       08).  The sequences \B, \N, \R, and \X are not special inside a charac-
+       ter class. Like any  other  unrecognized  escape  sequences,  they  are
+       treated  as  the  literal characters "B", "N", "R", and "X" by default,
+       but cause an error if the PCRE_EXTRA option is set. Outside a character
+       class, these sequences have different meanings.
 
    Absolute and relative back references
 
@@ -3337,8 +3435,7 @@ BACKSLASH
 
    Generic character types
 
-       Another use of backslash is for specifying generic character types. The
-       following are always recognized:
+       Another use of backslash is for specifying generic character types:
 
          \d     any decimal digit
          \D     any character that is not a decimal digit
@@ -3351,14 +3448,17 @@ BACKSLASH
          \w     any "word" character
          \W     any "non-word" character
 
-       Each pair of escape sequences partitions the complete set of characters
-       into  two disjoint sets. Any given character matches one, and only one,
-       of each pair.
+       There is also the single sequence \N, which matches a non-newline char-
+       acter.  This is the same as the "." metacharacter when  PCRE_DOTALL  is
+       not set.
 
-       These character type sequences can appear both inside and outside char-
-       acter  classes.  They each match one character of the appropriate type.
-       If the current matching point is at the end of the subject string,  all
-       of them fail, since there is no character to match.
+       Each  pair of lower and upper case escape sequences partitions the com-
+       plete set of characters into two disjoint  sets.  Any  given  character
+       matches  one, and only one, of each pair. The sequences can appear both
+       inside and outside character classes. They each match one character  of
+       the  appropriate  type.  If the current matching point is at the end of
+       the subject string, all of them fail, because there is no character  to
+       match.
 
        For  compatibility  with Perl, \s does not match the VT character (code
        11).  This makes it different from the the POSIX "space" class. The  \s
@@ -3366,16 +3466,37 @@ BACKSLASH
        "use locale;" is included in a Perl script, \s may match the VT charac-
        ter. In PCRE, it never does.
 
-       In  UTF-8 mode, characters with values greater than 128 never match \d,
-       \s, or \w, and always match \D, \S, and \W. This is true even when Uni-
-       code  character  property  support is available. These sequences retain
-       their original meanings from before UTF-8 support was available, mainly
-       for  efficiency  reasons. Note that this also affects \b, because it is
-       defined in terms of \w and \W.
+       A  "word"  character is an underscore or any character that is a letter
+       or digit.  By default, the definition of letters  and  digits  is  con-
+       trolled  by PCRE's low-valued character tables, and may vary if locale-
+       specific matching is taking place (see "Locale support" in the  pcreapi
+       page).  For  example,  in  a French locale such as "fr_FR" in Unix-like
+       systems, or "french" in Windows, some character codes greater than  128
+       are  used  for  accented letters, and these are then matched by \w. The
+       use of locales with Unicode is discouraged.
+
+       By default, in UTF-8 mode, characters  with  values  greater  than  128
+       never  match  \d,  \s,  or  \w,  and always match \D, \S, and \W. These
+       sequences retain their original meanings from before UTF-8 support  was
+       available,  mainly for efficiency reasons. However, if PCRE is compiled
+       with Unicode property support, and the PCRE_UCP option is set, the  be-
+       haviour  is  changed  so  that Unicode properties are used to determine
+       character types, as follows:
+
+         \d  any character that \p{Nd} matches (decimal digit)
+         \s  any character that \p{Z} matches, plus HT, LF, FF, CR
+         \w  any character that \p{L} or \p{N} matches, plus underscore
+
+       The upper case escapes match the inverse sets of characters. Note  that
+       \d  matches  only decimal digits, whereas \w matches any Unicode digit,
+       as well as any Unicode letter, and underscore. Note also that  PCRE_UCP
+       affects  \b,  and  \B  because  they are defined in terms of \w and \W.
+       Matching these sequences is noticeably slower when PCRE_UCP is set.
 
        The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to
-       the  other  sequences, these do match certain high-valued codepoints in
-       UTF-8 mode.  The horizontal space characters are:
+       the  other  sequences,  which  match  only ASCII characters by default,
+       these always  match  certain  high-valued  codepoints  in  UTF-8  mode,
+       whether or not PCRE_UCP is set. The horizontal space characters are:
 
          U+0009     Horizontal tab
          U+0020     Space
@@ -3407,15 +3528,6 @@ BACKSLASH
          U+2028     Line separator
          U+2029     Paragraph separator
 
-       A "word" character is an underscore or any character less than 256 that
-       is  a  letter  or  digit.  The definition of letters and digits is con-
-       trolled by PCRE's low-valued character tables, and may vary if  locale-
-       specific  matching is taking place (see "Locale support" in the pcreapi
-       page). For example, in a French locale such  as  "fr_FR"  in  Unix-like
-       systems,  or "french" in Windows, some character codes greater than 128
-       are used for accented letters, and these are matched by \w. The use  of
-       locales with Unicode is discouraged.
-
    Newline sequences
 
        Outside  a  character class, by default, the escape sequence \R matches
@@ -3454,29 +3566,33 @@ BACKSLASH
        are  not  Perl-compatible,  are  recognized only at the very start of a
        pattern, and that they must be in upper case. If more than one of  them
        is present, the last one is used. They can be combined with a change of
-       newline convention, for example, a pattern can start with:
+       newline convention; for example, a pattern can start with:
 
          (*ANY)(*BSR_ANYCRLF)
 
-       Inside a character class, \R matches the letter "R".
+       They can also be combined with the (*UTF8) or (*UCP) special sequences.
+       Inside  a  character  class,  \R  is  treated as an unrecognized escape
+       sequence, and so matches the letter "R" by default, but causes an error
+       if PCRE_EXTRA is set.
 
    Unicode character properties
 
        When PCRE is built with Unicode character property support, three addi-
-       tional  escape sequences that match characters with specific properties
-       are available.  When not in UTF-8 mode, these sequences are  of  course
-       limited  to  testing characters whose codepoints are less than 256, but
+       tional escape sequences that match characters with specific  properties
+       are  available.   When not in UTF-8 mode, these sequences are of course
+       limited to testing characters whose codepoints are less than  256,  but
        they do work in this mode.  The extra escape sequences are:
 
          \p{xx}   a character with the xx property
          \P{xx}   a character without the xx property
          \X       an extended Unicode sequence
 
-       The property names represented by xx above are limited to  the  Unicode
-       script names, the general category properties, and "Any", which matches
-       any character (including newline). Other properties such as "InMusical-
-       Symbols"  are  not  currently supported by PCRE. Note that \P{Any} does
-       not match any characters, so always causes a match failure.
+       The  property  names represented by xx above are limited to the Unicode
+       script names, the general category properties, "Any", which matches any
+       character   (including  newline),  and  some  special  PCRE  properties
+       (described in the next section).  Other Perl properties such as  "InMu-
+       sicalSymbols"  are  not  currently supported by PCRE. Note that \P{Any}
+       does not match any characters, so always causes a match failure.
 
        Sets of Unicode characters are defined as belonging to certain scripts.
        A  character from one of these sets can be matched using a script name.
@@ -3503,14 +3619,15 @@ BACKSLASH
        Tai_Tham,  Tai_Viet,  Tamil,  Telugu,  Thaana, Thai, Tibetan, Tifinagh,
        Ugaritic, Vai, Yi.
 
-       Each character has exactly one general category property, specified  by
-       a two-letter abbreviation. For compatibility with Perl, negation can be
-       specified by including a circumflex between the opening brace  and  the
-       property name. For example, \p{^Lu} is the same as \P{Lu}.
+       Each character has exactly one Unicode general category property, spec-
+       ified  by a two-letter abbreviation. For compatibility with Perl, nega-
+       tion can be specified by including a  circumflex  between  the  opening
+       brace  and  the  property  name.  For  example,  \p{^Lu} is the same as
+       \P{Lu}.
 
        If only one letter is specified with \p or \P, it includes all the gen-
-       eral category properties that start with that letter. In this case,  in
-       the  absence of negation, the curly brackets in the escape sequence are
+       eral  category properties that start with that letter. In this case, in
+       the absence of negation, the curly brackets in the escape sequence  are
        optional; these two examples have the same effect:
 
          \p{L}
@@ -3562,73 +3679,94 @@ BACKSLASH
          Zp    Paragraph separator
          Zs    Space separator
 
-       The special property L& is also supported: it matches a character  that
-       has  the  Lu,  Ll, or Lt property, in other words, a letter that is not
+       The  special property L& is also supported: it matches a character that
+       has the Lu, Ll, or Lt property, in other words, a letter  that  is  not
        classified as a modifier or "other".
 
-       The Cs (Surrogate) property applies only to  characters  in  the  range
-       U+D800  to  U+DFFF. Such characters are not valid in UTF-8 strings (see
+       The  Cs  (Surrogate)  property  applies only to characters in the range
+       U+D800 to U+DFFF. Such characters are not valid in UTF-8  strings  (see
        RFC 3629) and so cannot be tested by PCRE, unless UTF-8 validity check-
-       ing  has  been  turned off (see the discussion of PCRE_NO_UTF8_CHECK in
+       ing has been turned off (see the discussion  of  PCRE_NO_UTF8_CHECK  in
        the pcreapi page). Perl does not support the Cs property.
 
-       The long synonyms for  property  names  that  Perl  supports  (such  as
-       \p{Letter})  are  not  supported by PCRE, nor is it permitted to prefix
+       The  long  synonyms  for  property  names  that  Perl supports (such as
+       \p{Letter}) are not supported by PCRE, nor is it  permitted  to  prefix
        any of these properties with "Is".
 
        No character that is in the Unicode table has the Cn (unassigned) prop-
        erty.  Instead, this property is assumed for any code point that is not
        in the Unicode table.
 
-       Specifying caseless matching does not affect  these  escape  sequences.
+       Specifying  caseless  matching  does not affect these escape sequences.
        For example, \p{Lu} always matches only upper case letters.
 
-       The  \X  escape  matches  any number of Unicode characters that form an
+       The \X escape matches any number of Unicode  characters  that  form  an
        extended Unicode sequence. \X is equivalent to
 
          (?>\PM\pM*)
 
-       That is, it matches a character without the "mark"  property,  followed
-       by  zero  or  more  characters with the "mark" property, and treats the
-       sequence as an atomic group (see below).  Characters  with  the  "mark"
-       property  are  typically  accents  that affect the preceding character.
-       None of them have codepoints less than 256, so  in  non-UTF-8  mode  \X
+       That  is,  it matches a character without the "mark" property, followed
+       by zero or more characters with the "mark"  property,  and  treats  the
+       sequence  as  an  atomic group (see below).  Characters with the "mark"
+       property are typically accents that  affect  the  preceding  character.
+       None  of  them  have  codepoints less than 256, so in non-UTF-8 mode \X
        matches any one character.
 
-       Matching  characters  by Unicode property is not fast, because PCRE has
-       to search a structure that contains  data  for  over  fifteen  thousand
+       Matching characters by Unicode property is not fast, because  PCRE  has
+       to  search  a  structure  that  contains data for over fifteen thousand
        characters. That is why the traditional escape sequences such as \d and
-       \w do not use Unicode properties in PCRE.
+       \w  do  not  use  Unicode properties in PCRE by default, though you can
+       make them do so by setting the PCRE_UCP option for pcre_compile() or by
+       starting the pattern with (*UCP).
+
+   PCRE's additional properties
+
+       As  well  as  the standard Unicode properties described in the previous
+       section, PCRE supports four more that make it possible to convert  tra-
+       ditional escape sequences such as \w and \s and POSIX character classes
+       to use Unicode properties. PCRE uses these non-standard, non-Perl prop-
+       erties internally when PCRE_UCP is set. They are:
+
+         Xan   Any alphanumeric character
+         Xps   Any POSIX space character
+         Xsp   Any Perl space character
+         Xwd   Any Perl "word" character
+
+       Xan  matches  characters that have either the L (letter) or the N (num-
+       ber) property. Xps matches the characters tab, linefeed, vertical  tab,
+       formfeed,  or  carriage  return, and any other character that has the Z
+       (separator) property.  Xsp is the same as Xps, except that vertical tab
+       is excluded. Xwd matches the same characters as Xan, plus underscore.
 
    Resetting the match start
 
        The escape sequence \K, which is a Perl 5.10 feature, causes any previ-
-       ously  matched  characters  not  to  be  included  in the final matched
+       ously matched characters not  to  be  included  in  the  final  matched
        sequence. For example, the pattern:
 
          foo\Kbar
 
-       matches "foobar", but reports that it has matched "bar".  This  feature
-       is  similar  to  a lookbehind assertion (described below).  However, in
-       this case, the part of the subject before the real match does not  have
-       to  be of fixed length, as lookbehind assertions do. The use of \K does
-       not interfere with the setting of captured  substrings.   For  example,
+       matches  "foobar",  but reports that it has matched "bar". This feature
+       is similar to a lookbehind assertion (described  below).   However,  in
+       this  case, the part of the subject before the real match does not have
+       to be of fixed length, as lookbehind assertions do. The use of \K  does
+       not  interfere  with  the setting of captured substrings.  For example,
        when the pattern
 
          (foo)\Kbar
 
        matches "foobar", the first substring is still set to "foo".
 
-       Perl  documents  that  the  use  of  \K  within assertions is "not well
-       defined". In PCRE, \K is acted upon  when  it  occurs  inside  positive
+       Perl documents that the use  of  \K  within  assertions  is  "not  well
+       defined".  In  PCRE,  \K  is  acted upon when it occurs inside positive
        assertions, but is ignored in negative assertions.
 
    Simple assertions
 
-       The  final use of backslash is for certain simple assertions. An asser-
-       tion specifies a condition that has to be met at a particular point  in
-       a  match, without consuming any characters from the subject string. The
-       use of subpatterns for more complicated assertions is described  below.
+       The final use of backslash is for certain simple assertions. An  asser-
+       tion  specifies a condition that has to be met at a particular point in
+       a match, without consuming any characters from the subject string.  The
+       use  of subpatterns for more complicated assertions is described below.
        The backslashed assertions are:
 
          \b     matches at a word boundary
@@ -3639,15 +3777,20 @@ BACKSLASH
          \z     matches only at the end of the subject
          \G     matches at the first matching position in the subject
 
-       These  assertions may not appear in character classes (but note that \b
-       has a different meaning, namely the backspace character, inside a char-
-       acter class).
+       Inside a character class, \b has a different meaning;  it  matches  the
+       backspace  character.  If  any  other  of these assertions appears in a
+       character class, by default it matches the corresponding literal  char-
+       acter  (for  example,  \B  matches  the  letter  B).  However,  if  the
+       PCRE_EXTRA option is set, an "invalid escape sequence" error is  gener-
+       ated instead.
 
        A  word  boundary is a position in the subject string where the current
        character and the previous character do not both match \w or  \W  (i.e.
        one  matches  \w  and the other matches \W), or the start or end of the
-       string if the first or last character matches \w, respectively. Neither
-       PCRE  nor  Perl  has a separte "start of word" or "end of word" metase-
+       string if the first or last  character  matches  \w,  respectively.  In
+       UTF-8  mode,  the  meanings  of \w and \W can be changed by setting the
+       PCRE_UCP option. When this is done, it also affects \b and \B.  Neither
+       PCRE  nor  Perl has a separate "start of word" or "end of word" metase-
        quence. However, whatever follows \b normally determines which  it  is.
        For example, the fragment \ba matches "a" at the start of a word.
 
@@ -3732,7 +3875,7 @@ CIRCUMFLEX AND DOLLAR
        set.
 
 
-FULL STOP (PERIOD, DOT)
+FULL STOP (PERIOD, DOT) AND \N
 
        Outside a character class, a dot in the pattern matches any one charac-
        ter  in  the subject string except (by default) a character that signi-
@@ -3755,6 +3898,10 @@ FULL STOP (PERIOD, DOT)
        flex and dollar, the only relationship being  that  they  both  involve
        newlines. Dot has no special meaning in a character class.
 
+       The escape sequence \N always behaves as a dot does when PCRE_DOTALL is
+       not set. In other words, it matches any one character except  one  that
+       signifies the end of a line.
+
 
 MATCHING A SINGLE BYTE
 
@@ -3848,13 +3995,13 @@ SQUARE BRACKETS AND CHARACTER CLASSES
        concept  of  case for characters with values greater than 128 only when
        it is compiled with Unicode property support.
 
-       The character types \d, \D, \p, \P, \s, \S, \w, and \W may also  appear
-       in  a  character  class,  and add the characters that they match to the
-       class. For example, [\dABCDEF] matches any hexadecimal digit. A circum-
-       flex  can  conveniently  be used with the upper case character types to
-       specify a more restricted set of characters  than  the  matching  lower
-       case  type.  For example, the class [^\W_] matches any letter or digit,
-       but not underscore.
+       The character types \d, \D, \h, \H, \p, \P, \s, \S, \v, \V, \w, and  \W
+       may  also appear in a character class, and add the characters that they
+       match to the class. For example,  [\dABCDEF]  matches  any  hexadecimal
+       digit.  A circumflex can conveniently be used with the upper case char-
+       acter types to specify a more restricted set  of  characters  than  the
+       matching  lower  case  type.  For example, the class [^\W_] matches any
+       letter or digit, but not underscore.
 
        The only metacharacters that are recognized in  character  classes  are
        backslash,  hyphen  (only  where  it can be interpreted as specifying a
@@ -3873,7 +4020,7 @@ POSIX CHARACTER CLASSES
          [01[:alpha:]%]
 
        matches "0", "1", any alphabetic character, or "%". The supported class
-       names are
+       names are:
 
          alnum    letters and digits
          alpha    letters
@@ -3884,7 +4031,7 @@ POSIX CHARACTER CLASSES
          graph    printing characters, excluding space
          lower    lower case letters
          print    printing characters, including space
-         punct    printing characters, excluding letters and digits
+         punct    printing characters, excluding letters and digits and space
          space    white space (not quite the same as \s)
          upper    upper case letters
          word     "word" characters (same as \w)
@@ -3905,30 +4052,46 @@ POSIX CHARACTER CLASSES
        POSIX syntax [.ch.] and [=ch=] where "ch" is a "collating element", but
        these are not supported, and an error is given if they are encountered.
 
-       In UTF-8 mode, characters with values greater than 128 do not match any
-       of the POSIX character classes.
+       By  default,  in UTF-8 mode, characters with values greater than 128 do
+       not match any of the POSIX character classes. However, if the  PCRE_UCP
+       option  is passed to pcre_compile(), some of the classes are changed so
+       that Unicode character properties are used. This is achieved by replac-
+       ing the POSIX classes by other sequences, as follows:
+
+         [:alnum:]  becomes  \p{Xan}
+         [:alpha:]  becomes  \p{L}
+         [:blank:]  becomes  \h
+         [:digit:]  becomes  \p{Nd}
+         [:lower:]  becomes  \p{Ll}
+         [:space:]  becomes  \p{Xps}
+         [:upper:]  becomes  \p{Lu}
+         [:word:]   becomes  \p{Xwd}
+
+       Negated  versions,  such  as [:^alpha:] use \P instead of \p. The other
+       POSIX classes are unchanged, and match only characters with code points
+       less than 128.
 
 
 VERTICAL BAR
 
-       Vertical bar characters are used to separate alternative patterns.  For
+       Vertical  bar characters are used to separate alternative patterns. For
        example, the pattern
 
          gilbert|sullivan
 
-       matches  either "gilbert" or "sullivan". Any number of alternatives may
-       appear, and an empty  alternative  is  permitted  (matching  the  empty
+       matches either "gilbert" or "sullivan". Any number of alternatives  may
+       appear,  and  an  empty  alternative  is  permitted (matching the empty
        string). The matching process tries each alternative in turn, from left
-       to right, and the first one that succeeds is used. If the  alternatives
-       are  within a subpattern (defined below), "succeeds" means matching the
+       to  right, and the first one that succeeds is used. If the alternatives
+       are within a subpattern (defined below), "succeeds" means matching  the
        rest of the main pattern as well as the alternative in the subpattern.
 
 
 INTERNAL OPTION SETTING
 
-       The settings of the  PCRE_CASELESS,  PCRE_MULTILINE,  PCRE_DOTALL,  and
-       PCRE_EXTENDED  options  (which are Perl-compatible) can be changed from
-       within the pattern by  a  sequence  of  Perl  option  letters  enclosed
+       The  settings  of  the  PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
+       PCRE_EXTENDED options (which are Perl-compatible) can be  changed  from
+       within  the  pattern  by  a  sequence  of  Perl option letters enclosed
        between "(?" and ")".  The option letters are
 
          i  for PCRE_CASELESS
@@ -3938,47 +4101,48 @@ INTERNAL OPTION SETTING
 
        For example, (?im) sets caseless, multiline matching. It is also possi-
        ble to unset these options by preceding the letter with a hyphen, and a
-       combined  setting and unsetting such as (?im-sx), which sets PCRE_CASE-
-       LESS and PCRE_MULTILINE while unsetting PCRE_DOTALL and  PCRE_EXTENDED,
-       is  also  permitted.  If  a  letter  appears  both before and after the
+       combined setting and unsetting such as (?im-sx), which sets  PCRE_CASE-
+       LESS  and PCRE_MULTILINE while unsetting PCRE_DOTALL and PCRE_EXTENDED,
+       is also permitted. If a  letter  appears  both  before  and  after  the
        hyphen, the option is unset.
 
-       The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and  PCRE_EXTRA
-       can  be changed in the same way as the Perl-compatible options by using
+       The  PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA
+       can be changed in the same way as the Perl-compatible options by  using
        the characters J, U and X respectively.
 
-       When one of these option changes occurs at  top  level  (that  is,  not
-       inside  subpattern parentheses), the change applies to the remainder of
+       When  one  of  these  option  changes occurs at top level (that is, not
+       inside subpattern parentheses), the change applies to the remainder  of
        the pattern that follows. If the change is placed right at the start of
        a pattern, PCRE extracts it into the global options (and it will there-
        fore show up in data extracted by the pcre_fullinfo() function).
 
-       An option change within a subpattern (see below for  a  description  of
+       An  option  change  within a subpattern (see below for a description of
        subpatterns) affects only that part of the current pattern that follows
        it, so
 
          (a(?i)b)c
 
        matches abc and aBc and no other strings (assuming PCRE_CASELESS is not
-       used).   By  this means, options can be made to have different settings
-       in different parts of the pattern. Any changes made in one  alternative
-       do  carry  on  into subsequent branches within the same subpattern. For
+       used).  By this means, options can be made to have  different  settings
+       in  different parts of the pattern. Any changes made in one alternative
+       do carry on into subsequent branches within the  same  subpattern.  For
        example,
 
          (a(?i)b|c)
 
-       matches "ab", "aB", "c", and "C", even though  when  matching  "C"  the
-       first  branch  is  abandoned before the option setting. This is because
-       the effects of option settings happen at compile time. There  would  be
+       matches  "ab",  "aB",  "c",  and "C", even though when matching "C" the
+       first branch is abandoned before the option setting.  This  is  because
+       the  effects  of option settings happen at compile time. There would be
        some very weird behaviour otherwise.
 
-       Note:  There  are  other  PCRE-specific  options that can be set by the
-       application when the compile or match functions  are  called.  In  some
+       Note: There are other PCRE-specific options that  can  be  set  by  the
+       application  when  the  compile  or match functions are called. In some
        cases the pattern can contain special leading sequences such as (*CRLF)
-       to override what the application has set or what  has  been  defaulted.
-       Details  are  given  in the section entitled "Newline sequences" above.
-       There is also the (*UTF8) leading sequence that  can  be  used  to  set
-       UTF-8 mode; this is equivalent to setting the PCRE_UTF8 option.
+       to  override  what  the application has set or what has been defaulted.
+       Details are given in the section entitled  "Newline  sequences"  above.
+       There  are  also  the  (*UTF8) and (*UCP) leading sequences that can be
+       used to set UTF-8 and Unicode property modes; they  are  equivalent  to
+       setting the PCRE_UTF8 and the PCRE_UCP options, respectively.
 
 
 SUBPATTERNS
@@ -5144,14 +5308,26 @@ BACKTRACKING CONTROL
        tested.
 
        The  new verbs make use of what was previously invalid syntax: an open-
-       ing parenthesis followed by an asterisk. In Perl, they are generally of
-       the form (*VERB:ARG) but PCRE does not support the use of arguments, so
-       its general form is just (*VERB). Any number of these verbs  may  occur
-       in a pattern. There are two kinds:
+       ing parenthesis followed by an asterisk. They are generally of the form
+       (*VERB)  or (*VERB:NAME). Some may take either form, with differing be-
+       haviour, depending on whether or not an argument is present. An name is
+       a  sequence  of letters, digits, and underscores. If the name is empty,
+       that is, if the closing parenthesis immediately follows the colon,  the
+       effect is as if the colon were not there. Any number of these verbs may
+       occur in a pattern.
+
+       PCRE contains some optimizations that are used to speed up matching  by
+       running some checks at the start of each match attempt. For example, it
+       may know the minimum length of matching subject, or that  a  particular
+       character  must  be present. When one of these optimizations suppresses
+       the running of a match, any included backtracking verbs  will  not,  of
+       course, be processed. You can suppress the start-of-match optimizations
+       by setting the PCRE_NO_START_OPTIMIZE option when calling pcre_exec().
 
    Verbs that act immediately
 
-       The following verbs act as soon as they are encountered:
+       The following verbs act as soon as they are encountered. They  may  not
+       be followed by a name.
 
           (*ACCEPT)
 
@@ -5180,70 +5356,174 @@ BACKTRACKING CONTROL
        A  match  with the string "aaaa" always fails, but the callout is taken
        before each backtrack happens (in this example, 10 times).
 
+   Recording which path was taken
+
+       There is one verb whose main purpose  is  to  track  how  a  match  was
+       arrived  at,  though  it  also  has a secondary use in conjunction with
+       advancing the match starting point (see (*SKIP) below).
+
+         (*MARK:NAME) or (*:NAME)
+
+       A name is always  required  with  this  verb.  There  may  be  as  many
+       instances  of  (*MARK) as you like in a pattern, and their names do not
+       have to be unique.
+
+       When a match succeeds, the name  of  the  last-encountered  (*MARK)  is
+       passed  back  to  the  caller  via  the  pcre_extra  data structure, as
+       described in the section on pcre_extra in the pcreapi documentation. No
+       data  is  returned  for a partial match. Here is an example of pcretest
+       output, where the /K modifier requests the retrieval and outputting  of
+       (*MARK) data:
+
+         /X(*MARK:A)Y|X(*MARK:B)Z/K
+         XY
+          0: XY
+         MK: A
+         XZ
+          0: XZ
+         MK: B
+
+       The (*MARK) name is tagged with "MK:" in this output, and in this exam-
+       ple it indicates which of the two alternatives matched. This is a  more
+       efficient  way of obtaining this information than putting each alterna-
+       tive in its own capturing parentheses.
+
+       A name may also be returned after a failed  match  if  the  final  path
+       through  the  pattern involves (*MARK). However, unless (*MARK) used in
+       conjunction with (*COMMIT), this is unlikely to  happen  for  an  unan-
+       chored pattern because, as the starting point for matching is advanced,
+       the final check is often with an empty string, causing a failure before
+       (*MARK) is reached. For example:
+
+         /X(*MARK:A)Y|X(*MARK:B)Z/K
+         XP
+         No match
+
+       There are three potential starting points for this match (starting with
+       X, starting with P, and with  an  empty  string).  If  the  pattern  is
+       anchored, the result is different:
+
+         /^X(*MARK:A)Y|^X(*MARK:B)Z/K
+         XP
+         No match, mark = B
+
+       PCRE's  start-of-match  optimizations can also interfere with this. For
+       example, if, as a result of a call to pcre_study(), it knows the  mini-
+       mum  subject  length for a match, a shorter subject will not be scanned
+       at all.
+
+       Note that similar anomalies (though different in detail) exist in Perl,
+       no  doubt  for the same reasons. The use of (*MARK) data after a failed
+       match of an unanchored pattern is not recommended, unless (*COMMIT)  is
+       involved.
+
    Verbs that act after backtracking
 
        The following verbs do nothing when they are encountered. Matching con-
-       tinues  with what follows, but if there is no subsequent match, a fail-
-       ure is forced.  The verbs  differ  in  exactly  what  kind  of  failure
-       occurs.
+       tinues with what follows, but if there is no subsequent match,  causing
+       a  backtrack  to  the  verb, a failure is forced. That is, backtracking
+       cannot pass to the left of the verb. However, when one of  these  verbs
+       appears  inside  an atomic group, its effect is confined to that group,
+       because once the group has been matched, there is never any  backtrack-
+       ing  into  it.  In  this situation, backtracking can "jump back" to the
+       left of the entire atomic group. (Remember also, as stated above,  that
+       this localization also applies in subroutine calls and assertions.)
+
+       These  verbs  differ  in exactly what kind of failure occurs when back-
+       tracking reaches them.
 
          (*COMMIT)
 
-       This  verb  causes  the whole match to fail outright if the rest of the
-       pattern does not match. Even if the pattern is unanchored,  no  further
-       attempts  to  find  a match by advancing the starting point take place.
-       Once (*COMMIT) has been passed, pcre_exec() is committed to  finding  a
-       match at the current starting point, or not at all. For example:
+       This verb, which may not be followed by a name, causes the whole  match
+       to fail outright if the rest of the pattern does not match. Even if the
+       pattern is unanchored, no further attempts to find a match by advancing
+       the  starting  point  take  place.  Once  (*COMMIT)  has  been  passed,
+       pcre_exec() is committed to finding a match  at  the  current  starting
+       point, or not at all. For example:
 
          a+(*COMMIT)b
 
        This  matches  "xxaab" but not "aacaab". It can be thought of as a kind
-       of dynamic anchor, or "I've started, so I must finish."
-
-         (*PRUNE)
+       of dynamic anchor, or "I've started, so I must finish." The name of the
+       most  recently passed (*MARK) in the path is passed back when (*COMMIT)
+       forces a match failure.
+
+       Note that (*COMMIT) at the start of a pattern is not  the  same  as  an
+       anchor,  unless  PCRE's start-of-match optimizations are turned off, as
+       shown in this pcretest example:
+
+         /(*COMMIT)abc/
+         xyzabc
+          0: abc
+         xyzabc\Y
+         No match
 
-       This verb causes the match to fail at the current position if the  rest
-       of the pattern does not match. If the pattern is unanchored, the normal
-       "bumpalong" advance to the next starting character then happens.  Back-
-       tracking  can  occur as usual to the left of (*PRUNE), or when matching
-       to the right of (*PRUNE), but if there is no match to the right,  back-
-       tracking  cannot  cross (*PRUNE).  In simple cases, the use of (*PRUNE)
-       is just an alternative to an atomic group or possessive quantifier, but
-       there  are  some uses of (*PRUNE) that cannot be expressed in any other
-       way.
+       PCRE knows that any match must start  with  "a",  so  the  optimization
+       skips  along the subject to "a" before running the first match attempt,
+       which succeeds. When the optimization is disabled by the \Y  escape  in
+       the second subject, the match starts at "x" and so the (*COMMIT) causes
+       it to fail without trying any other starting points.
+
+         (*PRUNE) or (*PRUNE:NAME)
+
+       This verb causes the match to fail at the current starting position  in
+       the  subject  if the rest of the pattern does not match. If the pattern
+       is unanchored, the normal "bumpalong"  advance  to  the  next  starting
+       character  then happens. Backtracking can occur as usual to the left of
+       (*PRUNE), before it is reached,  or  when  matching  to  the  right  of
+       (*PRUNE),  but  if  there is no match to the right, backtracking cannot
+       cross (*PRUNE). In simple cases, the use of (*PRUNE) is just an  alter-
+       native  to an atomic group or possessive quantifier, but there are some
+       uses of (*PRUNE) that cannot be expressed in any other way.  The behav-
+       iour  of  (*PRUNE:NAME)  is  the  same as (*MARK:NAME)(*PRUNE) when the
+       match fails completely; the name is passed back if this  is  the  final
+       attempt.   (*PRUNE:NAME)  does  not  pass back a name if the match suc-
+       ceeds. In an anchored pattern (*PRUNE) has the same  effect  as  (*COM-
+       MIT).
 
          (*SKIP)
 
-       This verb is like (*PRUNE), except that if the pattern  is  unanchored,
-       the  "bumpalong" advance is not to the next character, but to the posi-
-       tion in the subject where (*SKIP) was  encountered.  (*SKIP)  signifies
-       that  whatever  text  was  matched leading up to it cannot be part of a
-       successful match. Consider:
+       This  verb, when given without a name, is like (*PRUNE), except that if
+       the pattern is unanchored, the "bumpalong" advance is not to  the  next
+       character, but to the position in the subject where (*SKIP) was encoun-
+       tered. (*SKIP) signifies that whatever text was matched leading  up  to
+       it cannot be part of a successful match. Consider:
 
          a+(*SKIP)b
 
-       If the subject is "aaaac...",  after  the  first  match  attempt  fails
-       (starting  at  the  first  character in the string), the starting point
+       If  the  subject  is  "aaaac...",  after  the first match attempt fails
+       (starting at the first character in the  string),  the  starting  point
        skips on to start the next attempt at "c". Note that a possessive quan-
-       tifer  does not have the same effect as this example; although it would
-       suppress backtracking  during  the  first  match  attempt,  the  second
-       attempt  would  start at the second character instead of skipping on to
+       tifer does not have the same effect as this example; although it  would
+       suppress  backtracking  during  the  first  match  attempt,  the second
+       attempt would start at the second character instead of skipping  on  to
        "c".
 
-         (*THEN)
+         (*SKIP:NAME)
+
+       When  (*SKIP) has an associated name, its behaviour is modified. If the
+       following pattern fails to match, the previous path through the pattern
+       is  searched for the most recent (*MARK) that has the same name. If one
+       is found, the "bumpalong" advance is to the subject position that  cor-
+       responds  to  that (*MARK) instead of to where (*SKIP) was encountered.
+       If no (*MARK) with a matching name is found, normal "bumpalong" of  one
+       character happens (the (*SKIP) is ignored).
+
+         (*THEN) or (*THEN:NAME)
 
        This verb causes a skip to the next alternation if the rest of the pat-
        tern does not match. That is, it cancels pending backtracking, but only
-       within the current alternation. Its name  comes  from  the  observation
+       within  the  current  alternation.  Its name comes from the observation
        that it can be used for a pattern-based if-then-else block:
 
          ( COND1 (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) ...
 
-       If  the COND1 pattern matches, FOO is tried (and possibly further items
-       after the end of the group if FOO succeeds);  on  failure  the  matcher
-       skips  to  the second alternative and tries COND2, without backtracking
-       into COND1. If (*THEN) is used outside  of  any  alternation,  it  acts
-       exactly like (*PRUNE).
+       If the COND1 pattern matches, FOO is tried (and possibly further  items
+       after  the  end  of  the group if FOO succeeds); on failure the matcher
+       skips to the second alternative and tries COND2,  without  backtracking
+       into  COND1.  The  behaviour  of  (*THEN:NAME)  is  exactly the same as
+       (*MARK:NAME)(*THEN) if the overall  match  fails.  If  (*THEN)  is  not
+       directly inside an alternation, it acts like (*PRUNE).
 
 
 SEE ALSO
@@ -5260,7 +5540,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 06 March 2010
+       Last updated: 18 May 2010
        Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -5308,6 +5588,7 @@ CHARACTER TYPES
          \D         a character that is not a decimal digit
          \h         a horizontal whitespace character
          \H         a character that is not a horizontal whitespace character
+         \N         a character that is not a newline
          \p{xx}     a character with the xx property
          \P{xx}     a character without the xx property
          \R         a newline sequence
@@ -5319,10 +5600,12 @@ CHARACTER TYPES
          \W         a "non-word" character
          \X         an extended Unicode sequence
 
-       In PCRE, \d, \D, \s, \S, \w, and \W recognize only ASCII characters.
+       In  PCRE,  by  default, \d, \D, \s, \S, \w, and \W recognize only ASCII
+       characters, even in UTF-8 mode. However, this can be changed by setting
+       the PCRE_UCP option.
 
 
-GENERAL CATEGORY PROPERTY CODES FOR \p and \P
+GENERAL CATEGORY PROPERTIES FOR \p and \P
 
          C          Other
          Cc         Control
@@ -5370,6 +5653,14 @@ GENERAL CATEGORY PROPERTY CODES FOR \p and \P
          Zs         Space separator
 
 
+PCRE SPECIAL CATEGORY PROPERTIES FOR \p and \P
+
+         Xan        Alphanumeric: union of properties L and N
+         Xps        POSIX space: property Z or tab, NL, VT, FF, CR
+         Xsp        Perl space: property Z or tab, NL, FF, CR
+         Xwd        Perl word: property Xan or underscore
+
+
 SCRIPT NAMES FOR \p AND \P
 
        Arabic, Armenian, Avestan, Balinese, Bamum, Bengali, Bopomofo, Braille,
@@ -5411,8 +5702,9 @@ CHARACTER CLASSES
          word        same as \w
          xdigit      hexadecimal digit
 
-       In PCRE, POSIX character set names recognize only ASCII characters. You
-       can use \Q...\E inside a character class.
+       In PCRE, POSIX character set names recognize only ASCII  characters  by
+       default,  but  some  of them use Unicode properties if PCRE_UCP is set.
+       You can use \Q...\E inside a character class.
 
 
 QUANTIFIERS
@@ -5437,7 +5729,7 @@ QUANTIFIERS
 
 ANCHORS AND SIMPLE ASSERTIONS
 
-         \b          word boundary (only ASCII letters recognized)
+         \b          word boundary
          \B          not a word boundary
          ^           start of subject
                       also after internal newline in multiline mode
@@ -5492,10 +5784,11 @@ OPTION SETTING
          (?x)            extended (ignore white space)
          (?-...)         unset option(s)
 
-       The following is recognized only at the start of a pattern or after one
-       of the newline-setting options with similar syntax:
+       The following are recognized only at the start of a  pattern  or  after
+       one of the newline-setting options with similar syntax:
 
-         (*UTF8)         set UTF-8 mode
+         (*UTF8)         set UTF-8 mode (PCRE_UTF8)
+         (*UCP)          set PCRE_UCP (use Unicode properties for \d etc)
 
 
 LOOKAHEAD AND LOOKBEHIND ASSERTIONS
@@ -5564,7 +5857,7 @@ BACKTRACKING CONTROL
          (*ACCEPT)       force successful match
          (*FAIL)         force backtrack; synonym (*F)
 
-       The following act only when a subsequent match failure causes  a  back-
+       The  following  act only when a subsequent match failure causes a back-
        track to reach them. They all force a match failure, but they differ in
        what happens afterwards. Those that advance the start-of-match point do
        so only if the pattern is not anchored.
@@ -5577,8 +5870,8 @@ BACKTRACKING CONTROL
 
 NEWLINE CONVENTIONS
 
-       These  are  recognized only at the very start of the pattern or after a
-       (*BSR_...) or (*UTF8) option.
+       These are recognized only at the very start of the pattern or  after  a
+       (*BSR_...) or (*UTF8) or (*UCP) option.
 
          (*CR)           carriage return only
          (*LF)           linefeed only
@@ -5589,8 +5882,8 @@ NEWLINE CONVENTIONS
 
 WHAT \R MATCHES
 
-       These are recognized only at the very start of the pattern or  after  a
-       (*...) option that sets the newline convention or UTF-8 mode.
+       These  are  recognized only at the very start of the pattern or after a
+       (*...) option that sets the newline convention or UTF-8 or UCP mode.
 
          (*BSR_ANYCRLF)  CR, LF, or CRLF
          (*BSR_UNICODE)  any Unicode newline sequence
@@ -5616,7 +5909,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 01 March 2010
+       Last updated: 12 May 2010
        Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -6217,6 +6510,14 @@ PROCESSING TIME
        If you can find an alternative pattern  that  does  not  use  character
        properties, it will probably be faster.
 
+       By  default,  the  escape  sequences  \b, \d, \s, and \w, and the POSIX
+       character classes such as [:alpha:]  do  not  use  Unicode  properties,
+       partly for backwards compatibility, and partly for performance reasons.
+       However, you can set PCRE_UCP if you want Unicode character  properties
+       to  be  used.  This  can double the matching time for items such as \d,
+       when matched with  pcre_exec();  the  performance  loss  is  less  with
+       pcre_dfa_exec(), and in both cases there is not much difference for \b.
+
        When  a  pattern  begins  with .* not in parentheses, or in parentheses
        that are not the subject of a backreference, and the PCRE_DOTALL option
        is  set, the pattern is implicitly anchored by PCRE, since it can match
@@ -6282,7 +6583,7 @@ AUTHOR
 
 REVISION
 
-       Last updated: 07 March 2010
+       Last updated: 16 May 2010
        Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
@@ -6388,33 +6689,40 @@ COMPILING A PATTERN
        ing,  the  nmatch  and  pmatch  arguments  are ignored, and no captured
        strings are returned.
 
+         REG_UCP
+
+       The PCRE_UCP option is set when the regular expression  is  passed  for
+       compilation  to  the  native  function. This causes PCRE to use Unicode
+       properties when matchine \d, \w,  etc.,  instead  of  just  recognizing
+       ASCII values. Note that REG_UTF8 is not part of the POSIX standard.
+
          REG_UNGREEDY
 
-       The PCRE_UNGREEDY option is set when the regular expression  is  passed
-       for  compilation  to the native function. Note that REG_UNGREEDY is not
+       The  PCRE_UNGREEDY  option is set when the regular expression is passed
+       for compilation to the native function. Note that REG_UNGREEDY  is  not
        part of the POSIX standard.
 
          REG_UTF8
 
-       The PCRE_UTF8 option is set when the regular expression is  passed  for
-       compilation  to the native function. This causes the pattern itself and
-       all data strings used for matching it to be treated as  UTF-8  strings.
+       The  PCRE_UTF8  option is set when the regular expression is passed for
+       compilation to the native function. This causes the pattern itself  and
+       all  data  strings used for matching it to be treated as UTF-8 strings.
        Note that REG_UTF8 is not part of the POSIX standard.
 
-       In  the  absence  of  these  flags, no options are passed to the native
-       function.  This means the the  regex  is  compiled  with  PCRE  default
-       semantics.  In particular, the way it handles newline characters in the
-       subject string is the Perl way, not the POSIX way.  Note  that  setting
-       PCRE_MULTILINE  has only some of the effects specified for REG_NEWLINE.
-       It does not affect the way newlines are matched by . (they are not)  or
+       In the absence of these flags, no options  are  passed  to  the  native
+       function.   This  means  the  the  regex  is compiled with PCRE default
+       semantics. In particular, the way it handles newline characters in  the
+       subject  string  is  the Perl way, not the POSIX way. Note that setting
+       PCRE_MULTILINE has only some of the effects specified for  REG_NEWLINE.
+       It  does not affect the way newlines are matched by . (they are not) or
        by a negative class such as [^a] (they are).
 
-       The  yield of regcomp() is zero on success, and non-zero otherwise. The
+       The yield of regcomp() is zero on success, and non-zero otherwise.  The
        preg structure is filled in on success, and one member of the structure
-       is  public: re_nsub contains the number of capturing subpatterns in the
+       is public: re_nsub contains the number of capturing subpatterns in  the
        regular expression. Various error codes are defined in the header file.
 
-       NOTE: If the yield of regcomp() is non-zero, you must  not  attempt  to
+       NOTE:  If  the  yield of regcomp() is non-zero, you must not attempt to
        use the contents of the preg structure. If, for example, you pass it to
        regexec(), the result is undefined and your program is likely to crash.
 
@@ -6422,9 +6730,9 @@ COMPILING A PATTERN
 MATCHING NEWLINE CHARACTERS
 
        This area is not simple, because POSIX and Perl take different views of
-       things.   It  is  not possible to get PCRE to obey POSIX semantics, but
-       then PCRE was never intended to be a POSIX engine. The following  table
-       lists  the  different  possibilities for matching newline characters in
+       things.  It is not possible to get PCRE to obey  POSIX  semantics,  but
+       then  PCRE was never intended to be a POSIX engine. The following table
+       lists the different possibilities for matching  newline  characters  in
        PCRE:
 
                                  Default   Change with
@@ -6446,19 +6754,19 @@ MATCHING NEWLINE CHARACTERS
          ^ matches \n in middle     no     REG_NEWLINE
 
        PCRE's behaviour is the same as Perl's, except that there is no equiva-
-       lent  for  PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl, there is
+       lent for PCRE_DOLLAR_ENDONLY in Perl. In both PCRE and Perl,  there  is
        no way to stop newline from matching [^a].
 
-       The  default  POSIX  newline  handling  can  be  obtained  by   setting
-       PCRE_DOTALL  and  PCRE_DOLLAR_ENDONLY, but there is no way to make PCRE
+       The   default  POSIX  newline  handling  can  be  obtained  by  setting
+       PCRE_DOTALL and PCRE_DOLLAR_ENDONLY, but there is no way to  make  PCRE
        behave exactly as for the REG_NEWLINE action.
 
 
 MATCHING A PATTERN
 
-       The function regexec() is called  to  match  a  compiled  pattern  preg
-       against  a  given string, which is by default terminated by a zero byte
-       (but see REG_STARTEND below), subject to the options in  eflags.  These
+       The  function  regexec()  is  called  to  match a compiled pattern preg
+       against a given string, which is by default terminated by a  zero  byte
+       (but  see  REG_STARTEND below), subject to the options in eflags. These
        can be:
 
          REG_NOTBOL
@@ -6480,17 +6788,17 @@ MATCHING A PATTERN
 
          REG_STARTEND
 
-       The string is considered to start at string +  pmatch[0].rm_so  and  to
-       have  a terminating NUL located at string + pmatch[0].rm_eo (there need
-       not actually be a NUL at that location), regardless  of  the  value  of
-       nmatch.  This  is a BSD extension, compatible with but not specified by
-       IEEE Standard 1003.2 (POSIX.2), and should  be  used  with  caution  in
+       The  string  is  considered to start at string + pmatch[0].rm_so and to
+       have a terminating NUL located at string + pmatch[0].rm_eo (there  need
+       not  actually  be  a  NUL at that location), regardless of the value of
+       nmatch. This is a BSD extension, compatible with but not  specified  by
+       IEEE  Standard  1003.2  (POSIX.2),  and  should be used with caution in
        software intended to be portable to other systems. Note that a non-zero
        rm_so does not imply REG_NOTBOL; REG_STARTEND affects only the location
        of the string, not how it is matched.
 
-       If  the pattern was compiled with the REG_NOSUB flag, no data about any
-       matched strings  is  returned.  The  nmatch  and  pmatch  arguments  of
+       If the pattern was compiled with the REG_NOSUB flag, no data about  any
+       matched  strings  is  returned.  The  nmatch  and  pmatch  arguments of
        regexec() are ignored.
 
        If the value of nmatch is zero, or if the value pmatch is NULL, no data
@@ -6498,34 +6806,34 @@ MATCHING A PATTERN
 
        Otherwise,the portion of the string that was matched, and also any cap-
        tured substrings, are returned via the pmatch argument, which points to
-       an array of nmatch structures of type regmatch_t, containing  the  mem-
-       bers  rm_so  and rm_eo. These contain the offset to the first character
-       of each substring and the offset to the first character after  the  end
-       of  each substring, respectively. The 0th element of the vector relates
-       to the entire portion of string that was matched;  subsequent  elements
-       relate  to  the capturing subpatterns of the regular expression. Unused
+       an  array  of nmatch structures of type regmatch_t, containing the mem-
+       bers rm_so and rm_eo. These contain the offset to the  first  character
+       of  each  substring and the offset to the first character after the end
+       of each substring, respectively. The 0th element of the vector  relates
+       to  the  entire portion of string that was matched; subsequent elements
+       relate to the capturing subpatterns of the regular  expression.  Unused
        entries in the array have both structure members set to -1.
 
-       A successful match yields  a  zero  return;  various  error  codes  are
-       defined  in  the  header  file,  of which REG_NOMATCH is the "expected"
+       A  successful  match  yields  a  zero  return;  various error codes are
+       defined in the header file, of  which  REG_NOMATCH  is  the  "expected"
        failure code.
 
 
 ERROR MESSAGES
 
        The regerror() function maps a non-zero errorcode from either regcomp()
-       or  regexec()  to  a  printable message. If preg is not NULL, the error
+       or regexec() to a printable message. If preg is  not  NULL,  the  error
        should have arisen from the use of that structure. A message terminated
-       by  a  binary  zero  is  placed  in  errbuf. The length of the message,
-       including the zero, is limited to errbuf_size. The yield of  the  func-
+       by a binary zero is placed  in  errbuf.  The  length  of  the  message,
+       including  the  zero, is limited to errbuf_size. The yield of the func-
        tion is the size of buffer needed to hold the whole message.
 
 
 MEMORY USAGE
 
-       Compiling  a regular expression causes memory to be allocated and asso-
-       ciated with the preg structure. The function regfree() frees  all  such
-       memory,  after  which  preg may no longer be used as a compiled expres-
+       Compiling a regular expression causes memory to be allocated and  asso-
+       ciated  with  the preg structure. The function regfree() frees all such
+       memory, after which preg may no longer be used as  a  compiled  expres-
        sion.
 
 
@@ -6538,8 +6846,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 02 September 2009
-       Copyright (c) 1997-2009 University of Cambridge.
+       Last updated: 16 May 2010
+       Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 
 
@@ -6925,8 +7233,14 @@ PCRE SAMPLE PROGRAM
          gcc -o pcredemo -I/usr/local/include pcredemo.c \
              -L/usr/local/lib -lpcre
 
-       Once you have compiled the demonstration program, you  can  run  simple
-       tests like this:
+       In a Windows environment, if you want to statically  link  the  program
+       against a non-dll pcre.a file, you must uncomment the line that defines
+       PCRE_STATIC before including pcre.h, because  otherwise  the  pcre_mal-
+       loc()   and   pcre_free()   exported   functions   will   be   declared
+       __declspec(dllimport), with unwanted results.
+
+       Once you have compiled and linked the demonstration  program,  you  can
+       run simple tests like this:
 
          ./pcredemo 'cat|dog' 'the cat sat on the mat'
          ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
@@ -6960,8 +7274,8 @@ AUTHOR
 
 REVISION
 
-       Last updated: 30 September 2009
-       Copyright (c) 1997-2009 University of Cambridge.
+       Last updated: 26 May 2010
+       Copyright (c) 1997-2010 University of Cambridge.
 ------------------------------------------------------------------------------
 PCRESTACK(3)                                                      PCRESTACK(3)
 
diff --git a/ext/pcre/pcrelib/pcre.h b/ext/pcre/pcrelib/pcre.h
index 890b13d..febb617 100644
--- a/ext/pcre/pcrelib/pcre.h
+++ b/ext/pcre/pcrelib/pcre.h
@@ -5,7 +5,7 @@
 /* This is the public header file for the PCRE library, to be #included by
 applications that call the PCRE functions.
 
-           Copyright (c) 1997-2009 University of Cambridge
+           Copyright (c) 1997-2010 University of Cambridge
 
 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE.
 /* The current PCRE version information. */
 
 #define PCRE_MAJOR          8
-#define PCRE_MINOR          02
+#define PCRE_MINOR          10
 #define PCRE_PRERELEASE     
-#define PCRE_DATE           2010-03-19
+#define PCRE_DATE           2010-06-25
 
 /* When an application links to a PCRE DLL in Windows, the symbols that are
 imported have to be identified as such. When building PCRE, the appropriate
@@ -131,6 +131,7 @@ both, so we keep them all distinct. */
 #define PCRE_NO_START_OPTIMISE  0x04000000
 #define PCRE_PARTIAL_HARD       0x08000000
 #define PCRE_NOTEMPTY_ATSTART   0x10000000
+#define PCRE_UCP                0x20000000
 
 /* Exec-time and get/set-time error codes */
 
@@ -200,6 +201,7 @@ these bits, just add new ones on the end, in order to remain compatible. */
 #define PCRE_EXTRA_CALLOUT_DATA           0x0004
 #define PCRE_EXTRA_TABLES                 0x0008
 #define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
+#define PCRE_EXTRA_MARK                   0x0020
 
 /* Types */
 
@@ -225,6 +227,7 @@ typedef struct pcre_extra {
   void *callout_data;             /* Data passed back in callouts */
   const unsigned char *tables;    /* Pointer to character tables */
   unsigned long int match_limit_recursion; /* Max recursive calls to match() */
+  unsigned char **mark;           /* For passing back a mark pointer */
 } pcre_extra;
 
 /* The structure for passing out data via the pcre_callout_function. We use a
diff --git a/ext/pcre/pcrelib/pcre_chartables.c b/ext/pcre/pcrelib/pcre_chartables.c
index f1dbaae..980c23f 100644
--- a/ext/pcre/pcrelib/pcre_chartables.c
+++ b/ext/pcre/pcrelib/pcre_chartables.c
@@ -14,7 +14,7 @@ example ISO-8859-1. When dftables is run, it creates these tables in the
 current locale. If PCRE is configured with --enable-rebuild-chartables, this
 happens automatically.
 
-The following #includes are present because without the gcc 4.x may remove the
+The following #includes are present because without them gcc 4.x may remove the
 array definition from the final binary if PCRE is built into a static library
 and dead code stripping is activated. This leads to link errors. Pulling in the
 header ensures that the array gets flagged as "someone outside this compilation
diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c
index 54e23ea..53027e6 100644
--- a/ext/pcre/pcrelib/pcre_compile.c
+++ b/ext/pcre/pcrelib/pcre_compile.c
@@ -122,7 +122,7 @@ static const short int escapes[] = {
      -ESC_H,                  0,
      0,                       -ESC_K,
      0,                       0,
-     0,                       0,
+     -ESC_N,                  0,
      -ESC_P,                  -ESC_Q,
      -ESC_R,                  -ESC_S,
      0,                       0,
@@ -169,7 +169,7 @@ static const short int escapes[] = {
 /*  B8 */     0,     0,      0,       0,      0,   ']',    '=',    '-',
 /*  C0 */   '{',-ESC_A, -ESC_B,  -ESC_C, -ESC_D,-ESC_E,      0, -ESC_G,
 /*  C8 */-ESC_H,     0,      0,       0,      0,     0,      0,      0,
-/*  D0 */   '}',     0, -ESC_K,       0,      0,     0,      0, -ESC_P,
+/*  D0 */   '}',     0, -ESC_K,       0,      0,-ESC_N,      0, -ESC_P,
 /*  D8 */-ESC_Q,-ESC_R,      0,       0,      0,     0,      0,      0,
 /*  E0 */  '\\',     0, -ESC_S,       0,      0,-ESC_V, -ESC_W, -ESC_X,
 /*  E8 */     0,-ESC_Z,      0,       0,      0,     0,      0,      0,
@@ -186,11 +186,14 @@ string is built from string macros so that it works in UTF-8 mode on EBCDIC
 platforms. */
 
 typedef struct verbitem {
-  int   len;
-  int   op;
+  int   len;                 /* Length of verb name */
+  int   op;                  /* Op when no arg, or -1 if arg mandatory */
+  int   op_arg;              /* Op when arg present, or -1 if not allowed */
 } verbitem;
 
 static const char verbnames[] =
+  "\0"                       /* Empty name is a shorthand for MARK */
+  STRING_MARK0
   STRING_ACCEPT0
   STRING_COMMIT0
   STRING_F0
@@ -200,13 +203,15 @@ static const char verbnames[] =
   STRING_THEN;
 
 static const verbitem verbs[] = {
-  { 6, OP_ACCEPT },
-  { 6, OP_COMMIT },
-  { 1, OP_FAIL },
-  { 4, OP_FAIL },
-  { 5, OP_PRUNE },
-  { 4, OP_SKIP  },
-  { 4, OP_THEN  }
+  { 0, -1,        OP_MARK },
+  { 4, -1,        OP_MARK },
+  { 6, OP_ACCEPT, -1 },
+  { 6, OP_COMMIT, -1 },
+  { 1, OP_FAIL,   -1 },
+  { 4, OP_FAIL,   -1 },
+  { 5, OP_PRUNE,  OP_PRUNE_ARG },
+  { 4, OP_SKIP,   OP_SKIP_ARG  },
+  { 4, OP_THEN,   OP_THEN_ARG  }
 };
 
 static const int verbcount = sizeof(verbs)/sizeof(verbitem);
@@ -254,6 +259,53 @@ static const int posix_class_maps[] = {
   cbit_xdigit,-1,          0              /* xdigit */
 };
 
+/* Table of substitutes for \d etc when PCRE_UCP is set. The POSIX class
+substitutes must be in the order of the names, defined above, and there are
+both positive and negative cases. NULL means no substitute. */
+
+#ifdef SUPPORT_UCP
+static const uschar *substitutes[] = {
+  (uschar *)"\\P{Nd}",    /* \D */
+  (uschar *)"\\p{Nd}",    /* \d */
+  (uschar *)"\\P{Xsp}",   /* \S */       /* NOTE: Xsp is Perl space */
+  (uschar *)"\\p{Xsp}",   /* \s */
+  (uschar *)"\\P{Xwd}",   /* \W */
+  (uschar *)"\\p{Xwd}"    /* \w */
+};
+
+static const uschar *posix_substitutes[] = {
+  (uschar *)"\\p{L}",     /* alpha */
+  (uschar *)"\\p{Ll}",    /* lower */
+  (uschar *)"\\p{Lu}",    /* upper */
+  (uschar *)"\\p{Xan}",   /* alnum */
+  NULL,                   /* ascii */
+  (uschar *)"\\h",        /* blank */
+  NULL,                   /* cntrl */
+  (uschar *)"\\p{Nd}",    /* digit */
+  NULL,                   /* graph */
+  NULL,                   /* print */
+  NULL,                   /* punct */
+  (uschar *)"\\p{Xps}",   /* space */    /* NOTE: Xps is POSIX space */
+  (uschar *)"\\p{Xwd}",   /* word */
+  NULL,                   /* xdigit */
+  /* Negated cases */
+  (uschar *)"\\P{L}",     /* ^alpha */
+  (uschar *)"\\P{Ll}",    /* ^lower */
+  (uschar *)"\\P{Lu}",    /* ^upper */
+  (uschar *)"\\P{Xan}",   /* ^alnum */
+  NULL,                   /* ^ascii */
+  (uschar *)"\\H",        /* ^blank */
+  NULL,                   /* ^cntrl */
+  (uschar *)"\\P{Nd}",    /* ^digit */
+  NULL,                   /* ^graph */
+  NULL,                   /* ^print */
+  NULL,                   /* ^punct */
+  (uschar *)"\\P{Xps}",   /* ^space */   /* NOTE: Xps is POSIX space */
+  (uschar *)"\\P{Xwd}",   /* ^word */
+  NULL                    /* ^xdigit */
+};
+#define POSIX_SUBSIZE (sizeof(posix_substitutes)/sizeof(uschar *))
+#endif
 
 #define STRING(a)  # a
 #define XSTRING(s) STRING(s)
@@ -317,7 +369,7 @@ static const char error_texts[] =
   /* 35 */
   "invalid condition (?(0)\0"
   "\\C not allowed in lookbehind assertion\0"
-  "PCRE does not support \\L, \\l, \\N, \\U, or \\u\0"
+  "PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u\0"
   "number after (?C is > 255\0"
   "closing ) for (?C expected\0"
   /* 40 */
@@ -343,7 +395,7 @@ static const char error_texts[] =
   "inconsistent NEWLINE options\0"
   "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
   "a numbered reference must not be zero\0"
-  "(*VERB) with an argument is not supported\0"
+  "an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)\0"
   /* 60 */
   "(*VERB) not recognized\0"
   "number is too big\0"
@@ -351,7 +403,10 @@ static const char error_texts[] =
   "digit expected after (?+\0"
   "] is an invalid data character in JavaScript compatibility mode\0"
   /* 65 */
-  "different names for subpatterns of the same number are not allowed\0";
+  "different names for subpatterns of the same number are not allowed\0"
+  "(*MARK) must have an argument\0"
+  "this version of PCRE is not compiled with PCRE_UCP support\0"
+  ;
 
 /* Table to identify digits and hex digits. This is used when compiling
 patterns. Note that the tables in chartables are dependent on the locale, and
@@ -584,7 +639,6 @@ else
 
     case CHAR_l:
     case CHAR_L:
-    case CHAR_N:
     case CHAR_u:
     case CHAR_U:
     *errorcodeptr = ERR37;
@@ -822,6 +876,19 @@ else
     }
   }
 
+/* Perl supports \N{name} for character names, as well as plain \N for "not
+newline". PCRE does not support \N{name}. */
+
+if (c == -ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET)
+  *errorcodeptr = ERR37;
+
+/* If PCRE_UCP is set, we change the values for \d etc. */
+
+if ((options & PCRE_UCP) != 0 && c <= -ESC_D && c >= -ESC_w)
+  c -= (ESC_DU - ESC_D);
+
+/* Set the pointer to the final character before returning. */
+
 *ptrptr = ptr;
 return c;
 }
@@ -1060,25 +1127,39 @@ dealing with. The very first call may not start with a parenthesis. */
 
 if (ptr[0] == CHAR_LEFT_PARENTHESIS)
   {
-  if (ptr[1] == CHAR_QUESTION_MARK &&
-      ptr[2] == CHAR_VERTICAL_LINE)
+  /* Handle specials such as (*SKIP) or (*UTF8) etc. */
+
+  if (ptr[1] == CHAR_ASTERISK) ptr += 2;
+
+  /* Handle a normal, unnamed capturing parenthesis. */
+
+  else if (ptr[1] != CHAR_QUESTION_MARK)
+    {
+    *count += 1;
+    if (name == NULL && *count == lorn) return *count;
+    ptr++;
+    }
+
+  /* All cases now have (? at the start. Remember when we are in a group
+  where the parenthesis numbers are duplicated. */
+
+  else if (ptr[2] == CHAR_VERTICAL_LINE)
     {
     ptr += 3;
     dup_parens = TRUE;
     }
 
-  /* Handle a normal, unnamed capturing parenthesis */
+  /* Handle comments; all characters are allowed until a ket is reached. */
 
-  else if (ptr[1] != CHAR_QUESTION_MARK && ptr[1] != CHAR_ASTERISK)
+  else if (ptr[2] == CHAR_NUMBER_SIGN)
     {
-    *count += 1;
-    if (name == NULL && *count == lorn) return *count;
-    ptr++;
+    for (ptr += 3; *ptr != 0; ptr++) if (*ptr == CHAR_RIGHT_PARENTHESIS) break;
+    goto FAIL_EXIT;
     }
 
   /* Handle a condition. If it is an assertion, just carry on so that it
   is processed as normal. If not, skip to the closing parenthesis of the
-  condition (there can't be any nested parens. */
+  condition (there can't be any nested parens). */
 
   else if (ptr[2] == CHAR_LEFT_PARENTHESIS)
     {
@@ -1090,7 +1171,7 @@ if (ptr[0] == CHAR_LEFT_PARENTHESIS)
       }
     }
 
-  /* We have either (? or (* and not a condition */
+  /* Start with (? but not a condition. */
 
   else
     {
@@ -1212,8 +1293,7 @@ for (; *ptr != 0; ptr++)
   else if (*ptr == CHAR_RIGHT_PARENTHESIS)
     {
     if (dup_parens && *count < hwm_count) *count = hwm_count;
-    *ptrptr = ptr;
-    return -1;
+    goto FAIL_EXIT;
     }
 
   else if (*ptr == CHAR_VERTICAL_LINE && dup_parens)
@@ -1613,7 +1693,8 @@ for (;;)
 
   /* Otherwise, we can get the item's length from the table, except that for
   repeated character types, we have to test for \p and \P, which have an extra
-  two bytes of parameters. */
+  two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we
+  must add in its length. */
 
   else
     {
@@ -1637,6 +1718,13 @@ for (;;)
       case OP_TYPEPOSUPTO:
       if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
       break;
+
+      case OP_MARK:
+      case OP_PRUNE_ARG:
+      case OP_SKIP_ARG:
+      case OP_THEN_ARG:
+      code += code[1];
+      break;
       }
 
     /* Add in the fixed length from the table */
@@ -1708,7 +1796,8 @@ for (;;)
 
   /* Otherwise, we can get the item's length from the table, except that for
   repeated character types, we have to test for \p and \P, which have an extra
-  two bytes of parameters. */
+  two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we
+  must add in its length. */
 
   else
     {
@@ -1732,6 +1821,13 @@ for (;;)
       case OP_TYPEEXACT:
       if (code[3] == OP_PROP || code[3] == OP_NOTPROP) code += 2;
       break;
+
+      case OP_MARK:
+      case OP_PRUNE_ARG:
+      case OP_SKIP_ARG:
+      case OP_THEN_ARG:
+      code += code[1];
+      break;
       }
 
     /* Add in the fixed length from the table */
@@ -2001,6 +2097,16 @@ for (code = first_significant_code(code + _pcre_OP_lengths[*code], NULL, 0, TRUE
     break;
 #endif
 
+    /* MARK, and PRUNE/SKIP/THEN with an argument must skip over the argument
+    string. */
+
+    case OP_MARK:
+    case OP_PRUNE_ARG:
+    case OP_SKIP_ARG:
+    case OP_THEN_ARG:
+    code += code[1];
+    break;
+
     /* None of the remaining opcodes are required to match a character. */
 
     default:
@@ -2221,8 +2327,8 @@ auto_callout(uschar *code, const uschar *ptr, compile_data *cd)
 {
 *code++ = OP_CALLOUT;
 *code++ = 255;
-PUT(code, 0, ptr - cd->start_pattern);  /* Pattern offset */
-PUT(code, LINK_SIZE, 0);                /* Default length */
+PUT(code, 0, (int)(ptr - cd->start_pattern));  /* Pattern offset */
+PUT(code, LINK_SIZE, 0);                       /* Default length */
 return code + 2*LINK_SIZE;
 }
 
@@ -2247,7 +2353,7 @@ Returns:             nothing
 static void
 complete_callout(uschar *previous_callout, const uschar *ptr, compile_data *cd)
 {
-int length = ptr - cd->start_pattern - GET(previous_callout, 2);
+int length = (int)(ptr - cd->start_pattern - GET(previous_callout, 2));
 PUT(previous_callout, 2 + LINK_SIZE, length);
 }
 
@@ -2297,6 +2403,69 @@ for (++c; c <= d; c++)
 
 return TRUE;
 }
+
+
+
+/*************************************************
+*        Check a character and a property        *
+*************************************************/
+
+/* This function is called by check_auto_possessive() when a property item
+is adjacent to a fixed character.
+
+Arguments:
+  c            the character
+  ptype        the property type
+  pdata        the data for the type
+  negated      TRUE if it's a negated property (\P or \p{^)
+
+Returns:       TRUE if auto-possessifying is OK
+*/
+
+static BOOL
+check_char_prop(int c, int ptype, int pdata, BOOL negated)
+{
+const ucd_record *prop = GET_UCD(c);
+switch(ptype)
+  {
+  case PT_LAMP:
+  return (prop->chartype == ucp_Lu ||
+          prop->chartype == ucp_Ll ||
+          prop->chartype == ucp_Lt) == negated;
+
+  case PT_GC:
+  return (pdata == _pcre_ucp_gentype[prop->chartype]) == negated;
+
+  case PT_PC:
+  return (pdata == prop->chartype) == negated;
+
+  case PT_SC:
+  return (pdata == prop->script) == negated;
+
+  /* These are specials */
+
+  case PT_ALNUM:
+  return (_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+          _pcre_ucp_gentype[prop->chartype] == ucp_N) == negated;
+
+  case PT_SPACE:    /* Perl space */
+  return (_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+          c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
+          == negated;
+
+  case PT_PXSPACE:  /* POSIX space */
+  return (_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+          c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
+          c == CHAR_FF || c == CHAR_CR)
+          == negated;
+
+  case PT_WORD:
+  return (_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+          _pcre_ucp_gentype[prop->chartype] == ucp_N ||
+          c == CHAR_UNDERSCORE) == negated;
+  }
+return FALSE;
+}
 #endif  /* SUPPORT_UCP */
 
 
@@ -2310,10 +2479,8 @@ whether the next thing could possibly match the repeated item. If not, it makes
 sense to automatically possessify the repeated item.
 
 Arguments:
-  op_code       the repeated op code
-  this          data for this item, depends on the opcode
+  previous      pointer to the repeated opcode
   utf8          TRUE in UTF-8 mode
-  utf8_char     used for utf8 character bytes, NULL if not relevant
   ptr           next character in pattern
   options       options bits
   cd            contains pointers to tables etc.
@@ -2322,10 +2489,11 @@ Returns:        TRUE if possessifying is wanted
 */
 
 static BOOL
-check_auto_possessive(int op_code, int item, BOOL utf8, uschar *utf8_char,
-  const uschar *ptr, int options, compile_data *cd)
+check_auto_possessive(const uschar *previous, BOOL utf8, const uschar *ptr,
+  int options, compile_data *cd)
 {
-int next;
+int c, next;
+int op_code = *previous++;
 
 /* Skip whitespace and comments in extended mode */
 
@@ -2386,23 +2554,18 @@ if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK ||
   strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)
     return FALSE;
 
-/* Now compare the next item with the previous opcode. If the previous is a
-positive single character match, "item" either contains the character or, if
-"item" is greater than 127 in utf8 mode, the character's bytes are in
-utf8_char. */
-
-
-/* Handle cases when the next item is a character. */
+/* Now compare the next item with the previous opcode. First, handle cases when
+the next item is a character. */
 
 if (next >= 0) switch(op_code)
   {
   case OP_CHAR:
 #ifdef SUPPORT_UTF8
-  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+  GETCHARTEST(c, previous);
 #else
-  (void)(utf8_char);  /* Keep compiler happy by referencing function argument */
+  c = *previous;
 #endif
-  return item != next;
+  return c != next;
 
   /* For CHARNC (caseless character) we must check the other case. If we have
   Unicode property support, we can use it to test the other case of
@@ -2410,9 +2573,11 @@ if (next >= 0) switch(op_code)
 
   case OP_CHARNC:
 #ifdef SUPPORT_UTF8
-  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+  GETCHARTEST(c, previous);
+#else
+  c = *previous;
 #endif
-  if (item == next) return FALSE;
+  if (c == next) return FALSE;
 #ifdef SUPPORT_UTF8
   if (utf8)
     {
@@ -2423,16 +2588,16 @@ if (next >= 0) switch(op_code)
 #else
     othercase = NOTACHAR;
 #endif
-    return (unsigned int)item != othercase;
+    return (unsigned int)c != othercase;
     }
   else
 #endif  /* SUPPORT_UTF8 */
-  return (item != cd->fcc[next]);  /* Non-UTF-8 mode */
+  return (c != cd->fcc[next]);  /* Non-UTF-8 mode */
 
-  /* For OP_NOT, "item" must be a single-byte character. */
+  /* For OP_NOT, its data is always a single-byte character. */
 
   case OP_NOT:
-  if (item == next) return TRUE;
+  if ((c = *previous) == next) return TRUE;
   if ((options & PCRE_CASELESS) == 0) return FALSE;
 #ifdef SUPPORT_UTF8
   if (utf8)
@@ -2444,11 +2609,14 @@ if (next >= 0) switch(op_code)
 #else
     othercase = NOTACHAR;
 #endif
-    return (unsigned int)item == othercase;
+    return (unsigned int)c == othercase;
     }
   else
 #endif  /* SUPPORT_UTF8 */
-  return (item == cd->fcc[next]);  /* Non-UTF-8 mode */
+  return (c == cd->fcc[next]);  /* Non-UTF-8 mode */
+
+  /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not* set.
+  When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
 
   case OP_DIGIT:
   return next > 127 || (cd->ctypes[next] & ctype_digit) == 0;
@@ -2491,11 +2659,12 @@ if (next >= 0) switch(op_code)
     case 0x202f:
     case 0x205f:
     case 0x3000:
-    return op_code != OP_HSPACE;
+    return op_code == OP_NOT_HSPACE;
     default:
-    return op_code == OP_HSPACE;
+    return op_code != OP_NOT_HSPACE;
     }
 
+  case OP_ANYNL:
   case OP_VSPACE:
   case OP_NOT_VSPACE:
   switch(next)
@@ -2507,48 +2676,62 @@ if (next >= 0) switch(op_code)
     case 0x85:
     case 0x2028:
     case 0x2029:
-    return op_code != OP_VSPACE;
+    return op_code == OP_NOT_VSPACE;
     default:
-    return op_code == OP_VSPACE;
+    return op_code != OP_NOT_VSPACE;
     }
 
+#ifdef SUPPORT_UCP
+  case OP_PROP:
+  return check_char_prop(next, previous[0], previous[1], FALSE);
+
+  case OP_NOTPROP:
+  return check_char_prop(next, previous[0], previous[1], TRUE);
+#endif
+
   default:
   return FALSE;
   }
 
 
-/* Handle the case when the next item is \d, \s, etc. */
+/* Handle the case when the next item is \d, \s, etc. Note that when PCRE_UCP
+is set, \d turns into ESC_du rather than ESC_d, etc., so ESC_d etc. are
+generated only when PCRE_UCP is *not* set, that is, when only ASCII
+characteristics are recognized. Similarly, the opcodes OP_DIGIT etc. are
+replaced by OP_PROP codes when PCRE_UCP is set. */
 
 switch(op_code)
   {
   case OP_CHAR:
   case OP_CHARNC:
 #ifdef SUPPORT_UTF8
-  if (utf8 && item > 127) { GETCHAR(item, utf8_char); }
+  GETCHARTEST(c, previous);
+#else
+  c = *previous;
 #endif
   switch(-next)
     {
     case ESC_d:
-    return item > 127 || (cd->ctypes[item] & ctype_digit) == 0;
+    return c > 127 || (cd->ctypes[c] & ctype_digit) == 0;
 
     case ESC_D:
-    return item <= 127 && (cd->ctypes[item] & ctype_digit) != 0;
+    return c <= 127 && (cd->ctypes[c] & ctype_digit) != 0;
 
     case ESC_s:
-    return item > 127 || (cd->ctypes[item] & ctype_space) == 0;
+    return c > 127 || (cd->ctypes[c] & ctype_space) == 0;
 
     case ESC_S:
-    return item <= 127 && (cd->ctypes[item] & ctype_space) != 0;
+    return c <= 127 && (cd->ctypes[c] & ctype_space) != 0;
 
     case ESC_w:
-    return item > 127 || (cd->ctypes[item] & ctype_word) == 0;
+    return c > 127 || (cd->ctypes[c] & ctype_word) == 0;
 
     case ESC_W:
-    return item <= 127 && (cd->ctypes[item] & ctype_word) != 0;
+    return c <= 127 && (cd->ctypes[c] & ctype_word) != 0;
 
     case ESC_h:
     case ESC_H:
-    switch(item)
+    switch(c)
       {
       case 0x09:
       case 0x20:
@@ -2576,7 +2759,7 @@ switch(op_code)
 
     case ESC_v:
     case ESC_V:
-    switch(item)
+    switch(c)
       {
       case 0x0a:
       case 0x0b:
@@ -2590,38 +2773,92 @@ switch(op_code)
       return -next == ESC_v;
       }
 
+    /* When PCRE_UCP is set, these values get generated for \d etc. Find
+    their substitutions and process them. The result will always be either
+    -ESC_p or -ESC_P. Then fall through to process those values. */
+
+#ifdef SUPPORT_UCP
+    case ESC_du:
+    case ESC_DU:
+    case ESC_wu:
+    case ESC_WU:
+    case ESC_su:
+    case ESC_SU:
+      {
+      int temperrorcode = 0;
+      ptr = substitutes[-next - ESC_DU];
+      next = check_escape(&ptr, &temperrorcode, 0, options, FALSE);
+      if (temperrorcode != 0) return FALSE;
+      ptr++;    /* For compatibility */
+      }
+    /* Fall through */
+
+    case ESC_p:
+    case ESC_P:
+      {
+      int ptype, pdata, errorcodeptr;
+      BOOL negated;
+
+      ptr--;      /* Make ptr point at the p or P */
+      ptype = get_ucp(&ptr, &negated, &pdata, &errorcodeptr);
+      if (ptype < 0) return FALSE;
+      ptr++;      /* Point past the final curly ket */
+
+      /* If the property item is optional, we have to give up. (When generated
+      from \d etc by PCRE_UCP, this test will have been applied much earlier,
+      to the original \d etc. At this point, ptr will point to a zero byte. */
+
+      if (*ptr == CHAR_ASTERISK || *ptr == CHAR_QUESTION_MARK ||
+        strncmp((char *)ptr, STR_LEFT_CURLY_BRACKET STR_0 STR_COMMA, 3) == 0)
+          return FALSE;
+
+      /* Do the property check. */
+
+      return check_char_prop(c, ptype, pdata, (next == -ESC_P) != negated);
+      }
+#endif
+
     default:
     return FALSE;
     }
 
+  /* In principle, support for Unicode properties should be integrated here as
+  well. It means re-organizing the above code so as to get hold of the property
+  values before switching on the op-code. However, I wonder how many patterns
+  combine ASCII \d etc with Unicode properties? (Note that if PCRE_UCP is set,
+  these op-codes are never generated.) */
+
   case OP_DIGIT:
   return next == -ESC_D || next == -ESC_s || next == -ESC_W ||
-         next == -ESC_h || next == -ESC_v;
+         next == -ESC_h || next == -ESC_v || next == -ESC_R;
 
   case OP_NOT_DIGIT:
   return next == -ESC_d;
 
   case OP_WHITESPACE:
-  return next == -ESC_S || next == -ESC_d || next == -ESC_w;
+  return next == -ESC_S || next == -ESC_d || next == -ESC_w || next == -ESC_R;
 
   case OP_NOT_WHITESPACE:
   return next == -ESC_s || next == -ESC_h || next == -ESC_v;
 
   case OP_HSPACE:
-  return next == -ESC_S || next == -ESC_H || next == -ESC_d || next == -ESC_w;
+  return next == -ESC_S || next == -ESC_H || next == -ESC_d ||
+         next == -ESC_w || next == -ESC_v || next == -ESC_R;
 
   case OP_NOT_HSPACE:
   return next == -ESC_h;
 
   /* Can't have \S in here because VT matches \S (Perl anomaly) */
+  case OP_ANYNL:
   case OP_VSPACE:
   return next == -ESC_V || next == -ESC_d || next == -ESC_w;
 
   case OP_NOT_VSPACE:
-  return next == -ESC_v;
+  return next == -ESC_v || next == -ESC_R;
 
   case OP_WORDCHAR:
-  return next == -ESC_W || next == -ESC_s || next == -ESC_h || next == -ESC_v;
+  return next == -ESC_W || next == -ESC_s || next == -ESC_h ||
+         next == -ESC_v || next == -ESC_R;
 
   case OP_NOT_WORDCHAR:
   return next == -ESC_w || next == -ESC_d;
@@ -2685,6 +2922,7 @@ BOOL inescq = FALSE;
 BOOL groupsetfirstbyte = FALSE;
 const uschar *ptr = *ptrptr;
 const uschar *tempptr;
+const uschar *nestptr = NULL;
 uschar *previous = NULL;
 uschar *previous_callout = NULL;
 uschar *save_hwm = NULL;
@@ -2755,6 +2993,16 @@ for (;; ptr++)
 
   c = *ptr;
 
+  /* If we are at the end of a nested substitution, revert to the outer level
+  string. Nesting only happens one level deep. */
+
+  if (c == 0 && nestptr != NULL)
+    {
+    ptr = nestptr;
+    nestptr = NULL;
+    c = *ptr;
+    }
+
   /* If we are in the pre-compile phase, accumulate the length used for the
   previous cycle of this loop. */
 
@@ -2785,7 +3033,7 @@ for (;; ptr++)
       goto FAILED;
       }
 
-    *lengthptr += code - last_code;
+    *lengthptr += (int)(code - last_code);
     DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c));
 
     /* If "previous" is set and it is not at the start of the work space, move
@@ -2903,7 +3151,7 @@ for (;; ptr++)
         *errorcodeptr = ERR20;
         goto FAILED;
         }
-      *lengthptr += code - last_code;   /* To include callout length */
+      *lengthptr += (int)(code - last_code);   /* To include callout length */
       DPRINTF((">> end branch\n"));
       }
     return TRUE;
@@ -3108,7 +3356,7 @@ for (;; ptr++)
           ptr++;
           }
 
-        posix_class = check_posix_name(ptr, tempptr - ptr);
+        posix_class = check_posix_name(ptr, (int)(tempptr - ptr));
         if (posix_class < 0)
           {
           *errorcodeptr = ERR30;
@@ -3122,10 +3370,25 @@ for (;; ptr++)
         if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
           posix_class = 0;
 
-        /* We build the bit map for the POSIX class in a chunk of local store
-        because we may be adding and subtracting from it, and we don't want to
-        subtract bits that may be in the main map already. At the end we or the
-        result into the bit map that is being built. */
+        /* When PCRE_UCP is set, some of the POSIX classes are converted to
+        different escape sequences that use Unicode properties. */
+
+#ifdef SUPPORT_UCP
+        if ((options & PCRE_UCP) != 0)
+          {
+          int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0);
+          if (posix_substitutes[pc] != NULL)
+            {
+            nestptr = tempptr + 1;
+            ptr = posix_substitutes[pc] - 1;
+            continue;
+            }
+          }
+#endif
+        /* In the non-UCP case, we build the bit map for the POSIX class in a
+        chunk of local store because we may be adding and subtracting from it,
+        and we don't want to subtract bits that may be in the main map already.
+        At the end we or the result into the bit map that is being built. */
 
         posix_class *= 3;
 
@@ -3169,19 +3432,18 @@ for (;; ptr++)
 
       /* Backslash may introduce a single character, or it may introduce one
       of the specials, which just set a flag. The sequence \b is a special
-      case. Inside a class (and only there) it is treated as backspace.
-      Elsewhere it marks a word boundary. Other escapes have preset maps ready
-      to 'or' into the one we are building. We assume they have more than one
-      character in them, so set class_charcount bigger than one. */
+      case. Inside a class (and only there) it is treated as backspace. We
+      assume that other escapes have more than one character in them, so set
+      class_charcount bigger than one. Unrecognized escapes fall through and
+      are either treated as literal characters (by default), or are faulted if
+      PCRE_EXTRA is set. */
 
       if (c == CHAR_BACKSLASH)
         {
         c = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
         if (*errorcodeptr != 0) goto FAILED;
 
-        if (-c == ESC_b) c = CHAR_BS;       /* \b is backspace in a class */
-        else if (-c == ESC_X) c = CHAR_X;   /* \X is literal X in a class */
-        else if (-c == ESC_R) c = CHAR_R;   /* \R is literal R in a class */
+        if (-c == ESC_b) c = CHAR_BS;    /* \b is backspace in a class */
         else if (-c == ESC_Q)            /* Handle start of quoted string */
           {
           if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
@@ -3198,10 +3460,20 @@ for (;; ptr++)
           register const uschar *cbits = cd->cbits;
           class_charcount += 2;     /* Greater than 1 is what matters */
 
-          /* Save time by not doing this in the pre-compile phase. */
-
-          if (lengthptr == NULL) switch (-c)
+          switch (-c)
             {
+#ifdef SUPPORT_UCP
+            case ESC_du:     /* These are the values given for \d etc */
+            case ESC_DU:     /* when PCRE_UCP is set. We replace the */
+            case ESC_wu:     /* escape sequence with an appropriate \p */
+            case ESC_WU:     /* or \P to test Unicode properties instead */
+            case ESC_su:     /* of the default ASCII testing. */
+            case ESC_SU:
+            nestptr = ptr;
+            ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */
+            class_charcount -= 2;                /* Undo! */
+            continue;
+#endif
             case ESC_d:
             for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit];
             continue;
@@ -3231,20 +3503,7 @@ for (;; ptr++)
             classbits[1] |= 0x08;    /* Perl 5.004 onwards omits VT from \s */
             continue;
 
-            default:    /* Not recognized; fall through */
-            break;      /* Need "default" setting to stop compiler warning. */
-            }
-
-          /* In the pre-compile phase, just do the recognition. */
-
-          else if (c == -ESC_d || c == -ESC_D || c == -ESC_w ||
-                   c == -ESC_W || c == -ESC_s || c == -ESC_S) continue;
-
-          /* We need to deal with \H, \h, \V, and \v in both phases because
-          they use extra memory. */
-
-          if (-c == ESC_h)
-            {
+            case ESC_h:
             SETBIT(classbits, 0x09); /* VT */
             SETBIT(classbits, 0x20); /* SPACE */
             SETBIT(classbits, 0xa0); /* NSBP */
@@ -3268,10 +3527,8 @@ for (;; ptr++)
               }
 #endif
             continue;
-            }
 
-          if (-c == ESC_H)
-            {
+            case ESC_H:
             for (c = 0; c < 32; c++)
               {
               int x = 0xff;
@@ -3313,10 +3570,8 @@ for (;; ptr++)
               }
 #endif
             continue;
-            }
 
-          if (-c == ESC_v)
-            {
+            case ESC_v:
             SETBIT(classbits, 0x0a); /* LF */
             SETBIT(classbits, 0x0b); /* VT */
             SETBIT(classbits, 0x0c); /* FF */
@@ -3332,10 +3587,8 @@ for (;; ptr++)
               }
 #endif
             continue;
-            }
 
-          if (-c == ESC_V)
-            {
+            case ESC_V:
             for (c = 0; c < 32; c++)
               {
               int x = 0xff;
@@ -3365,38 +3618,38 @@ for (;; ptr++)
               }
 #endif
             continue;
-            }
-
-          /* We need to deal with \P and \p in both phases. */
 
 #ifdef SUPPORT_UCP
-          if (-c == ESC_p || -c == ESC_P)
-            {
-            BOOL negated;
-            int pdata;
-            int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
-            if (ptype < 0) goto FAILED;
-            class_utf8 = TRUE;
-            *class_utf8data++ = ((-c == ESC_p) != negated)?
-              XCL_PROP : XCL_NOTPROP;
-            *class_utf8data++ = ptype;
-            *class_utf8data++ = pdata;
-            class_charcount -= 2;   /* Not a < 256 character */
-            continue;
-            }
+            case ESC_p:
+            case ESC_P:
+              {
+              BOOL negated;
+              int pdata;
+              int ptype = get_ucp(&ptr, &negated, &pdata, errorcodeptr);
+              if (ptype < 0) goto FAILED;
+              class_utf8 = TRUE;
+              *class_utf8data++ = ((-c == ESC_p) != negated)?
+                XCL_PROP : XCL_NOTPROP;
+              *class_utf8data++ = ptype;
+              *class_utf8data++ = pdata;
+              class_charcount -= 2;   /* Not a < 256 character */
+              continue;
+              }
 #endif
-          /* Unrecognized escapes are faulted if PCRE is running in its
-          strict mode. By default, for compatibility with Perl, they are
-          treated as literals. */
+            /* Unrecognized escapes are faulted if PCRE is running in its
+            strict mode. By default, for compatibility with Perl, they are
+            treated as literals. */
 
-          if ((options & PCRE_EXTRA) != 0)
-            {
-            *errorcodeptr = ERR7;
-            goto FAILED;
+            default:
+            if ((options & PCRE_EXTRA) != 0)
+              {
+              *errorcodeptr = ERR7;
+              goto FAILED;
+              }
+            class_charcount -= 2;  /* Undo the default count from above */
+            c = *ptr;              /* Get the final character and fall through */
+            break;
             }
-
-          class_charcount -= 2;  /* Undo the default count from above */
-          c = *ptr;              /* Get the final character and fall through */
           }
 
         /* Fall through if we have a single character (c >= 0). This may be
@@ -3466,14 +3719,11 @@ for (;; ptr++)
           d = check_escape(&ptr, errorcodeptr, cd->bracount, options, TRUE);
           if (*errorcodeptr != 0) goto FAILED;
 
-          /* \b is backspace; \X is literal X; \R is literal R; any other
-          special means the '-' was literal */
+          /* \b is backspace; any other special means the '-' was literal */
 
           if (d < 0)
             {
-            if (d == -ESC_b) d = CHAR_BS;
-            else if (d == -ESC_X) d = CHAR_X;
-            else if (d == -ESC_R) d = CHAR_R; else
+            if (d == -ESC_b) d = CHAR_BS; else
               {
               ptr = oldptr;
               goto LONE_SINGLE_CHARACTER;  /* A few lines below */
@@ -3639,35 +3889,23 @@ for (;; ptr++)
         }
       }
 
-    /* Loop until ']' reached. This "while" is the end of the "do" above. */
+    /* Loop until ']' reached. This "while" is the end of the "do" far above.
+    If we are at the end of an internal nested string, revert to the outer
+    string. */
+
+    while (((c = *(++ptr)) != 0 ||
+           (nestptr != NULL &&
+             (ptr = nestptr, nestptr = NULL, c = *(++ptr)) != 0)) &&
+           (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));
 
-    while ((c = *(++ptr)) != 0 && (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));
+    /* Check for missing terminating ']' */
 
-    if (c == 0)                          /* Missing terminating ']' */
+    if (c == 0)
       {
       *errorcodeptr = ERR6;
       goto FAILED;
       }
 
-
-/* This code has been disabled because it would mean that \s counts as
-an explicit \r or \n reference, and that's not really what is wanted. Now
-we set the flag only if there is a literal "\r" or "\n" in the class. */
-
-#if 0
-    /* Remember whether \r or \n are in this class */
-
-    if (negate_class)
-      {
-      if ((classbits[1] & 0x24) != 0x24) cd->external_flags |= PCRE_HASCRORLF;
-      }
-    else
-      {
-      if ((classbits[1] & 0x24) != 0) cd->external_flags |= PCRE_HASCRORLF;
-      }
-#endif
-
-
     /* If class_charcount is 1, we saw precisely one character whose value is
     less than 256. As long as there were no characters >= 128 and there was no
     use of \p or \P, in other words, no use of any XCLASS features, we can
@@ -3731,13 +3969,14 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
     /* If there are characters with values > 255, we have to compile an
     extended class, with its own opcode, unless there was a negated special
-    such as \S in the class, because in that case all characters > 255 are in
-    the class, so any that were explicitly given as well can be ignored. If
-    (when there are explicit characters > 255 that must be listed) there are no
-    characters < 256, we can omit the bitmap in the actual compiled code. */
+    such as \S in the class, and PCRE_UCP is not set, because in that case all
+    characters > 255 are in the class, so any that were explicitly given as
+    well can be ignored. If (when there are explicit characters > 255 that must
+    be listed) there are no characters < 256, we can omit the bitmap in the
+    actual compiled code. */
 
 #ifdef SUPPORT_UTF8
-    if (class_utf8 && !should_flip_negation)
+    if (class_utf8 && (!should_flip_negation || (options & PCRE_UCP) != 0))
       {
       *class_utf8data++ = XCL_END;    /* Marks the end of extra data */
       *code++ = OP_XCLASS;
@@ -3763,10 +4002,11 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
       }
 #endif
 
-    /* If there are no characters > 255, set the opcode to OP_CLASS or
-    OP_NCLASS, depending on whether the whole class was negated and whether
-    there were negative specials such as \S in the class. Then copy the 32-byte
-    map into the code vector, negating it if necessary. */
+    /* If there are no characters > 255, or they are all to be included or
+    excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the
+    whole class was negated and whether there were negative specials such as \S
+    (non-UCP) in the class. Then copy the 32-byte map into the code vector,
+    negating it if necessary. */
 
     *code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS;
     if (negate_class)
@@ -3890,8 +4130,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
       if (!possessive_quantifier &&
           repeat_max < 0 &&
-          check_auto_possessive(*previous, c, utf8, utf8_char, ptr + 1,
-            options, cd))
+          check_auto_possessive(previous, utf8, ptr + 1, options, cd))
         {
         repeat_type = 0;    /* Force greedy */
         possessive_quantifier = TRUE;
@@ -3912,7 +4151,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
       c = previous[1];
       if (!possessive_quantifier &&
           repeat_max < 0 &&
-          check_auto_possessive(OP_NOT, c, utf8, NULL, ptr + 1, options, cd))
+          check_auto_possessive(previous, utf8, ptr + 1, options, cd))
         {
         repeat_type = 0;    /* Force greedy */
         possessive_quantifier = TRUE;
@@ -3936,7 +4175,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
       if (!possessive_quantifier &&
           repeat_max < 0 &&
-          check_auto_possessive(c, 0, utf8, NULL, ptr + 1, options, cd))
+          check_auto_possessive(previous, utf8, ptr + 1, options, cd))
         {
         repeat_type = 0;    /* Force greedy */
         possessive_quantifier = TRUE;
@@ -4146,7 +4385,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
       {
       register int i;
       int ketoffset = 0;
-      int len = code - previous;
+      int len = (int)(code - previous);
       uschar *bralink = NULL;
 
       /* Repeating a DEFINE group is pointless */
@@ -4167,7 +4406,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         {
         register uschar *ket = previous;
         do ket += GET(ket, 1); while (*ket != OP_KET);
-        ketoffset = code - ket;
+        ketoffset = (int)(code - ket);
         }
 
       /* The case of a zero minimum is special because of the need to stick
@@ -4235,7 +4474,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           /* We chain together the bracket offset fields that have to be
           filled in later when the ends of the brackets are reached. */
 
-          offset = (bralink == NULL)? 0 : previous - bralink;
+          offset = (bralink == NULL)? 0 : (int)(previous - bralink);
           bralink = previous;
           PUTINC(previous, 0, offset);
           }
@@ -4344,7 +4583,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
             {
             int offset;
             *code++ = OP_BRA;
-            offset = (bralink == NULL)? 0 : code - bralink;
+            offset = (bralink == NULL)? 0 : (int)(code - bralink);
             bralink = code;
             PUTINC(code, 0, offset);
             }
@@ -4365,7 +4604,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         while (bralink != NULL)
           {
           int oldlinkoffset;
-          int offset = code - bralink + 1;
+          int offset = (int)(code - bralink + 1);
           uschar *bra = code - offset;
           oldlinkoffset = GET(bra, 1);
           bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
@@ -4453,7 +4692,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 #endif
         }
 
-      len = code - tempcode;
+      len = (int)(code - tempcode);
       if (len > 0) switch (*tempcode)
         {
         case OP_STAR:  *tempcode = OP_POSSTAR; break;
@@ -4512,24 +4751,34 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
     /* First deal with various "verbs" that can be introduced by '*'. */
 
-    if (*(++ptr) == CHAR_ASTERISK && (cd->ctypes[ptr[1]] & ctype_letter) != 0)
+    if (*(++ptr) == CHAR_ASTERISK &&
+         ((cd->ctypes[ptr[1]] & ctype_letter) != 0 || ptr[1] == ':'))
       {
       int i, namelen;
+      int arglen = 0;
       const char *vn = verbnames;
-      const uschar *name = ++ptr;
+      const uschar *name = ptr + 1;
+      const uschar *arg = NULL;
       previous = NULL;
       while ((cd->ctypes[*++ptr] & ctype_letter) != 0) {};
+      namelen = (int)(ptr - name);
+
       if (*ptr == CHAR_COLON)
         {
-        *errorcodeptr = ERR59;   /* Not supported */
-        goto FAILED;
+        arg = ++ptr;
+        while ((cd->ctypes[*ptr] & (ctype_letter|ctype_digit)) != 0
+          || *ptr == '_') ptr++;
+        arglen = (int)(ptr - arg);
         }
+
       if (*ptr != CHAR_RIGHT_PARENTHESIS)
         {
         *errorcodeptr = ERR60;
         goto FAILED;
         }
-      namelen = ptr - name;
+
+      /* Scan the table of verb names */
+
       for (i = 0; i < verbcount; i++)
         {
         if (namelen == verbs[i].len &&
@@ -4547,13 +4796,41 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
               PUT2INC(code, 0, oc->number);
               }
             }
-          *code++ = verbs[i].op;
-          break;
+
+          /* Handle the cases with/without an argument */
+
+          if (arglen == 0)
+            {
+            if (verbs[i].op < 0)   /* Argument is mandatory */
+              {
+              *errorcodeptr = ERR66;
+              goto FAILED;
+              }
+            *code++ = verbs[i].op;
+            }
+
+          else
+            {
+            if (verbs[i].op_arg < 0)   /* Argument is forbidden */
+              {
+              *errorcodeptr = ERR59;
+              goto FAILED;
+              }
+            *code++ = verbs[i].op_arg;
+            *code++ = arglen;
+            memcpy(code, arg, arglen);
+            code += arglen;
+            *code++ = 0;
+            }
+
+          break;  /* Found verb, exit loop */
           }
+
         vn += verbs[i].len + 1;
         }
-      if (i < verbcount) continue;
-      *errorcodeptr = ERR60;
+
+      if (i < verbcount) continue;    /* Successfully handled a verb */
+      *errorcodeptr = ERR60;          /* Verb not recognized */
       goto FAILED;
       }
 
@@ -4672,7 +4949,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
               recno * 10 + *ptr - CHAR_0 : -1;
           ptr++;
           }
-        namelen = ptr - name;
+        namelen = (int)(ptr - name);
 
         if ((terminator > 0 && *ptr++ != terminator) ||
             *ptr++ != CHAR_RIGHT_PARENTHESIS)
@@ -4868,8 +5145,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
             goto FAILED;
             }
           *code++ = n;
-          PUT(code, 0, ptr - cd->start_pattern + 1);  /* Pattern offset */
-          PUT(code, LINK_SIZE, 0);                    /* Default length */
+          PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
+          PUT(code, LINK_SIZE, 0);                          /* Default length */
           code += 2 * LINK_SIZE;
           }
         previous = NULL;
@@ -4902,7 +5179,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           name = ++ptr;
 
           while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
-          namelen = ptr - name;
+          namelen = (int)(ptr - name);
 
           /* In the pre-compile phase, just do a syntax check. */
 
@@ -5032,7 +5309,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         NAMED_REF_OR_RECURSE:
         name = ++ptr;
         while ((cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
-        namelen = ptr - name;
+        namelen = (int)(ptr - name);
 
         /* In the pre-compile phase, do a syntax check and set a dummy
         reference number. */
@@ -5201,7 +5478,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
               of the group. */
 
               called = cd->start_code + recno;
-              PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);
+              PUTINC(cd->hwm, 0, (int)(code + 2 + LINK_SIZE - cd->start_code));
               }
 
             /* If not a forward reference, and the subpattern is still open,
@@ -5225,7 +5502,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
           code += 1 + LINK_SIZE;
 
           *code = OP_RECURSE;
-          PUT(code, 1, called - cd->start_code);
+          PUT(code, 1, (int)(called - cd->start_code));
           code += 1 + LINK_SIZE;
 
           *code = OP_KET;
@@ -5336,8 +5613,8 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
         }     /* End of switch for character following (? */
       }       /* End of (? handling */
 
-    /* Opening parenthesis not followed by '?'. If PCRE_NO_AUTO_CAPTURE is set,
-    all unadorned brackets become non-capturing and behave like (?:...)
+    /* Opening parenthesis not followed by '*' or '?'. If PCRE_NO_AUTO_CAPTURE
+    is set, all unadorned brackets become non-capturing and behave like (?:...)
     brackets. */
 
     else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)
@@ -5529,11 +5806,12 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 
     /* ===================================================================*/
     /* Handle metasequences introduced by \. For ones like \d, the ESC_ values
-    are arranged to be the negation of the corresponding OP_values. For the
-    back references, the values are ESC_REF plus the reference number. Only
-    back references and those types that consume a character may be repeated.
-    We can test for values between ESC_b and ESC_Z for the latter; this may
-    have to change if any new ones are ever created. */
+    are arranged to be the negation of the corresponding OP_values in the
+    default case when PCRE_UCP is not set. For the back references, the values
+    are ESC_REF plus the reference number. Only back references and those types
+    that consume a character may be repeated. We can test for values between
+    ESC_b and ESC_Z for the latter; this may have to change if any new ones are
+    ever created. */
 
     case CHAR_BACKSLASH:
     tempptr = ptr;
@@ -5693,12 +5971,24 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */
 #endif
 
       /* For the rest (including \X when Unicode properties are supported), we
-      can obtain the OP value by negating the escape value. */
+      can obtain the OP value by negating the escape value in the default
+      situation when PCRE_UCP is not set. When it *is* set, we substitute
+      Unicode property tests. */
 
       else
         {
-        previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
-        *code++ = -c;
+#ifdef SUPPORT_UCP
+        if (-c >= ESC_DU && -c <= ESC_wu)
+          {
+          nestptr = ptr + 1;                   /* Where to resume */
+          ptr = substitutes[-c - ESC_DU] - 1;  /* Just before substitute */
+          }
+        else
+#endif
+          {
+          previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
+          *code++ = -c;
+          }
         }
       continue;
       }
@@ -6030,7 +6320,7 @@ for (;;)
     {
     if (lengthptr == NULL)
       {
-      int branch_length = code - last_branch;
+      int branch_length = (int)(code - last_branch);
       do
         {
         int prev_length = GET(last_branch, 1);
@@ -6044,7 +6334,7 @@ for (;;)
     /* Fill in the ket */
 
     *code = OP_KET;
-    PUT(code, 1, code - start_bracket);
+    PUT(code, 1, (int)(code - start_bracket));
     code += 1 + LINK_SIZE;
 
     /* If it was a capturing subpattern, check to see if it contained any
@@ -6059,9 +6349,9 @@ for (;;)
           code - start_bracket);
         *start_bracket = OP_ONCE;
         code += 1 + LINK_SIZE;
-        PUT(start_bracket, 1, code - start_bracket);
+        PUT(start_bracket, 1, (int)(code - start_bracket));
         *code = OP_KET;
-        PUT(code, 1, code - start_bracket);
+        PUT(code, 1, (int)(code - start_bracket));
         code += 1 + LINK_SIZE;
         length += 2 + 2*LINK_SIZE;
         }
@@ -6116,7 +6406,7 @@ for (;;)
   else
     {
     *code = OP_ALT;
-    PUT(code, 1, code - last_branch);
+    PUT(code, 1, (int)(code - last_branch));
     bc.current_branch = last_branch = code;
     code += 1 + LINK_SIZE;
     }
@@ -6435,7 +6725,7 @@ int length = 1;  /* For final END opcode */
 int firstbyte, reqbyte, newline;
 int errorcode = 0;
 int skipatstart = 0;
-BOOL utf8 = (options & PCRE_UTF8) != 0;
+BOOL utf8;
 size_t size;
 uschar *code;
 const uschar *codestart;
@@ -6505,6 +6795,8 @@ while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS &&
 
   if (strncmp((char *)(ptr+skipatstart+2), STRING_UTF8_RIGHTPAR, 5) == 0)
     { skipatstart += 7; options |= PCRE_UTF8; continue; }
+  else if (strncmp((char *)(ptr+skipatstart+2), STRING_UCP_RIGHTPAR, 4) == 0)
+    { skipatstart += 6; options |= PCRE_UCP; continue; }
 
   if (strncmp((char *)(ptr+skipatstart+2), STRING_CR_RIGHTPAR, 3) == 0)
     { skipatstart += 5; newnl = PCRE_NEWLINE_CR; }
@@ -6529,6 +6821,8 @@ while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS &&
   else break;
   }
 
+utf8 = (options & PCRE_UTF8) != 0;
+
 /* Can't support UTF8 unless PCRE has been compiled to include the code. */
 
 #ifdef SUPPORT_UTF8
@@ -6546,6 +6840,16 @@ if (utf8)
   }
 #endif
 
+/* Can't support UCP unless PCRE has been compiled to include the code. */
+
+#ifndef SUPPORT_UCP
+if ((options & PCRE_UCP) != 0)
+  {
+  errorcode = ERR67;
+  goto PCRE_EARLY_ERROR_RETURN;
+  }
+#endif
+
 /* Check validity of \R options. */
 
 switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
@@ -6674,7 +6978,7 @@ regex compiled on a system with 4-byte pointers is run on another with 8-byte
 pointers. */
 
 re->magic_number = MAGIC_NUMBER;
-re->size = size;
+re->size = (int)size;
 re->options = cd->external_options;
 re->flags = cd->external_flags;
 re->dummy1 = 0;
@@ -6745,7 +7049,7 @@ while (errorcode == 0 && cd->hwm > cworkspace)
   recno = GET(codestart, offset);
   groupptr = _pcre_find_bracket(codestart, utf8, recno);
   if (groupptr == NULL) errorcode = ERR53;
-    else PUT(((uschar *)codestart), offset, groupptr - codestart);
+    else PUT(((uschar *)codestart), offset, (int)(groupptr - codestart));
   }
 
 /* Give an error if there's back reference to a non-existent capturing
@@ -6800,7 +7104,7 @@ if (errorcode != 0)
   {
   (pcre_free)(re);
   PCRE_EARLY_ERROR_RETURN:
-  *erroroffset = ptr - (const uschar *)pattern;
+  *erroroffset = (int)(ptr - (const uschar *)pattern);
   PCRE_EARLY_ERROR_RETURN2:
   *errorptr = find_error_text(errorcode);
   if (errorcodeptr != NULL) *errorcodeptr = errorcode;
diff --git a/ext/pcre/pcrelib/pcre_exec.c b/ext/pcre/pcrelib/pcre_exec.c
index 4fe798e..5588354 100644
--- a/ext/pcre/pcrelib/pcre_exec.c
+++ b/ext/pcre/pcrelib/pcre_exec.c
@@ -69,10 +69,20 @@ defined PCRE_ERROR_xxx codes, which are all negative. */
 /* Special internal returns from the match() function. Make them sufficiently
 negative to avoid the external error codes. */
 
-#define MATCH_COMMIT       (-999)
-#define MATCH_PRUNE        (-998)
-#define MATCH_SKIP         (-997)
-#define MATCH_THEN         (-996)
+#define MATCH_ACCEPT       (-999)
+#define MATCH_COMMIT       (-998)
+#define MATCH_PRUNE        (-997)
+#define MATCH_SKIP         (-996)
+#define MATCH_SKIP_ARG     (-995)
+#define MATCH_THEN         (-994)
+
+/* This is a convenience macro for code that occurs many times. */
+
+#define MRRETURN(ra) \
+  { \
+  md->mark = markptr; \
+  RRETURN(ra); \
+  }
 
 /* Maximum number of ints of offset to save on the stack for recursive calls.
 If the offset vector is bigger, malloc is used. This should be a multiple of 3,
@@ -243,7 +253,8 @@ enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM6,  RM7,  RM8,  RM9,  RM10,
        RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
        RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
        RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
-       RM51,  RM52, RM53, RM54 };
+       RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
+       RM61,  RM62 };
 
 /* These versions of the macros use the stack, as normal. There are debugging
 versions and production versions. Note that the "rw" argument of RMATCH isn't
@@ -282,6 +293,7 @@ argument of match(), which never changes. */
 #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
   {\
   heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
+  if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
   frame->Xwhere = rw; \
   newframe->Xeptr = ra;\
   newframe->Xecode = rb;\
@@ -302,9 +314,9 @@ argument of match(), which never changes. */
 
 #define RRETURN(ra)\
   {\
-  heapframe *newframe = frame;\
-  frame = newframe->Xprevframe;\
-  (pcre_stack_free)(newframe);\
+  heapframe *oldframe = frame;\
+  frame = oldframe->Xprevframe;\
+  (pcre_stack_free)(oldframe);\
   if (frame != NULL)\
     {\
     rrc = ra;\
@@ -411,14 +423,14 @@ the subject. */
   if (md->partial != 0 && eptr >= md->end_subject && eptr > mstart)\
     {\
     md->hitend = TRUE;\
-    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
+    if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL);\
     }
 
 #define SCHECK_PARTIAL()\
   if (md->partial != 0 && eptr > mstart)\
     {\
     md->hitend = TRUE;\
-    if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);\
+    if (md->partial > 1) MRRETURN(PCRE_ERROR_PARTIAL);\
     }
 
 
@@ -446,13 +458,14 @@ Arguments:
 
 Returns:       MATCH_MATCH if matched            )  these values are >= 0
                MATCH_NOMATCH if failed to match  )
+               a negative MATCH_xxx value for PRUNE, SKIP, etc
                a negative PCRE_ERROR_xxx value if aborted by an error condition
                  (e.g. stopped by repeated call or recursion limit)
 */
 
 static int
-match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, USPTR
-  markptr, int offset_top, match_data *md, unsigned long int ims,
+match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,
+  const uschar *markptr, int offset_top, match_data *md, unsigned long int ims,
   eptrblock *eptrb, int flags, unsigned int rdepth)
 {
 /* These variables do not need to be preserved over recursion in this function,
@@ -474,6 +487,7 @@ heap whenever RMATCH() does a "recursion". See the macro definitions above. */
 
 #ifdef NO_RECURSE
 heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));
+if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
 frame->Xprevframe = NULL;            /* Marks the top level */
 
 /* Copy in the original argument variables */
@@ -669,32 +683,81 @@ for (;;)
 
   switch(op)
     {
+    case OP_MARK:
+    markptr = ecode + 2;
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
+      ims, eptrb, flags, RM55);
+
+    /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
+    argument, and we must check whether that argument matches this MARK's
+    argument. It is passed back in md->start_match_ptr (an overloading of that
+    variable). If it does match, we reset that variable to the current subject
+    position and return MATCH_SKIP. Otherwise, pass back the return code
+    unaltered. */
+
+    if (rrc == MATCH_SKIP_ARG &&
+        strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)
+      {
+      md->start_match_ptr = eptr;
+      RRETURN(MATCH_SKIP);
+      }
+
+    if (md->mark == NULL) md->mark = markptr;
+    RRETURN(rrc);
+
     case OP_FAIL:
-    RRETURN(MATCH_NOMATCH);
+    MRRETURN(MATCH_NOMATCH);
+
+    case OP_COMMIT:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
+      ims, eptrb, flags, RM52);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    MRRETURN(MATCH_COMMIT);
 
     case OP_PRUNE:
     RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
       ims, eptrb, flags, RM51);
     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-    RRETURN(MATCH_PRUNE);
+    MRRETURN(MATCH_PRUNE);
 
-    case OP_COMMIT:
-    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
-      ims, eptrb, flags, RM52);
+    case OP_PRUNE_ARG:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
+      ims, eptrb, flags, RM56);
     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-    RRETURN(MATCH_COMMIT);
+    md->mark = ecode + 2;
+    RRETURN(MATCH_PRUNE);
 
     case OP_SKIP:
     RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
       ims, eptrb, flags, RM53);
     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
     md->start_match_ptr = eptr;   /* Pass back current position */
-    RRETURN(MATCH_SKIP);
+    MRRETURN(MATCH_SKIP);
+
+    case OP_SKIP_ARG:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
+      ims, eptrb, flags, RM57);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+
+    /* Pass back the current skip name by overloading md->start_match_ptr and
+    returning the special MATCH_SKIP_ARG return code. This will either be
+    caught by a matching MARK, or get to the top, where it is treated the same
+    as PRUNE. */
+
+    md->start_match_ptr = ecode + 2;
+    RRETURN(MATCH_SKIP_ARG);
 
     case OP_THEN:
     RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
       ims, eptrb, flags, RM54);
     if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    MRRETURN(MATCH_THEN);
+
+    case OP_THEN_ARG:
+    RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
+      ims, eptrb, flags, RM58);
+    if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+    md->mark = ecode + 2;
     RRETURN(MATCH_THEN);
 
     /* Handle a capturing bracket. If there is space in the offset vector, save
@@ -731,7 +794,8 @@ for (;;)
       save_capture_last = md->capture_last;
 
       DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
-      md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
+      md->offset_vector[md->offset_end - number] =
+        (int)(eptr - md->start_subject);
 
       flags = (op == OP_SCBRA)? match_cbegroup : 0;
       do
@@ -750,6 +814,7 @@ for (;;)
       md->offset_vector[offset+1] = save_offset2;
       md->offset_vector[md->offset_end - number] = save_offset3;
 
+      if (rrc != MATCH_THEN) md->mark = markptr;
       RRETURN(MATCH_NOMATCH);
       }
 
@@ -789,6 +854,7 @@ for (;;)
 
         RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
           eptrb, flags, RM48);
+        if (rrc == MATCH_NOMATCH) md->mark = markptr;
         RRETURN(rrc);
         }
 
@@ -824,15 +890,15 @@ for (;;)
         cb.callout_number   = ecode[LINK_SIZE+2];
         cb.offset_vector    = md->offset_vector;
         cb.subject          = (PCRE_SPTR)md->start_subject;
-        cb.subject_length   = md->end_subject - md->start_subject;
-        cb.start_match      = mstart - md->start_subject;
-        cb.current_position = eptr - md->start_subject;
+        cb.subject_length   = (int)(md->end_subject - md->start_subject);
+        cb.start_match      = (int)(mstart - md->start_subject);
+        cb.current_position = (int)(eptr - md->start_subject);
         cb.pattern_position = GET(ecode, LINK_SIZE + 3);
         cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
         cb.capture_top      = offset_top/2;
         cb.capture_last     = md->capture_last;
         cb.callout_data     = md->callout_data;
-        if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
+        if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
         if (rrc < 0) RRETURN(rrc);
         }
       ecode += _pcre_OP_lengths[OP_CALLOUT];
@@ -1052,7 +1118,7 @@ for (;;)
       {
       md->offset_vector[offset] =
         md->offset_vector[md->offset_end - number];
-      md->offset_vector[offset+1] = eptr - md->start_subject;
+      md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
       if (offset_top <= offset) offset_top = offset + 2;
       }
     ecode += 3;
@@ -1087,14 +1153,19 @@ for (;;)
         (md->notempty ||
           (md->notempty_atstart &&
             mstart == md->start_subject + md->start_offset)))
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
 
     /* Otherwise, we have a match. */
 
     md->end_match_ptr = eptr;           /* Record where we ended */
     md->end_offset_top = offset_top;    /* and how many extracts were taken */
     md->start_match_ptr = mstart;       /* and the start (\K can modify) */
-    RRETURN(MATCH_MATCH);
+
+    /* For some reason, the macros don't work properly if an expression is
+    given as the argument to MRRETURN when the heap is in use. */
+
+    rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
+    MRRETURN(rrc);
 
     /* Change option settings */
 
@@ -1116,7 +1187,7 @@ for (;;)
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
         RM4);
-      if (rrc == MATCH_MATCH)
+      if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
         {
         mstart = md->start_match_ptr;   /* In case \K reset it */
         break;
@@ -1125,7 +1196,7 @@ for (;;)
       ecode += GET(ecode, 1);
       }
     while (*ecode == OP_ALT);
-    if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
+    if (*ecode == OP_KET) MRRETURN(MATCH_NOMATCH);
 
     /* If checking an assertion for a condition, return MATCH_MATCH. */
 
@@ -1149,7 +1220,7 @@ for (;;)
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
         RM5);
-      if (rrc == MATCH_MATCH) RRETURN(MATCH_NOMATCH);
+      if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);
       if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
         {
         do ecode += GET(ecode,1); while (*ecode == OP_ALT);
@@ -1178,7 +1249,7 @@ for (;;)
       while (i-- > 0)
         {
         eptr--;
-        if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
+        if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
         BACKCHAR(eptr);
         }
       }
@@ -1189,7 +1260,7 @@ for (;;)
 
       {
       eptr -= GET(ecode, 1);
-      if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
+      if (eptr < md->start_subject) MRRETURN(MATCH_NOMATCH);
       }
 
     /* Save the earliest consulted character, then skip to next op code */
@@ -1210,15 +1281,15 @@ for (;;)
       cb.callout_number   = ecode[1];
       cb.offset_vector    = md->offset_vector;
       cb.subject          = (PCRE_SPTR)md->start_subject;
-      cb.subject_length   = md->end_subject - md->start_subject;
-      cb.start_match      = mstart - md->start_subject;
-      cb.current_position = eptr - md->start_subject;
+      cb.subject_length   = (int)(md->end_subject - md->start_subject);
+      cb.start_match      = (int)(mstart - md->start_subject);
+      cb.current_position = (int)(eptr - md->start_subject);
       cb.pattern_position = GET(ecode, 2);
       cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
       cb.capture_top      = offset_top/2;
       cb.capture_last     = md->capture_last;
       cb.callout_data     = md->callout_data;
-      if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
+      if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
       if (rrc < 0) RRETURN(rrc);
       }
     ecode += 2 + 2*LINK_SIZE;
@@ -1284,13 +1355,13 @@ for (;;)
         {
         RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
           md, ims, eptrb, flags, RM6);
-        if (rrc == MATCH_MATCH)
+        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
           {
           DPRINTF(("Recursion matched\n"));
           md->recursive = new_recursive.prevrec;
           if (new_recursive.offset_save != stacksave)
             (pcre_free)(new_recursive.offset_save);
-          RRETURN(MATCH_MATCH);
+          MRRETURN(MATCH_MATCH);
           }
         else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
           {
@@ -1311,7 +1382,7 @@ for (;;)
       md->recursive = new_recursive.prevrec;
       if (new_recursive.offset_save != stacksave)
         (pcre_free)(new_recursive.offset_save);
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     /* Control never reaches here */
 
@@ -1330,7 +1401,7 @@ for (;;)
     do
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
-      if (rrc == MATCH_MATCH)
+      if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
         {
         mstart = md->start_match_ptr;
         break;
@@ -1465,7 +1536,7 @@ for (;;)
       md->end_match_ptr = eptr;      /* For ONCE */
       md->end_offset_top = offset_top;
       md->start_match_ptr = mstart;
-      RRETURN(MATCH_MATCH);
+      MRRETURN(MATCH_MATCH);
       }
 
     /* For capturing groups we have to check the group number back at the start
@@ -1489,7 +1560,7 @@ for (;;)
         {
         md->offset_vector[offset] =
           md->offset_vector[md->offset_end - number];
-        md->offset_vector[offset+1] = eptr - md->start_subject;
+        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
         if (offset_top <= offset) offset_top = offset + 2;
         }
 
@@ -1560,12 +1631,12 @@ for (;;)
     /* Start of subject unless notbol, or after internal newline if multiline */
 
     case OP_CIRC:
-    if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
+    if (md->notbol && eptr == md->start_subject) MRRETURN(MATCH_NOMATCH);
     if ((ims & PCRE_MULTILINE) != 0)
       {
       if (eptr != md->start_subject &&
           (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
       ecode++;
       break;
       }
@@ -1574,14 +1645,14 @@ for (;;)
     /* Start of subject assertion */
 
     case OP_SOD:
-    if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr != md->start_subject) MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
     /* Start of match assertion */
 
     case OP_SOM:
-    if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
+    if (eptr != md->start_subject + md->start_offset) MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1599,20 +1670,20 @@ for (;;)
     if ((ims & PCRE_MULTILINE) != 0)
       {
       if (eptr < md->end_subject)
-        { if (!IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH); }
+        { if (!IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH); }
       else
-        { if (md->noteol) RRETURN(MATCH_NOMATCH); }
+        { if (md->noteol) MRRETURN(MATCH_NOMATCH); }
       ecode++;
       break;
       }
     else
       {
-      if (md->noteol) RRETURN(MATCH_NOMATCH);
+      if (md->noteol) MRRETURN(MATCH_NOMATCH);
       if (!md->endonly)
         {
         if (eptr != md->end_subject &&
             (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
         ecode++;
         break;
         }
@@ -1622,7 +1693,7 @@ for (;;)
     /* End of subject assertion (\z) */
 
     case OP_EOD:
-    if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
+    if (eptr < md->end_subject) MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1631,7 +1702,7 @@ for (;;)
     case OP_EODN:
     if (eptr != md->end_subject &&
         (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1649,14 +1720,30 @@ for (;;)
 #ifdef SUPPORT_UTF8
       if (utf8)
         {
+        /* Get status of previous character */
+
         if (eptr == md->start_subject) prev_is_word = FALSE; else
           {
           USPTR lastptr = eptr - 1;
           while((*lastptr & 0xc0) == 0x80) lastptr--;
           if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
           GETCHAR(c, lastptr);
+#ifdef SUPPORT_UCP
+          if (md->use_ucp)
+            {
+            if (c == '_') prev_is_word = TRUE; else
+              {
+              int cat = UCD_CATEGORY(c);
+              prev_is_word = (cat == ucp_L || cat == ucp_N);
+              }
+            }
+          else
+#endif
           prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
           }
+
+        /* Get status of next character */
+
         if (eptr >= md->end_subject)
           {
           SCHECK_PARTIAL();
@@ -1665,47 +1752,89 @@ for (;;)
         else
           {
           GETCHAR(c, eptr);
+#ifdef SUPPORT_UCP
+          if (md->use_ucp)
+            {
+            if (c == '_') cur_is_word = TRUE; else
+              {
+              int cat = UCD_CATEGORY(c);
+              cur_is_word = (cat == ucp_L || cat == ucp_N);
+              }
+            }
+          else
+#endif
           cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
           }
         }
       else
 #endif
 
-      /* Not in UTF-8 mode */
+      /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
+      consistency with the behaviour of \w we do use it in this case. */
 
         {
+        /* Get status of previous character */
+
         if (eptr == md->start_subject) prev_is_word = FALSE; else
           {
           if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
+#ifdef SUPPORT_UCP
+          if (md->use_ucp)
+            {
+            c = eptr[-1];
+            if (c == '_') prev_is_word = TRUE; else
+              {
+              int cat = UCD_CATEGORY(c);
+              prev_is_word = (cat == ucp_L || cat == ucp_N);
+              }
+            }
+          else
+#endif
           prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
           }
+
+        /* Get status of next character */
+
         if (eptr >= md->end_subject)
           {
           SCHECK_PARTIAL();
           cur_is_word = FALSE;
           }
-        else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
+        else
+#ifdef SUPPORT_UCP
+        if (md->use_ucp)
+          {
+          c = *eptr;
+          if (c == '_') cur_is_word = TRUE; else
+            {
+            int cat = UCD_CATEGORY(c);
+            cur_is_word = (cat == ucp_L || cat == ucp_N);
+            }
+          }
+        else
+#endif
+        cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
         }
 
       /* Now see if the situation is what we want */
 
       if ((*ecode++ == OP_WORD_BOUNDARY)?
            cur_is_word == prev_is_word : cur_is_word != prev_is_word)
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
       }
     break;
 
     /* Match a single character type; inline for speed */
 
     case OP_ANY:
-    if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+    if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
     /* Fall through */
 
     case OP_ALLANY:
     if (eptr++ >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     if (utf8) while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
     ecode++;
@@ -1718,7 +1847,7 @@ for (;;)
     if (eptr++ >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     ecode++;
     break;
@@ -1727,7 +1856,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1736,7 +1865,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_digit) != 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1744,7 +1873,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1753,7 +1882,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_digit) == 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1761,7 +1890,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1770,7 +1899,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_space) != 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1778,7 +1907,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1787,7 +1916,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_space) == 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1795,7 +1924,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1804,7 +1933,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_word) != 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1812,7 +1941,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     if (
@@ -1821,7 +1950,7 @@ for (;;)
 #endif
        (md->ctypes[c] & ctype_word) == 0
        )
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
     ecode++;
     break;
 
@@ -1829,12 +1958,12 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
-      default: RRETURN(MATCH_NOMATCH);
+      default: MRRETURN(MATCH_NOMATCH);
       case 0x000d:
       if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
       break;
@@ -1847,7 +1976,7 @@ for (;;)
       case 0x0085:
       case 0x2028:
       case 0x2029:
-      if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+      if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
       break;
       }
     ecode++;
@@ -1857,7 +1986,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     switch(c)
@@ -1882,7 +2011,7 @@ for (;;)
       case 0x202f:    /* NARROW NO-BREAK SPACE */
       case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
       case 0x3000:    /* IDEOGRAPHIC SPACE */
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     ecode++;
     break;
@@ -1891,12 +2020,12 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
-      default: RRETURN(MATCH_NOMATCH);
+      default: MRRETURN(MATCH_NOMATCH);
       case 0x09:      /* HT */
       case 0x20:      /* SPACE */
       case 0xa0:      /* NBSP */
@@ -1925,7 +2054,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     switch(c)
@@ -1938,7 +2067,7 @@ for (;;)
       case 0x85:      /* NEL */
       case 0x2028:    /* LINE SEPARATOR */
       case 0x2029:    /* PARAGRAPH SEPARATOR */
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     ecode++;
     break;
@@ -1947,12 +2076,12 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
     switch(c)
       {
-      default: RRETURN(MATCH_NOMATCH);
+      default: MRRETURN(MATCH_NOMATCH);
       case 0x0a:      /* LF */
       case 0x0b:      /* VT */
       case 0x0c:      /* FF */
@@ -1974,7 +2103,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
       {
@@ -1983,31 +2112,63 @@ for (;;)
       switch(ecode[1])
         {
         case PT_ANY:
-        if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
+        if (op == OP_NOTPROP) MRRETURN(MATCH_NOMATCH);
         break;
 
         case PT_LAMP:
         if ((prop->chartype == ucp_Lu ||
              prop->chartype == ucp_Ll ||
              prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
-          RRETURN(MATCH_NOMATCH);
-         break;
+          MRRETURN(MATCH_NOMATCH);
+        break;
 
         case PT_GC:
         if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
         break;
 
         case PT_PC:
         if ((ecode[2] != prop->chartype) == (op == OP_PROP))
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
         break;
 
         case PT_SC:
         if ((ecode[2] != prop->script) == (op == OP_PROP))
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
+        break;
+
+        /* These are specials */
+
+        case PT_ALNUM:
+        if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+             _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
+          MRRETURN(MATCH_NOMATCH);
+        break;
+
+        case PT_SPACE:    /* Perl space */
+        if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+             c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
+               == (op == OP_NOTPROP))
+          MRRETURN(MATCH_NOMATCH);
         break;
 
+        case PT_PXSPACE:  /* POSIX space */
+        if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+             c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
+             c == CHAR_FF || c == CHAR_CR)
+               == (op == OP_NOTPROP))
+          MRRETURN(MATCH_NOMATCH);
+        break;
+
+        case PT_WORD:
+        if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+             _pcre_ucp_gentype[prop->chartype] == ucp_N ||
+             c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
+          MRRETURN(MATCH_NOMATCH);
+        break;
+
+        /* This should never occur */
+
         default:
         RRETURN(PCRE_ERROR_INTERNAL);
         }
@@ -2023,12 +2184,12 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     GETCHARINCTEST(c, eptr);
       {
       int category = UCD_CATEGORY(c);
-      if (category == ucp_M) RRETURN(MATCH_NOMATCH);
+      if (category == ucp_M) MRRETURN(MATCH_NOMATCH);
       while (eptr < md->end_subject)
         {
         int len = 1;
@@ -2073,7 +2234,7 @@ for (;;)
       referenced subpattern. */
 
       if (offset >= offset_top || md->offset_vector[offset] < 0)
-        length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;
+        length = (md->jscript_compat)? 0 : (int)(md->end_subject - eptr + 1);
       else
         length = md->offset_vector[offset+1] - md->offset_vector[offset];
 
@@ -2107,7 +2268,7 @@ for (;;)
         if (!match_ref(offset, eptr, length, md, ims))
           {
           CHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
         eptr += length;
         continue;              /* With the main loop */
@@ -2127,7 +2288,7 @@ for (;;)
         if (!match_ref(offset, eptr, length, md, ims))
           {
           CHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
         eptr += length;
         }
@@ -2145,11 +2306,11 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM14);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (!match_ref(offset, eptr, length, md, ims))
             {
             CHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           eptr += length;
           }
@@ -2176,7 +2337,7 @@ for (;;)
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
           eptr -= length;
           }
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       }
     /* Control never gets here */
@@ -2238,16 +2399,16 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           if (c > 255)
             {
-            if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
+            if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
             }
           else
             {
-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
             }
           }
         }
@@ -2260,10 +2421,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           c = *eptr++;
-          if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+          if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
           }
         }
 
@@ -2285,20 +2446,20 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM16);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINC(c, eptr);
             if (c > 255)
               {
-              if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
+              if (op == OP_CLASS) MRRETURN(MATCH_NOMATCH);
               }
             else
               {
-              if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+              if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
               }
             }
           }
@@ -2310,14 +2471,14 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM17);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             c = *eptr++;
-            if ((data[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
+            if ((data[c/8] & (1 << (c&7))) == 0) MRRETURN(MATCH_NOMATCH);
             }
           }
         /* Control never gets here */
@@ -2383,7 +2544,7 @@ for (;;)
             }
           }
 
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       }
     /* Control never gets here */
@@ -2435,10 +2596,10 @@ for (;;)
         if (eptr >= md->end_subject)
           {
           SCHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
         GETCHARINCTEST(c, eptr);
-        if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
+        if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
         }
 
       /* If max == min we can continue with the main loop without the
@@ -2455,14 +2616,14 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM20);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINCTEST(c, eptr);
-          if (!_pcre_xclass(c, data)) RRETURN(MATCH_NOMATCH);
+          if (!_pcre_xclass(c, data)) MRRETURN(MATCH_NOMATCH);
           }
         /* Control never gets here */
         }
@@ -2491,7 +2652,7 @@ for (;;)
           if (eptr-- == pp) break;        /* Stop if tried at original pos */
           if (utf8) BACKCHAR(eptr);
           }
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
 
       /* Control never gets here */
@@ -2510,9 +2671,9 @@ for (;;)
       if (length > md->end_subject - eptr)
         {
         CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
-      while (length-- > 0) if (*ecode++ != *eptr++) RRETURN(MATCH_NOMATCH);
+      while (length-- > 0) if (*ecode++ != *eptr++) MRRETURN(MATCH_NOMATCH);
       }
     else
 #endif
@@ -2522,9 +2683,9 @@ for (;;)
       if (md->end_subject - eptr < 1)
         {
         SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
-      if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
+      if (ecode[1] != *eptr++) MRRETURN(MATCH_NOMATCH);
       ecode += 2;
       }
     break;
@@ -2542,7 +2703,7 @@ for (;;)
       if (length > md->end_subject - eptr)
         {
         CHECK_PARTIAL();             /* Not SCHECK_PARTIAL() */
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
 
       /* If the pattern character's value is < 128, we have only one byte, and
@@ -2550,7 +2711,7 @@ for (;;)
 
       if (fc < 128)
         {
-        if (md->lcc[*ecode++] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+        if (md->lcc[*ecode++] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
         }
 
       /* Otherwise we must pick up the subject character */
@@ -2569,7 +2730,7 @@ for (;;)
 #ifdef SUPPORT_UCP
           if (dc != UCD_OTHERCASE(fc))
 #endif
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           }
         }
       }
@@ -2581,9 +2742,9 @@ for (;;)
       if (md->end_subject - eptr < 1)
         {
         SCHECK_PARTIAL();            /* This one can use SCHECK_PARTIAL() */
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
-      if (md->lcc[ecode[1]] != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+      if (md->lcc[ecode[1]] != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
       ecode += 2;
       }
     break;
@@ -2677,7 +2838,7 @@ for (;;)
           else
             {
             CHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           }
 
@@ -2689,7 +2850,7 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM22);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr <= md->end_subject - length &&
               memcmp(eptr, charptr, length) == 0) eptr += length;
 #ifdef SUPPORT_UCP
@@ -2700,7 +2861,7 @@ for (;;)
             else
               {
               CHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             }
           /* Control never gets here */
@@ -2731,7 +2892,7 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM23);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (eptr == pp) { RRETURN(MATCH_NOMATCH); }
+            if (eptr == pp) { MRRETURN(MATCH_NOMATCH); }
 #ifdef SUPPORT_UCP
             eptr--;
             BACKCHAR(eptr);
@@ -2774,9 +2935,9 @@ for (;;)
         if (eptr >= md->end_subject)
           {
           SCHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
-        if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+        if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
         }
       if (min == max) continue;
       if (minimize)
@@ -2785,13 +2946,13 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM24);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (fc != md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+          if (fc != md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
           }
         /* Control never gets here */
         }
@@ -2817,7 +2978,7 @@ for (;;)
           eptr--;
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
           }
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       /* Control never gets here */
       }
@@ -2831,9 +2992,9 @@ for (;;)
         if (eptr >= md->end_subject)
           {
           SCHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
-        if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+        if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
         }
 
       if (min == max) continue;
@@ -2844,13 +3005,13 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM26);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (fc != *eptr++) RRETURN(MATCH_NOMATCH);
+          if (fc != *eptr++) MRRETURN(MATCH_NOMATCH);
           }
         /* Control never gets here */
         }
@@ -2875,7 +3036,7 @@ for (;;)
           eptr--;
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
           }
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       }
     /* Control never gets here */
@@ -2887,7 +3048,7 @@ for (;;)
     if (eptr >= md->end_subject)
       {
       SCHECK_PARTIAL();
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     ecode++;
     GETCHARINCTEST(c, eptr);
@@ -2897,11 +3058,11 @@ for (;;)
       if (c < 256)
 #endif
       c = md->lcc[c];
-      if (md->lcc[*ecode++] == c) RRETURN(MATCH_NOMATCH);
+      if (md->lcc[*ecode++] == c) MRRETURN(MATCH_NOMATCH);
       }
     else
       {
-      if (*ecode++ == c) RRETURN(MATCH_NOMATCH);
+      if (*ecode++ == c) MRRETURN(MATCH_NOMATCH);
       }
     break;
 
@@ -2995,11 +3156,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(d, eptr);
           if (d < 256) d = md->lcc[d];
-          if (fc == d) RRETURN(MATCH_NOMATCH);
+          if (fc == d) MRRETURN(MATCH_NOMATCH);
           }
         }
       else
@@ -3012,9 +3173,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+          if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
           }
         }
 
@@ -3031,15 +3192,15 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM28);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINC(d, eptr);
             if (d < 256) d = md->lcc[d];
-            if (fc == d) RRETURN(MATCH_NOMATCH);
+            if (fc == d) MRRETURN(MATCH_NOMATCH);
             }
           }
         else
@@ -3050,13 +3211,13 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM29);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            if (fc == md->lcc[*eptr++]) RRETURN(MATCH_NOMATCH);
+            if (fc == md->lcc[*eptr++]) MRRETURN(MATCH_NOMATCH);
             }
           }
         /* Control never gets here */
@@ -3118,7 +3279,7 @@ for (;;)
             }
           }
 
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       /* Control never gets here */
       }
@@ -3137,10 +3298,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(d, eptr);
-          if (fc == d) RRETURN(MATCH_NOMATCH);
+          if (fc == d) MRRETURN(MATCH_NOMATCH);
           }
         }
       else
@@ -3152,9 +3313,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
+          if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
           }
         }
 
@@ -3171,14 +3332,14 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM32);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINC(d, eptr);
-            if (fc == d) RRETURN(MATCH_NOMATCH);
+            if (fc == d) MRRETURN(MATCH_NOMATCH);
             }
           }
         else
@@ -3189,13 +3350,13 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM33);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
+            if (fc == *eptr++) MRRETURN(MATCH_NOMATCH);
             }
           }
         /* Control never gets here */
@@ -3256,7 +3417,7 @@ for (;;)
             }
           }
 
-        RRETURN(MATCH_NOMATCH);
+        MRRETURN(MATCH_NOMATCH);
         }
       }
     /* Control never gets here */
@@ -3350,13 +3511,13 @@ for (;;)
         switch(prop_type)
           {
           case PT_ANY:
-          if (prop_fail_result) RRETURN(MATCH_NOMATCH);
+          if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
           for (i = 1; i <= min; i++)
             {
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINCTEST(c, eptr);
             }
@@ -3368,14 +3529,14 @@ for (;;)
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
                  prop_chartype == ucp_Ll ||
                  prop_chartype == ucp_Lt) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           break;
 
@@ -3385,12 +3546,12 @@ for (;;)
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINCTEST(c, eptr);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           break;
 
@@ -3400,12 +3561,12 @@ for (;;)
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           break;
 
@@ -3415,15 +3576,84 @@ for (;;)
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             GETCHARINCTEST(c, eptr);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           break;
 
+          case PT_ALNUM:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L || prop_category == ucp_N)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_SPACE:    /* Perl space */
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_FF || c == CHAR_CR)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_PXSPACE:  /* POSIX space */
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          case PT_WORD:
+          for (i = 1; i <= min; i++)
+            {
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L || prop_category == ucp_N ||
+                 c == CHAR_UNDERSCORE)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          break;
+
+          /* This should not occur */
+
           default:
           RRETURN(PCRE_ERROR_INTERNAL);
           }
@@ -3439,11 +3669,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINCTEST(c, eptr);
           prop_category = UCD_CATEGORY(c);
-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
+          if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
           while (eptr < md->end_subject)
             {
             int len = 1;
@@ -3470,9 +3700,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+          if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
           eptr++;
           while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
           }
@@ -3484,7 +3714,7 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           eptr++;
           while (eptr < md->end_subject && (*eptr & 0xc0) == 0x80) eptr++;
@@ -3492,7 +3722,7 @@ for (;;)
         break;
 
         case OP_ANYBYTE:
-        if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
+        if (eptr > md->end_subject - min) MRRETURN(MATCH_NOMATCH);
         eptr += min;
         break;
 
@@ -3502,12 +3732,12 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           switch(c)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x000d:
             if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
             break;
@@ -3520,7 +3750,7 @@ for (;;)
             case 0x0085:
             case 0x2028:
             case 0x2029:
-            if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+            if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
             break;
             }
           }
@@ -3532,7 +3762,7 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           switch(c)
@@ -3557,7 +3787,7 @@ for (;;)
             case 0x202f:    /* NARROW NO-BREAK SPACE */
             case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
             case 0x3000:    /* IDEOGRAPHIC SPACE */
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           }
         break;
@@ -3568,12 +3798,12 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           switch(c)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x09:      /* HT */
             case 0x20:      /* SPACE */
             case 0xa0:      /* NBSP */
@@ -3604,7 +3834,7 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           switch(c)
@@ -3617,7 +3847,7 @@ for (;;)
             case 0x85:      /* NEL */
             case 0x2028:    /* LINE SEPARATOR */
             case 0x2029:    /* PARAGRAPH SEPARATOR */
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           }
         break;
@@ -3628,12 +3858,12 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           switch(c)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x0a:      /* LF */
             case 0x0b:      /* VT */
             case 0x0c:      /* FF */
@@ -3652,11 +3882,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINC(c, eptr);
           if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3666,10 +3896,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_digit) == 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
         break;
@@ -3680,10 +3910,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (*eptr < 128 && (md->ctypes[*eptr] & ctype_space) != 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
           }
         break;
@@ -3694,10 +3924,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_space) == 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
         break;
@@ -3708,10 +3938,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
           }
         break;
@@ -3722,10 +3952,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (*eptr >= 128 || (md->ctypes[*eptr++] & ctype_word) == 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           /* No need to skip more bytes - we know it's a 1-byte character */
           }
         break;
@@ -3748,9 +3978,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
+          if (IS_NEWLINE(eptr)) MRRETURN(MATCH_NOMATCH);
           eptr++;
           }
         break;
@@ -3759,7 +3989,7 @@ for (;;)
         if (eptr > md->end_subject - min)
           {
           SCHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
         eptr += min;
         break;
@@ -3768,7 +3998,7 @@ for (;;)
         if (eptr > md->end_subject - min)
           {
           SCHECK_PARTIAL();
-          RRETURN(MATCH_NOMATCH);
+          MRRETURN(MATCH_NOMATCH);
           }
         eptr += min;
         break;
@@ -3779,11 +4009,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           switch(*eptr++)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x000d:
             if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
             break;
@@ -3793,7 +4023,7 @@ for (;;)
             case 0x000b:
             case 0x000c:
             case 0x0085:
-            if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+            if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
             break;
             }
           }
@@ -3805,7 +4035,7 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           switch(*eptr++)
             {
@@ -3813,7 +4043,7 @@ for (;;)
             case 0x09:      /* HT */
             case 0x20:      /* SPACE */
             case 0xa0:      /* NBSP */
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           }
         break;
@@ -3824,11 +4054,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           switch(*eptr++)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x09:      /* HT */
             case 0x20:      /* SPACE */
             case 0xa0:      /* NBSP */
@@ -3843,7 +4073,7 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           switch(*eptr++)
             {
@@ -3853,7 +4083,7 @@ for (;;)
             case 0x0c:      /* FF */
             case 0x0d:      /* CR */
             case 0x85:      /* NEL */
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           }
         break;
@@ -3864,11 +4094,11 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           switch(*eptr++)
             {
-            default: RRETURN(MATCH_NOMATCH);
+            default: MRRETURN(MATCH_NOMATCH);
             case 0x0a:      /* LF */
             case 0x0b:      /* VT */
             case 0x0c:      /* FF */
@@ -3885,9 +4115,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if ((md->ctypes[*eptr++] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
+          if ((md->ctypes[*eptr++] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3897,9 +4127,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if ((md->ctypes[*eptr++] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
+          if ((md->ctypes[*eptr++] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3909,9 +4139,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if ((md->ctypes[*eptr++] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
+          if ((md->ctypes[*eptr++] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3921,9 +4151,9 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
-          if ((md->ctypes[*eptr++] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
+          if ((md->ctypes[*eptr++] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3933,10 +4163,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if ((md->ctypes[*eptr++] & ctype_word) != 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3946,10 +4176,10 @@ for (;;)
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if ((md->ctypes[*eptr++] & ctype_word) == 0)
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           }
         break;
 
@@ -3978,14 +4208,14 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM36);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            GETCHARINC(c, eptr);
-            if (prop_fail_result) RRETURN(MATCH_NOMATCH);
+            GETCHARINCTEST(c, eptr);
+            if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
             }
           /* Control never gets here */
 
@@ -3994,18 +4224,18 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM37);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            GETCHARINC(c, eptr);
+            GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
                  prop_chartype == ucp_Ll ||
                  prop_chartype == ucp_Lt) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           /* Control never gets here */
 
@@ -4014,16 +4244,16 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM38);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            GETCHARINC(c, eptr);
+            GETCHARINCTEST(c, eptr);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           /* Control never gets here */
 
@@ -4032,16 +4262,16 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM39);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            GETCHARINC(c, eptr);
+            GETCHARINCTEST(c, eptr);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             }
           /* Control never gets here */
 
@@ -4050,19 +4280,101 @@ for (;;)
             {
             RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM40);
             if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-            if (fi >= max) RRETURN(MATCH_NOMATCH);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
             if (eptr >= md->end_subject)
               {
               SCHECK_PARTIAL();
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
-            GETCHARINC(c, eptr);
+            GETCHARINCTEST(c, eptr);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_ALNUM:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM59);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L || prop_category == ucp_N)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_SPACE:    /* Perl space */
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM60);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_FF || c == CHAR_CR)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
             }
           /* Control never gets here */
 
+          case PT_PXSPACE:  /* POSIX space */
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM61);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          case PT_WORD:
+          for (fi = min;; fi++)
+            {
+            RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM62);
+            if (rrc != MATCH_NOMATCH) RRETURN(rrc);
+            if (fi >= max) MRRETURN(MATCH_NOMATCH);
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              MRRETURN(MATCH_NOMATCH);
+              }
+            GETCHARINCTEST(c, eptr);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L ||
+                 prop_category == ucp_N ||
+                 c == CHAR_UNDERSCORE)
+                   == prop_fail_result)
+              MRRETURN(MATCH_NOMATCH);
+            }
+          /* Control never gets here */
+
+          /* This should never occur */
+
           default:
           RRETURN(PCRE_ERROR_INTERNAL);
           }
@@ -4077,15 +4389,15 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM41);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           GETCHARINCTEST(c, eptr);
           prop_category = UCD_CATEGORY(c);
-          if (prop_category == ucp_M) RRETURN(MATCH_NOMATCH);
+          if (prop_category == ucp_M) MRRETURN(MATCH_NOMATCH);
           while (eptr < md->end_subject)
             {
             int len = 1;
@@ -4109,14 +4421,14 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM42);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (ctype == OP_ANY && IS_NEWLINE(eptr))
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           GETCHARINC(c, eptr);
           switch(ctype)
             {
@@ -4128,7 +4440,7 @@ for (;;)
             case OP_ANYNL:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x000d:
               if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
               break;
@@ -4140,7 +4452,7 @@ for (;;)
               case 0x0085:
               case 0x2028:
               case 0x2029:
-              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
               break;
               }
             break;
@@ -4168,14 +4480,14 @@ for (;;)
               case 0x202f:    /* NARROW NO-BREAK SPACE */
               case 0x205f:    /* MEDIUM MATHEMATICAL SPACE */
               case 0x3000:    /* IDEOGRAPHIC SPACE */
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             break;
 
             case OP_HSPACE:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x09:      /* HT */
               case 0x20:      /* SPACE */
               case 0xa0:      /* NBSP */
@@ -4210,14 +4522,14 @@ for (;;)
               case 0x85:      /* NEL */
               case 0x2028:    /* LINE SEPARATOR */
               case 0x2029:    /* PARAGRAPH SEPARATOR */
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             break;
 
             case OP_VSPACE:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x0a:      /* LF */
               case 0x0b:      /* VT */
               case 0x0c:      /* FF */
@@ -4231,32 +4543,32 @@ for (;;)
 
             case OP_NOT_DIGIT:
             if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_DIGIT:
             if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_NOT_WHITESPACE:
             if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_WHITESPACE:
             if  (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_NOT_WORDCHAR:
             if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_WORDCHAR:
             if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
             break;
 
             default:
@@ -4272,14 +4584,14 @@ for (;;)
           {
           RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM43);
           if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-          if (fi >= max) RRETURN(MATCH_NOMATCH);
+          if (fi >= max) MRRETURN(MATCH_NOMATCH);
           if (eptr >= md->end_subject)
             {
             SCHECK_PARTIAL();
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
             }
           if (ctype == OP_ANY && IS_NEWLINE(eptr))
-            RRETURN(MATCH_NOMATCH);
+            MRRETURN(MATCH_NOMATCH);
           c = *eptr++;
           switch(ctype)
             {
@@ -4291,7 +4603,7 @@ for (;;)
             case OP_ANYNL:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x000d:
               if (eptr < md->end_subject && *eptr == 0x0a) eptr++;
               break;
@@ -4302,7 +4614,7 @@ for (;;)
               case 0x000b:
               case 0x000c:
               case 0x0085:
-              if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
+              if (md->bsr_anycrlf) MRRETURN(MATCH_NOMATCH);
               break;
               }
             break;
@@ -4314,14 +4626,14 @@ for (;;)
               case 0x09:      /* HT */
               case 0x20:      /* SPACE */
               case 0xa0:      /* NBSP */
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             break;
 
             case OP_HSPACE:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x09:      /* HT */
               case 0x20:      /* SPACE */
               case 0xa0:      /* NBSP */
@@ -4338,14 +4650,14 @@ for (;;)
               case 0x0c:      /* FF */
               case 0x0d:      /* CR */
               case 0x85:      /* NEL */
-              RRETURN(MATCH_NOMATCH);
+              MRRETURN(MATCH_NOMATCH);
               }
             break;
 
             case OP_VSPACE:
             switch(c)
               {
-              default: RRETURN(MATCH_NOMATCH);
+              default: MRRETURN(MATCH_NOMATCH);
               case 0x0a:      /* LF */
               case 0x0b:      /* VT */
               case 0x0c:      /* FF */
@@ -4356,27 +4668,27 @@ for (;;)
             break;
 
             case OP_NOT_DIGIT:
-            if ((md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
+            if ((md->ctypes[c] & ctype_digit) != 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_DIGIT:
-            if ((md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
+            if ((md->ctypes[c] & ctype_digit) == 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_NOT_WHITESPACE:
-            if ((md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
+            if ((md->ctypes[c] & ctype_space) != 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_WHITESPACE:
-            if  ((md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
+            if  ((md->ctypes[c] & ctype_space) == 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_NOT_WORDCHAR:
-            if ((md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
+            if ((md->ctypes[c] & ctype_word) != 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             case OP_WORDCHAR:
-            if ((md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
+            if ((md->ctypes[c] & ctype_word) == 0) MRRETURN(MATCH_NOMATCH);
             break;
 
             default:
@@ -4409,7 +4721,7 @@ for (;;)
               SCHECK_PARTIAL();
               break;
               }
-            GETCHARLEN(c, eptr, len);
+            GETCHARLENTEST(c, eptr, len);
             if (prop_fail_result) break;
             eptr+= len;
             }
@@ -4424,7 +4736,7 @@ for (;;)
               SCHECK_PARTIAL();
               break;
               }
-            GETCHARLEN(c, eptr, len);
+            GETCHARLENTEST(c, eptr, len);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == ucp_Lu ||
                  prop_chartype == ucp_Ll ||
@@ -4443,7 +4755,7 @@ for (;;)
               SCHECK_PARTIAL();
               break;
               }
-            GETCHARLEN(c, eptr, len);
+            GETCHARLENTEST(c, eptr, len);
             prop_category = UCD_CATEGORY(c);
             if ((prop_category == prop_value) == prop_fail_result)
               break;
@@ -4460,7 +4772,7 @@ for (;;)
               SCHECK_PARTIAL();
               break;
               }
-            GETCHARLEN(c, eptr, len);
+            GETCHARLENTEST(c, eptr, len);
             prop_chartype = UCD_CHARTYPE(c);
             if ((prop_chartype == prop_value) == prop_fail_result)
               break;
@@ -4477,13 +4789,90 @@ for (;;)
               SCHECK_PARTIAL();
               break;
               }
-            GETCHARLEN(c, eptr, len);
+            GETCHARLENTEST(c, eptr, len);
             prop_script = UCD_SCRIPT(c);
             if ((prop_script == prop_value) == prop_fail_result)
               break;
             eptr+= len;
             }
           break;
+
+          case PT_ALNUM:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            GETCHARLENTEST(c, eptr, len);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L || prop_category == ucp_N)
+                 == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_SPACE:    /* Perl space */
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            GETCHARLENTEST(c, eptr, len);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_FF || c == CHAR_CR)
+                 == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_PXSPACE:  /* POSIX space */
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            GETCHARLENTEST(c, eptr, len);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
+                 c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
+                 == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          case PT_WORD:
+          for (i = min; i < max; i++)
+            {
+            int len = 1;
+            if (eptr >= md->end_subject)
+              {
+              SCHECK_PARTIAL();
+              break;
+              }
+            GETCHARLENTEST(c, eptr, len);
+            prop_category = UCD_CATEGORY(c);
+            if ((prop_category == ucp_L || prop_category == ucp_N ||
+                 c == CHAR_UNDERSCORE) == prop_fail_result)
+              break;
+            eptr+= len;
+            }
+          break;
+
+          default:
+          RRETURN(PCRE_ERROR_INTERNAL);
           }
 
         /* eptr is now past the end of the maximum run */
@@ -5036,7 +5425,7 @@ for (;;)
 
       /* Get here if we can't make it match with any permitted repetitions */
 
-      RRETURN(MATCH_NOMATCH);
+      MRRETURN(MATCH_NOMATCH);
       }
     /* Control never gets here */
 
@@ -5069,12 +5458,13 @@ switch (frame->Xwhere)
   LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
   LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
   LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
-  LBL(53) LBL(54)
+  LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58)
 #ifdef SUPPORT_UTF8
   LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
   LBL(32) LBL(34) LBL(42) LBL(46)
 #ifdef SUPPORT_UCP
   LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
+  LBL(59) LBL(60) LBL(61) LBL(62)
 #endif  /* SUPPORT_UCP */
 #endif  /* SUPPORT_UTF8 */
   default:
@@ -5278,6 +5668,7 @@ end_subject = md->end_subject;
 
 md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
 utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;
+md->use_ucp = (re->options & PCRE_UCP) != 0;
 md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
 
 md->notbol = (options & PCRE_NOTBOL) != 0;
@@ -5287,6 +5678,7 @@ md->notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
 md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :
               ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;
 md->hitend = FALSE;
+md->mark = NULL;                        /* In case never set */
 
 md->recursive = NULL;                   /* No recursion at top level */
 
@@ -5565,8 +5957,16 @@ for(;;)
       while (start_match < end_subject)
         {
         register unsigned int c = *start_match;
-        if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;
-          else break;
+        if ((start_bits[c/8] & (1 << (c&7))) == 0)
+          {
+          start_match++;
+#ifdef SUPPORT_UTF8
+          if (utf8)
+            while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
+              start_match++;
+#endif
+          }
+        else break;
         }
       }
     }   /* Starting optimizations */
@@ -5667,6 +6067,23 @@ for(;;)
 
   switch(rc)
     {
+    /* SKIP passes back the next starting point explicitly, but if it is the
+    same as the match we have just done, treat it as NOMATCH. */
+
+    case MATCH_SKIP:
+    if (md->start_match_ptr != start_match)
+      {
+      new_start_match = md->start_match_ptr;
+      break;
+      }
+    /* Fall through */
+
+    /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
+    the SKIP's arg was not found. We also treat this as NOMATCH. */
+
+    case MATCH_SKIP_ARG:
+    /* Fall through */
+
     /* NOMATCH and PRUNE advance by one character. THEN at this level acts
     exactly like PRUNE. */
 
@@ -5681,12 +6098,6 @@ for(;;)
 #endif
     break;
 
-    /* SKIP passes back the next starting point explicitly. */
-
-    case MATCH_SKIP:
-    new_start_match = md->start_match_ptr;
-    break;
-
     /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
 
     case MATCH_COMMIT:
@@ -5732,7 +6143,8 @@ for(;;)
          md->nllen == 2))
     start_match++;
 
-  }   /* End of for(;;) "bumpalong" loop */
+  md->mark = NULL;   /* Reset for start of next match attempt */
+  }                  /* End of for(;;) "bumpalong" loop */
 
 /* ==========================================================================*/
 
@@ -5756,7 +6168,7 @@ capturing parentheses than vector slots. */
 
 ENDLOOP:
 
-if (rc == MATCH_MATCH)
+if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
   {
   if (using_temporary_offsets)
     {
@@ -5782,12 +6194,12 @@ if (rc == MATCH_MATCH)
 
   if (offsetcount < 2) rc = 0; else
     {
-    offsets[0] = md->start_match_ptr - md->start_subject;
-    offsets[1] = md->end_match_ptr - md->start_subject;
+    offsets[0] = (int)(md->start_match_ptr - md->start_subject);
+    offsets[1] = (int)(md->end_match_ptr - md->start_subject);
     }
 
   DPRINTF((">>>> returning %d\n", rc));
-  return rc;
+  goto RETURN_MARK;
   }
 
 /* Control gets here if there has been an error, or if the overall match
@@ -5799,26 +6211,43 @@ if (using_temporary_offsets)
   (pcre_free)(md->offset_vector);
   }
 
+/* For anything other than nomatch or partial match, just return the code. */
+
 if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
   {
   DPRINTF((">>>> error: returning %d\n", rc));
   return rc;
   }
-else if (start_partial != NULL)
+
+/* Handle partial matches - disable any mark data */
+
+if (start_partial != NULL)
   {
   DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));
+  md->mark = NULL;
   if (offsetcount > 1)
     {
-    offsets[0] = start_partial - (USPTR)subject;
-    offsets[1] = end_subject - (USPTR)subject;
+    offsets[0] = (int)(start_partial - (USPTR)subject);
+    offsets[1] = (int)(end_subject - (USPTR)subject);
     }
-  return PCRE_ERROR_PARTIAL;
+  rc = PCRE_ERROR_PARTIAL;
   }
+
+/* This is the classic nomatch case */
+
 else
   {
   DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
-  return PCRE_ERROR_NOMATCH;
+  rc = PCRE_ERROR_NOMATCH;
   }
+
+/* Return the MARK data if it has been requested. */
+
+RETURN_MARK:
+
+if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
+  *(extra_data->mark) = (unsigned char *)(md->mark);
+return rc;
 }
 
 /* End of pcre_exec.c */
diff --git a/ext/pcre/pcrelib/pcre_internal.h b/ext/pcre/pcrelib/pcre_internal.h
index 0938782..039a140 100644
--- a/ext/pcre/pcrelib/pcre_internal.h
+++ b/ext/pcre/pcrelib/pcre_internal.h
@@ -191,6 +191,7 @@ arithmetic. Handle this by defining a macro for the appropriate type. If
 stdint.h is available, include it; it may define INT64_MAX. Systems that do not
 have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set
 by "configure". */
+
 #ifdef PHP_WIN32
 #include "win32/php_stdint.h"
 #elif HAVE_STDINT_H
@@ -476,7 +477,8 @@ know we are in UTF-8 mode. */
       } \
     }
 
-/* Get the next character, testing for UTF-8 mode, and advancing the pointer */
+/* Get the next character, testing for UTF-8 mode, and advancing the pointer.
+This is called when we don't know if we are in UTF-8 mode. */
 
 #define GETCHARINCTEST(c, eptr) \
   c = *eptr++; \
@@ -513,7 +515,7 @@ if there are extra bytes. This is called when we know we are in UTF-8 mode. */
 
 /* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
 pointer, incrementing length if there are extra bytes. This is called when we
-know we are in UTF-8 mode. */
+do not know if we are in UTF-8 mode. */
 
 #define GETCHARLENTEST(c, eptr, len) \
   c = *eptr; \
@@ -581,7 +583,7 @@ time, run time, or study time, respectively. */
    PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
    PCRE_NO_AUTO_CAPTURE|PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
    PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
-   PCRE_JAVASCRIPT_COMPAT)
+   PCRE_JAVASCRIPT_COMPAT|PCRE_UCP)
 
 #define PUBLIC_EXEC_OPTIONS \
   (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
@@ -876,6 +878,7 @@ so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
 #define STRING_COMMIT0              "COMMIT\0"
 #define STRING_F0                   "F\0"
 #define STRING_FAIL0                "FAIL\0"
+#define STRING_MARK0                "MARK\0"
 #define STRING_PRUNE0               "PRUNE\0"
 #define STRING_SKIP0                "SKIP\0"
 #define STRING_THEN                 "THEN"
@@ -905,6 +908,7 @@ so that PCRE works on both ASCII and EBCDIC platforms, in non-UTF-mode only. */
 #define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
 #define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
 #define STRING_UTF8_RIGHTPAR        "UTF8)"
+#define STRING_UCP_RIGHTPAR         "UCP)"
 
 #else  /* SUPPORT_UTF8 */
 
@@ -1128,6 +1132,7 @@ only. */
 #define STRING_COMMIT0              STR_C STR_O STR_M STR_M STR_I STR_T "\0"
 #define STRING_F0                   STR_F "\0"
 #define STRING_FAIL0                STR_F STR_A STR_I STR_L "\0"
+#define STRING_MARK0                STR_M STR_A STR_R STR_K "\0"
 #define STRING_PRUNE0               STR_P STR_R STR_U STR_N STR_E "\0"
 #define STRING_SKIP0                STR_S STR_K STR_I STR_P "\0"
 #define STRING_THEN                 STR_T STR_H STR_E STR_N
@@ -1157,6 +1162,7 @@ only. */
 #define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
 #define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
 #define STRING_UTF8_RIGHTPAR        STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
+#define STRING_UCP_RIGHTPAR         STR_U STR_C STR_P STR_RIGHT_PARENTHESIS
 
 #endif  /* SUPPORT_UTF8 */
 
@@ -1189,9 +1195,13 @@ only. */
 
 #define PT_ANY        0    /* Any property - matches all chars */
 #define PT_LAMP       1    /* L& - the union of Lu, Ll, Lt */
-#define PT_GC         2    /* General characteristic (e.g. L) */
-#define PT_PC         3    /* Particular characteristic (e.g. Lu) */
+#define PT_GC         2    /* Specified general characteristic (e.g. L) */
+#define PT_PC         3    /* Specified particular characteristic (e.g. Lu) */
 #define PT_SC         4    /* Script (e.g. Han) */
+#define PT_ALNUM      5    /* Alphanumeric - the union of L and N */
+#define PT_SPACE      6    /* Perl space - Z plus 9,10,12,13 */
+#define PT_PXSPACE    7    /* POSIX space - Z plus 9,10,11,12,13 */
+#define PT_WORD       8    /* Word - L plus N plus underscore */
 
 /* Flag bits and data types for the extended class (OP_XCLASS) for classes that
 contain UTF-8 characters with values greater than 255. */
@@ -1208,9 +1218,15 @@ contain UTF-8 characters with values greater than 255. */
 /* These are escaped items that aren't just an encoding of a particular data
 value such as \n. They must have non-zero values, as check_escape() returns
 their negation. Also, they must appear in the same order as in the opcode
-definitions below, up to ESC_z. There's a dummy for OP_ANY because it
-corresponds to "." rather than an escape sequence, and another for OP_ALLANY
-(which is used for [^] in JavaScript compatibility mode).
+definitions below, up to ESC_z. There's a dummy for OP_ALLANY because it
+corresponds to "." in DOTALL mode rather than an escape sequence. It is also
+used for [^] in JavaScript compatibility mode. In non-DOTALL mode, "." behaves
+like \N.
+
+The special values ESC_DU, ESC_du, etc. are used instead of ESC_D, ESC_d, etc.
+when PCRE_UCP is set, when replacement of \d etc by \p sequences is required.
+They must be contiguous, and remain in order so that the replacements can be
+looked up from a table.
 
 The final escape must be ESC_REF as subsequent values are used for
 backreferences (\1, \2, \3, etc). There are two tests in the code for an escape
@@ -1220,11 +1236,12 @@ put in between that don't consume a character, that code will have to change.
 */
 
 enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
-       ESC_W, ESC_w, ESC_dum1, ESC_dum2, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
-       ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z, ESC_E, ESC_Q, ESC_g, ESC_k,
+       ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
+       ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,
+       ESC_E, ESC_Q, ESC_g, ESC_k,
+       ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu,
        ESC_REF };
 
-
 /* Opcode table: Starting from 1 (i.e. after OP_END), the values up to
 OP_EOD must correspond in order to the list of escapes immediately above.
 
@@ -1248,8 +1265,8 @@ enum {
   OP_WHITESPACE,         /*  9 \s */
   OP_NOT_WORDCHAR,       /* 10 \W */
   OP_WORDCHAR,           /* 11 \w */
-  OP_ANY,            /* 12 Match any character (subject to DOTALL) */
-  OP_ALLANY,         /* 13 Match any character (not subject to DOTALL) */
+  OP_ANY,            /* 12 Match any character except newline */
+  OP_ALLANY,         /* 13 Match any character */
   OP_ANYBYTE,        /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
   OP_NOTPROP,        /* 15 \P (not Unicode property) */
   OP_PROP,           /* 16 \p (Unicode property) */
@@ -1379,20 +1396,24 @@ enum {
 
   /* These are backtracking control verbs */
 
-  OP_PRUNE,          /* 107 */
-  OP_SKIP,           /* 108 */
-  OP_THEN,           /* 109 */
-  OP_COMMIT,         /* 110 */
+  OP_MARK,           /* 107 always has an argument */
+  OP_PRUNE,          /* 108 */
+  OP_PRUNE_ARG,      /* 109 same, but with argument */
+  OP_SKIP,           /* 110 */
+  OP_SKIP_ARG,       /* 111 same, but with argument */
+  OP_THEN,           /* 112 */
+  OP_THEN_ARG,       /* 113 same, but with argument */
+  OP_COMMIT,         /* 114 */
 
   /* These are forced failure and success verbs */
 
-  OP_FAIL,           /* 111 */
-  OP_ACCEPT,         /* 112 */
-  OP_CLOSE,          /* 113 Used before OP_ACCEPT to close open captures */
+  OP_FAIL,           /* 115 */
+  OP_ACCEPT,         /* 116 */
+  OP_CLOSE,          /* 117 Used before OP_ACCEPT to close open captures */
 
   /* This is used to skip a subpattern with a {0} quantifier */
 
-  OP_SKIPZERO,       /* 114 */
+  OP_SKIPZERO,       /* 118 */
 
   /* This is not an opcode, but is used to check that tables indexed by opcode
   are the correct length, in order to catch updating errors - there have been
@@ -1403,7 +1424,7 @@ enum {
 
 /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro
 definitions that follow must also be updated to match. There are also tables
-called "coptable" cna "poptable" in pcre_dfa_exec.c that must be updated. */
+called "coptable" and "poptable" in pcre_dfa_exec.c that must be updated. */
 
 
 /* This macro defines textual names for all the opcodes. These are used only
@@ -1428,7 +1449,8 @@ for debugging. The macro is referenced only in pcre_printint.c. */
   "Once", "Bra", "CBra", "Cond", "SBra", "SCBra", "SCond",        \
   "Cond ref", "Cond nref", "Cond rec", "Cond nrec", "Cond def",   \
   "Brazero", "Braminzero",                                        \
-  "*PRUNE", "*SKIP", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT",      \
+  "*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP",                  \
+  "*THEN", "*THEN", "*COMMIT", "*FAIL", "*ACCEPT",                \
   "Close", "Skip zero"
 
 
@@ -1494,8 +1516,9 @@ in UTF-8 mode. The code that uses this table must know about such things. */
   3, 3,                          /* RREF, NRREF                            */ \
   1,                             /* DEF                                    */ \
   1, 1,                          /* BRAZERO, BRAMINZERO                    */ \
-  1, 1, 1, 1,                    /* PRUNE, SKIP, THEN, COMMIT,             */ \
-  1, 1, 3, 1                     /* FAIL, ACCEPT, CLOSE, SKIPZERO          */
+  3, 1, 3,                       /* MARK, PRUNE, PRUNE_ARG,                */ \
+  1, 3, 1, 3,                    /* SKIP, SKIP_ARG, THEN, THEN_ARG,        */ \
+  1, 1, 1, 3, 1                  /* COMMIT, FAIL, ACCEPT, CLOSE, SKIPZERO  */
 
 
 /* A magic value for OP_RREF and OP_NRREF to indicate the "any recursion"
@@ -1513,7 +1536,7 @@ enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,
        ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
        ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
        ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
-       ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERRCOUNT };
+       ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERRCOUNT };
 
 /* The real format of the start of the pcre block; the index of names and the
 code vector run on as long as necessary after the end. We store an explicit
@@ -1656,6 +1679,7 @@ typedef struct match_data {
   BOOL   noteol;                /* NOTEOL flag */
   BOOL   utf8;                  /* UTF8 flag */
   BOOL   jscript_compat;        /* JAVASCRIPT_COMPAT flag */
+  BOOL   use_ucp;               /* PCRE_UCP flag */
   BOOL   endonly;               /* Dollar not before final \n */
   BOOL   notempty;              /* Empty string match not wanted */
   BOOL   notempty_atstart;      /* Empty string match at start not wanted */
@@ -1675,6 +1699,7 @@ typedef struct match_data {
   int    eptrn;                 /* Next free eptrblock */
   recursion_info *recursive;    /* Linked list of recursion data */
   void  *callout_data;          /* To pass back to callouts */
+  const uschar *mark;           /* Mark pointer to pass back */
 } match_data;
 
 /* A similar structure is used for the same purpose by the DFA matching
diff --git a/ext/pcre/pcrelib/pcre_printint.src b/ext/pcre/pcrelib/pcre_printint.src
index 86b02b5..49d9317 100644
--- a/ext/pcre/pcrelib/pcre_printint.src
+++ b/ext/pcre/pcrelib/pcre_printint.src
@@ -534,6 +534,14 @@ for(;;)
       }
     break;
 
+    case OP_MARK:
+    case OP_PRUNE_ARG:
+    case OP_SKIP_ARG:
+    case OP_THEN_ARG:
+    fprintf(f, "    %s %s", OP_names[*code], code + 2);
+    extra += code[1];
+    break;
+
     /* Anything else is just an item with no data*/
 
     default:
diff --git a/ext/pcre/pcrelib/pcre_study.c b/ext/pcre/pcrelib/pcre_study.c
index 2653624..3ac7e81 100644
--- a/ext/pcre/pcrelib/pcre_study.c
+++ b/ext/pcre/pcrelib/pcre_study.c
@@ -46,6 +46,7 @@ supporting functions. */
 
 #include "pcre_internal.h"
 
+#define SET_BIT(c) start_bits[c/8] |= (1 << (c&7))
 
 /* Returns from set_start_bits() */
 
@@ -411,6 +412,15 @@ for (;;)
 #endif
     break;
 
+    /* Skip these, but we need to add in the name length. */
+
+    case OP_MARK:
+    case OP_PRUNE_ARG:
+    case OP_SKIP_ARG:
+    case OP_THEN_ARG:
+    cc += _pcre_OP_lengths[op] + cc[1];
+    break;
+
     /* For the record, these are the opcodes that are matched by "default":
     OP_ACCEPT, OP_CLOSE, OP_COMMIT, OP_FAIL, OP_PRUNE, OP_SET_SOM, OP_SKIP,
     OP_THEN. */
@@ -429,25 +439,121 @@ for (;;)
 *      Set a bit and maybe its alternate case    *
 *************************************************/
 
-/* Given a character, set its bit in the table, and also the bit for the other
-version of a letter if we are caseless.
+/* Given a character, set its first byte's bit in the table, and also the
+corresponding bit for the other version of a letter if we are caseless. In
+UTF-8 mode, for characters greater than 127, we can only do the caseless thing
+when Unicode property support is available.
 
 Arguments:
   start_bits    points to the bit map
-  c             is the character
+  p             points to the character
   caseless      the caseless flag
   cd            the block with char table pointers
+  utf8          TRUE for UTF-8 mode
+
+Returns:        pointer after the character
+*/
+
+static const uschar *
+set_table_bit(uschar *start_bits, const uschar *p, BOOL caseless,
+  compile_data *cd, BOOL utf8)
+{
+unsigned int c = *p;
+
+SET_BIT(c);
+
+#ifdef SUPPORT_UTF8
+if (utf8 && c > 127)
+  {
+  GETCHARINC(c, p);
+#ifdef SUPPORT_UCP
+  if (caseless)
+    {
+    uschar buff[8];
+    c = UCD_OTHERCASE(c);
+    (void)_pcre_ord2utf8(c, buff);
+    SET_BIT(buff[0]);
+    }
+#endif
+  return p;
+  }
+#endif
+
+/* Not UTF-8 mode, or character is less than 127. */
+
+if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
+return p + 1;
+}
+
+
 
-Returns:        nothing
+/*************************************************
+*     Set bits for a positive character type     *
+*************************************************/
+
+/* This function sets starting bits for a character type. In UTF-8 mode, we can
+only do a direct setting for bytes less than 128, as otherwise there can be
+confusion with bytes in the middle of UTF-8 characters. In a "traditional"
+environment, the tables will only recognize ASCII characters anyway, but in at
+least one Windows environment, some higher bytes bits were set in the tables.
+So we deal with that case by considering the UTF-8 encoding.
+
+Arguments:
+  start_bits     the starting bitmap
+  cbit type      the type of character wanted
+  table_limit    32 for non-UTF-8; 16 for UTF-8
+  cd             the block with char table pointers
+
+Returns:         nothing
 */
 
 static void
-set_table_bit(uschar *start_bits, unsigned int c, BOOL caseless,
+set_type_bits(uschar *start_bits, int cbit_type, int table_limit,
   compile_data *cd)
 {
-start_bits[c/8] |= (1 << (c&7));
-if (caseless && (cd->ctypes[c] & ctype_letter) != 0)
-  start_bits[cd->fcc[c]/8] |= (1 << (cd->fcc[c]&7));
+register int c;
+for (c = 0; c < table_limit; c++) start_bits[c] |= cd->cbits[c+cbit_type];
+if (table_limit == 32) return;
+for (c = 128; c < 256; c++)
+  {
+  if ((cd->cbits[c/8] & (1 << (c&7))) != 0)
+    {
+    uschar buff[8];
+    (void)_pcre_ord2utf8(c, buff);
+    SET_BIT(buff[0]);
+    }
+  }
+}
+
+
+/*************************************************
+*     Set bits for a negative character type     *
+*************************************************/
+
+/* This function sets starting bits for a negative character type such as \D.
+In UTF-8 mode, we can only do a direct setting for bytes less than 128, as
+otherwise there can be confusion with bytes in the middle of UTF-8 characters.
+Unlike in the positive case, where we can set appropriate starting bits for
+specific high-valued UTF-8 characters, in this case we have to set the bits for
+all high-valued characters. The lowest is 0xc2, but we overkill by starting at
+0xc0 (192) for simplicity.
+
+Arguments:
+  start_bits     the starting bitmap
+  cbit type      the type of character wanted
+  table_limit    32 for non-UTF-8; 16 for UTF-8
+  cd             the block with char table pointers
+
+Returns:         nothing
+*/
+
+static void
+set_nottype_bits(uschar *start_bits, int cbit_type, int table_limit,
+  compile_data *cd)
+{
+register int c;
+for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->cbits[c+cbit_type];
+if (table_limit != 32) for (c = 24; c < 32; c++) start_bits[c] = 0xff;
 }
 
 
@@ -482,6 +588,7 @@ set_start_bits(const uschar *code, uschar *start_bits, BOOL caseless,
 {
 register int c;
 int yield = SSB_DONE;
+int table_limit = utf8? 16:32;
 
 #if 0
 /* ========================================================================= */
@@ -605,12 +712,7 @@ do
       case OP_QUERY:
       case OP_MINQUERY:
       case OP_POSQUERY:
-      set_table_bit(start_bits, tcode[1], caseless, cd);
-      tcode += 2;
-#ifdef SUPPORT_UTF8
-      if (utf8 && tcode[-1] >= 0xc0)
-        tcode += _pcre_utf8_table4[tcode[-1] & 0x3f];
-#endif
+      tcode = set_table_bit(start_bits, tcode + 1, caseless, cd, utf8);
       break;
 
       /* Single-char upto sets the bit and tries the next */
@@ -618,12 +720,7 @@ do
       case OP_UPTO:
       case OP_MINUPTO:
       case OP_POSUPTO:
-      set_table_bit(start_bits, tcode[3], caseless, cd);
-      tcode += 4;
-#ifdef SUPPORT_UTF8
-      if (utf8 && tcode[-1] >= 0xc0)
-        tcode += _pcre_utf8_table4[tcode[-1] & 0x3f];
-#endif
+      tcode = set_table_bit(start_bits, tcode + 3, caseless, cd, utf8);
       break;
 
       /* At least one single char sets the bit and stops */
@@ -636,59 +733,86 @@ do
       case OP_PLUS:
       case OP_MINPLUS:
       case OP_POSPLUS:
-      set_table_bit(start_bits, tcode[1], caseless, cd);
+      (void)set_table_bit(start_bits, tcode + 1, caseless, cd, utf8);
       try_next = FALSE;
       break;
 
-      /* Single character type sets the bits and stops */
+      /* Special spacing and line-terminating items. These recognize specific
+      lists of characters. The difference between VSPACE and ANYNL is that the
+      latter can match the two-character CRLF sequence, but that is not
+      relevant for finding the first character, so their code here is
+      identical. */
+
+      case OP_HSPACE:
+      SET_BIT(0x09);
+      SET_BIT(0x20);
+      if (utf8)
+        {
+        SET_BIT(0xC2);  /* For U+00A0 */
+        SET_BIT(0xE1);  /* For U+1680, U+180E */
+        SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
+        SET_BIT(0xE3);  /* For U+3000 */
+        }
+      else SET_BIT(0xA0);
+      try_next = FALSE;
+      break;
+
+      case OP_ANYNL:
+      case OP_VSPACE:
+      SET_BIT(0x0A);
+      SET_BIT(0x0B);
+      SET_BIT(0x0C);
+      SET_BIT(0x0D);
+      if (utf8)
+        {
+        SET_BIT(0xC2);  /* For U+0085 */
+        SET_BIT(0xE2);  /* For U+2028, U+2029 */
+        }
+      else SET_BIT(0x85);
+      try_next = FALSE;
+      break;
+
+      /* Single character types set the bits and stop. Note that if PCRE_UCP
+      is set, we do not see these op codes because \d etc are converted to
+      properties. Therefore, these apply in the case when only characters less
+      than 256 are recognized to match the types. */
 
       case OP_NOT_DIGIT:
-      for (c = 0; c < 32; c++)
-        start_bits[c] |= ~cd->cbits[c+cbit_digit];
+      set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
       try_next = FALSE;
       break;
 
       case OP_DIGIT:
-      for (c = 0; c < 32; c++)
-        start_bits[c] |= cd->cbits[c+cbit_digit];
+      set_type_bits(start_bits, cbit_digit, table_limit, cd);
       try_next = FALSE;
       break;
 
       /* The cbit_space table has vertical tab as whitespace; we have to
-      discard it. */
+      ensure it is set as not whitespace. */
 
       case OP_NOT_WHITESPACE:
-      for (c = 0; c < 32; c++)
-        {
-        int d = cd->cbits[c+cbit_space];
-        if (c == 1) d &= ~0x08;
-        start_bits[c] |= ~d;
-        }
+      set_nottype_bits(start_bits, cbit_space, table_limit, cd);
+      start_bits[1] |= 0x08;
       try_next = FALSE;
       break;
 
       /* The cbit_space table has vertical tab as whitespace; we have to
-      discard it. */
+      not set it from the table. */
 
       case OP_WHITESPACE:
-      for (c = 0; c < 32; c++)
-        {
-        int d = cd->cbits[c+cbit_space];
-        if (c == 1) d &= ~0x08;
-        start_bits[c] |= d;
-        }
+      c = start_bits[1];    /* Save in case it was already set */
+      set_type_bits(start_bits, cbit_space, table_limit, cd);
+      start_bits[1] = (start_bits[1] & ~0x08) | c;
       try_next = FALSE;
       break;
 
       case OP_NOT_WORDCHAR:
-      for (c = 0; c < 32; c++)
-        start_bits[c] |= ~cd->cbits[c+cbit_word];
+      set_nottype_bits(start_bits, cbit_word, table_limit, cd);
       try_next = FALSE;
       break;
 
       case OP_WORDCHAR:
-      for (c = 0; c < 32; c++)
-        start_bits[c] |= cd->cbits[c+cbit_word];
+      set_type_bits(start_bits, cbit_word, table_limit, cd);
       try_next = FALSE;
       break;
 
@@ -697,6 +821,7 @@ do
 
       case OP_TYPEPLUS:
       case OP_TYPEMINPLUS:
+      case OP_TYPEPOSPLUS:
       tcode++;
       break;
 
@@ -720,52 +845,69 @@ do
       case OP_TYPEPOSQUERY:
       switch(tcode[1])
         {
+        default:
         case OP_ANY:
         case OP_ALLANY:
         return SSB_FAIL;
 
+        case OP_HSPACE:
+        SET_BIT(0x09);
+        SET_BIT(0x20);
+        if (utf8)
+          {
+          SET_BIT(0xC2);  /* For U+00A0 */
+          SET_BIT(0xE1);  /* For U+1680, U+180E */
+          SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
+          SET_BIT(0xE3);  /* For U+3000 */
+          }
+        else SET_BIT(0xA0);
+        break;
+
+        case OP_ANYNL:
+        case OP_VSPACE:
+        SET_BIT(0x0A);
+        SET_BIT(0x0B);
+        SET_BIT(0x0C);
+        SET_BIT(0x0D);
+        if (utf8)
+          {
+          SET_BIT(0xC2);  /* For U+0085 */
+          SET_BIT(0xE2);  /* For U+2028, U+2029 */
+          }
+        else SET_BIT(0x85);
+        break;
+
         case OP_NOT_DIGIT:
-        for (c = 0; c < 32; c++)
-          start_bits[c] |= ~cd->cbits[c+cbit_digit];
+        set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
         break;
 
         case OP_DIGIT:
-        for (c = 0; c < 32; c++)
-          start_bits[c] |= cd->cbits[c+cbit_digit];
+        set_type_bits(start_bits, cbit_digit, table_limit, cd);
         break;
 
         /* The cbit_space table has vertical tab as whitespace; we have to
-        discard it. */
+        ensure it gets set as not whitespace. */
 
         case OP_NOT_WHITESPACE:
-        for (c = 0; c < 32; c++)
-          {
-          int d = cd->cbits[c+cbit_space];
-          if (c == 1) d &= ~0x08;
-          start_bits[c] |= ~d;
-          }
+        set_nottype_bits(start_bits, cbit_space, table_limit, cd);
+        start_bits[1] |= 0x08;
         break;
 
         /* The cbit_space table has vertical tab as whitespace; we have to
-        discard it. */
+        avoid setting it. */
 
         case OP_WHITESPACE:
-        for (c = 0; c < 32; c++)
-          {
-          int d = cd->cbits[c+cbit_space];
-          if (c == 1) d &= ~0x08;
-          start_bits[c] |= d;
-          }
+        c = start_bits[1];    /* Save in case it was already set */
+        set_type_bits(start_bits, cbit_space, table_limit, cd);
+        start_bits[1] = (start_bits[1] & ~0x08) | c;
         break;
 
         case OP_NOT_WORDCHAR:
-        for (c = 0; c < 32; c++)
-          start_bits[c] |= ~cd->cbits[c+cbit_word];
+        set_nottype_bits(start_bits, cbit_word, table_limit, cd);
         break;
 
         case OP_WORDCHAR:
-        for (c = 0; c < 32; c++)
-          start_bits[c] |= cd->cbits[c+cbit_word];
+        set_type_bits(start_bits, cbit_word, table_limit, cd);
         break;
         }
 
diff --git a/ext/pcre/pcrelib/pcre_tables.c b/ext/pcre/pcrelib/pcre_tables.c
index fbccd56..4dfcbc6 100644
--- a/ext/pcre/pcrelib/pcre_tables.c
+++ b/ext/pcre/pcrelib/pcre_tables.c
@@ -241,6 +241,10 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */
 #define STRING_Tifinagh0 STR_T STR_i STR_f STR_i STR_n STR_a STR_g STR_h "\0"
 #define STRING_Ugaritic0 STR_U STR_g STR_a STR_r STR_i STR_t STR_i STR_c "\0"
 #define STRING_Vai0 STR_V STR_a STR_i "\0"
+#define STRING_Xan0 STR_X STR_a STR_n "\0"
+#define STRING_Xps0 STR_X STR_p STR_s "\0"
+#define STRING_Xsp0 STR_X STR_s STR_p "\0"
+#define STRING_Xwd0 STR_X STR_w STR_d "\0"
 #define STRING_Yi0 STR_Y STR_i "\0"
 #define STRING_Z0 STR_Z "\0"
 #define STRING_Zl0 STR_Z STR_l "\0"
@@ -374,6 +378,10 @@ const char _pcre_utt_names[] =
   STRING_Tifinagh0
   STRING_Ugaritic0
   STRING_Vai0
+  STRING_Xan0
+  STRING_Xps0
+  STRING_Xsp0
+  STRING_Xwd0
   STRING_Yi0
   STRING_Z0
   STRING_Zl0
@@ -507,11 +515,15 @@ const ucp_type_table _pcre_utt[] = {
   { 891, PT_SC, ucp_Tifinagh },
   { 900, PT_SC, ucp_Ugaritic },
   { 909, PT_SC, ucp_Vai },
-  { 913, PT_SC, ucp_Yi },
-  { 916, PT_GC, ucp_Z },
-  { 918, PT_PC, ucp_Zl },
-  { 921, PT_PC, ucp_Zp },
-  { 924, PT_PC, ucp_Zs }
+  { 913, PT_ALNUM, 0 },
+  { 917, PT_PXSPACE, 0 },
+  { 921, PT_SPACE, 0 },
+  { 925, PT_WORD, 0 },
+  { 929, PT_SC, ucp_Yi },
+  { 932, PT_GC, ucp_Z },
+  { 934, PT_PC, ucp_Zl },
+  { 937, PT_PC, ucp_Zp },
+  { 940, PT_PC, ucp_Zs }
 };
 
 const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
diff --git a/ext/pcre/pcrelib/pcre_xclass.c b/ext/pcre/pcrelib/pcre_xclass.c
index 3fc3ba3..98841c5 100644
--- a/ext/pcre/pcrelib/pcre_xclass.c
+++ b/ext/pcre/pcrelib/pcre_xclass.c
@@ -6,7 +6,7 @@
 and semantics are as close as possible to those of the Perl 5 language.
 
                        Written by Philip Hazel
-           Copyright (c) 1997-2009 University of Cambridge
+           Copyright (c) 1997-2010 University of Cambridge
 
 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -110,12 +110,13 @@ while ((t = *data++) != XCL_END)
       break;
 
       case PT_LAMP:
-      if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll || prop->chartype == ucp_Lt) ==
-          (t == XCL_PROP)) return !negated;
+      if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
+           prop->chartype == ucp_Lt) == (t == XCL_PROP)) return !negated;
       break;
 
       case PT_GC:
-      if ((data[1] == _pcre_ucp_gentype[prop->chartype]) == (t == XCL_PROP)) return !negated;
+      if ((data[1] == _pcre_ucp_gentype[prop->chartype]) == (t == XCL_PROP))
+        return !negated;
       break;
 
       case PT_PC:
@@ -126,6 +127,33 @@ while ((t = *data++) != XCL_END)
       if ((data[1] == prop->script) == (t == XCL_PROP)) return !negated;
       break;
 
+      case PT_ALNUM:
+      if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+           _pcre_ucp_gentype[prop->chartype] == ucp_N) == (t == XCL_PROP))
+        return !negated;
+      break;
+
+      case PT_SPACE:    /* Perl space */
+      if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+           c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
+             == (t == XCL_PROP))
+        return !negated;
+      break;
+
+      case PT_PXSPACE:  /* POSIX space */
+      if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
+           c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
+           c == CHAR_FF || c == CHAR_CR) == (t == XCL_PROP))
+        return !negated;
+      break;
+
+      case PT_WORD:
+      if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
+           _pcre_ucp_gentype[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE)
+             == (t == XCL_PROP))
+        return !negated;
+      break;
+
       /* This should never occur, but compilers may mutter if there is no
       default. */
 
diff --git a/ext/pcre/pcrelib/pcreposix.c b/ext/pcre/pcrelib/pcreposix.c
index bae2054..29d8446 100644
--- a/ext/pcre/pcrelib/pcreposix.c
+++ b/ext/pcre/pcrelib/pcreposix.c
@@ -6,7 +6,7 @@
 and semantics are as close as possible to those of the Perl 5 language.
 
                        Written by Philip Hazel
-           Copyright (c) 1997-2009 University of Cambridge
+           Copyright (c) 1997-2010 University of Cambridge
 
 -----------------------------------------------------------------------------
 Redistribution and use in source and binary forms, with or without
@@ -55,6 +55,11 @@ previously been set. */
 #  define PCREPOSIX_EXP_DEFN __declspec(dllexport)
 #endif
 
+/* We include pcre.h before pcre_internal.h so that the PCRE library functions
+are declared as "import" for Windows by defining PCRE_EXP_DECL as "import".
+This is needed even though pcre_internal.h itself includes pcre.h, because it
+does so after it has set PCRE_EXP_DECL to "export" if it is not already set. */
+
 #include "pcre.h"
 #include "pcre_internal.h"
 #include "pcreposix.h"
@@ -133,7 +138,7 @@ static const int eint[] = {
   REG_INVARG,  /* inconsistent NEWLINE options */
   REG_BADPAT,  /* \g is not followed followed by an (optionally braced) non-zero number */
   REG_BADPAT,  /* a numbered reference must not be zero */
-  REG_BADPAT,  /* (*VERB) with an argument is not supported */
+  REG_BADPAT,  /* an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT) */
   /* 60 */
   REG_BADPAT,  /* (*VERB) not recognized */
   REG_BADPAT,  /* number is too big */
@@ -141,7 +146,9 @@ static const int eint[] = {
   REG_BADPAT,  /* digit expected after (?+ */
   REG_BADPAT,  /* ] is an invalid data character in JavaScript compatibility mode */
   /* 65 */
-  REG_BADPAT   /* different names for subpatterns of the same number are not allowed */
+  REG_BADPAT,  /* different names for subpatterns of the same number are not allowed */
+  REG_BADPAT,  /* (*MARK) must have an argument */
+  REG_INVARG,  /* this version of PCRE is not compiled with PCRE_UCP support */
 };
 
 /* Table of texts corresponding to POSIX error codes */
@@ -245,6 +252,7 @@ if ((cflags & REG_NEWLINE) != 0)  options |= PCRE_MULTILINE;
 if ((cflags & REG_DOTALL) != 0)   options |= PCRE_DOTALL;
 if ((cflags & REG_NOSUB) != 0)    options |= PCRE_NO_AUTO_CAPTURE;
 if ((cflags & REG_UTF8) != 0)     options |= PCRE_UTF8;
+if ((cflags & REG_UCP) != 0)      options |= PCRE_UCP;
 if ((cflags & REG_UNGREEDY) != 0) options |= PCRE_UNGREEDY;
 
 preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
@@ -334,13 +342,13 @@ if ((eflags & REG_STARTEND) != 0)
 else
   {
   so = 0;
-  eo = strlen(string);
+  eo = (int)strlen(string);
   }
 
 rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),
-  0, options, ovector, nmatch * 3);
+  0, options, ovector, (int)(nmatch * 3));
 
-if (rc == 0) rc = nmatch;    /* All captured slots were filled in */
+if (rc == 0) rc = (int)nmatch;    /* All captured slots were filled in */
 
 /* Successful match */
 
diff --git a/ext/pcre/pcrelib/pcreposix.h b/ext/pcre/pcrelib/pcreposix.h
index 8ad58f5..b90e2ec 100644
--- a/ext/pcre/pcrelib/pcreposix.h
+++ b/ext/pcre/pcrelib/pcreposix.h
@@ -62,6 +62,7 @@ extern "C" {
 #define REG_STARTEND  0x0080   /* BSD feature: pass subject string by so,eo */
 #define REG_NOTEMPTY  0x0100   /* NOT defined by POSIX; maps to PCRE_NOTEMPTY */
 #define REG_UNGREEDY  0x0200   /* NOT defined by POSIX; maps to PCRE_UNGREEDY */
+#define REG_UCP       0x0400   /* NOT defined by POSIX; maps to PCRE_UCP */
 
 /* This is not used by PCRE, but by defining it we make it easier
 to slot PCRE into existing programs that make POSIX calls. */
diff --git a/ext/pcre/pcrelib/testdata/testinput10 b/ext/pcre/pcrelib/testdata/testinput10
index 420c274..99afab8 100644
--- a/ext/pcre/pcrelib/testdata/testinput10
+++ b/ext/pcre/pcrelib/testdata/testinput10
@@ -1,7 +1,8 @@
 /-- These are a few representative patterns whose lengths and offsets are to be 
 shown when the link size is 2. This is just a doublecheck test to ensure the 
 sizes don't go horribly wrong when something is changed. The pattern contents 
-are all themselves checked in other tests. --/
+are all themselves checked in other tests. Unicode, including property support, 
+is required for these tests. --/
 
 /((?i)b)/BM
 
@@ -121,4 +122,14 @@ are all themselves checked in other tests. --/
 
 /[^\xaa]/8BM
 
+/[^\d]/8WB
+
+/[[:^alpha:][:^cntrl:]]+/8WB
+
+/[[:^cntrl:][:^alpha:]]+/8WB
+
+/[[:alpha:]]+/8WB
+
+/[[:^alpha:]\S]+/8WB
+
 /-- End of testinput10 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput2 b/ext/pcre/pcrelib/testdata/testinput2
index 94a18c9..cc94bed 100644
--- a/ext/pcre/pcrelib/testdata/testinput2
+++ b/ext/pcre/pcrelib/testdata/testinput2
@@ -2,12 +2,12 @@
     of PCRE's API, error diagnostics, and the compiled code of some patterns.
     It also checks the non-Perl syntax the PCRE supports (Python, .NET, 
     Oniguruma). Finally, there are some tests where PCRE and Perl differ, 
-    either because PCRE can't be compatible, or there is potential Perl 
+    either because PCRE can't be compatible, or there is a possible Perl 
     bug. --/  
   
-/-- Originally, the Perl 5.10 things were in here too, but now I have separated
-    many (most?) of them out into test 11. However, there may still be some
-    that were overlooked. --/   
+/-- Originally, the Perl 5.10 and 5.11 things were in here too, but now I have 
+    separated many (most?) of them out into test 11. However, there may still 
+    be some that were overlooked. --/   
 
 /(a)b|/I
 
@@ -51,6 +51,16 @@
 
 /(?X)[\B]/
 
+/(?X)[\R]/
+
+/(?X)[\X]/
+
+/[\B]/BZ
+
+/[\R]/BZ
+
+/[\X]/BZ
+
 /[z-a]/
 
 /^*/
@@ -2279,8 +2289,6 @@ a random value. /Ix
 /a+b?(*THEN)c+(*FAIL)/C
     aaabccc
     
-/a(*PRUNE:XXX)b/
-
 /a(*MARK)b/ 
 
 /(?i:A{1,}\6666666666)/
@@ -3232,4 +3240,255 @@ a random value. /Ix
 
 /(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
 
+/abc(*MARK:)pqr/
+
+/abc(*:)pqr/
+
+/abc(*FAIL:123)xyz/
+
+/--- This should, and does, fail. In Perl, it does not, which I think is a 
+     bug because replacing the B in the pattern by (B|D) does make it fail. ---/
+
+/A(*COMMIT)B/+K
+    ACABX
+
+/--- These should be different, but in Perl 5.11 are not, which I think
+     is a bug in Perl. ---/
+
+/A(*THEN)B|A(*THEN)C/K
+    AC
+
+/A(*PRUNE)B|A(*PRUNE)C/K
+    AC
+    
+/--- A whole lot of tests of verbs with arguments are here rather than in test
+     11 because Perl doesn't seem to follow its specification entirely 
+     correctly. ---/
+
+/--- Perl 5.11 sets $REGERROR on the AC failure case here; PCRE does not. It is
+     not clear how Perl defines "involved in the failure of the match". ---/ 
+
+/^(A(*THEN:A)B|C(*THEN:B)D)/K
+    AB
+    CD
+    ** Failers
+    AC
+    CB    
+    
+/--- Check the use of names for success and failure. PCRE doesn't show these 
+names for success, though Perl does, contrary to its spec. ---/
+
+/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/K
+    AB
+    CD
+    ** Failers
+    AC
+    CB    
+    
+/--- An empty name does not pass back an empty string. It is the same as if no
+name were given. ---/ 
+
+/^(A(*PRUNE:)B|C(*PRUNE:B)D)/K
+    AB
+    CD 
+
+/--- PRUNE goes to next bumpalong; COMMIT does not. ---/
+    
+/A(*PRUNE:A)B/K
+    ACAB
+
+/(*MARK:A)(*PRUNE:B)(C|X)/K
+    C
+    D 
+
+/(*MARK:A)(*THEN:B)(C|X)/K
+    C
+    D 
+
+/--- This should fail, as the skip causes a bump to offset 3 (the skip) ---/
+
+/A(*MARK:A)A+(*SKIP)(B|Z) | AC/xK
+    AAAC
+
+/--- Same --/
+
+/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/xK
+    AAAC
+
+/--- This should fail; the SKIP advances by one, but when we get to AC, the
+     PRUNE kills it. ---/ 
+    
+/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/xK
+    AAAC
+
+/A(*:A)A+(*SKIP)(B|Z) | AC/xK
+    AAAC
+
+/--- This should fail, as a null name is the same as no name ---/
+
+/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/xK
+    AAAC
+
+/--- This fails in PCRE, and I think that is in accordance with Perl's 
+     documentation, though in Perl it succeeds. ---/
+    
+/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/xK
+    AAAC
+
+/--- Mark names can be duplicated ---/
+
+/A(*:A)B|X(*:A)Y/K
+    AABC
+    XXYZ 
+    
+/^A(*:A)B|^X(*:A)Y/K
+    ** Failers
+    XAQQ
+    
+/--- A check on what happens after hitting a mark and them bumping along to
+something that does not even start. Perl reports tags after the failures here, 
+though it does not when the individual letters are made into something 
+more complicated. ---/
+
+/A(*:A)B|XX(*:B)Y/K
+    AABC
+    XXYZ 
+    ** Failers
+    XAQQ  
+    XAQQXZZ  
+    AXQQQ 
+    AXXQQQ 
+    
+/--- COMMIT at the start of a pattern should be the same as an anchor. Perl 
+optimizations defeat this. So does the PCRE optimization unless we disable it 
+with \Y. ---/
+
+/(*COMMIT)ABC/
+    ABCDEFG
+    ** Failers
+    DEFGABC\Y  
+    
+/--- Repeat some tests with added studying. ---/
+
+/A(*COMMIT)B/+KS
+    ACABX
+ 
+/A(*THEN)B|A(*THEN)C/KS
+    AC
+
+/A(*PRUNE)B|A(*PRUNE)C/KS
+    AC
+
+/^(A(*THEN:A)B|C(*THEN:B)D)/KS
+    AB
+    CD
+    ** Failers
+    AC
+    CB    
+
+/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/KS
+    AB
+    CD
+    ** Failers
+    AC
+    CB    
+
+/^(A(*PRUNE:)B|C(*PRUNE:B)D)/KS
+    AB
+    CD 
+
+/A(*PRUNE:A)B/KS
+    ACAB
+
+/(*MARK:A)(*PRUNE:B)(C|X)/KS
+    C
+    D 
+
+/(*MARK:A)(*THEN:B)(C|X)/KS
+    C
+    D 
+
+/A(*MARK:A)A+(*SKIP)(B|Z) | AC/xKS
+    AAAC
+
+/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/xKS
+    AAAC
+    
+/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/xKS
+    AAAC
+
+/A(*:A)A+(*SKIP)(B|Z) | AC/xKS
+    AAAC
+
+/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/xKS
+    AAAC
+
+/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/xKS
+    AAAC
+
+/A(*:A)B|XX(*:B)Y/KS
+    AABC
+    XXYZ 
+    ** Failers
+    XAQQ  
+    XAQQXZZ  
+    AXQQQ 
+    AXXQQQ 
+    
+/(*COMMIT)ABC/
+    ABCDEFG
+    ** Failers
+    DEFGABC\Y  
+
+/^(ab (c+(*THEN)cd) | xyz)/x
+    abcccd  
+
+/^(ab (c+(*PRUNE)cd) | xyz)/x
+    abcccd  
+
+/^(ab (c+(*FAIL)cd) | xyz)/x
+    abcccd  
+    
+/--- Perl 5.11 gets some of these wrong ---/ 
+
+/(?>.(*ACCEPT))*?5/
+    abcde
+
+/(.(*ACCEPT))*?5/
+    abcde
+
+/(.(*ACCEPT))5/
+    abcde
+
+/(.(*ACCEPT))*5/
+    abcde
+
+/A\NB./BZ
+  ACBD
+  ** Failers
+  A\nB
+  ACB\n   
+
+/A\NB./sBZ
+  ACBD
+  ACB\n 
+  ** Failers
+  A\nB  
+  
+/A\NB/<crlf>
+  A\nB
+  A\rB
+  ** Failers
+  A\r\nB    
+
+/\R+b/BZ
+
+/\R+\n/BZ
+
+/\R+\d/BZ
+
+/\d*\R/BZ
+
+/\s*\R/BZ
+
 /-- End of testinput2 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput5 b/ext/pcre/pcrelib/testdata/testinput5
index 68795e6..5e200b3 100644
--- a/ext/pcre/pcrelib/testdata/testinput5
+++ b/ext/pcre/pcrelib/testdata/testinput5
@@ -745,4 +745,53 @@ can't tell the difference.) --/
 /X\W{3}X/8
     \PX
 
+/\h/SI
+
+/\h/SI8
+    ABC\x{09}
+    ABC\x{20}
+    ABC\x{a0}
+    ABC\x{1680}
+    ABC\x{180e}
+    ABC\x{2000}
+    ABC\x{202f} 
+    ABC\x{205f} 
+    ABC\x{3000} 
+
+/\v/SI
+
+/\v/SI8
+    ABC\x{0a}
+    ABC\x{0b}
+    ABC\x{0c}
+    ABC\x{0d}
+    ABC\x{85}
+    ABC\x{2028}
+
+/\R/SI
+
+/\R/SI8
+
+/\h*A/SI8
+    CDBABC
+    
+/\v+A/SI8
+
+/\s?xxx\s/8SI
+
+/\sxxx\s/8T1
+    AB\x{85}xxx\x{a0}XYZ
+    AB\x{a0}xxx\x{85}XYZ
+
+/\sxxx\s/I8ST1
+    AB\x{85}xxx\x{a0}XYZ
+    AB\x{a0}xxx\x{85}XYZ
+
+/\S \S/8T1
+    \x{a2} \x{84} 
+
+/\S \S/I8ST1
+    \x{a2} \x{84} 
+    A Z 
+
 /-- End of testinput5 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput6 b/ext/pcre/pcrelib/testdata/testinput6
index 759018a..e923e00 100644
--- a/ext/pcre/pcrelib/testdata/testinput6
+++ b/ext/pcre/pcrelib/testdata/testinput6
@@ -752,4 +752,54 @@
 /\p{Avestan}\p{Bamum}\p{Egyptian_Hieroglyphs}\p{Imperial_Aramaic}\p{Inscriptional_Pahlavi}\p{Inscriptional_Parthian}\p{Javanese}\p{Kaithi}\p{Lisu}\p{Meetei_Mayek}\p{Old_South_Arabian}\p{Old_Turkic}\p{Samaritan}\p{Tai_Tham}\p{Tai_Viet}/8
     \x{10b00}\x{a6ef}\x{13007}\x{10857}\x{10b78}\x{10b58}\x{a980}\x{110c1}\x{a4ff}\x{abc0}\x{10a7d}\x{10c48}\x{0800}\x{1aad}\x{aac0}
 
+/^\w+/8W
+    Az_\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+
+/^[[:xdigit:]]*/8W
+    1a\x{660}\x{bef}\x{16ee}
+  
+/^\d+/8W
+    1\x{660}\x{bef}\x{16ee}
+  
+/^[[:digit:]]+/8W
+    1\x{660}\x{bef}\x{16ee}
+
+/^>\s+/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+  
+/^>\pZ+/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+  
+/^>[[:space:]]*/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+
+/^>[[:blank:]]*/8W
+    >\x{20}\x{a0}\x{1680}\x{180e}\x{2000}\x{202f}\x{9}\x{b}\x{2028} 
+
+/^[[:alpha:]]*/8W
+    Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}
+
+/^[[:alnum:]]*/8W
+    Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+
+/^[[:cntrl:]]*/8W
+    \x{0}\x{09}\x{1f}\x{7f}\x{9f} 
+
+/^[[:graph:]]*/8W
+    A\x{a1}\x{a0}
+
+/^[[:print:]]*/8W
+    A z\x{a0}\x{a1}
+
+/^[[:punct:]]*/8W
+    .+\x{a1}\x{a0}
+
+/\p{Zs}*?\R/
+    ** Failers
+    a\xFCb   
+
+/\p{Zs}*\R/                                                                    
+    ** Failers 
+    a\xFCb   
+
 /-- End of testinput6 --/
diff --git a/ext/pcre/pcrelib/testdata/testinput9 b/ext/pcre/pcrelib/testdata/testinput9
index 590420c..8d312e0 100644
--- a/ext/pcre/pcrelib/testdata/testinput9
+++ b/ext/pcre/pcrelib/testdata/testinput9
@@ -847,4 +847,143 @@
     ** Failers 
     \x{1d79}\x{a77d} 
 
+/^\p{Xan}/8
+    ABCD
+    1234
+    \x{6ca}
+    \x{a6c}
+    \x{10a7}   
+    ** Failers
+    _ABC   
+
+/^\p{Xan}+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+    ** Failers
+    _ABC   
+
+/^\p{Xan}*/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+    
+/^\p{Xan}{2,9}/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+    
+/^[\p{Xan}]/8
+    ABCD1234_
+    1234abcd_
+    \x{6ca}
+    \x{a6c}
+    \x{10a7}   
+    ** Failers
+    _ABC   
+ 
+/^[\p{Xan}]+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+    ** Failers
+    _ABC   
+
+/^>\p{Xsp}/8
+    >\x{1680}\x{2028}\x{0b}
+    ** Failers
+    \x{0b} 
+
+/^>\p{Xsp}+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+
+/^>\p{Xsp}*/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+    
+/^>\p{Xsp}{2,9}/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+    
+/^>[\p{Xsp}]/8
+    >\x{2028}\x{0b}
+ 
+/^>[\p{Xsp}]+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+
+/^>\p{Xps}/8
+    >\x{1680}\x{2028}\x{0b}
+    >\x{a0} 
+    ** Failers
+    \x{0b} 
+
+/^>\p{Xps}+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+
+/^>\p{Xps}+?/8
+    >\x{1680}\x{2028}\x{0b}
+
+/^>\p{Xps}*/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+    
+/^>\p{Xps}{2,9}/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+    
+/^>\p{Xps}{2,9}?/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+    
+/^>[\p{Xps}]/8
+    >\x{2028}\x{0b}
+ 
+/^>[\p{Xps}]+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+
+/^\p{Xwd}/8
+    ABCD
+    1234
+    \x{6ca}
+    \x{a6c}
+    \x{10a7}
+    _ABC    
+    ** Failers
+    [] 
+
+/^\p{Xwd}+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+
+/^\p{Xwd}*/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+    
+/^\p{Xwd}{2,9}/8
+    A_12\x{6ca}\x{a6c}\x{10a7}
+    
+/^[\p{Xwd}]/8
+    ABCD1234_
+    1234abcd_
+    \x{6ca}
+    \x{a6c}
+    \x{10a7}   
+    _ABC 
+    ** Failers
+    []   
+ 
+/^[\p{Xwd}]+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+
+/-- Unicode properties for \b abd \B --/
+
+/\b...\B/8W
+    abc_
+    \x{37e}abc\x{376} 
+    \x{37e}\x{376}\x{371}\x{393}\x{394} 
+    !\x{c0}++\x{c1}\x{c2} 
+    !\x{c0}+++++ 
+
+/-- Without PCRE_UCP, non-ASCII always fail, even if < 256  --/
+
+/\b...\B/8
+    abc_
+    ** Failers 
+    \x{37e}abc\x{376} 
+    \x{37e}\x{376}\x{371}\x{393}\x{394} 
+    !\x{c0}++\x{c1}\x{c2} 
+    !\x{c0}+++++ 
+
+/-- With PCRE_UCP, non-UTF8 chars that are < 256 still check properties  --/
+
+/\b...\B/W
+    abc_
+    !\x{c0}++\x{c1}\x{c2} 
+    !\x{c0}+++++ 
+
 /-- End of testinput9 --/ 
diff --git a/ext/pcre/pcrelib/testdata/testoutput10 b/ext/pcre/pcrelib/testdata/testoutput10
index a0db640..4994584 100644
--- a/ext/pcre/pcrelib/testdata/testoutput10
+++ b/ext/pcre/pcrelib/testdata/testoutput10
@@ -1,7 +1,8 @@
 /-- These are a few representative patterns whose lengths and offsets are to be 
 shown when the link size is 2. This is just a doublecheck test to ensure the 
 sizes don't go horribly wrong when something is changed. The pattern contents 
-are all themselves checked in other tests. --/
+are all themselves checked in other tests. Unicode, including property support, 
+is required for these tests. --/
 
 /((?i)b)/BM
 Memory allocation (code space): 21
@@ -666,4 +667,44 @@ Memory allocation (code space): 40
  39     End
 ------------------------------------------------------------------
 
+/[^\d]/8WB
+------------------------------------------------------------------
+  0  11 Bra
+  3     [^\p{Nd}]
+ 11  11 Ket
+ 14     End
+------------------------------------------------------------------
+
+/[[:^alpha:][:^cntrl:]]+/8WB
+------------------------------------------------------------------
+  0  44 Bra
+  3     [ -~\x80-\xff\P{L}]+
+ 44  44 Ket
+ 47     End
+------------------------------------------------------------------
+
+/[[:^cntrl:][:^alpha:]]+/8WB
+------------------------------------------------------------------
+  0  44 Bra
+  3     [ -~\x80-\xff\P{L}]+
+ 44  44 Ket
+ 47     End
+------------------------------------------------------------------
+
+/[[:alpha:]]+/8WB
+------------------------------------------------------------------
+  0  12 Bra
+  3     [\p{L}]+
+ 12  12 Ket
+ 15     End
+------------------------------------------------------------------
+
+/[[:^alpha:]\S]+/8WB
+------------------------------------------------------------------
+  0  15 Bra
+  3     [\P{L}\P{Xsp}]+
+ 15  15 Ket
+ 18     End
+------------------------------------------------------------------
+
 /-- End of testinput10 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput2 b/ext/pcre/pcrelib/testdata/testoutput2
index c29bd5f..2baa6e9 100644
--- a/ext/pcre/pcrelib/testdata/testoutput2
+++ b/ext/pcre/pcrelib/testdata/testoutput2
@@ -2,12 +2,12 @@
     of PCRE's API, error diagnostics, and the compiled code of some patterns.
     It also checks the non-Perl syntax the PCRE supports (Python, .NET, 
     Oniguruma). Finally, there are some tests where PCRE and Perl differ, 
-    either because PCRE can't be compatible, or there is potential Perl 
+    either because PCRE can't be compatible, or there is a possible Perl 
     bug. --/  
   
-/-- Originally, the Perl 5.10 things were in here too, but now I have separated
-    many (most?) of them out into test 11. However, there may still be some
-    that were overlooked. --/   
+/-- Originally, the Perl 5.10 and 5.11 things were in here too, but now I have 
+    separated many (most?) of them out into test 11. However, there may still 
+    be some that were overlooked. --/   
 
 /(a)b|/I
 Capturing subpattern count = 1
@@ -103,6 +103,36 @@ Failed: missing terminating ] for character class at offset 5
 /(?X)[\B]/
 Failed: invalid escape sequence in character class at offset 6
 
+/(?X)[\R]/
+Failed: invalid escape sequence in character class at offset 6
+
+/(?X)[\X]/
+Failed: invalid escape sequence in character class at offset 6
+
+/[\B]/BZ
+------------------------------------------------------------------
+        Bra
+        B
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\R]/BZ
+------------------------------------------------------------------
+        Bra
+        R
+        Ket
+        End
+------------------------------------------------------------------
+
+/[\X]/BZ
+------------------------------------------------------------------
+        Bra
+        X
+        Ket
+        End
+------------------------------------------------------------------
+
 /[z-a]/
 Failed: range out of order in character class at offset 3
 
@@ -3198,19 +3228,19 @@ Failed: POSIX collating elements are not supported at offset 0
 Failed: POSIX named classes are supported only within a class at offset 0
 
 /\l/I
-Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+Failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1
 
 /\L/I
-Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+Failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1
 
 /\N{name}/I
-Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+Failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1
 
 /\u/I
-Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+Failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1
 
 /\U/I
-Failed: PCRE does not support \L, \l, \N, \U, or \u at offset 1
+Failed: PCRE does not support \L, \l, \N{name}, \U, or \u at offset 1
 
 /[/I
 Failed: missing terminating ] for character class at offset 1
@@ -8667,11 +8697,8 @@ No match
 +13   ^  ^      (*FAIL)
 No match
     
-/a(*PRUNE:XXX)b/
-Failed: (*VERB) with an argument is not supported at offset 8
-
 /a(*MARK)b/ 
-Failed: (*VERB) not recognized at offset 7
+Failed: (*MARK) must have an argument at offset 7
 
 /(?i:A{1,}\6666666666)/
 Failed: number is too big at offset 19
@@ -10668,4 +10695,435 @@ No match
 /(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
 Failed: recursive call could loop indefinitely at offset 31
 
+/abc(*MARK:)pqr/
+Failed: (*MARK) must have an argument at offset 10
+
+/abc(*:)pqr/
+Failed: (*MARK) must have an argument at offset 6
+
+/abc(*FAIL:123)xyz/
+Failed: an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT) at offset 13
+
+/--- This should, and does, fail. In Perl, it does not, which I think is a 
+     bug because replacing the B in the pattern by (B|D) does make it fail. ---/
+
+/A(*COMMIT)B/+K
+    ACABX
+No match
+
+/--- These should be different, but in Perl 5.11 are not, which I think
+     is a bug in Perl. ---/
+
+/A(*THEN)B|A(*THEN)C/K
+    AC
+ 0: AC
+
+/A(*PRUNE)B|A(*PRUNE)C/K
+    AC
+No match
+    
+/--- A whole lot of tests of verbs with arguments are here rather than in test
+     11 because Perl doesn't seem to follow its specification entirely 
+     correctly. ---/
+
+/--- Perl 5.11 sets $REGERROR on the AC failure case here; PCRE does not. It is
+     not clear how Perl defines "involved in the failure of the match". ---/ 
+
+/^(A(*THEN:A)B|C(*THEN:B)D)/K
+    AB
+ 0: AB
+ 1: AB
+    CD
+ 0: CD
+ 1: CD
+    ** Failers
+No match
+    AC
+No match
+    CB    
+No match, mark = B
+    
+/--- Check the use of names for success and failure. PCRE doesn't show these 
+names for success, though Perl does, contrary to its spec. ---/
+
+/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/K
+    AB
+ 0: AB
+ 1: AB
+    CD
+ 0: CD
+ 1: CD
+    ** Failers
+No match
+    AC
+No match, mark = A
+    CB    
+No match, mark = B
+    
+/--- An empty name does not pass back an empty string. It is the same as if no
+name were given. ---/ 
+
+/^(A(*PRUNE:)B|C(*PRUNE:B)D)/K
+    AB
+ 0: AB
+ 1: AB
+    CD 
+ 0: CD
+ 1: CD
+
+/--- PRUNE goes to next bumpalong; COMMIT does not. ---/
+    
+/A(*PRUNE:A)B/K
+    ACAB
+ 0: AB
+
+/(*MARK:A)(*PRUNE:B)(C|X)/K
+    C
+ 0: C
+ 1: C
+MK: A
+    D 
+No match, mark = B
+
+/(*MARK:A)(*THEN:B)(C|X)/K
+    C
+ 0: C
+ 1: C
+MK: A
+    D 
+No match, mark = B
+
+/--- This should fail, as the skip causes a bump to offset 3 (the skip) ---/
+
+/A(*MARK:A)A+(*SKIP)(B|Z) | AC/xK
+    AAAC
+No match
+
+/--- Same --/
+
+/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/xK
+    AAAC
+No match
+
+/--- This should fail; the SKIP advances by one, but when we get to AC, the
+     PRUNE kills it. ---/ 
+    
+/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/xK
+    AAAC
+No match
+
+/A(*:A)A+(*SKIP)(B|Z) | AC/xK
+    AAAC
+No match
+
+/--- This should fail, as a null name is the same as no name ---/
+
+/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/xK
+    AAAC
+No match
+
+/--- This fails in PCRE, and I think that is in accordance with Perl's 
+     documentation, though in Perl it succeeds. ---/
+    
+/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/xK
+    AAAC
+No match
+
+/--- Mark names can be duplicated ---/
+
+/A(*:A)B|X(*:A)Y/K
+    AABC
+ 0: AB
+MK: A
+    XXYZ 
+ 0: XY
+MK: A
+    
+/^A(*:A)B|^X(*:A)Y/K
+    ** Failers
+No match
+    XAQQ
+No match, mark = A
+    
+/--- A check on what happens after hitting a mark and them bumping along to
+something that does not even start. Perl reports tags after the failures here, 
+though it does not when the individual letters are made into something 
+more complicated. ---/
+
+/A(*:A)B|XX(*:B)Y/K
+    AABC
+ 0: AB
+MK: A
+    XXYZ 
+ 0: XXY
+MK: B
+    ** Failers
+No match
+    XAQQ  
+No match
+    XAQQXZZ  
+No match
+    AXQQQ 
+No match
+    AXXQQQ 
+No match
+    
+/--- COMMIT at the start of a pattern should be the same as an anchor. Perl 
+optimizations defeat this. So does the PCRE optimization unless we disable it 
+with \Y. ---/
+
+/(*COMMIT)ABC/
+    ABCDEFG
+ 0: ABC
+    ** Failers
+No match
+    DEFGABC\Y  
+No match
+    
+/--- Repeat some tests with added studying. ---/
+
+/A(*COMMIT)B/+KS
+    ACABX
+No match
+ 
+/A(*THEN)B|A(*THEN)C/KS
+    AC
+ 0: AC
+
+/A(*PRUNE)B|A(*PRUNE)C/KS
+    AC
+No match
+
+/^(A(*THEN:A)B|C(*THEN:B)D)/KS
+    AB
+ 0: AB
+ 1: AB
+    CD
+ 0: CD
+ 1: CD
+    ** Failers
+No match
+    AC
+No match
+    CB    
+No match, mark = B
+
+/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/KS
+    AB
+ 0: AB
+ 1: AB
+    CD
+ 0: CD
+ 1: CD
+    ** Failers
+No match
+    AC
+No match, mark = A
+    CB    
+No match, mark = B
+
+/^(A(*PRUNE:)B|C(*PRUNE:B)D)/KS
+    AB
+ 0: AB
+ 1: AB
+    CD 
+ 0: CD
+ 1: CD
+
+/A(*PRUNE:A)B/KS
+    ACAB
+ 0: AB
+
+/(*MARK:A)(*PRUNE:B)(C|X)/KS
+    C
+ 0: C
+ 1: C
+MK: A
+    D 
+No match
+
+/(*MARK:A)(*THEN:B)(C|X)/KS
+    C
+ 0: C
+ 1: C
+MK: A
+    D 
+No match
+
+/A(*MARK:A)A+(*SKIP)(B|Z) | AC/xKS
+    AAAC
+No match
+
+/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/xKS
+    AAAC
+No match
+    
+/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/xKS
+    AAAC
+No match
+
+/A(*:A)A+(*SKIP)(B|Z) | AC/xKS
+    AAAC
+No match
+
+/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/xKS
+    AAAC
+No match
+
+/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/xKS
+    AAAC
+No match
+
+/A(*:A)B|XX(*:B)Y/KS
+    AABC
+ 0: AB
+MK: A
+    XXYZ 
+ 0: XXY
+MK: B
+    ** Failers
+No match
+    XAQQ  
+No match
+    XAQQXZZ  
+No match
+    AXQQQ 
+No match
+    AXXQQQ 
+No match
+    
+/(*COMMIT)ABC/
+    ABCDEFG
+ 0: ABC
+    ** Failers
+No match
+    DEFGABC\Y  
+No match
+
+/^(ab (c+(*THEN)cd) | xyz)/x
+    abcccd  
+No match
+
+/^(ab (c+(*PRUNE)cd) | xyz)/x
+    abcccd  
+No match
+
+/^(ab (c+(*FAIL)cd) | xyz)/x
+    abcccd  
+No match
+    
+/--- Perl 5.11 gets some of these wrong ---/ 
+
+/(?>.(*ACCEPT))*?5/
+    abcde
+ 0: a
+
+/(.(*ACCEPT))*?5/
+    abcde
+ 0: a
+ 1: a
+
+/(.(*ACCEPT))5/
+    abcde
+ 0: a
+ 1: a
+
+/(.(*ACCEPT))*5/
+    abcde
+ 0: a
+ 1: a
+
+/A\NB./BZ
+------------------------------------------------------------------
+        Bra
+        A
+        Any
+        B
+        Any
+        Ket
+        End
+------------------------------------------------------------------
+  ACBD
+ 0: ACBD
+  ** Failers
+No match
+  A\nB
+No match
+  ACB\n   
+No match
+
+/A\NB./sBZ
+------------------------------------------------------------------
+        Bra
+        A
+        Any
+        B
+        AllAny
+        Ket
+        End
+------------------------------------------------------------------
+  ACBD
+ 0: ACBD
+  ACB\n 
+ 0: ACB\x0a
+  ** Failers
+No match
+  A\nB  
+No match
+  
+/A\NB/<crlf>
+  A\nB
+ 0: A\x0aB
+  A\rB
+ 0: A\x0dB
+  ** Failers
+No match
+  A\r\nB    
+No match
+
+/\R+b/BZ
+------------------------------------------------------------------
+        Bra
+        \R++
+        b
+        Ket
+        End
+------------------------------------------------------------------
+
+/\R+\n/BZ
+------------------------------------------------------------------
+        Bra
+        \R+
+        \x0a
+        Ket
+        End
+------------------------------------------------------------------
+
+/\R+\d/BZ
+------------------------------------------------------------------
+        Bra
+        \R++
+        \d
+        Ket
+        End
+------------------------------------------------------------------
+
+/\d*\R/BZ
+------------------------------------------------------------------
+        Bra
+        \d*+
+        \R
+        Ket
+        End
+------------------------------------------------------------------
+
+/\s*\R/BZ
+------------------------------------------------------------------
+        Bra
+        \s*+
+        \R
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput2 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput5 b/ext/pcre/pcrelib/testdata/testoutput5
index 9d815ff..b3ce48a 100644
--- a/ext/pcre/pcrelib/testdata/testoutput5
+++ b/ext/pcre/pcrelib/testdata/testoutput5
@@ -2076,4 +2076,150 @@ Partial match: abcde
     \PX
 Partial match: X
 
+/\h/SI
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Subject length lower bound = 1
+Starting byte set: \x09 \x20 \xa0 
+
+/\h/SI8
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+Subject length lower bound = 1
+Starting byte set: \x09 \x20 \xc2 \xe1 \xe2 \xe3 
+    ABC\x{09}
+ 0: \x{09}
+    ABC\x{20}
+ 0:  
+    ABC\x{a0}
+ 0: \x{a0}
+    ABC\x{1680}
+ 0: \x{1680}
+    ABC\x{180e}
+ 0: \x{180e}
+    ABC\x{2000}
+ 0: \x{2000}
+    ABC\x{202f} 
+ 0: \x{202f}
+    ABC\x{205f} 
+ 0: \x{205f}
+    ABC\x{3000} 
+ 0: \x{3000}
+
+/\v/SI
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Subject length lower bound = 1
+Starting byte set: \x0a \x0b \x0c \x0d \x85 
+
+/\v/SI8
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+Subject length lower bound = 1
+Starting byte set: \x0a \x0b \x0c \x0d \xc2 \xe2 
+    ABC\x{0a}
+ 0: \x{0a}
+    ABC\x{0b}
+ 0: \x{0b}
+    ABC\x{0c}
+ 0: \x{0c}
+    ABC\x{0d}
+ 0: \x{0d}
+    ABC\x{85}
+ 0: \x{85}
+    ABC\x{2028}
+ 0: \x{2028}
+
+/\R/SI
+Capturing subpattern count = 0
+No options
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: \x0a \x0b \x0c \x0d \x85 
+
+/\R/SI8
+Capturing subpattern count = 0
+Options: utf8
+No first char
+No need char
+Subject length lower bound = 2
+Starting byte set: \x0a \x0b \x0c \x0d \xc2 \xe2 
+
+/\h*A/SI8
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'A'
+Subject length lower bound = 1
+Starting byte set: \x09 \x20 A \xc2 \xe1 \xe2 \xe3 
+    CDBABC
+ 0: A
+    
+/\v+A/SI8
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'A'
+Subject length lower bound = 2
+Starting byte set: \x0a \x0b \x0c \x0d \xc2 \xe2 
+
+/\s?xxx\s/8SI
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'x'
+Subject length lower bound = 4
+Starting byte set: \x09 \x0a \x0c \x0d \x20 x 
+
+/\sxxx\s/8T1
+    AB\x{85}xxx\x{a0}XYZ
+ 0: \x{85}xxx\x{a0}
+    AB\x{a0}xxx\x{85}XYZ
+ 0: \x{a0}xxx\x{85}
+
+/\sxxx\s/I8ST1
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = 'x'
+Subject length lower bound = 5
+Starting byte set: \x09 \x0a \x0c \x0d \x20 \xc2 
+    AB\x{85}xxx\x{a0}XYZ
+ 0: \x{85}xxx\x{a0}
+    AB\x{a0}xxx\x{85}XYZ
+ 0: \x{a0}xxx\x{85}
+
+/\S \S/8T1
+    \x{a2} \x{84} 
+ 0: \x{a2} \x{84}
+
+/\S \S/I8ST1
+Capturing subpattern count = 0
+Options: utf8
+No first char
+Need char = ' '
+Subject length lower bound = 3
+Starting byte set: \x00 \x01 \x02 \x03 \x04 \x05 \x06 \x07 \x08 \x0b \x0e 
+  \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1a \x1b \x1c \x1d 
+  \x1e \x1f ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 
+  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e 
+  f g h i j k l m n o p q r s t u v w x y z { | } ~ \x7f \xc0 \xc1 \xc2 \xc3 
+  \xc4 \xc5 \xc6 \xc7 \xc8 \xc9 \xca \xcb \xcc \xcd \xce \xcf \xd0 \xd1 \xd2 
+  \xd3 \xd4 \xd5 \xd6 \xd7 \xd8 \xd9 \xda \xdb \xdc \xdd \xde \xdf \xe0 \xe1 
+  \xe2 \xe3 \xe4 \xe5 \xe6 \xe7 \xe8 \xe9 \xea \xeb \xec \xed \xee \xef \xf0 
+  \xf1 \xf2 \xf3 \xf4 \xf5 \xf6 \xf7 \xf8 \xf9 \xfa \xfb \xfc \xfd \xfe \xff 
+    \x{a2} \x{84} 
+ 0: \x{a2} \x{84}
+    A Z 
+ 0: A Z
+
 /-- End of testinput5 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput6 b/ext/pcre/pcrelib/testdata/testoutput6
index b4176eb..e000083 100644
--- a/ext/pcre/pcrelib/testdata/testoutput6
+++ b/ext/pcre/pcrelib/testdata/testoutput6
@@ -1285,4 +1285,72 @@ No match
     \x{10b00}\x{a6ef}\x{13007}\x{10857}\x{10b78}\x{10b58}\x{a980}\x{110c1}\x{a4ff}\x{abc0}\x{10a7d}\x{10c48}\x{0800}\x{1aad}\x{aac0}
  0: \x{10b00}\x{a6ef}\x{13007}\x{10857}\x{10b78}\x{10b58}\x{a980}\x{110c1}\x{a4ff}\x{abc0}\x{10a7d}\x{10c48}\x{800}\x{1aad}\x{aac0}
 
+/^\w+/8W
+    Az_\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+ 0: Az_\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+
+/^[[:xdigit:]]*/8W
+    1a\x{660}\x{bef}\x{16ee}
+ 0: 1a
+  
+/^\d+/8W
+    1\x{660}\x{bef}\x{16ee}
+ 0: 1\x{660}\x{bef}
+  
+/^[[:digit:]]+/8W
+    1\x{660}\x{bef}\x{16ee}
+ 0: 1\x{660}\x{bef}
+
+/^>\s+/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+ 0: > \x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{09}
+  
+/^>\pZ+/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+ 0: > \x{a0}\x{1680}\x{2028}\x{2029}\x{202f}
+  
+/^>[[:space:]]*/8W
+    >\x{20}\x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{9}\x{b} 
+ 0: > \x{a0}\x{1680}\x{2028}\x{2029}\x{202f}\x{09}\x{0b}
+
+/^>[[:blank:]]*/8W
+    >\x{20}\x{a0}\x{1680}\x{180e}\x{2000}\x{202f}\x{9}\x{b}\x{2028} 
+ 0: > \x{a0}\x{1680}\x{180e}\x{2000}\x{202f}\x{09}
+
+/^[[:alpha:]]*/8W
+    Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}
+ 0: Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}
+
+/^[[:alnum:]]*/8W
+    Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+ 0: Az\x{aa}\x{c0}\x{1c5}\x{2b0}\x{3b6}\x{1d7c9}\x{2fa1d}1\x{660}\x{bef}\x{16ee}
+
+/^[[:cntrl:]]*/8W
+    \x{0}\x{09}\x{1f}\x{7f}\x{9f} 
+ 0: \x{00}\x{09}\x{1f}\x{7f}
+
+/^[[:graph:]]*/8W
+    A\x{a1}\x{a0}
+ 0: A
+
+/^[[:print:]]*/8W
+    A z\x{a0}\x{a1}
+ 0: A z
+
+/^[[:punct:]]*/8W
+    .+\x{a1}\x{a0}
+ 0: .+
+
+/\p{Zs}*?\R/
+    ** Failers
+No match
+    a\xFCb   
+No match
+
+/\p{Zs}*\R/                                                                    
+    ** Failers 
+No match
+    a\xFCb   
+No match
+
 /-- End of testinput6 --/
diff --git a/ext/pcre/pcrelib/testdata/testoutput9 b/ext/pcre/pcrelib/testdata/testoutput9
index 851e3f0..cb70f1c 100644
--- a/ext/pcre/pcrelib/testdata/testoutput9
+++ b/ext/pcre/pcrelib/testdata/testoutput9
@@ -1674,4 +1674,364 @@ No match
     \x{1d79}\x{a77d} 
 No match
 
+/^\p{Xan}/8
+    ABCD
+ 0: A
+    1234
+ 0: 1
+    \x{6ca}
+ 0: \x{6ca}
+    \x{a6c}
+ 0: \x{a6c}
+    \x{10a7}   
+ 0: \x{10a7}
+    ** Failers
+No match
+    _ABC   
+No match
+
+/^\p{Xan}+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 1: ABCD1234\x{6ca}\x{a6c}
+ 2: ABCD1234\x{6ca}
+ 3: ABCD1234
+ 4: ABCD123
+ 5: ABCD12
+ 6: ABCD1
+ 7: ABCD
+ 8: ABC
+ 9: AB
+10: A
+    ** Failers
+No match
+    _ABC   
+No match
+
+/^\p{Xan}*/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 1: ABCD1234\x{6ca}\x{a6c}
+ 2: ABCD1234\x{6ca}
+ 3: ABCD1234
+ 4: ABCD123
+ 5: ABCD12
+ 6: ABCD1
+ 7: ABCD
+ 8: ABC
+ 9: AB
+10: A
+11: 
+    
+/^\p{Xan}{2,9}/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}
+ 1: ABCD1234
+ 2: ABCD123
+ 3: ABCD12
+ 4: ABCD1
+ 5: ABCD
+ 6: ABC
+ 7: AB
+    
+/^[\p{Xan}]/8
+    ABCD1234_
+ 0: A
+    1234abcd_
+ 0: 1
+    \x{6ca}
+ 0: \x{6ca}
+    \x{a6c}
+ 0: \x{a6c}
+    \x{10a7}   
+ 0: \x{10a7}
+    ** Failers
+No match
+    _ABC   
+No match
+ 
+/^[\p{Xan}]+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 1: ABCD1234\x{6ca}\x{a6c}
+ 2: ABCD1234\x{6ca}
+ 3: ABCD1234
+ 4: ABCD123
+ 5: ABCD12
+ 6: ABCD1
+ 7: ABCD
+ 8: ABC
+ 9: AB
+10: A
+    ** Failers
+No match
+    _ABC   
+No match
+
+/^>\p{Xsp}/8
+    >\x{1680}\x{2028}\x{0b}
+ 0: >\x{1680}
+    ** Failers
+No match
+    \x{0b} 
+No match
+
+/^>\p{Xsp}+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}
+ 4: > \x{09}\x{0a}\x{0c}
+ 5: > \x{09}\x{0a}
+ 6: > \x{09}
+ 7: > 
+
+/^>\p{Xsp}*/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}
+ 4: > \x{09}\x{0a}\x{0c}
+ 5: > \x{09}\x{0a}
+ 6: > \x{09}
+ 7: > 
+ 8: >
+    
+/^>\p{Xsp}{2,9}/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}
+ 4: > \x{09}\x{0a}\x{0c}
+ 5: > \x{09}\x{0a}
+ 6: > \x{09}
+    
+/^>[\p{Xsp}]/8
+    >\x{2028}\x{0b}
+ 0: >\x{2028}
+ 
+/^>[\p{Xsp}]+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}
+ 4: > \x{09}\x{0a}\x{0c}
+ 5: > \x{09}\x{0a}
+ 6: > \x{09}
+ 7: > 
+
+/^>\p{Xps}/8
+    >\x{1680}\x{2028}\x{0b}
+ 0: >\x{1680}
+    >\x{a0} 
+ 0: >\x{a0}
+    ** Failers
+No match
+    \x{0b} 
+No match
+
+/^>\p{Xps}+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 4: > \x{09}\x{0a}\x{0c}\x{0d}
+ 5: > \x{09}\x{0a}\x{0c}
+ 6: > \x{09}\x{0a}
+ 7: > \x{09}
+ 8: > 
+
+/^>\p{Xps}+?/8
+    >\x{1680}\x{2028}\x{0b}
+ 0: >\x{1680}\x{2028}\x{0b}
+ 1: >\x{1680}\x{2028}
+ 2: >\x{1680}
+
+/^>\p{Xps}*/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 4: > \x{09}\x{0a}\x{0c}\x{0d}
+ 5: > \x{09}\x{0a}\x{0c}
+ 6: > \x{09}\x{0a}
+ 7: > \x{09}
+ 8: > 
+ 9: >
+    
+/^>\p{Xps}{2,9}/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 4: > \x{09}\x{0a}\x{0c}\x{0d}
+ 5: > \x{09}\x{0a}\x{0c}
+ 6: > \x{09}\x{0a}
+ 7: > \x{09}
+    
+/^>\p{Xps}{2,9}?/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 4: > \x{09}\x{0a}\x{0c}\x{0d}
+ 5: > \x{09}\x{0a}\x{0c}
+ 6: > \x{09}\x{0a}
+ 7: > \x{09}
+    
+/^>[\p{Xps}]/8
+    >\x{2028}\x{0b}
+ 0: >\x{2028}
+ 
+/^>[\p{Xps}]+/8
+    > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 0: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}\x{0b}
+ 1: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}\x{2028}
+ 2: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}\x{1680}
+ 3: > \x{09}\x{0a}\x{0c}\x{0d}\x{a0}
+ 4: > \x{09}\x{0a}\x{0c}\x{0d}
+ 5: > \x{09}\x{0a}\x{0c}
+ 6: > \x{09}\x{0a}
+ 7: > \x{09}
+ 8: > 
+
+/^\p{Xwd}/8
+    ABCD
+ 0: A
+    1234
+ 0: 1
+    \x{6ca}
+ 0: \x{6ca}
+    \x{a6c}
+ 0: \x{a6c}
+    \x{10a7}
+ 0: \x{10a7}
+    _ABC    
+ 0: _
+    ** Failers
+No match
+    [] 
+No match
+
+/^\p{Xwd}+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 1: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 2: ABCD1234\x{6ca}\x{a6c}
+ 3: ABCD1234\x{6ca}
+ 4: ABCD1234
+ 5: ABCD123
+ 6: ABCD12
+ 7: ABCD1
+ 8: ABCD
+ 9: ABC
+10: AB
+11: A
+
+/^\p{Xwd}*/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 1: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 2: ABCD1234\x{6ca}\x{a6c}
+ 3: ABCD1234\x{6ca}
+ 4: ABCD1234
+ 5: ABCD123
+ 6: ABCD12
+ 7: ABCD1
+ 8: ABCD
+ 9: ABC
+10: AB
+11: A
+12: 
+    
+/^\p{Xwd}{2,9}/8
+    A_12\x{6ca}\x{a6c}\x{10a7}
+ 0: A_12\x{6ca}\x{a6c}\x{10a7}
+ 1: A_12\x{6ca}\x{a6c}
+ 2: A_12\x{6ca}
+ 3: A_12
+ 4: A_1
+ 5: A_
+    
+/^[\p{Xwd}]/8
+    ABCD1234_
+ 0: A
+    1234abcd_
+ 0: 1
+    \x{6ca}
+ 0: \x{6ca}
+    \x{a6c}
+ 0: \x{a6c}
+    \x{10a7}   
+ 0: \x{10a7}
+    _ABC 
+ 0: _
+    ** Failers
+No match
+    []   
+No match
+ 
+/^[\p{Xwd}]+/8
+    ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 0: ABCD1234\x{6ca}\x{a6c}\x{10a7}_
+ 1: ABCD1234\x{6ca}\x{a6c}\x{10a7}
+ 2: ABCD1234\x{6ca}\x{a6c}
+ 3: ABCD1234\x{6ca}
+ 4: ABCD1234
+ 5: ABCD123
+ 6: ABCD12
+ 7: ABCD1
+ 8: ABCD
+ 9: ABC
+10: AB
+11: A
+
+/-- Unicode properties for \b abd \B --/
+
+/\b...\B/8W
+    abc_
+ 0: abc
+    \x{37e}abc\x{376} 
+ 0: abc
+    \x{37e}\x{376}\x{371}\x{393}\x{394} 
+ 0: \x{376}\x{371}\x{393}
+    !\x{c0}++\x{c1}\x{c2} 
+ 0: ++\x{c1}
+    !\x{c0}+++++ 
+ 0: \x{c0}++
+
+/-- Without PCRE_UCP, non-ASCII always fail, even if < 256  --/
+
+/\b...\B/8
+    abc_
+ 0: abc
+    ** Failers 
+ 0: Fai
+    \x{37e}abc\x{376} 
+No match
+    \x{37e}\x{376}\x{371}\x{393}\x{394} 
+No match
+    !\x{c0}++\x{c1}\x{c2} 
+No match
+    !\x{c0}+++++ 
+No match
+
+/-- With PCRE_UCP, non-UTF8 chars that are < 256 still check properties  --/
+
+/\b...\B/W
+    abc_
+ 0: abc
+    !\x{c0}++\x{c1}\x{c2} 
+ 0: ++\xc1
+    !\x{c0}+++++ 
+ 0: \xc0++
+
 /-- End of testinput9 --/ 
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index bacb74f..2cbc72a 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_pcre.c 305133 2010-11-06 18:35:38Z felipe $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -350,7 +350,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_le
 			case 'S':	do_study  = 1;					break;
 			case 'U':	coptions |= PCRE_UNGREEDY;		break;
 			case 'X':	coptions |= PCRE_EXTRA;			break;
-			case 'u':	coptions |= PCRE_UTF8;			break;
+			case 'u':	coptions |= PCRE_UTF8;
+	/* In  PCRE,  by  default, \d, \D, \s, \S, \w, and \W recognize only ASCII
+       characters, even in UTF-8 mode. However, this can be changed by setting
+       the PCRE_UCP option. */
+#ifdef PCRE_UCP
+						coptions |= PCRE_UCP;
+#endif			
+				break;
 
 			/* Custom preg options */
 			case 'e':	poptions |= PREG_REPLACE_EVAL;	break;
@@ -747,7 +754,12 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
 	efree(offsets);
 	efree(subpat_names);
 
-	RETVAL_LONG(matched);
+	/* Did we encounter an error? */
+	if (PCRE_G(error_code) == PHP_PCRE_NO_ERROR) {
+		RETVAL_LONG(matched);
+	} else {
+		RETVAL_FALSE;
+	}
 }
 /* }}} */
 
diff --git a/ext/pcre/tests/backtrack_limit.phpt b/ext/pcre/tests/backtrack_limit.phpt
index 517e727..419e6c2 100644
--- a/ext/pcre/tests/backtrack_limit.phpt
+++ b/ext/pcre/tests/backtrack_limit.phpt
@@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
 
 ?>
 --EXPECT--
-int(0)
+bool(false)
 bool(true)
 int(10)
 bool(true)
diff --git a/ext/pcre/tests/bug33200.phpt b/ext/pcre/tests/bug33200.phpt
index 67a4d86..ddbb065 100644
--- a/ext/pcre/tests/bug33200.phpt
+++ b/ext/pcre/tests/bug33200.phpt
@@ -9,5 +9,5 @@ $str = preg_replace("/(some.*text)/e", "strtoupper('\\1')", $str);
 echo $str . "\r\n";
 ?>
 --EXPECT--
-Warning: Directive 'magic_quotes_sybase' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_sybase' is deprecated in PHP 5.3 and greater in Unknown on line 0
 SOME '$SAMPLE' TEXT
diff --git a/ext/pcre/tests/bug52732.phpt b/ext/pcre/tests/bug52732.phpt
new file mode 100644
index 0000000..8cfa204
--- /dev/null
+++ b/ext/pcre/tests/bug52732.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #52732 (Docs say preg_match() returns FALSE on error, but it returns int(0))
+--INI--
+pcre.backtrack_limit=1
+--FILE--
+<?php
+$ret = preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
+
+var_dump($ret);
+
+?>
+--EXPECT--
+bool(false)
\ No newline at end of file
diff --git a/ext/pcre/tests/bug52971.phpt b/ext/pcre/tests/bug52971.phpt
new file mode 100644
index 0000000..5949cb2
--- /dev/null
+++ b/ext/pcre/tests/bug52971.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #52971 (PCRE-Meta-Characters not working with utf-8)
+--SKIPIF--
+<?php if ((double)PCRE_VERSION < 8.1) die('skip PCRE_VERSION >= 8.1 is required!'); ?>
+--FILE--
+<?php
+
+$message = 'Der ist ein Süßwasserpool Süsswasserpool ... verschiedene Wassersportmöglichkeiten bei ...';
+
+$pattern = '/\bwasser/iu';
+preg_match_all($pattern, $message, $match, PREG_OFFSET_CAPTURE);
+var_dump($match);
+
+$pattern = '/[^\w]wasser/iu';
+preg_match_all($pattern, $message, $match, PREG_OFFSET_CAPTURE);
+var_dump($match);
+
+?>
+--EXPECTF--
+array(1) {
+  [0]=>
+  array(1) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(6) "Wasser"
+      [1]=>
+      int(61)
+    }
+  }
+}
+array(1) {
+  [0]=>
+  array(1) {
+    [0]=>
+    array(2) {
+      [0]=>
+      string(7) " Wasser"
+      [1]=>
+      int(60)
+    }
+  }
+}
diff --git a/ext/pcre/tests/invalid_utf8_offset.phpt b/ext/pcre/tests/invalid_utf8_offset.phpt
index b6ec1e5..50716ca 100644
--- a/ext/pcre/tests/invalid_utf8_offset.phpt
+++ b/ext/pcre/tests/invalid_utf8_offset.phpt
@@ -22,7 +22,7 @@ var_dump(preg_last_error() == PREG_NO_ERROR);
 echo "Done\n";
 ?>
 --EXPECT--
-int(0)
+bool(false)
 array(0) {
 }
 bool(true)
diff --git a/ext/pcre/tests/recursion_limit.phpt b/ext/pcre/tests/recursion_limit.phpt
index 9933b5c..7dee7ba 100644
--- a/ext/pcre/tests/recursion_limit.phpt
+++ b/ext/pcre/tests/recursion_limit.phpt
@@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
 
 ?>
 --EXPECT--
-int(0)
+bool(false)
 bool(true)
 int(1)
 bool(true)
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 5c85bff..a875fad 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c 300503 2010-06-16 23:13:29Z felipe $ */
+/* $Id: pdo_stmt.c 305381 2010-11-15 18:48:48Z felipe $ */
 
 /* The PDO Statement Handle Class */
 
@@ -1624,18 +1624,20 @@ 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;
 	PHP_STMT_GET_OBJ;
 
 	param.paramno = -1;
-	param.param_type = PDO_PARAM_STR;
 	
 	if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
-			"lz/|l", &param.paramno, &param.parameter, &param.param_type)) {
+			"lz/|l", &param.paramno, &param.parameter, &param_type)) {
 		if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|l", &param.name,
-				&param.namelen, &param.parameter, &param.param_type)) {
+				&param.namelen, &param.parameter, &param_type)) {
 			RETURN_FALSE;
 		}
 	}
+
+	param.param_type = (int) param_type;
 	
 	if (param.paramno > 0) {
 		--param.paramno; /* make it zero-based internally */
@@ -1887,7 +1889,7 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in
 	switch (stmt->default_fetch_type) {
 		case PDO_FETCH_INTO:
 			if (stmt->fetch.into) {
-				Z_DELREF_P(stmt->fetch.into);
+				zval_ptr_dtor(&stmt->fetch.into);
 				stmt->fetch.into = NULL;
 			}
 			break;
@@ -2619,7 +2621,7 @@ static zval *row_prop_or_dim_read(zval *object, zval *member, int type TSRMLS_DC
 			}
 			if (strcmp(Z_STRVAL_P(member), "queryString") == 0) {
 				zval_ptr_dtor(&return_value);
-				return std_object_handlers.read_property(object, member, IS_STRING TSRMLS_CC);
+				return std_object_handlers.read_property(object, member, type TSRMLS_CC);
 			}
 		}
 	}
diff --git a/ext/pdo/tests/bug47769.phpt b/ext/pdo/tests/bug47769.phpt
index 2cb75e3..3b2f1e8 100644
--- a/ext/pdo/tests/bug47769.phpt
+++ b/ext/pdo/tests/bug47769.phpt
@@ -1,5 +1,10 @@
 --TEST--
 Bug #47769 (Strange extends PDO)
+--SKIPIF--
+<?php
+if (!extension_loaded("pdo_sqlite"))
+	die("skip: PDO_SQLite not available");
+?>
 --FILE--
 <?php
 
diff --git a/ext/pdo/tests/bug_38253.phpt b/ext/pdo/tests/bug_38253.phpt
index ba937a0..4453c3b 100644
--- a/ext/pdo/tests/bug_38253.phpt
+++ b/ext/pdo/tests/bug_38253.phpt
@@ -24,7 +24,13 @@ var_dump($stmt->fetchAll());
 
 $pdo = PDOTest::factory();
 
-$pdo->exec ("create table test2 (id integer primary key, n text)");
+if ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
+    $type = "clob";
+} else{
+    $type = "text";
+}
+
+$pdo->exec ("create table test2 (id integer primary key, n $type)");
 $pdo->exec ("INSERT INTO test2 (id, n) VALUES (1,'hi')");
 
 $pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
diff --git a/ext/pdo/tests/bug_43139.phpt b/ext/pdo/tests/bug_43139.phpt
index 04b9bf3..2c04d79 100644
--- a/ext/pdo/tests/bug_43139.phpt
+++ b/ext/pdo/tests/bug_43139.phpt
@@ -17,7 +17,12 @@ $db = PDOTest::factory();
 $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 
-var_dump($db->query('select 0 as abc, 1 as xyz, 2 as def')->fetchAll(PDO::FETCH_GROUP));
+$from = '';
+if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
+	$from = 'from dual';
+}
+
+var_dump($db->query("select 0 as abc, 1 as xyz, 2 as def $from")->fetchAll(PDO::FETCH_GROUP));
 ?>
 --EXPECT--
 array(1) {
diff --git a/ext/pdo/tests/pdo_018.phpt b/ext/pdo/tests/pdo_018.phpt
index a57c6b7..7f27ce3 100644
--- a/ext/pdo/tests/pdo_018.phpt
+++ b/ext/pdo/tests/pdo_018.phpt
@@ -127,7 +127,13 @@ foreach($objs as $idx => $obj)
 unset($stmt);
 
 echo "===DATA===\n";
-var_dump($db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN));
+$res = $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN);
+
+// For Oracle map NULL to empty string so the test doesn't diff
+if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci' && $res[0] === null) {
+    $res[0] = "";
+}
+var_dump($res);
 
 echo "===FAILURE===\n";
 try
diff --git a/ext/pdo/tests/pdo_021.phpt b/ext/pdo/tests/pdo_021.phpt
index 688bd4a..fb25fc5 100644
--- a/ext/pdo/tests/pdo_021.phpt
+++ b/ext/pdo/tests/pdo_021.phpt
@@ -41,8 +41,6 @@ $select->execute();
 $num = $select->fetchColumn();
 echo 'There are ' . $num . " rows in the table.\n";
 
-$select->closeCursor();
-
 // Insert using named parameters
 $stmt2 = $db->prepare("INSERT INTO test VALUES(:first, :second, :third)");
 foreach ($data as $row) {
diff --git a/ext/pdo/tests/pdo_034.phpt b/ext/pdo/tests/pdo_034.phpt
index 3b30cdc..3803c2f 100644
--- a/ext/pdo/tests/pdo_034.phpt
+++ b/ext/pdo/tests/pdo_034.phpt
@@ -44,9 +44,9 @@ array(5) {
   string(1) "4"
 }
 
-Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain extactly 2 columns. in %s/pdo_034.php on line %d
+Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error: PDO::FETCH_KEY_PAIR fetch mode requires the result set to contain extactly 2 columns. in %spdo_034.php on line %d
 
-Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error%s/pdo_034.php on line %d
+Warning: PDOStatement::fetch(): SQLSTATE[HY000]: General error%spdo_034.php on line %d
 bool(false)
 array(5) {
   ["test0"]=>
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 09f653a..abc0061 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: dblib_stmt.c 295958 2010-03-08 12:39:44Z iliaa $ */
+/* $Id: dblib_stmt.c 302196 2010-08-13 22:12:37Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -170,8 +170,8 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
 					case SQLMONEY4:
 					case SQLMONEYN: {
 						DBFLT8 money_value;
-						dbconvert(NULL, S->cols[i].coltype, dbdata(H->link, i+1), dbdatlen(H->link, i+1), SQLFLT8, (LPBYTE)&money_value, val->len);
-						val->len = spprintf(val->data, 0, "%.4f", money_value);
+						dbconvert(NULL, S->cols[i].coltype, dbdata(H->link, i+1), dbdatlen(H->link, i+1), SQLFLT8, (LPBYTE)&money_value, 8);
+						val->len = spprintf(&val->data, 0, "%.4f", money_value);
 						}
 						break;
 					default:
diff --git a/ext/pdo_firebird/config.w32 b/ext/pdo_firebird/config.w32
index 82ddf06..8234e48 100644
--- a/ext/pdo_firebird/config.w32
+++ b/ext/pdo_firebird/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32 212867 2006-05-11 21:43:59Z edink $
+// $Id: config.w32 305343 2010-11-14 22:40:30Z pajoye $
 // vim:ft=javascript
 
 ARG_WITH("pdo-firebird", "Firebird support for PDO", "no");
@@ -7,7 +7,9 @@ if (PHP_PDO_FIREBIRD != "no") {
 
 	if ((CHECK_LIB("fbclient_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
 			|| CHECK_LIB("gds32_ms.lib", "pdo_firebird", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_PDO_FIREBIRD)
-		) && CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_PDO_FIREBIRD", PHP_PHP_BUILD + "\\interbase\\include;" + PHP_PDO_FIREBIRD)) {
+		) && CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_PDO_FIREBIRD", 
+				PHP_PHP_BUILD + "\\include\\interbase;" + PHP_PHP_BUILD + "\\interbase\\include;" + PHP_PDO_FIREBIRD)
+		) {
 
 		EXTENSION("pdo_firebird", "pdo_firebird.c firebird_driver.c firebird_statement.c");
 	} else {
diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index db6bca1..b72bb9d 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: firebird_driver.c 293447 2010-01-12 12:46:54Z iliaa $ */
+/* $Id: firebird_driver.c 305416 2010-11-16 21:02:14Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -547,7 +547,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
 	pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
 
 	switch (attr) {
-		char tmp[200];
+		char tmp[512];
 		
 		case PDO_ATTR_AUTOCOMMIT:
 			ZVAL_LONG(val,dbh->auto_commit);
@@ -590,6 +590,10 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
 				ZVAL_STRING(val,tmp,1);
 				return 1;
 			}
+			
+		case PDO_ATTR_FETCH_TABLE_NAMES:
+			ZVAL_BOOL(val, H->fetch_table_names);
+			return 1;
 	}
 	return 0;
 }       
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 8c6bb83..aea7bd5 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: firebird_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: firebird_statement.c 305476 2010-11-18 01:24:00Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -90,6 +90,9 @@ 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;
+	static char info_count[] = {isc_info_sql_records};
+	char result[64];
 
 	do {
 		/* named or open cursors should be closed first */
@@ -103,6 +106,35 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
 			break;
 		}
 		
+		/* Determine how many rows have changed. In this case we are
+		 * only interested in rows changed, not rows retrieved. That
+		 * should be handled by the client when fetching. */
+		stmt->row_count = affected_rows;
+		
+		switch (S->statement_type) {
+			case isc_info_sql_stmt_insert:
+			case isc_info_sql_stmt_update:
+			case isc_info_sql_stmt_delete:
+			case isc_info_sql_stmt_exec_procedure:
+				if (isc_dsql_sql_info(H->isc_status, &S->stmt, sizeof ( info_count),
+					info_count, sizeof(result), result)) {
+					break;
+				}
+				if (result[0] == isc_info_sql_records) {
+					unsigned i = 3, result_size = isc_vax_integer(&result[1], 2);
+					while (result[i] != isc_info_end && i < result_size) {
+						short len = (short) isc_vax_integer(&result[i + 1], 2);
+						if (result[i] != isc_info_req_select_count) {
+							affected_rows += isc_vax_integer(&result[i + 3], len);
+						}
+						i += len + 3;
+					}
+					stmt->row_count = affected_rows;
+				}
+			default:
+				;
+		}
+
 		/* commit? */
 		if (stmt->dbh->auto_commit && isc_commit_retaining(H->isc_status, &H->tr)) {
 			break;
@@ -142,6 +174,7 @@ static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
  		if (S->statement_type == isc_info_sql_stmt_exec_procedure) {
  			S->exhausted = 1;
  		}
+		stmt->row_count++;
 		return 1;
 	}
 	return 0;
diff --git a/ext/pdo_firebird/tests/rowCount.phpt b/ext/pdo_firebird/tests/rowCount.phpt
new file mode 100644
index 0000000..1cb09e1
--- /dev/null
+++ b/ext/pdo_firebird/tests/rowCount.phpt
@@ -0,0 +1,48 @@
+--TEST--
+PDO_Firebird: rowCount
+--SKIPIF--
+<?php extension_loaded("pdo_firebird") or die("skip"); ?>
+--FILE--
+<?php /* $Id: rowCount.phpt 305476 2010-11-18 01:24:00Z felipe $ */
+
+require("testdb.inc");
+
+$dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die;
+
+@$dbh->exec('DROP TABLE testz');
+$dbh->exec('CREATE TABLE testz (A VARCHAR(10))');
+$dbh->exec("INSERT INTO testz VALUES ('A')");
+$dbh->exec("INSERT INTO testz VALUES ('A')");
+$dbh->exec("INSERT INTO testz VALUES ('B')");
+$dbh->commit();
+
+$query = "SELECT * FROM testz WHERE A = ?";
+
+$stmt = $dbh->prepare($query);
+$stmt->execute(array('A'));
+$rows = $stmt->fetch();
+$rows = $stmt->fetch();
+var_dump($stmt->fetch());
+var_dump($stmt->rowCount());
+
+$stmt = $dbh->prepare('UPDATE testZ SET A="A" WHERE A != ?');
+$stmt->execute(array('A'));
+var_dump($stmt->rowCount());
+$dbh->commit();
+
+$stmt = $dbh->prepare('DELETE FROM testz');
+$stmt->execute();
+var_dump($stmt->rowCount());
+
+$dbh->commit();
+
+$dbh->exec('DROP TABLE testz');
+
+unset($dbh);
+
+?>
+--EXPECT--
+bool(false)
+int(2)
+int(1)
+int(3)
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index f4a501f..9a390d2 100755
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: mysql_statement.c 299574 2010-05-21 11:09:28Z andrey $ */
+/* $Id: mysql_statement.c 304072 2010-10-05 09:58:15Z kalle $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -886,7 +886,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
 #endif
 	
 	add_assoc_zval(return_value, "flags", flags);
-	add_assoc_string(return_value, "table",(F->table?F->table:""), 1);
+	add_assoc_string(return_value, "table",(char *) (F->table?F->table:""), 1);
 	PDO_DBG_RETURN(SUCCESS);
 } /* }}} */
 
diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h
index d9728b0..cfe5774 100755
--- a/ext/pdo_mysql/php_pdo_mysql_int.h
+++ b/ext/pdo_mysql/php_pdo_mysql_int.h
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_mysql_int.h 294278 2010-01-31 20:00:36Z gwynne $ */
+/* $Id: php_pdo_mysql_int.h 304627 2010-10-22 15:46:26Z andrey $ */
 
 #ifndef PHP_PDO_MYSQL_INT_H
 #define PHP_PDO_MYSQL_INT_H
@@ -41,8 +41,8 @@
 #define PDO_DBG_INF_FMT(...) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log_va(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0)
 #define PDO_DBG_ERR_FMT(...) do { if (dbg_skip_trace == FALSE) PDO_MYSQL_G(dbg)->m->log_va(PDO_MYSQL_G(dbg), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0)
 #define PDO_DBG_ENTER(func_name) zend_bool dbg_skip_trace = TRUE; if (PDO_MYSQL_G(dbg)) dbg_skip_trace = !PDO_MYSQL_G(dbg)->m->func_enter(PDO_MYSQL_G(dbg), __LINE__, __FILE__, func_name, strlen(func_name));
-#define PDO_DBG_RETURN(value)	do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__); return (value); } while (0)
-#define PDO_DBG_VOID_RETURN		do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__); return; } while (0)
+#define PDO_DBG_RETURN(value)	do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__, 0); return (value); } while (0)
+#define PDO_DBG_VOID_RETURN		do { if (PDO_MYSQL_G(dbg)) PDO_MYSQL_G(dbg)->m->func_leave(PDO_MYSQL_G(dbg), __LINE__, __FILE__, 0); return; } while (0)
 
 #else
 #define PDO_DBG_ENABLED 0
diff --git a/ext/pdo_mysql/tests/bug_42499.phpt b/ext/pdo_mysql/tests/bug_42499.phpt
index dece019..4ce497e 100644
--- a/ext/pdo_mysql/tests/bug_42499.phpt
+++ b/ext/pdo_mysql/tests/bug_42499.phpt
@@ -27,7 +27,7 @@ $db = MySQLPDOTest::factory();
 function bug_42499($db) {
 
 	$db->exec('DROP TABLE IF EXISTS test');
-	$db->exec('CREATE TABLE test(id CHAR(1)); INSERT INTO test(id) VALUES ("a")');
+	$db->exec("CREATE TABLE test(id CHAR(1)); INSERT INTO test(id) VALUES ('a')");
 
 	$stmt = $db->query('SELECT id AS _id FROM test');
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
@@ -35,7 +35,7 @@ function bug_42499($db) {
 	// You must not use exec() to run statements that create a result set!
 	$db->exec('SELECT id FROM test');
 	// This will bail at you because you have not fetched the SELECT results: this is not a bug!
-	$db->exec('INSERT INTO test(id) VALUES ("b")');
+	$db->exec("INSERT INTO test(id) VALUES ('b')");
 
 }
 
diff --git a/ext/pdo_mysql/tests/bug_44454.phpt b/ext/pdo_mysql/tests/bug_44454.phpt
index 7ad7f85..89a4e2a 100644
--- a/ext/pdo_mysql/tests/bug_44454.phpt
+++ b/ext/pdo_mysql/tests/bug_44454.phpt
@@ -33,6 +33,10 @@ function bug_44454($db) {
 			}
 		}
 
+		$db->exec('DROP TABLE IF EXISTS test');
+		$db->exec('CREATE TABLE test(a INT, b INT, UNIQUE KEY idx_ab (a, b))');
+		$db->exec('INSERT INTO test(a, b) VALUES (1, 1)');
+
 	} catch (Exception $e) {
 		printf("... While error %s\n", $e->getMessage()); ;
 	}
@@ -79,7 +83,7 @@ Native Prepared Statements
 ... PDO  - array (
   0 => '23000',
   1 => 1062,
-  2 => 'Duplicate entry \'1-1\' for key 1',
+  2 => 'Duplicate entry \'1-1\' for key %s',
 )
 ... SELECT has returned 1 row...
 ... INSERT should fail...
@@ -87,7 +91,7 @@ Native Prepared Statements
 ... PDO  - array (
   0 => '23000',
   1 => 1062,
-  2 => 'Duplicate entry \'1-1\' for key 1',
+  2 => 'Duplicate entry \'1-1\' for key %s',
 )
 
 Emulated Prepared Statements
@@ -97,7 +101,7 @@ Emulated Prepared Statements
 ... PDO  - array (
   0 => '23000',
   1 => 1062,
-  2 => 'Duplicate entry \'1-1\' for key 1',
+  2 => 'Duplicate entry \'1-1\' for key %s',
 )
 ... SELECT has returned 1 row...
 ... INSERT should fail...
@@ -105,6 +109,6 @@ Emulated Prepared Statements
 ... PDO  - array (
   0 => '23000',
   1 => 1062,
-  2 => 'Duplicate entry \'1-1\' for key 1',
+  2 => 'Duplicate entry \'1-1\' for key %s',
 )
 done!
diff --git a/ext/pdo_mysql/tests/bug_pecl_12925.phpt b/ext/pdo_mysql/tests/bug_pecl_12925.phpt
index 1867868..dc6933d 100644
--- a/ext/pdo_mysql/tests/bug_pecl_12925.phpt
+++ b/ext/pdo_mysql/tests/bug_pecl_12925.phpt
@@ -17,10 +17,10 @@ function bug_pecl_1295($db) {
 
 	$db->exec('DROP TABLE IF EXISTS test');
 	$db->exec('CREATE TABLE test(id CHAR(1))');
-	$db->exec('INSERT INTO test(id) VALUES ("a")');
-	$stmt = $db->prepare('UPDATE test SET id = "b"');
+	$db->exec("INSERT INTO test(id) VALUES ('a')");
+	$stmt = $db->prepare("UPDATE test SET id = 'b'");
 	$stmt->execute();
-	$stmt = $db->prepare('UPDATE test SET id = "c"');
+	$stmt = $db->prepare("UPDATE test SET id = 'c'");
 	$stmt->execute();
 	$stmt = $db->prepare('SELECT id FROM test');
 	$stmt->execute();
diff --git a/ext/pdo_mysql/tests/mysql_pdo_test.inc b/ext/pdo_mysql/tests/mysql_pdo_test.inc
index 7367919..01c4cb9 100644
--- a/ext/pdo_mysql/tests/mysql_pdo_test.inc
+++ b/ext/pdo_mysql/tests/mysql_pdo_test.inc
@@ -38,7 +38,7 @@ class MySQLPDOTest extends PDOTest {
 
 		$db->exec('DROP TABLE IF EXISTS test');
 		$db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine);
-		$db->exec('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")');
+		$db->exec("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')");
 	}
 
 	static function getTableEngine() {
@@ -159,7 +159,7 @@ class MySQLPDOTest extends PDOTest {
 	}
 
 	static function dropTestTable($db = NULL) {
-		if (is_null($db)) 
+		if (is_null($db))
 			$db = self::factory();
 
 		$db->exec('DROP TABLE IF EXISTS test');
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
index b1e5507..9a73f1b 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_autocommit.phpt
@@ -57,7 +57,7 @@ $db = MySQLPDOTest::factory();
 		$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
 		$num = $row['_num'];
 
-		$db->query('INSERT INTO test(id, label) VALUES (100, "z")');
+		$db->query("INSERT INTO test(id, label) VALUES (100, 'z')");
 		$num++;
 		$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
 		if ($row['_num'] != $num)
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
index 618d9e6..8ce8af4 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
@@ -26,7 +26,7 @@ $db = MySQLPDOTest::factory();
 		var_dump($known[$default]);
 
 	// lets see what the default is...
-	if (!is_object($stmt = $db->query('SELECT id, id AS "ID_UPPER", label FROM test ORDER BY id ASC LIMIT 2')))
+	if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2")))
 		printf("[002] %s - %s\n",
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
@@ -48,7 +48,7 @@ $db = MySQLPDOTest::factory();
 		printf("[006] Cannot add column %s - %s\n",
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
-	if (!is_object($stmt = $db->query('SELECT id, id AS "ID_UPPER", label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2')))
+	if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2")))
 		printf("[007] %s - %s\n",
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
@@ -62,7 +62,7 @@ $db = MySQLPDOTest::factory();
 		printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
 			var_export($tmp, true));
 
-	if (!is_object($stmt = $db->query('SELECT id, label, MiXeD, MYUPPER, MYUPPER AS "lower" FROM test ORDER BY id ASC LIMIT 1')))
+	if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1")))
 		printf("[010] %s - %s\n",
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
@@ -76,12 +76,12 @@ $db = MySQLPDOTest::factory();
 		printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
 			var_export($tmp, true));
 
-	if (!is_object($stmt = $db->query('SELECT id, label, MiXeD, MYUPPER, id AS "ID" FROM test ORDER BY id ASC LIMIT 1')))
+	if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1")))
 		printf("[013] %s - %s\n",
 			var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
 
 	var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
-	
+
 	print "done!";
 ?>
 --CLEAN--
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
index cdc0b26..1820804 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt
@@ -24,11 +24,11 @@ MySQLPDOTest::skip();
 		printf("[003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n");
 
 	$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
-	$stmt = $db->query('SELECT NULL AS z, "" AS a, " " AS b, TRIM(" ") as c, " d" AS d, "' . chr(0) . ' e" AS e');
+	$stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
 	$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 0);
-	$stmt = $db->query('SELECT NULL AS z, "" AS a, " " AS b, TRIM(" ") as c, " d" AS d, "' . chr(0) . ' e" AS e');
+	$stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
 	var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
 	$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
@@ -43,7 +43,7 @@ MySQLPDOTest::skip();
 	$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
 
 	if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) &&
-		(false !== $db->exec('CREATE PROCEDURE p() BEGIN SELECT NULL as z, "" AS a, " " AS b, TRIM(" ") as c, " d" AS d, " e" AS e; END;'))) {
+		(false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) {
 		// requires MySQL 5+
 		$stmt = $db->prepare('CALL p()');
 		$stmt->execute();
diff --git a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt
index 558ab23..3c21d0f 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt
@@ -27,7 +27,7 @@ $db = MySQLPDOTest::factory();
 		printf("[003] Did we change it from '%s' to '%s'?\n", $info, $info);
 
 	// lets hope we always run this in the same second as we did run the server info request...
-	if (!$stmt = $db->query('SHOW STATUS LIKE "%uptime%"'))
+	if (!$stmt = $db->query("SHOW STATUS LIKE '%uptime%'"))
 		printf("[004] Cannot run SHOW STATUS, [%s]\n", $db->errorCode());
 	else {
 		if (!$row = $stmt->fetch(PDO::FETCH_NUM))
diff --git a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
index 8871a31..ac9f8a3 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_begintransaction.phpt
@@ -59,7 +59,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	if (!$db->beginTransaction())
 		printf("[011] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
 
-	$db->exec(sprintf('INSERT INTO test(id, label) VALUES (%d, "z")', $row['id']));
+	$db->exec(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z')", $row['id']));
 
 	if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id']))))
 		printf("[012] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
@@ -166,7 +166,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 		printf("[035] Cannot start a transaction, [%s] [%s]\n",
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 
-	if (0 == $db->exec('INSERT INTO test(id, label) VALUES (1, "a")'))
+	if (0 == $db->exec("INSERT INTO test(id, label) VALUES (1, 'a')"))
 		printf("[036] Cannot insert data, [%s] [%s]\n",
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
index e213f66..f3cd530 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_commit.phpt
@@ -37,7 +37,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 		if (true !== ($tmp = $db->beginTransaction()))
 			printf("[004] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
 
-		$db->exec('INSERT INTO test(id, label) VALUES (100, "z")');
+		$db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
 
 		if (true !== ($tmp = $db->commit()))
 			printf("[005] No commit allowed? [%s] %s\n",
@@ -59,7 +59,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 		if (true !== ($tmp = $db->beginTransaction()))
 			printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
 
-		$db->exec('INSERT INTO test(id, label) VALUES (100, "z")');
+		$db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
 		if (true !== ($tmp = $db->commit()))
 			printf("[008] No commit allowed? [%s] %s\n",
 				$db->errorCode(), implode(' ', $db->errorInfo()));
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
index 381a2b5..2a0f527 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec.phpt
@@ -38,14 +38,14 @@ MySQLPDOTest::skip();
 
 		exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0);
 		exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
-		exec_and_count(4, $db, 'INSERT INTO test(id, col1) VALUES (1, "a")', 1);
-		exec_and_count(5, $db, 'INSERT INTO test(id, col1) VALUES (2, "b"), (3, "c")', 2);
-		exec_and_count(6, $db, 'UPDATE test SET id = 4 WHERE id = 3', 1);
-		exec_and_count(7, $db, 'INSERT INTO test(id, col1) VALUES (1, "d") ON DUPLICATE KEY UPDATE id = 3', 2);
-		exec_and_count(8, $db, 'UPDATE test SET id = 5 WHERE id = 5', 0);
-		exec_and_count(9, $db, 'INSERT INTO test(id, col1) VALUES (5, "e") ON DUPLICATE KEY UPDATE id = 6', 1);
-		exec_and_count(10, $db, 'REPLACE INTO test(id, col1) VALUES (5, "f")', 2);
-		exec_and_count(11, $db, 'REPLACE INTO test(id, col1) VALUES (6, "g")', 1);
+		exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1);
+		exec_and_count(5, $db, "INSERT INTO test(id, col1) VALUES (2, 'b'), (3, 'c')", 2);
+		exec_and_count(6, $db, "UPDATE test SET id = 4 WHERE id = 3", 1);
+		exec_and_count(7, $db, "INSERT INTO test(id, col1) VALUES (1, 'd') ON DUPLICATE KEY UPDATE id = 3", 2);
+		exec_and_count(8, $db, "UPDATE test SET id = 5 WHERE id = 5", 0);
+		exec_and_count(9, $db, "INSERT INTO test(id, col1) VALUES (5, 'e') ON DUPLICATE KEY UPDATE id = 6", 1);
+		exec_and_count(10, $db, "REPLACE INTO test(id, col1) VALUES (5, 'f')", 2);
+		exec_and_count(11, $db, "REPLACE INTO test(id, col1) VALUES (6, 'g')", 1);
 		exec_and_count(12, $db, 'DELETE FROM test WHERE id > 2', 4);
 		exec_and_count(13, $db, 'DROP TABLE test', 0);
 		exec_and_count(14, $db, 'SET @myvar = 1', 0);
@@ -54,7 +54,7 @@ MySQLPDOTest::skip();
 		printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
 
 		exec_and_count(36, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
-		exec_and_count(37, $db, 'INSERT INTO test(id, col1) VALUES (1, "a")', 1);
+		exec_and_count(37, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1);
 		// Results may vary. Typically you will get 1. But the MySQL 5.1 manual states: Truncation operations do not return the number of deleted rows.
 		// Don't rely on any return value!
 		exec_and_count(38, $db, 'TRUNCATE TABLE test', NULL);
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
index 1310c0e..37de557 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
@@ -57,7 +57,7 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 		exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0);
 		exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
 
-		$stmt = $db->query('SHOW VARIABLES LIKE "secure_file_priv"');
+		$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
 		if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
 			$filename = $row['value'] . DIRECTORY_SEPARATOR  . "pdo_mysql_exec_load_data.csv";
 		} else {
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
index ef85fab..d0e0ffc 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_select.phpt
@@ -38,19 +38,19 @@ MySQLPDOTest::skip();
 
 		exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0);
 		exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
-		exec_and_count(4, $db, 'INSERT INTO test(id, col1) VALUES (1, "a")', 1);
+		exec_and_count(4, $db, "INSERT INTO test(id, col1) VALUES (1, 'a')", 1);
 		// question is: will the result set be cleaned up, will it be possible to run more queries on the line?
 		// buffered or unbuffered does not matter!
 		$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
 		exec_and_count(5, $db, 'SELECT id FROM test', 0);
-		exec_and_count(6, $db, 'INSERT INTO test(id, col1) VALUES (2, "b")', 1);
+		exec_and_count(6, $db, "INSERT INTO test(id, col1) VALUES (2, 'b')", 1);
 
 	} catch (PDOException $e) {
 		printf("[001] %s, [%s] %s\n",
 			$e->getMessage(),
 			$db->errorCode(), implode(' ', $db->errorInfo()));
 	}
-	
+
 	print "done!";
 ?>
 --CLEAN--
@@ -61,5 +61,5 @@ $db = MySQLPDOTest::factory();
 ?>
 --EXPECTF--
 Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d
-[006] Expecting '1'/integer got ''/boolean when running 'INSERT INTO test(id, col1) VALUES (2, "b")', [HY000] HY000 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
+[006] Expecting '1'/integer got ''/boolean when running 'INSERT INTO test(id, col1) VALUES (2, 'b')', [HY000] HY000 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
 done!
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_interface.phpt b/ext/pdo_mysql/tests/pdo_mysql_interface.phpt
index 00c282b..9e13908 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_interface.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_interface.phpt
@@ -14,20 +14,21 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	$db = MySQLPDOTest::factory();
 
 	$expected = array(
-		'__construct'					=> true,
-		'prepare' 						=> true,
-		'beginTransaction'		=> true,
+		'__construct'							=> true,
+		'prepare' 							=> true,
+		'beginTransaction'						=> true,
 		'commit'							=> true,
-		'rollBack'						=> true,
-		'setAttribute'				=> true,
+		'rollBack'							=> true,
+		'setAttribute'							=> true,
 		'exec'								=> true,
 		'query'								=> true,
-		'lastInsertId'				=> true,
-		'errorCode'						=> true,
-		'errorInfo'						=> true,
-		'getAttribute'				=> true,
+		'lastInsertId'							=> true,
+		'errorCode'							=> true,
+		'errorInfo'							=> true,
+		'getAttribute'							=> true,
 		'quote'								=> true,
-		'__wakeup'						=> true,
+		'inTransaction'							=> true,
+		'__wakeup'							=> true,
 		'__sleep'							=> true,
 		'getAvailableDrivers'	=> true,
 	);
@@ -55,4 +56,4 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 
 	print "done!";
 --EXPECT--
-done!
\ No newline at end of file
+done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt
index 2bb5573..313b20d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_last_insert_id.phpt
@@ -34,7 +34,7 @@ $db = MySQLPDOTest::factory();
 			printf("[005] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp));
 
 		// no auto increment column
-		$db->exec('INSERT INTO test(id, col1) VALUES (100, "a")');
+		$db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')");
 		if ('0' !== ($tmp = $db->lastInsertId()))
 			printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp));
 
@@ -43,17 +43,17 @@ $db = MySQLPDOTest::factory();
 			printf("[006] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp));
 
 		// duplicate key
-		@$db->exec('INSERT INTO test(id, col1) VALUES (100, "a")');
+		@$db->exec("INSERT INTO test(id, col1) VALUES (100, 'a')");
 		if ('0' !== ($tmp = $db->lastInsertId()))
 			printf("[007] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp));
 
-		$db->exec('INSERT INTO test(id, col1) VALUES (101, "b")');
+		$db->exec("INSERT INTO test(id, col1) VALUES (101, 'b')");
 		if ('101' !== ($tmp = $db->lastInsertId()))
 			printf("[008] Expecting '0'/string got '%s'/%s", var_export($tmp, true), gettype($tmp));
 
 		$db->exec('ALTER TABLE test MODIFY col1 CHAR(10) UNIQUE');
 		// replace = delete + insert -> new auto increment value
-		$db->exec('REPLACE INTO test(col1) VALUES ("b")');
+		$db->exec("REPLACE INTO test(col1) VALUES ('b')");
 		$next_id = (int)$db->lastInsertId();
 
 		if ($next_id <= 101)
@@ -67,7 +67,7 @@ $db = MySQLPDOTest::factory();
 				$last_id, $next_id);
 		}
 
-		$db->exec('INSERT INTO test(col1) VALUES ("c"), ("d"), ("e")');
+		$db->exec("INSERT INTO test(col1) VALUES ('c'), ('d'), ('e')");
 		$next_id = (int)$db->lastInsertId();
 		if ($next_id <= $last_id)
 			printf("[011] Expecting at least %d, got %d\n", $last_id + 1, $next_id);
@@ -91,7 +91,7 @@ $db = MySQLPDOTest::factory();
 			$row = $stmt->fetch(PDO::FETCH_ASSOC);
 			$last_id = $row['_last_id'];
 
-			$db->exec('INSERT INTO test(col1) VALUES ("z")');
+			$db->exec("INSERT INTO test(col1) VALUES ('z')");
 			$next_id = (int)$db->lastInsertId();
 			if ($next_id < ($last_id + $inc))
 				printf("[012] Expecting at least %d, got %d\n", $last_id + $inc, $next_id);
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
index 4447146..b2db0d9 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated.phpt
@@ -98,12 +98,12 @@ $db = MySQLPDOTest::factory();
 
 		prepex(5, $db, 'DROP TABLE IF EXISTS test');
 		prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		prepex(7, $db, 'INSERT INTO test(id, label) VALUES(1, ":placeholder")');
+		prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')");
 		$stmt = prepex(8, $db, 'SELECT label FROM test');
 		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
 		prepex(9, $db, 'DELETE FROM test');
-		prepex(10, $db, 'INSERT INTO test(id, label) VALUES(1, ":placeholder")',
+		prepex(10, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')",
 			array(':placeholder' => 'first row'));
 		$stmt = prepex(11, $db, 'SELECT label FROM test');
 
@@ -200,12 +200,12 @@ $db = MySQLPDOTest::factory();
 		// and now, the same with anonymous placeholders...
 		prepex(45, $db, 'DROP TABLE IF EXISTS test');
 		prepex(46, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		prepex(47, $db, 'INSERT INTO test(id, label) VALUES(1, "?")');
+		prepex(47, $db, "INSERT INTO test(id, label) VALUES(1, '?')");
 		$stmt = prepex(48, $db, 'SELECT label FROM test');
 		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
 		prepex(49, $db, 'DELETE FROM test');
-		prepex(50, $db, 'INSERT INTO test(id, label) VALUES(1, "?")',
+		prepex(50, $db, "INSERT INTO test(id, label) VALUES(1, '?')",
 			array('first row'));
 		$stmt = prepex(51, $db, 'SELECT label FROM test');
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt
index c382025..c6b299e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_anonymous.phpt
@@ -20,7 +20,7 @@ $db = MySQLPDOTest::factory();
 		$db->exec('DROP TABLE IF EXISTS test');
 		$db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
 
-		$stmt = $db->prepare('INSERT INTO test(id, label) VALUES(1, "?")');
+		$stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')");
 		// you can bind as many values as you want no matter if they can be replaced or not
 		$stmt->execute(array('first row'));
 		if ('00000' !== $stmt->errorCode())
@@ -39,7 +39,7 @@ $db = MySQLPDOTest::factory();
 			printf("[004] Unable to switch off emulated prepared statements, test will fail\n");
 
 		$db->exec('DELETE FROM test');
-		$stmt = $db->prepare('INSERT INTO test(id, label) VALUES(1, "?")');
+		$stmt = $db->prepare("INSERT INTO test(id, label) VALUES(1, '?')");
 		// you can bind as many values as you want no matter if they can be replaced or not
 		$stmt->execute(array('first row'));
 		if ('00000' !== $stmt->errorCode())
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt
index e8f7d39..3a77d5e 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_emulated_placeholder_everywhere.phpt
@@ -20,7 +20,7 @@ MySQLPDOTest::skip();
 
 		$db->exec('DROP TABLE IF EXISTS test');
 		$db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		$db->exec('INSERT INTO test(id, label) VALUES (1, "row1")');
+		$db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')");
 
 		// So, what will happen? More placeholder but values and
 		// placeholders in interesting places...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
index b8b77ff..37d9cbd 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
@@ -60,7 +60,7 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 		exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0);
 		exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
 
-		$stmt = $db->query('SHOW VARIABLES LIKE "secure_file_priv"');
+		$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
 		if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
 			$filename = $row['value'] . DIRECTORY_SEPARATOR  . "pdo_mysql_exec_load_data.csv";
 		} else {
@@ -82,7 +82,7 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 		}
 
 		// Check the line
-		$stmt = $db->query('SELECT 1 as "one"');
+		$stmt = $db->query("SELECT 1 as 'one'");
 		if ($stmt->errorCode() != '0000') {
 			printf("[005] [%d] %s\n", $stmt->errorCode(), var_export($stmt->errorInfo(), true));
 		} else {
@@ -100,7 +100,7 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
 			implode(' ', $db->errorInfo()),
 			(isset($stmt)) ? implode(' ', $stmt->errorInfo()) : 'N/A');
 	}
-	
+
 	print "done!";
 ?>
 --CLEAN--
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
index b9027c8..43006c6 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native.phpt
@@ -119,7 +119,7 @@ $db = MySQLPDOTest::factory();
 
 		prepex(5, $db, 'DROP TABLE IF EXISTS test');
 		prepex(6, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		prepex(7, $db, 'INSERT INTO test(id, label) VALUES(1, ":placeholder")');
+		prepex(7, $db, "INSERT INTO test(id, label) VALUES(1, ':placeholder')");
 		$stmt = prepex(8, $db, 'SELECT label FROM test ORDER BY id ASC');
 		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
@@ -183,8 +183,8 @@ $db = MySQLPDOTest::factory();
 		}
 
 		$db->exec('DELETE FROM test');
-		$db->exec('INSERT INTO test(id, label) VALUES (1, "row1")');
-		$db->exec('INSERT INTO test(id, label) VALUES (2, "row2")');
+		$db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')");
+		$db->exec("INSERT INTO test(id, label) VALUES (2, 'row2')");
 
 		$sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = :placeholder)",
 			$db->quote('%ro%'));
@@ -201,7 +201,7 @@ $db = MySQLPDOTest::factory();
 		// and now, the same with anonymous placeholders...
 		prepex(33, $db, 'DROP TABLE IF EXISTS test');
 		prepex(34, $db, sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		prepex(35, $db, 'INSERT INTO test(id, label) VALUES(1, "?")');
+		prepex(35, $db, "INSERT INTO test(id, label) VALUES(1, '?')");
 		$stmt = prepex(36, $db, 'SELECT label FROM test');
 		var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt
index 8c367af..42c3d07 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_clear_error.phpt
@@ -23,7 +23,7 @@ $db = MySQLPDOTest::factory();
 			printf("[002] Unable to turn on emulated prepared statements\n");
 
 		// INSERT a single row
-		$db->exec('INSERT INTO test(id, label) VALUES (1, "row1")');
+		$db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')");
 
 		$stmt = $db->prepare('SELECT unknown_column FROM test WHERE id > :placeholder ORDER BY id ASC');
 		$stmt->execute(array(':placeholder' => 0));
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt
index c9d122a..e382dff 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_dup_named_placeholder.phpt
@@ -60,7 +60,7 @@ $db = MySQLPDOTest::factory();
 		//
 
 		$db->exec('DELETE FROM test');
-		$db->exec('INSERT INTO test (id, label1, label2) VALUES (1, "row1", "row2")');
+		$db->exec("INSERT INTO test (id, label1, label2) VALUES (1, 'row1', 'row2')");
 		$sql = "SELECT id, label1 FROM test WHERE id = :placeholder AND label1 = (SELECT label1 AS 'SELECT' FROM test WHERE id = :placeholder)";
 
 		// emulated...
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt
index c4a74ea..530170d 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_named_placeholder.phpt
@@ -22,7 +22,7 @@ $db = MySQLPDOTest::factory();
 			printf("[002] Unable to turn off emulated prepared statements\n");
 
 		// INSERT a single row
-		$stmt = $db->prepare('INSERT INTO test(id, label) VALUES (100, ":placeholder")');
+		$stmt = $db->prepare("INSERT INTO test(id, label) VALUES (100, ':placeholder')");
 
 		// Yes, there is no placeholder to bind to and named placeholder
 		// do not work with MySQL native PS, but lets see what happens!
@@ -45,7 +45,7 @@ $db = MySQLPDOTest::factory();
 			printf("[004] Unable to turn on emulated prepared statements\n");
 
 		// Note that the "named placeholder" is enclosed by double quotes.
-		$stmt = $db->prepare('INSERT INTO test(id, label) VALUES(101, ":placeholder")');
+		$stmt = $db->prepare("INSERT INTO test(id, label) VALUES(101, ':placeholder')");
 		// No replacement shall be made
 		$stmt->execute(array(':placeholder' => 'row1'));
 		// Again, I'd like to see an error message
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt
index 0f8c888..dbff9c4 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_native_placeholder_everywhere.phpt
@@ -18,7 +18,7 @@ $db = MySQLPDOTest::factory();
 
 		$db->exec('DROP TABLE IF EXISTS test');
 		$db->exec(sprintf('CREATE TABLE test(id INT, label CHAR(255)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
-		$db->exec('INSERT INTO test(id, label) VALUES (1, "row1")');
+		$db->exec("INSERT INTO test(id, label) VALUES (1, 'row1')");
 
 		$stmt = $db->prepare('SELECT ?, id, label FROM test WHERE ? = ? ORDER BY id ASC');
 		$stmt->execute(array('id', 'label', 'label'));
diff --git a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
index 193b1a1..c0737b2 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_rollback.phpt
@@ -20,7 +20,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 	$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
 	$num = $row['_num'];
 
-	$db->query('INSERT INTO test(id, label) VALUES (100, "z")');
+	$db->query("INSERT INTO test(id, label) VALUES (100, 'z')");
 	$num++;
 	$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
 	if ($row['_num'] != $num)
@@ -33,7 +33,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
 		printf("[002] ROLLBACK has failed\n");
 
 	$db->beginTransaction();
-	$db->query('INSERT INTO test(id, label) VALUES (100, "z")');
+	$db->query("INSERT INTO test(id, label) VALUES (100, 'z')");
 	$db->query('DROP TABLE IF EXISTS test2');
 	$db->query('CREATE TABLE test2(id INT)');
 	$num++;
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
index 85985dd..54b433f 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_columncount.phpt
@@ -22,7 +22,7 @@ $db = MySQLPDOTest::factory();
 		if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
 			printf("[002] Unable to turn on emulated prepared statements\n");
 
-		$stmt = $db->prepare('SELECT id, label, "?" as foo FROM test');
+		$stmt = $db->prepare("SELECT id, label, '?' as foo FROM test");
 		$stmt->execute();
 		var_dump($stmt->columnCount());
 
@@ -40,7 +40,7 @@ $db = MySQLPDOTest::factory();
 		if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
 			printf("[004] Unable to turn off emulated prepared statements\n");
 
-		$stmt = $db->prepare('SELECT id, label, "?" as foo, "TODO - Stored Procedure" as bar FROM test');
+		$stmt = $db->prepare("SELECT id, label, '?' as foo, 'TODO - Stored Procedure' as bar FROM test");
 		$stmt->execute();
 		var_dump($stmt->columnCount());
 
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt
index 928e90d..fa4b122 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_non_select.phpt
@@ -70,7 +70,7 @@ MySQLPDOTest::skip();
 			printf("[011] Unable to turn off emulated prepared statements\n");
 
 		$native_support = 'no';
-		if ($db->exec('PREPARE mystmt FROM "DESCRIBE test id"')) {
+		if ($db->exec("PREPARE mystmt FROM 'DESCRIBE test id'")) {
 			$native_support = 'yes';
 			$db->exec('DEALLOCATE PREPARE mystmt');
 		}
@@ -104,7 +104,7 @@ MySQLPDOTest::skip();
 
 
 		$native_support = 'no';
-		if ($db->exec('PREPARE mystmt FROM "SHOW ENGINES"')) {
+		if ($db->exec("PREPARE mystmt FROM 'SHOW ENGINES'")) {
 			$native_support = 'yes';
 			$db->exec('DEALLOCATE PREPARE mystmt');
 		}
@@ -137,7 +137,7 @@ MySQLPDOTest::skip();
 				var_export($show_native, true));
 
 		$native_support = 'no';
-		if ($db->exec('PREPARE mystmt FROM "EXPLAIN SELECT id FROM test"')) {
+		if ($db->exec("PREPARE mystmt FROM 'EXPLAIN SELECT id FROM test'")) {
 			$native_support = 'yes';
 			$db->exec('DEALLOCATE PREPARE mystmt');
 		}
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
index e9b231c..a935e1a 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetch_serialize_simple.phpt
@@ -45,7 +45,7 @@ if (version_compare(PHP_VERSION, '5.1.0', '<'))
 		printf("\nAnd now magic PDO using fetchAll(PDO::FETCH_CLASS|PDO::FETCH_SERIALIZE)...\n");
 		$db->exec('DROP TABLE IF EXISTS test');
 		$db->exec(sprintf('CREATE TABLE test(myobj BLOB) ENGINE=%s', MySQLPDOTest::getTableEngine()));
-		$db->exec('INSERT INTO test(myobj) VALUES ("Data fetched from DB to be given to unserialize()")');
+		$db->exec("INSERT INTO test(myobj) VALUES ('Data fetched from DB to be given to unserialize()')");
 
 		$stmt = $db->prepare('SELECT myobj FROM test');
 		$stmt->execute();
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
index 067f9ca..2e278b1 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_fetchobject.phpt
@@ -6,6 +6,16 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
 MySQLPDOTest::skip();
 $db = MySQLPDOTest::factory();
+
+try {
+	$query = "SELECT '', NULL, \"\" FROM DUAL";
+	$stmt = $db->prepare($query);
+	$ok = @$stmt->execute();
+} catch (PDOException $e) {
+	die("skip: Test cannot be run with SQL mode ANSI");
+}
+if (!$ok)
+	die("skip: Test cannot be run with SQL mode ANSI");
 ?>
 --FILE--
 <?php
@@ -15,7 +25,6 @@ MySQLPDOTest::createTestTable($db);
 
 try {
 
-	// default settings
 	$query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3";
 	$stmt = $db->prepare($query);
 
@@ -39,7 +48,8 @@ try {
 			$this->not_a_magic_one();
 			printf("myclass::__set(%s, -%s-) %d\n",
 				$prop, var_export($value, true), $this->set_calls, self::$static_set_calls);
-			$this->{$prop} = $value;
+			if ("" != $prop)
+				$this->{$prop} = $value;
 		}
 
 		// NOTE: PDO can call regular methods prior to calling __construct()
@@ -96,4 +106,4 @@ object(myclass)#%d (4) {
   [%u|b%"null"]=>
   NULL
 }
-done!
\ No newline at end of file
+done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt
index 19ae195..0fef334 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt
@@ -76,7 +76,7 @@ try {
 			return true;
 		}
 
-		if (!$db->exec(sprintf('INSERT INTO test(id, label) VALUES (1, "%s")', $value))) {
+		if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) {
 			printf("[%03d] + 1] Insert failed, %d - %s\n", $offset,
 				$db->errorCode(), var_export($db->errorInfo(), true));
 			return false;
@@ -141,6 +141,11 @@ try {
 		return true;
 	}
 
+	$stmt = $db->prepare('SELECT @@sql_mode AS _mode');
+	$stmt->execute();
+	$row = $stmt->fetch(PDO::FETCH_ASSOC);
+	$real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true;
+
 	$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
 	$is_mysqlnd = MySQLPDOTest::isPDOMySQLnd();
 	test_meta($db, 20, 'BIT(8)', 1, NULL, ($is_mysqlnd) ? PDO::PARAM_INT : PDO::PARAM_STR);
@@ -160,10 +165,10 @@ try {
 	test_meta($db, 120, 'BIGINT', -9223372036854775808, 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR);
 	test_meta($db, 130, 'BIGINT UNSIGNED', 18446744073709551615, 'LONGLONG', ($is_mysqlnd) ? ((PHP_INT_SIZE == 4) ? PDO::PARAM_STR : PDO::PARAM_INT) : PDO::PARAM_STR);
 
-	test_meta($db, 130, 'REAL', -1.01, 'DOUBLE', PDO::PARAM_STR);
-	test_meta($db, 140, 'REAL UNSIGNED', 1.01, 'DOUBLE', PDO::PARAM_STR);
-	test_meta($db, 150, 'REAL ZEROFILL', -1.01, 'DOUBLE', PDO::PARAM_STR);
-	test_meta($db, 160, 'REAL UNSIGNED ZEROFILL', 1.01, 'DOUBLE', PDO::PARAM_STR);
+	test_meta($db, 130, 'REAL', -1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
+	test_meta($db, 140, 'REAL UNSIGNED', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
+	test_meta($db, 150, 'REAL ZEROFILL', -1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
+	test_meta($db, 160, 'REAL UNSIGNED ZEROFILL', 1.01, ($real_as_float) ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
 
 	test_meta($db, 170, 'DOUBLE', -1.01, 'DOUBLE', PDO::PARAM_STR);
 	test_meta($db, 180, 'DOUBLE UNSIGNED', 1.01, 'DOUBLE', PDO::PARAM_STR);
diff --git a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
index c83130d..3595631 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_subclass.phpt
@@ -81,7 +81,7 @@ $db = MySQLPDOTest::factory();
 $db->exec('DROP TABLE IF EXISTS test');
 ?>
 --EXPECTF--
-__construct('%S', '%S', '%S')
+__construct('%S', '%S', %s)
 exec('DROP TABLE IF EXISTS test')
 exec('CREATE TABLE test(id INT)')
 exec('INSERT INTO test(id) VALUES (1), (2)')
diff --git a/ext/pdo_mysql/tests/pdo_mysql_types.phpt b/ext/pdo_mysql/tests/pdo_mysql_types.phpt
index 3629ab9..22c6b66 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_types.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_types.phpt
@@ -103,8 +103,8 @@ MySQLPDOTest::skip();
 	test_type($db, 80, 'MEDIUMINT', -8388608, ($is_mysqlnd) ? -8388608 : '-8388608');
 	test_type($db, 90, 'MEDIUMINT UNSIGNED', 16777215, ($is_mysqlnd) ? 16777215 : '16777215');
 
-	test_type($db, 100, 'INT', -2147483648, 
-		($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (double)-2147483648) : '-2147483648', 
+	test_type($db, 100, 'INT', -2147483648,
+		($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? (int)-2147483648 : (double)-2147483648) : '-2147483648',
 		NULL, ($is_mysqlnd) ? 'integer' : NULL);
 
 	test_type($db, 110, 'INT UNSIGNED', 4294967295, ($is_mysqlnd) ? ((PHP_INT_SIZE > 4) ? 4294967295 : '4294967295') : '4294967295');
diff --git a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
index 7c0ec37..f97bd1b 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_types_zerofill.phpt
@@ -91,9 +91,14 @@ MySQLPDOTest::skip();
 	$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
 	$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
 
+	$stmt = $db->prepare('SELECT @@sql_mode AS _mode');
+	$stmt->execute();
+	$row = $stmt->fetch(PDO::FETCH_ASSOC);
+	$real_as_float = (false === stristr($row['_mode'], "REAL_AS_FLOAT")) ? false : true;
+
 	test_type($db, 100, 'REAL ZEROFILL', -1.01, NULL, '/^[0]*0$/');
-	test_type($db, 110, 'REAL ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/');
-	test_type($db, 120, 'REAL UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/');
+	test_type($db, 110, 'REAL ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\.0.*$/' : '/^[0]*1\.01$/');
+	test_type($db, 120, 'REAL UNSIGNED ZEROFILL', 1.01, NULL, ($real_as_float) ? '/^[0]*1\..*$/' : '/^[0]*1\.01$/');
 
 	test_type($db, 130, 'DOUBLE ZEROFILL', -1.01, NULL, '/^[0]*0$/');
 	test_type($db, 140, 'DOUBLE ZEROFILL', 1.01, NULL, '/^[0]*1\.01$/');
diff --git a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt
index b21f1b7..372ccec 100644
--- a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt
+++ b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt
@@ -17,7 +17,7 @@ echo "ATTR_CLIENT_VERSION: ";
 $cv = $dbh->getAttribute(PDO::ATTR_CLIENT_VERSION);
 var_dump($cv);
 
-$s = split("\.", $cv);
+$s = explode(".", $cv);
 if ($s[0] >= 10 && count($s) > 1 && $s[1] >= 2) {
 	if (count($s) != 5) {
 		echo "Wrong number of values in array\nVersion was: ";
diff --git a/ext/pdo_pgsql/tests/bug36727.phpt b/ext/pdo_pgsql/tests/bug36727.phpt
index f1b906b..34d14db 100644
--- a/ext/pdo_pgsql/tests/bug36727.phpt
+++ b/ext/pdo_pgsql/tests/bug36727.phpt
@@ -19,6 +19,6 @@ var_dump($stmt->bindValue(':test', 1, PDO::PARAM_INT));
 echo "Done\n";
 ?>
 --EXPECTF--
-Warning: PDOStatement::bindValue(): SQLSTATE[HY093]: Invalid parameter number: :test in %s/bug36727.php on line %d
+Warning: PDOStatement::bindValue(): SQLSTATE[HY093]: Invalid parameter number: :test in %sbug36727.php on line %d
 bool(false)
 Done
\ No newline at end of file
diff --git a/ext/pdo_sqlite/tests/bug52487.phpt b/ext/pdo_sqlite/tests/bug52487.phpt
new file mode 100644
index 0000000..fc65bd3
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug52487.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #52487 (PDO::FETCH_INTO leaks memory)
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+$stmt = $db->prepare("select 1 as attr");
+for ($i = 0; $i < 10; $i++) {
+	$stmt->setFetchMode(PDO::FETCH_INTO, new stdClass);
+}
+
+print "ok\n";
+
+?>
+--EXPECT--
+ok
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index af8988e..ca2d0f9 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c 298840 2010-05-01 18:27:42Z geissert $ */
+/* $Id: pgsql.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include <stdlib.h>
 
@@ -3339,6 +3339,10 @@ PHP_FUNCTION(pg_lo_import)
 		WRONG_PARAM_COUNT;
 	}
 
+	if (strlen(file_in) != name_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) &&(!php_checkuid(file_in, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
@@ -3476,6 +3480,10 @@ PHP_FUNCTION(pg_lo_export)
 		RETURN_FALSE;
 	}
 
+	if (strlen(file_out) != name_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) &&(!php_checkuid(file_out, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
@@ -5930,7 +5938,7 @@ PHP_FUNCTION(pg_insert)
 }
 /* }}} */
 
-static inline int build_assignment_string(smart_str *querystr, HashTable *ht, const char *pad, int pad_len TSRMLS_DC)
+static inline int build_assignment_string(smart_str *querystr, HashTable *ht, int where_cond, const char *pad, int pad_len TSRMLS_DC)
 {
 	HashPosition pos;
 	uint fld_len;
@@ -5949,7 +5957,11 @@ static inline int build_assignment_string(smart_str *querystr, HashTable *ht, co
 			return -1;
 		}
 		smart_str_appendl(querystr, fld, fld_len - 1);
-		smart_str_appendc(querystr, '=');
+		if (where_cond && Z_TYPE_PP(val) == IS_STRING && !strcmp(Z_STRVAL_PP(val), "NULL")) {
+			smart_str_appends(querystr, " IS ");
+		} else {
+			smart_str_appendc(querystr, '=');
+		}
 		
 		switch(Z_TYPE_PP(val)) {
 			case IS_STRING:
@@ -6011,12 +6023,12 @@ PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *var
 	smart_str_appends(&querystr, table);
 	smart_str_appends(&querystr, " SET ");
 
-	if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), ",", 1 TSRMLS_CC))
+	if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), 0, ",", 1 TSRMLS_CC))
 		goto cleanup;
 	
 	smart_str_appends(&querystr, " WHERE ");
 	
-	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC))
+	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC))
 		goto cleanup;
 
 	smart_str_appendc(&querystr, ';');	
@@ -6112,7 +6124,7 @@ PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids
 	smart_str_appends(&querystr, table);
 	smart_str_appends(&querystr, " WHERE ");
 
-	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC))
+	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC))
 		goto cleanup;
 
 	smart_str_appendc(&querystr, ';');
@@ -6251,7 +6263,7 @@ PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids
 	smart_str_appends(&querystr, table);
 	smart_str_appends(&querystr, " WHERE ");
 
-	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC))
+	if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC))
 		goto cleanup;
 
 	smart_str_appendc(&querystr, ';');
diff --git a/ext/pgsql/tests/bug47199.phpt b/ext/pgsql/tests/bug47199.phpt
new file mode 100644
index 0000000..5bfac0b
--- /dev/null
+++ b/ext/pgsql/tests/bug47199.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Bug #47199 (pg_delete fails on NULL)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('config.inc');
+
+$dbh = pg_connect($conn_str);
+$tbl_name = 'test_47199';
+ at pg_query("DROP TABLE $tbl_name");
+pg_query("CREATE TABLE $tbl_name (null_field INT, not_null_field INT NOT NULL)");
+
+pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 1));
+pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 2));
+
+var_dump(pg_fetch_all(pg_query('SELECT * FROM '. $tbl_name)));
+
+$query = pg_delete($dbh, $tbl_name, array('null_field' => NULL,'not_null_field' => 2), PGSQL_DML_STRING|PGSQL_DML_EXEC);
+
+echo $query, "\n";
+
+$query = pg_update($dbh, $tbl_name, array('null_field' => NULL, 'not_null_field' => 0), array('not_null_field' => 1, 'null_field' => ''), PGSQL_DML_STRING|PGSQL_DML_EXEC);
+
+echo $query, "\n";
+
+var_dump(pg_fetch_all(pg_query('SELECT * FROM '. $tbl_name)));
+
+ at pg_query("DROP TABLE $tbl_name");
+pg_close($dbh);
+
+echo PHP_EOL."Done".PHP_EOL;
+
+?>
+--EXPECTF--
+array(2) {
+  [0]=>
+  array(2) {
+    ["null_field"]=>
+    NULL
+    ["not_null_field"]=>
+    string(1) "1"
+  }
+  [1]=>
+  array(2) {
+    ["null_field"]=>
+    NULL
+    ["not_null_field"]=>
+    string(1) "2"
+  }
+}
+DELETE FROM test_47199 WHERE null_field IS NULL AND not_null_field=2;
+UPDATE test_47199 SET null_field=NULL,not_null_field=0 WHERE not_null_field=1 AND null_field IS NULL;
+array(1) {
+  [0]=>
+  array(2) {
+    ["null_field"]=>
+    NULL
+    ["not_null_field"]=>
+    string(1) "0"
+  }
+}
+
+Done
\ No newline at end of file
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 4bdf619..bccc32e 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c 298908 2010-05-03 14:41:40Z iliaa $ */
+/* $Id: phar.c 305584 2010-11-20 20:59:28Z kalle $ */
 
 #define PHAR_MAIN 1
 #include "phar_internal.h"
@@ -512,7 +512,7 @@ void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
 	(buffer) += 2
 #else
 # define PHAR_GET_32(buffer, var) \
-	var = *(php_uint32*)(buffer); \
+	memcpy(&var, buffer, sizeof(var)); \
 	buffer += 4
 # define PHAR_GET_16(buffer, var) \
 	var = *(php_uint16*)(buffer); \
@@ -2491,7 +2491,7 @@ static inline void phar_set_32(char *buffer, int var) /* {{{ */
 	*((buffer) + 1) = (unsigned char) (((var) >> 8) & 0xFF);
 	*((buffer) + 0) = (unsigned char) ((var) & 0xFF);
 #else
-	*(php_uint32 *)(buffer) = (php_uint32)(var);
+	 memcpy(buffer, &var, sizeof(var));
 #endif
 } /* }}} */
 
@@ -3668,7 +3668,7 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
 	php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
 	php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
 	php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
-	php_info_print_table_row(2, "SVN revision", "$Revision: 298908 $");
+	php_info_print_table_row(2, "SVN revision", "$Revision: 305584 $");
 	php_info_print_table_row(2, "Phar-based phar archives", "enabled");
 	php_info_print_table_row(2, "Tar-based phar archives", "enabled");
 	php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index e7ee3e7..89a84a2 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar_object.c 298642 2010-04-27 08:23:25Z bjori $ */
+/* $Id: phar_object.c 303709 2010-09-23 04:41:14Z aharvey $ */
 
 #include "phar_internal.h"
 #include "func_interceptors.h"
@@ -1251,8 +1251,12 @@ static spl_other_handler phar_spl_foreign_handler = {
 
 /* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]])
  * Construct a Phar archive object
- * {{{ proto void PharData::__construct(string fname [[, int flags [, string alias]], int file format = Phar::TAR])
+ *
+ * proto void PharData::__construct(string fname [[, int flags [, string alias]], int file format = Phar::TAR])
  * Construct a PharData archive object
+ *
+ * This function is used as the constructor for both the Phar and PharData
+ * classes, hence the two prototypes above.
  */
 PHP_METHOD(Phar, __construct)
 {
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 2b91e8d..1fbbbb1 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -470,7 +470,7 @@ static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
 	if (stream->mode[0] == 'w' || (stream->mode[0] == 'r' && stream->mode[1] == '+')) {
 		ret = phar_flush(((phar_entry_data *)stream->abstract)->phar, 0, 0, 0, &error TSRMLS_CC);
 		if (error) {
-			php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, error);
+			php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, "%s", error);
 			efree(error);
 		}
 		return ret;
diff --git a/ext/phar/tests/phpinfo_001.phpt b/ext/phar/tests/phpinfo_001.phpt
index e81ed71..5de74da 100644
--- a/ext/phar/tests/phpinfo_001.phpt
+++ b/ext/phar/tests/phpinfo_001.phpt
@@ -26,7 +26,7 @@ phpinfo(INFO_MODULES);
 Phar: PHP Archive support => enabled
 Phar EXT version => %s
 Phar API version => 1.1.1
-CVS revision => %sRevision: %s $
+SVN revision => %sRevision: %s $
 Phar-based phar archives => enabled
 Tar-based phar archives => enabled
 ZIP-based phar archives => enabled
@@ -48,7 +48,7 @@ Phar
 Phar: PHP Archive support => enabled
 Phar EXT version => %s
 Phar API version => 1.1.1
-CVS revision => %sRevision: %s $
+SVN revision => %sRevision: %s $
 Phar-based phar archives => enabled
 Tar-based phar archives => enabled
 ZIP-based phar archives => enabled
diff --git a/ext/phar/tests/phpinfo_002.phpt b/ext/phar/tests/phpinfo_002.phpt
index a9a73cd..da6db95 100644
--- a/ext/phar/tests/phpinfo_002.phpt
+++ b/ext/phar/tests/phpinfo_002.phpt
@@ -24,7 +24,7 @@ Phar
 Phar: PHP Archive support => enabled
 Phar EXT version => %s
 Phar API version => 1.1.1
-CVS revision => %sRevision: %s $
+SVN revision => %sRevision: %s $
 Phar-based phar archives => enabled
 Tar-based phar archives => enabled
 ZIP-based phar archives => enabled
diff --git a/ext/phar/tests/phpinfo_003.phpt b/ext/phar/tests/phpinfo_003.phpt
index 04602d2..031d3cf 100644
--- a/ext/phar/tests/phpinfo_003.phpt
+++ b/ext/phar/tests/phpinfo_003.phpt
@@ -24,7 +24,7 @@ Phar
 Phar: PHP Archive support => enabled
 Phar EXT version => %s
 Phar API version => 1.1.1
-CVS revision => %cRevision: %s $
+SVN revision => %cRevision: %s $
 Phar-based phar archives => enabled
 Tar-based phar archives => enabled
 ZIP-based phar archives => enabled
diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt
index 33b0e7b..c49205c 100644
--- a/ext/phar/tests/phpinfo_004.phpt
+++ b/ext/phar/tests/phpinfo_004.phpt
@@ -29,7 +29,7 @@ phpinfo(INFO_MODULES);
 <tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
 <tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
 <tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
-<tr><td class="e">CVS revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
 <tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
 <tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
 <tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
@@ -53,7 +53,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full
 <tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
 <tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
 <tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
-<tr><td class="e">CVS revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
 <tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
 <tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
 <tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index f3d9366..885c997 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: posix.c 300764 2010-06-26 16:03:39Z felipe $ */
+/* $Id: posix.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -310,7 +310,7 @@ const zend_function_entry posix_functions[] = {
 static PHP_MINFO_FUNCTION(posix)
 {
 	php_info_print_table_start();
-	php_info_print_table_row(2, "Revision", "$Revision: 300764 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 305507 $");
 	php_info_print_table_end();
 }
 /* }}} */
@@ -842,6 +842,10 @@ PHP_FUNCTION(posix_mkfifo)
 		RETURN_FALSE;
 	}
 
+	if (strlen(path) != path_len) {
+		RETURN_FALSE;
+	}
+
 	if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) ||
 			(PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) {
 		RETURN_FALSE;
@@ -877,6 +881,10 @@ PHP_FUNCTION(posix_mknod)
 		RETURN_FALSE;
 	}
 
+	if (strlen(path) != path_len) {
+		RETURN_FALSE;
+	}
+
 	if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) ||
 			(PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) {
 		RETURN_FALSE;
@@ -957,6 +965,10 @@ PHP_FUNCTION(posix_access)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	path = expand_filepath(filename, NULL TSRMLS_CC);
 	if (!path) {
 		POSIX_G(last_error) = EIO;
diff --git a/ext/posix/tests/posix_access.phpt b/ext/posix/tests/posix_access.phpt
index 1bd601a..e585e67 100644
--- a/ext/posix/tests/posix_access.phpt
+++ b/ext/posix/tests/posix_access.phpt
@@ -43,7 +43,7 @@ chmod ($filename, 0700);
 unlink($filename);
 ?>
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
 bool(true)
 bool(true)
 bool(true)
diff --git a/ext/posix/tests/posix_access_error_modes.phpt b/ext/posix/tests/posix_access_error_modes.phpt
index 0d79996..951ae01 100644
--- a/ext/posix/tests/posix_access_error_modes.phpt
+++ b/ext/posix/tests/posix_access_error_modes.phpt
@@ -37,7 +37,7 @@ chmod ($filename, 0700);
 unlink($filename);
 ?>
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line %d
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line %d
 bool(false)
 bool(false)
 bool(false)
diff --git a/ext/posix/tests/posix_access_error_wrongparams.phpt b/ext/posix/tests/posix_access_error_wrongparams.phpt
index 7f938a8..111ec6c 100644
--- a/ext/posix/tests/posix_access_error_wrongparams.phpt
+++ b/ext/posix/tests/posix_access_error_wrongparams.phpt
@@ -28,7 +28,7 @@ var_dump(posix_access('./foobar'));
 ?>
 ===DONE===
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Warning: posix_access() expects at least 1 parameter, 0 given in %s on line %d
 bool(false)
diff --git a/ext/posix/tests/posix_access_safemode.phpt b/ext/posix/tests/posix_access_safemode.phpt
index 1e156f9..ec0c3e8 100644
--- a/ext/posix/tests/posix_access_safemode.phpt
+++ b/ext/posix/tests/posix_access_safemode.phpt
@@ -19,6 +19,6 @@ var_dump(posix_access('/tmp', POSIX_W_OK));
 ?>
 ===DONE===
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
 bool(false)
 ===DONE===
diff --git a/ext/posix/tests/posix_mkfifo_safemode.phpt b/ext/posix/tests/posix_mkfifo_safemode.phpt
index 9dbddc2..6f1f092 100644
--- a/ext/posix/tests/posix_mkfifo_safemode.phpt
+++ b/ext/posix/tests/posix_mkfifo_safemode.phpt
@@ -36,7 +36,7 @@ unlink($dir . '/bar');
 rmdir($dir);
 ?>
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
 
 Warning: posix_mkfifo(): SAFE MODE Restriction in effect.  The script whose uid is %d is not allowed to access /tmp owned by uid %d in %s on line %d
 bool(false)
diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c
index 4db27d9..d11f692 100644
--- a/ext/pspell/pspell.c
+++ b/ext/pspell/pspell.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: pspell.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: pspell.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #define IS_EXT_MODULE
 
@@ -402,6 +402,10 @@ static PHP_FUNCTION(pspell_new_personal)
 	}
 #endif
 
+	if (strlen(personal) != personal_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) && (!php_checkuid(personal, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		delete_pspell_config(config);
 		RETURN_FALSE;
@@ -834,6 +838,10 @@ static void pspell_config_path(INTERNAL_FUNCTION_PARAMETERS, char *option)
 		return;
 	}
 
+	if (strlen(value) != value_len) {
+		RETURN_FALSE;
+	}
+
 	PSPELL_FETCH_CONFIG;
 
 	if (PG(safe_mode) && (!php_checkuid(value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
@@ -891,6 +899,10 @@ static PHP_FUNCTION(pspell_config_repl)
 
 	pspell_config_replace(config, "save-repl", "true");
 
+	if (strlen(repl) != repl_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) && (!php_checkuid(repl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
diff --git a/ext/recode/CREDITS b/ext/recode/CREDITS
index b3460e8..aae8240 100644
--- a/ext/recode/CREDITS
+++ b/ext/recode/CREDITS
@@ -1,2 +1,2 @@
 Recode
-Kristian Köhntopp
+Kristian Koehntopp
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a1363a9..018e262 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c 300393 2010-06-11 23:37:55Z felipe $ */
+/* $Id: php_reflection.c 305605 2010-11-21 12:24:09Z johannes $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -190,7 +190,8 @@ typedef enum {
 	REF_TYPE_OTHER,      /* Must be 0 */
 	REF_TYPE_FUNCTION,
 	REF_TYPE_PARAMETER,
-	REF_TYPE_PROPERTY
+	REF_TYPE_PROPERTY,
+	REF_TYPE_DYNAMIC_PROPERTY
 } reflection_type_t;
 
 /* Struct for reflection objects */
@@ -272,6 +273,7 @@ static void reflection_free_objects_storage(void *object TSRMLS_DC)
 {
 	reflection_object *intern = (reflection_object *) object;
 	parameter_reference *reference;
+	property_reference *prop_reference;
 
 	if (intern->ptr) {
 		switch (intern->ref_type) {
@@ -286,6 +288,11 @@ static void reflection_free_objects_storage(void *object TSRMLS_DC)
 		case REF_TYPE_PROPERTY:
 			efree(intern->ptr);
 			break;
+		case REF_TYPE_DYNAMIC_PROPERTY:
+			prop_reference = (property_reference*)intern->ptr;
+			efree(prop_reference->prop.name);
+			efree(intern->ptr);
+			break;
 		case REF_TYPE_OTHER:
 			break;
 		}
@@ -2934,6 +2941,10 @@ ZEND_METHOD(reflection_method, getDeclaringClass)
 
 	METHOD_NOTSTATIC(reflection_method_ptr);
 	GET_REFLECTION_OBJECT_PTR(mptr);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zend_reflection_class_factory(mptr->common.scope, return_value TSRMLS_CC);
 }
@@ -2949,6 +2960,10 @@ ZEND_METHOD(reflection_method, getPrototype)
 	METHOD_NOTSTATIC(reflection_method_ptr);
 	GET_REFLECTION_OBJECT_PTR(mptr);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (!mptr->common.prototype) {
 		zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
 			"Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name);
@@ -3575,13 +3590,15 @@ ZEND_METHOD(reflection_class, getProperty)
 		if (zend_hash_exists(Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC), name, name_len+1)) {
 			zend_property_info property_info_tmp;
 			property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC;
-			property_info_tmp.name = name;
+			property_info_tmp.name = estrndup(name, name_len);
 			property_info_tmp.name_length = name_len;
 			property_info_tmp.h = zend_get_hash_value(name, name_len+1);
 			property_info_tmp.doc_comment = NULL;
 			property_info_tmp.ce = ce;
 
 			reflection_property_factory(ce, &property_info_tmp, return_value TSRMLS_CC);
+			intern = (reflection_object *) zend_object_store_get_object(return_value TSRMLS_CC);
+			intern->ref_type = REF_TYPE_DYNAMIC_PROPERTY;
 			return;
 		}
 	}
@@ -3652,6 +3669,7 @@ static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, ze
 	ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0);
 	if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) {
 		MAKE_STD_ZVAL(property);
+		EG(std_property_info).flags = ZEND_ACC_IMPLICIT_PUBLIC;
 		reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC);
 		add_next_index_zval(retval, property);
 	}
@@ -3995,7 +4013,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
 		if (params) {
 			efree(params);
 		}
-	} else if (!ZEND_NUM_ARGS()) {
+	} else if (!ZEND_NUM_ARGS() || !argc) {
 		object_init_ex(return_value, ce);
 	} else {
 		zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
@@ -4174,6 +4192,10 @@ ZEND_METHOD(reflection_class, isIterateable)
 {
 	reflection_object *intern;
 	zend_class_entry *ce;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	METHOD_NOTSTATIC(reflection_class_ptr);
 	GET_REFLECTION_OBJECT_PTR(ce);
@@ -4188,6 +4210,10 @@ ZEND_METHOD(reflection_class, getExtension)
 {
 	reflection_object *intern;
 	zend_class_entry *ce;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	METHOD_NOTSTATIC(reflection_class_ptr);
 	GET_REFLECTION_OBJECT_PTR(ce);
@@ -4204,6 +4230,10 @@ ZEND_METHOD(reflection_class, getExtensionName)
 {
 	reflection_object *intern;
 	zend_class_entry *ce;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	METHOD_NOTSTATIC(reflection_class_ptr);
 	GET_REFLECTION_OBJECT_PTR(ce);
@@ -5505,7 +5535,7 @@ PHP_MINFO_FUNCTION(reflection) /* {{{ */
 	php_info_print_table_start();
 	php_info_print_table_header(2, "Reflection", "enabled");
 
-	php_info_print_table_row(2, "Version", "$Revision: 300393 $");
+	php_info_print_table_row(2, "Version", "$Revision: 305605 $");
 
 	php_info_print_table_end();
 } /* }}} */
@@ -5519,7 +5549,7 @@ zend_module_entry reflection_module_entry = { /* {{{ */
 	NULL,
 	NULL,
 	PHP_MINFO(reflection),
-	"$Revision: 300393 $",
+	"$Revision: 305605 $",
 	STANDARD_MODULE_PROPERTIES
 }; /* }}} */
 
diff --git a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
index f3881c5..1f5ba43 100644
--- a/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt
@@ -64,10 +64,7 @@ foreach ($classes as $class) {
 				 
 ?>
 --EXPECTF--
-
-Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26
-
-Strict Standards: %s for class NewAndOldCtor in %s on line 31
+Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
 Constructor of NewCtor: __construct
 Constructor of ExtendsNewCtor: __construct
 Constructor of OldCtor: OldCtor
@@ -79,4 +76,4 @@ Constructor of C: C
 Constructor of D1: __construct
 Constructor of D2: C
 No constructor for X
-No constructor for Y
\ No newline at end of file
+No constructor for Y
diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
index 3ece915..4936413 100644
--- a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
+++ b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt
@@ -62,13 +62,27 @@ Is ExtendsIteratorAggregateImpl iterable? bool(true)
 Is A iterable? bool(false)
 
 Test invalid params:
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 34
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 2 given in %s on line 35
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 36
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 37
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 38
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 39
+NULL
+
+Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 40
+NULL
 
 Test static invocation:
 
diff --git a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
index dcc6080..2a2f02f 100644
--- a/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionMethod_constructor_basic.phpt
@@ -86,8 +86,6 @@ var_dump($methodInfo->isConstructor());
 ?>
 --EXPECTF--
 Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
-
-Strict Standards: %s for class NewAndOldCtor in %s on line %d
 New-style constructor:
 bool(true)
 
diff --git a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
index a784f6d..5a0c36f 100644
--- a/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
+++ b/ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt
@@ -64,10 +64,7 @@ foreach ($classes as $class) {
 				
 ?>
 --EXPECTF--
-
-Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26
-
-Strict Standards: %s for class NewAndOldCtor in %s on line 31
+Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line %d
 Constructor of NewCtor: __construct
 Constructor of ExtendsNewCtor: __construct
 Constructor of OldCtor: OldCtor
diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
new file mode 100644
index 0000000..6570770
--- /dev/null
+++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ReflectionParameter::isDefault()
+--FILE--
+<?php
+class A {
+public $defprop;
+}
+$a = new A;
+$a->myprop = null;
+
+$ro = new ReflectionObject($a);
+$props = $ro->getProperties();
+$prop1 = $props[0];
+var_dump($prop1->isDefault());
+$prop2 = $props[1];
+var_dump($prop2->isDefault());
+
+var_dump($ro->getProperty('defprop')->isDefault());
+var_dump($ro->getProperty('myprop')->isDefault());
+
+$prop1 = new ReflectionProperty($a, 'defprop');
+$prop2 = new ReflectionProperty($a, 'myprop');
+var_dump($prop1->isDefault());
+var_dump($prop2->isDefault());
+?>
+==DONE==
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+==DONE==
diff --git a/ext/reflection/tests/bug52854.phpt b/ext/reflection/tests/bug52854.phpt
new file mode 100644
index 0000000..255522d
--- /dev/null
+++ b/ext/reflection/tests/bug52854.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #52854: ReflectionClass::newInstanceArgs does not work for classes without constructors
+--FILE--
+<?php
+class Test {
+}
+$c = new ReflectionClass('Test');
+var_dump(new Test);
+var_dump(new Test());
+var_dump($c->newInstance());
+var_dump($c->newInstanceArgs(array()));
+
+try {
+	var_dump($c->newInstanceArgs(array(1)));
+} catch(ReflectionException $e) {
+	echo $e->getMessage()."\n";
+}
+?>
+--EXPECTF--
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+object(Test)#%d (0) {
+}
+Class Test does not have a constructor, so you cannot pass any constructor arguments
diff --git a/ext/reflection/tests/bug53366.phpt b/ext/reflection/tests/bug53366.phpt
new file mode 100644
index 0000000..5fb119d
--- /dev/null
+++ b/ext/reflection/tests/bug53366.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #53366 (Reflection doesnt get dynamic property value from getProperty())
+--FILE--
+<?php
+
+class UserClass {
+}
+
+$myClass = new UserClass;
+$myClass->id = 1000;
+
+$reflect = new ReflectionObject($myClass);
+
+var_dump($reflect->getProperty('id'));
+var_dump($reflect->getProperty('id')->getValue($myClass));
+
+?>
+--EXPECTF--
+object(ReflectionProperty)#%d (2) {
+  ["name"]=>
+  string(2) "id"
+  ["class"]=>
+  string(9) "UserClass"
+}
+int(1000)
diff --git a/ext/session/config.m4 b/ext/session/config.m4
index 8a0d4c0..8e2cba2 100644
--- a/ext/session/config.m4
+++ b/ext/session/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 286445 2009-07-28 08:59:08Z tony2001 $
+dnl $Id: config.m4 305038 2010-11-02 20:51:02Z felipe $
 dnl
 
 PHP_ARG_ENABLE(session, whether to enable PHP sessions,
@@ -13,6 +13,7 @@ if test "$PHP_SESSION" != "no"; then
   PHP_PREAD_TEST
   PHP_NEW_EXTENSION(session, session.c mod_files.c mod_mm.c mod_user.c, $ext_shared)
   PHP_ADD_EXTENSION_DEP(session, hash, true)
+  PHP_ADD_EXTENSION_DEP(session, spl)
   PHP_SUBST(SESSION_SHARED_LIBADD)
   PHP_INSTALL_HEADERS(ext/session, [php_session.h mod_files.h mod_user.h])
   AC_DEFINE(HAVE_PHP_SESSION,1,[ ])
diff --git a/ext/session/session.c b/ext/session/session.c
index 095fc7d..9d4905d 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: session.c 300296 2010-06-08 22:30:16Z pajoye $ */
+/* $Id: session.c 305034 2010-11-02 18:34:56Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -403,9 +403,8 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */
 	efree(buf);
 
 	if (PS(entropy_length) > 0) {
-		unsigned char rbuf[2048];
-
 #ifdef PHP_WIN32
+		unsigned char rbuf[2048];
 		size_t toread = PS(entropy_length);
 
 		if (php_win32_get_random_bytes(rbuf, (size_t) toread) == SUCCESS){
@@ -2283,6 +2282,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */
 
 static const zend_module_dep session_deps[] = { /* {{{ */
 	ZEND_MOD_OPTIONAL("hash")
+	ZEND_MOD_REQUIRED("spl")
 	{NULL, NULL, NULL}
 };
 /* }}} */
diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt
index 19dff78..543eba7 100644
--- a/ext/session/tests/001.phpt
+++ b/ext/session/tests/001.phpt
@@ -31,7 +31,7 @@ print session_encode()."\n";
 
 session_destroy();
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Deprecated: Function session_register() is deprecated in %s on line %d
 
diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt
index 8a4e002..677a958 100644
--- a/ext/session/tests/003.phpt
+++ b/ext/session/tests/003.phpt
@@ -28,7 +28,7 @@ var_dump($baz);
 var_dump($arr);
 session_destroy();
 --EXPECT--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 object(foo)#1 (2) {
   ["bar"]=>
   string(2) "ok"
diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt
index 2ff675e..3e6de25 100644
--- a/ext/session/tests/004.phpt
+++ b/ext/session/tests/004.phpt
@@ -73,7 +73,7 @@ var_dump($arr);
 session_destroy();
 ?>
 --EXPECT--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 OPEN: PHPSESSID
 READ: abtest
 object(foo)#2 (2) {
diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt
index 124f0a8..4e6682c 100644
--- a/ext/session/tests/005.phpt
+++ b/ext/session/tests/005.phpt
@@ -85,7 +85,7 @@ var_dump($baz); var_dump($arr); var_dump($c);
 session_destroy();
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 OPEN: PHPSESSID
 READ: abtest
 object(foo)#2 (2) {
diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt
index 7c7af61..9ab28f6 100644
--- a/ext/session/tests/006.phpt
+++ b/ext/session/tests/006.phpt
@@ -45,7 +45,7 @@ echo "values after session:\n";
 var_dump($a,$b);
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 original values:
 object(a)#%d (1) {
   ["test"]=>
diff --git a/ext/session/tests/007.phpt b/ext/session/tests/007.phpt
index 9531b3d..54768e2 100644
--- a/ext/session/tests/007.phpt
+++ b/ext/session/tests/007.phpt
@@ -50,9 +50,9 @@ var_dump($HTTP_SESSION_VARS);
 session_destroy();
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
-Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Deprecated: Function session_register() is deprecated in %s on line %d
 float(3.14)
diff --git a/ext/session/tests/008-php4.2.3.phpt b/ext/session/tests/008-php4.2.3.phpt
index 4fe938f..1b26900 100644
--- a/ext/session/tests/008-php4.2.3.phpt
+++ b/ext/session/tests/008-php4.2.3.phpt
@@ -58,7 +58,7 @@ var_dump($HTTP_SESSION_VARS);
 session_destroy();
 ?>
 --EXPECTF--
-Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
 NULL
 session_write_close(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively
 array(1) {
diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt
index 705a275..1a7e87c 100644
--- a/ext/session/tests/009.phpt
+++ b/ext/session/tests/009.phpt
@@ -43,7 +43,7 @@ var_dump($HTTP_SESSION_VARS);
 session_destroy();
 ?>
 --EXPECT--
-Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
 array(0) {
 }
 array(1) {
diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt
index 32aeb29..b52333a 100644
--- a/ext/session/tests/012.phpt
+++ b/ext/session/tests/012.phpt
@@ -32,7 +32,7 @@ session_destroy();
 print "I live\n";
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Deprecated: Function session_register() is deprecated in %s on line %d
 I live
diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt
index ad6c14e..04322f9 100644
--- a/ext/session/tests/013.phpt
+++ b/ext/session/tests/013.phpt
@@ -24,5 +24,5 @@ session_destroy();
 print "I live\n";
 ?>
 --EXPECT--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 I live
diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt
index 4e77a7a..be1119d 100644
--- a/ext/session/tests/014.phpt
+++ b/ext/session/tests/014.phpt
@@ -33,7 +33,7 @@ ini_set("session.use_trans_sid","1");
 session_destroy();
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 <a href="/link?PHPSESSID=abtest">
 
 Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d
diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt
index 5bdd03b..9c4f8ca 100644
--- a/ext/session/tests/019.phpt
+++ b/ext/session/tests/019.phpt
@@ -47,7 +47,7 @@ var_dump($_SESSION);
 session_destroy();
 ?>
 --EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Deprecated: Function session_register() is deprecated in %s on line %d
 array(2) {
diff --git a/ext/session/tests/bug53141.phpt b/ext/session/tests/bug53141.phpt
new file mode 100644
index 0000000..765d272
--- /dev/null
+++ b/ext/session/tests/bug53141.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #53141 (autoload misbehaves if called from closing session)
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+spl_autoload_register(function ($class) {
+    var_dump("Loading $class");
+    eval('class Bar {}');
+});
+
+class Foo
+{
+    function __sleep()
+    {
+        new Bar;
+        return array();
+    }
+}
+
+session_start();
+$_SESSION['foo'] = new Foo;
+
+?>
+--EXPECT--
+string(11) "Loading Bar"
\ No newline at end of file
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 4301307..c15097d 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c 299424 2010-05-17 07:50:33Z dmitry $ */
+/* $Id: simplexml.c 302715 2010-08-23 17:01:44Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2567,7 +2567,7 @@ PHP_MINFO_FUNCTION(simplexml)
 {
 	php_info_print_table_start();
 	php_info_print_table_header(2, "Simplexml support", "enabled");
-	php_info_print_table_row(2, "Revision", "$Revision: 299424 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 302715 $");
 	php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
 		"enabled");
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 621ae08..ac909c8 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_encoding.c 300457 2010-06-15 08:22:51Z dmitry $ */
+/* $Id: php_encoding.c 303034 2010-09-03 22:24:08Z rasmus $ */
 
 #include <time.h>
 
@@ -373,7 +373,7 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
 		HashTable *ht = Z_OBJPROP_P(data);
 
 		if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
-			soap_error0(E_ERROR, "Encoding: SoapVar hasn't 'enc_type' property");
+			soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
 		}
 
 		if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
@@ -1751,7 +1751,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
 				return 2;
 			} else {
 				if (strict) {
-					soap_error1(E_ERROR,  "Encoding: object hasn't '%s' property", model->u.element->name);
+					soap_error1(E_ERROR,  "Encoding: object has no '%s' property", model->u.element->name);
 				}
 				return 0;
 			}
@@ -1784,7 +1784,7 @@ static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *
 				return 2;
 			} else {
 				if (strict) {
-					soap_error0(E_ERROR,  "Encoding: object hasn't 'any' property");
+					soap_error0(E_ERROR,  "Encoding: object has no 'any' property");
 				}
 				return 0;
 			}
@@ -3632,7 +3632,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
 			zval **ztype;
 
 			if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
-				soap_error0(E_ERROR,  "Encoding: SoapVar hasn't 'enc_type' property");
+				soap_error0(E_ERROR,  "Encoding: SoapVar has no 'enc_type' property");
 			}
 			cur_type = Z_LVAL_PP(ztype);
 
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index a6a645f..1f5c48f 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_http.c 299903 2010-05-28 12:18:03Z dmitry $ */
+/* $Id: php_http.c 304084 2010-10-05 11:43:59Z dmitry $ */
 
 #include "php_soap.h"
 #include "ext/standard/base64.h"
@@ -137,6 +137,13 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
 		smart_str_appendc(&soap_headers, ':');
 		smart_str_append_unsigned(&soap_headers, phpurl->port);
 		smart_str_append_const(&soap_headers, " HTTP/1.1\r\n");
+		smart_str_append_const(&soap_headers, "Host: ");
+		smart_str_appends(&soap_headers, phpurl->host);
+		if (phpurl->port != 80) {
+			smart_str_appendc(&soap_headers, ':');
+			smart_str_append_unsigned(&soap_headers, phpurl->port);
+		}
+		smart_str_append_const(&soap_headers, "\r\n");
 		proxy_authentication(this_ptr, &soap_headers TSRMLS_CC);
 		smart_str_append_const(&soap_headers, "\r\n");
 		if (php_stream_write(stream, soap_headers.c, soap_headers.len) != soap_headers.len) {
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index 0b02fbd..e86a204 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_packet_soap.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_packet_soap.c 303034 2010-09-03 22:24:08Z rasmus $ */
 
 #include "php_soap.h"
 
@@ -340,7 +340,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
 				}
 			}
 		} else {
-		  /* Function hasn't WSDL description */
+		  /* Function has no WSDL description */
 			xmlNodePtr val;
 			val = resp->children;
 			while (val != NULL) {
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index 256ece5..37d519e 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -17,7 +17,7 @@
   |          Dmitry Stogov <dmitry at zend.com>                             |
   +----------------------------------------------------------------------+
 */
-/* $Id: php_sdl.c 299013 2010-05-05 07:43:45Z dmitry $ */
+/* $Id: php_sdl.c 305198 2010-11-08 11:34:32Z dmitry $ */
 
 #include "php_soap.h"
 #include "ext/libxml/php_libxml.h"
@@ -373,7 +373,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include
 					soap_error1(E_ERROR, "Parsing WSDL: <message> '%s' already defined", name->children->content);
 				}
 			} else {
-				soap_error0(E_ERROR, "Parsing WSDL: <message> hasn't name attribute");
+				soap_error0(E_ERROR, "Parsing WSDL: <message> has no name attribute");
 			}
 
 		} else if (node_is_equal(trav,"portType")) {
@@ -383,7 +383,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include
 					soap_error1(E_ERROR, "Parsing WSDL: <portType> '%s' already defined", name->children->content);
 				}
 			} else {
-				soap_error0(E_ERROR, "Parsing WSDL: <portType> hasn't name attribute");
+				soap_error0(E_ERROR, "Parsing WSDL: <portType> has no name attribute");
 			}
 
 		} else if (node_is_equal(trav,"binding")) {
@@ -393,7 +393,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include
 					soap_error1(E_ERROR, "Parsing WSDL: <binding> '%s' already defined", name->children->content);
 				}
 			} else {
-				soap_error0(E_ERROR, "Parsing WSDL: <binding> hasn't name attribute");
+				soap_error0(E_ERROR, "Parsing WSDL: <binding> has no name attribute");
 			}
 
 		} else if (node_is_equal(trav,"service")) {
@@ -403,7 +403,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include
 					soap_error1(E_ERROR, "Parsing WSDL: <service> '%s' already defined", name->children->content);
 				}
 			} else {
-				soap_error0(E_ERROR, "Parsing WSDL: <service> hasn't name attribute");
+				soap_error0(E_ERROR, "Parsing WSDL: <service> has no name attribute");
 			}
 		} else if (!node_is_equal(trav,"documentation")) {
 			soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
@@ -3250,10 +3250,13 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
 		php_stream_context_set_option(context, "http", "proxy", str_proxy);
 		zval_ptr_dtor(&str_proxy);
 
-		MAKE_STD_ZVAL(str_proxy);
-		ZVAL_BOOL(str_proxy, 1);
-		php_stream_context_set_option(context, "http", "request_fulluri", str_proxy);
-		zval_ptr_dtor(&str_proxy);
+		if (uri_len < sizeof("https://")-1 ||
+		    strncasecmp(uri, "https://", sizeof("https://")-1) != 0) {
+			MAKE_STD_ZVAL(str_proxy);
+			ZVAL_BOOL(str_proxy, 1);
+			php_stream_context_set_option(context, "http", "request_fulluri", str_proxy);
+			zval_ptr_dtor(&str_proxy);
+		}
 
 		proxy_authentication(this_ptr, &headers TSRMLS_CC);
 	}
diff --git a/ext/soap/tests/bugs/bug50698_1.phpt b/ext/soap/tests/bugs/bug50698_1.phpt
index c5d634a..eb5f1e0 100644
--- a/ext/soap/tests/bugs/bug50698_1.phpt
+++ b/ext/soap/tests/bugs/bug50698_1.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Request #50698_1 (SoapClient should handle wsdls with some incompatiable endpoints)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --INI--
 soap.wsdl_cache_enabled=0
 --FILE--
diff --git a/ext/soap/tests/bugs/bug50698_2.phpt b/ext/soap/tests/bugs/bug50698_2.phpt
index 86ddf48..a39f4b5 100644
--- a/ext/soap/tests/bugs/bug50698_2.phpt
+++ b/ext/soap/tests/bugs/bug50698_2.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Request #50698_2 (SoapClient should handle wsdls with some incompatiable endpoints -- EDGECASE: Large mix of compatiable and incompatiable endpoints.)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --INI--
 soap.wsdl_cache_enabled=0
 --FILE--
diff --git a/ext/soap/tests/bugs/bug50698_3.phpt b/ext/soap/tests/bugs/bug50698_3.phpt
index 16a24db..6cee6a6 100644
--- a/ext/soap/tests/bugs/bug50698_3.phpt
+++ b/ext/soap/tests/bugs/bug50698_3.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Request #50698_3 (SoapClient should handle wsdls with some incompatiable endpoints -- EDGECASE: Large set of endpoints all incompatiable.)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --INI--
 soap.wsdl_cache_enabled=0
 --FILE--
diff --git a/ext/soap/tests/bugs/bug50698_4.phpt b/ext/soap/tests/bugs/bug50698_4.phpt
index ca444d7..bb02d00 100644
--- a/ext/soap/tests/bugs/bug50698_4.phpt
+++ b/ext/soap/tests/bugs/bug50698_4.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Request #50698_4 (SoapClient should handle wsdls with some incompatiable endpoints)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --INI--
 soap.wsdl_cache_enabled=0
 --FILE--
diff --git a/ext/soap/tests/bugs/bug50762.phpt b/ext/soap/tests/bugs/bug50762.phpt
index f9099f1..77eb6ee 100644
--- a/ext/soap/tests/bugs/bug50762.phpt
+++ b/ext/soap/tests/bugs/bug50762.phpt
@@ -1,5 +1,7 @@
 --TEST--
 Bug #50762 (in WSDL mode Soap Header handler function only being called if defined in WSDL)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
 class testSoap {
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 58bf883..93194cd 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c 300176 2010-06-04 00:10:15Z felipe $ */
+/* $Id: php_spl.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -339,14 +339,13 @@ PHP_FUNCTION(spl_autoload)
  Register and return default file extensions for spl_autoload */
 PHP_FUNCTION(spl_autoload_extensions)
 {
-	char *file_exts;
+	char *file_exts = NULL;
 	int file_exts_len;
 
-	if (ZEND_NUM_ARGS() > 0) {
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_exts, &file_exts_len) == FAILURE) {
-			return;
-		}
-	
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &file_exts, &file_exts_len) == FAILURE) {
+		return;
+	}
+	if (file_exts) {
 		if (SPL_G(autoload_extensions)) {
 			efree(SPL_G(autoload_extensions));
 		}
@@ -669,6 +668,10 @@ PHP_FUNCTION(spl_autoload_functions)
 	HashPosition function_pos;
 	autoload_func_info *alfi;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (!EG(autoload_func)) {
 		if (zend_hash_find(EG(function_table), ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME), (void **) &fptr) == SUCCESS) {
 			array_init(return_value);
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 313e5a3..640cf34 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c 299327 2010-05-13 08:09:54Z dmitry $ */
+/* $Id: spl_array.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1143,6 +1143,10 @@ SPL_METHOD(Array, getIteratorClass)
 {
 	zval *object = getThis();
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_STRING(intern->ce_get_iterator->name, 1);
 }
@@ -1155,6 +1159,10 @@ SPL_METHOD(Array, getFlags)
 	zval *object = getThis();
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(intern->ar_flags & ~SPL_ARRAY_INT_MASK);
 }
 /* }}} */
@@ -1202,6 +1210,10 @@ SPL_METHOD(Array, getIterator)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	spl_array_object *iterator;
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
@@ -1221,6 +1233,10 @@ SPL_METHOD(Array, rewind)
 {
 	zval *object = getThis();
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_array_rewind(intern TSRMLS_CC);
 }
@@ -1316,6 +1332,10 @@ SPL_METHOD(Array, count)
 {
 	long count;
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_array_object_count_elements_helper(intern, &count TSRMLS_CC);
 
@@ -1399,6 +1419,10 @@ SPL_METHOD(Array, current)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	zval **entry;
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
@@ -1421,6 +1445,10 @@ SPL_METHOD(Array, current)
    Return current array key */
 SPL_METHOD(Array, key)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	spl_array_iterator_key(getThis(), return_value TSRMLS_CC);
 } /* }}} */
 
@@ -1463,6 +1491,10 @@ SPL_METHOD(Array, next)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
 		return;
@@ -1480,6 +1512,10 @@ SPL_METHOD(Array, valid)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
 		return;
@@ -1502,6 +1538,10 @@ SPL_METHOD(Array, hasChildren)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
 		RETURN_FALSE;
@@ -1527,6 +1567,10 @@ SPL_METHOD(Array, getChildren)
 	zval *object = getThis(), **entry, *flags;
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
@@ -1563,7 +1607,7 @@ smart_str spl_array_serialize_helper(spl_array_object *intern, php_serialize_dat
 	zval members, *pmembers;
 	smart_str buf = {0};
 	zval *flags;
-
+	
 	if (!aht) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
 		return buf;
@@ -1603,6 +1647,10 @@ SPL_METHOD(Array, serialize)
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	int was_in_serialize = intern->serialize_data != NULL;
 	smart_str buf;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!was_in_serialize) {
 		intern->serialize_data = emalloc(sizeof(php_serialize_data_t));
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 92f89ff..e13c18e 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c 298647 2010-04-27 08:56:01Z colder $ */
+/* $Id: spl_directory.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -275,6 +275,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
 	
 	intern->u.file.delimiter = ',';
 	intern->u.file.enclosure = '"';
+	intern->u.file.escape = '\\';
 
 	zend_hash_find(&intern->std.ce->function_table, "getcurrentline", sizeof("getcurrentline"), (void **) &intern->u.file.func_getCurr);
 
@@ -673,6 +674,10 @@ SPL_METHOD(DirectoryIterator, __construct)
 SPL_METHOD(DirectoryIterator, rewind)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern->u.dir.index = 0;
 	if (intern->u.dir.dirp) {
@@ -687,6 +692,10 @@ SPL_METHOD(DirectoryIterator, rewind)
 SPL_METHOD(DirectoryIterator, key)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (intern->u.dir.dirp) {
 		RETURN_LONG(intern->u.dir.index);
@@ -700,6 +709,9 @@ SPL_METHOD(DirectoryIterator, key)
    Return this (needed for Iterator interface) */
 SPL_METHOD(DirectoryIterator, current)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	RETURN_ZVAL(getThis(), 1, 0);
 }
 /* }}} */
@@ -710,6 +722,10 @@ SPL_METHOD(DirectoryIterator, next)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern->u.dir.index++;
 	do {
@@ -764,6 +780,10 @@ SPL_METHOD(DirectoryIterator, seek)
 SPL_METHOD(DirectoryIterator, valid)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(intern->u.dir.entry.d_name[0] != '\0');
 }
@@ -776,6 +796,10 @@ SPL_METHOD(SplFileInfo, getPath)
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	char *path;
 	int path_len;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
   	path = spl_filesystem_object_get_path(intern, &path_len TSRMLS_CC);
 	RETURN_STRINGL(path, path_len, 1);
@@ -788,6 +812,10 @@ SPL_METHOD(SplFileInfo, getFilename)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	int path_len;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_filesystem_object_get_path(intern, &path_len TSRMLS_CC);
 	
@@ -804,6 +832,10 @@ SPL_METHOD(SplFileInfo, getFilename)
 SPL_METHOD(DirectoryIterator, getFilename)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_STRING(intern->u.dir.entry.d_name, 1);
 }
@@ -864,6 +896,10 @@ SPL_METHOD(SplFileInfo, getPathname)
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	char *path;
 	int path_len;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	path = spl_filesystem_object_get_pathname(intern, &path_len TSRMLS_CC);
 	if (path != NULL) {
 		RETURN_STRINGL(path, path_len, 1);
@@ -878,6 +914,10 @@ SPL_METHOD(SplFileInfo, getPathname)
 SPL_METHOD(FilesystemIterator, key)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (SPL_FILE_DIR_KEY(intern, SPL_FILE_DIR_KEY_AS_FILENAME)) {
 		RETURN_STRING(intern->u.dir.entry.d_name, 1);
@@ -893,6 +933,10 @@ SPL_METHOD(FilesystemIterator, key)
 SPL_METHOD(FilesystemIterator, current)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (SPL_FILE_DIR_CURRENT(intern, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
 		spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -912,6 +956,10 @@ SPL_METHOD(FilesystemIterator, current)
 SPL_METHOD(DirectoryIterator, isDot)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(spl_filesystem_is_dot(intern->u.dir.entry.d_name));
 }
@@ -956,6 +1004,9 @@ SPL_METHOD(SplFileInfo, func_name) \
 { \
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
 	zend_error_handling error_handling; \
+	if (zend_parse_parameters_none() == FAILURE) { \
+		return; \
+	} \
  \
 	zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);\
 	spl_filesystem_object_get_file_name(intern TSRMLS_CC); \
@@ -1047,11 +1098,28 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
 	int ret;
 	char buff[MAXPATHLEN];
 	zend_error_handling error_handling;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
-#ifdef HAVE_SYMLINK
-	ret = readlink(intern->file_name, buff, MAXPATHLEN-1);
+#if defined(PHP_WIN32) || HAVE_SYMLINK
+	if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) {
+		char expanded_path[MAXPATHLEN];
+
+		/* TODO: Fix expand_filepath to do not resolve links but only expand the path
+		   avoiding double two resolution attempts
+		   (Pierre) */
+		if (!expand_filepath(intern->file_name, expanded_path TSRMLS_CC)) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
+			RETURN_FALSE;
+		}
+		ret = php_sys_readlink(expanded_path, buff, MAXPATHLEN - 1);
+	} else {
+		ret = php_sys_readlink(intern->file_name, buff,  MAXPATHLEN-1);
+	}
 #else
 	ret = -1; /* always fail if not implemented */
 #endif
@@ -1079,6 +1147,10 @@ SPL_METHOD(SplFileInfo, getRealPath)
 	char buff[MAXPATHLEN];
 	char *filename;
 	zend_error_handling error_handling;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
@@ -1212,6 +1284,10 @@ SPL_METHOD(FilesystemIterator, rewind)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
 	intern->u.dir.index = 0;
 	if (intern->u.dir.dirp) {
 		php_stream_rewinddir(intern->u.dir.dirp);
@@ -1227,6 +1303,10 @@ SPL_METHOD(FilesystemIterator, rewind)
 SPL_METHOD(FilesystemIterator, getFlags)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_LONG(intern->flags & (SPL_FILE_DIR_KEY_MODE_MASK | SPL_FILE_DIR_CURRENT_MODE_MASK | SPL_FILE_DIR_OTHERS_MASK));
 } /* }}} */
@@ -1238,7 +1318,9 @@ SPL_METHOD(FilesystemIterator, setFlags)
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	long flags;
 
-	zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags);
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
+		return;
+	}
 
 	intern->flags &= ~(SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK|SPL_FILE_DIR_OTHERS_MASK);
 	intern->flags |= ((SPL_FILE_DIR_KEY_MODE_MASK|SPL_FILE_DIR_CURRENT_MODE_MASK|SPL_FILE_DIR_OTHERS_MASK) & flags);
@@ -1250,13 +1332,13 @@ SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
 {
 	zend_bool allow_links = 0;
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-	
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &allow_links) == FAILURE) {
+		return;
+	}
 	if (spl_filesystem_is_invalid_or_dot(intern->u.dir.entry.d_name)) {
 		RETURN_FALSE;
 	} else {
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &allow_links) == FAILURE) {
-			return;
-		}
 		spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 		if (!allow_links && !(intern->flags & SPL_FILE_DIR_FOLLOW_SYMLINKS)) {
 			php_stat(intern->file_name, intern->file_name_len, FS_IS_LINK, return_value TSRMLS_CC);
@@ -1278,6 +1360,10 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
 	spl_filesystem_object *subdir;
 	char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	spl_filesystem_object_get_file_name(intern TSRMLS_CC);
 
 	if (SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
@@ -1310,6 +1396,10 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
 SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (intern->u.dir.sub_path) {
 		RETURN_STRINGL(intern->u.dir.sub_path, intern->u.dir.sub_path_len, 1);
@@ -1327,6 +1417,10 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
 	char *sub_name;
 	int len;
 	char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (intern->u.dir.sub_path) {
 		len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, slash, intern->u.dir.entry.d_name);
@@ -1358,6 +1452,10 @@ SPL_METHOD(GlobIterator, __construct)
 SPL_METHOD(GlobIterator, count)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
 		RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
@@ -1862,7 +1960,11 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
 
 	result = zend_call_function(&fci, &fcic TSRMLS_CC);
 	
-	ZVAL_ZVAL(return_value, retval, 1, 1);
+	if (result == FAILURE) {
+		RETVAL_FALSE;
+	} else {
+		ZVAL_ZVAL(return_value, retval, 1, 1);
+	}
 
 	efree(params);
 	return result;
@@ -2098,6 +2200,10 @@ SPL_METHOD(SplTempFileObject, __construct)
 SPL_METHOD(SplFileObject, rewind)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
 } /* }}} */
@@ -2107,6 +2213,10 @@ SPL_METHOD(SplFileObject, rewind)
 SPL_METHOD(SplFileObject, eof)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(php_stream_eof(intern->u.file.stream));
 } /* }}} */
@@ -2116,6 +2226,10 @@ SPL_METHOD(SplFileObject, eof)
 SPL_METHOD(SplFileObject, valid)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {
 		RETURN_BOOL(intern->u.file.current_line || intern->u.file.current_zval);
@@ -2129,6 +2243,10 @@ SPL_METHOD(SplFileObject, valid)
 SPL_METHOD(SplFileObject, fgets)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (spl_filesystem_file_read(intern, 0 TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
@@ -2141,6 +2259,10 @@ SPL_METHOD(SplFileObject, fgets)
 SPL_METHOD(SplFileObject, current)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!intern->u.file.current_line && !intern->u.file.current_zval) {
 		spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
@@ -2158,6 +2280,10 @@ SPL_METHOD(SplFileObject, current)
 SPL_METHOD(SplFileObject, key)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 /*	Do not read the next line to support correct counting with fgetc()
 	if (!intern->current_line) {
@@ -2171,6 +2297,10 @@ SPL_METHOD(SplFileObject, key)
 SPL_METHOD(SplFileObject, next)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_filesystem_file_free_line(intern TSRMLS_CC);
 	if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {
@@ -2194,6 +2324,10 @@ SPL_METHOD(SplFileObject, getFlags)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
 	RETURN_LONG(intern->flags & SPL_FILE_OBJECT_MASK);
 } /* }}} */
 
@@ -2222,6 +2356,10 @@ SPL_METHOD(SplFileObject, setMaxLineLen)
 SPL_METHOD(SplFileObject, getMaxLineLen)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_LONG((long)intern->u.file.max_line_len);
 } /* }}} */
@@ -2230,6 +2368,10 @@ SPL_METHOD(SplFileObject, getMaxLineLen)
    Return false */
 SPL_METHOD(SplFileObject, hasChildren)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_FALSE;
 } /* }}} */
 
@@ -2237,6 +2379,9 @@ SPL_METHOD(SplFileObject, hasChildren)
    Read NULL */
 SPL_METHOD(SplFileObject, getChildren)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* return NULL */
 } /* }}} */
 
@@ -2579,7 +2724,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0)
 	ZEND_ARG_INFO(0, allowable_tags)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 0, 0, 1) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 1, 0, 1)
 	ZEND_ARG_INFO(0, format)
 ZEND_END_ARG_INFO()
 
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 505e92d..c0baf46 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_dllist.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: spl_dllist.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1043,6 +1043,10 @@ static void spl_dllist_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /*
 SPL_METHOD(SplDoublyLinkedList, key)
 {
 	spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_LONG(intern->traverse_position);
 }
@@ -1053,6 +1057,10 @@ SPL_METHOD(SplDoublyLinkedList, key)
 SPL_METHOD(SplDoublyLinkedList, prev)
 {
 	spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_dllist_it_helper_move_forward(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags ^ SPL_DLLIST_IT_LIFO TSRMLS_CC);
 }
@@ -1063,6 +1071,10 @@ SPL_METHOD(SplDoublyLinkedList, prev)
 SPL_METHOD(SplDoublyLinkedList, next)
 {
 	spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_dllist_it_helper_move_forward(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags TSRMLS_CC);
 }
@@ -1073,6 +1085,10 @@ SPL_METHOD(SplDoublyLinkedList, next)
 SPL_METHOD(SplDoublyLinkedList, valid)
 {
 	spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(intern->traverse_pointer != NULL);
 }
@@ -1083,6 +1099,10 @@ SPL_METHOD(SplDoublyLinkedList, valid)
 SPL_METHOD(SplDoublyLinkedList, rewind)
 {
 	spl_dllist_object *intern = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_dllist_it_helper_rewind(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags TSRMLS_CC);
 }
@@ -1094,6 +1114,10 @@ SPL_METHOD(SplDoublyLinkedList, current)
 {
 	spl_dllist_object     *intern  = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	spl_ptr_llist_element *element = intern->traverse_pointer;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (element == NULL || element->data == NULL) {
 		RETURN_NULL();
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index b7bc246..e81cfcc 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: spl_fixedarray.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: spl_fixedarray.c 305565 2010-11-19 20:07:32Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -158,6 +158,9 @@ static HashTable* spl_fixedarray_object_get_properties(zval *obj TSRMLS_DC) /* {
 				zend_hash_index_update(intern->std.properties, i, (void *)&intern->array->elements[i], sizeof(zval *), NULL);
 				Z_ADDREF_P(intern->array->elements[i]);
 			} else {
+				if (GC_G(gc_active)) {
+					return NULL;
+				}
 				zend_hash_index_update(intern->std.properties, i, (void *)&EG(uninitialized_zval_ptr), sizeof(zval *), NULL);
 				Z_ADDREF_P(EG(uninitialized_zval_ptr));
 			}
@@ -406,7 +409,11 @@ static void spl_fixedarray_object_write_dimension(zval *object, zval *offset, zv
 	intern = (spl_fixedarray_object *)zend_object_store_get_object(object TSRMLS_CC);
 
 	if (intern->fptr_offset_set) {
-		SEPARATE_ARG_IF_REF(offset);
+		if (!offset) {
+			ALLOC_INIT_ZVAL(offset);
+		} else {
+			SEPARATE_ARG_IF_REF(offset);
+		}
 		SEPARATE_ARG_IF_REF(value);
 		zend_call_method_with_2_params(&object, intern->std.ce, &intern->fptr_offset_set, "offsetSet", NULL, offset, value);
 		zval_ptr_dtor(&value);
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index d063377..bb164d8 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_heap.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: spl_heap.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -982,6 +982,10 @@ SPL_METHOD(SplHeap, key)
 {
 	spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}		
+	
 	RETURN_LONG(intern->heap->count - 1);
 }
 /* }}} */
@@ -992,6 +996,10 @@ SPL_METHOD(SplHeap, next)
 {
 	spl_heap_object      *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	spl_ptr_heap_element  elem   = spl_ptr_heap_delete_top(intern->heap, getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (elem != NULL) {
 		zval_ptr_dtor((zval **)&elem);
@@ -1004,6 +1012,10 @@ SPL_METHOD(SplHeap, next)
 SPL_METHOD(SplHeap, valid)
 {
 	spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(intern->heap->count != 0);
 }
@@ -1013,6 +1025,9 @@ SPL_METHOD(SplHeap, valid)
    Rewind the datastructure back to the start */
 SPL_METHOD(SplHeap, rewind)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* do nothing, the iterator always points to the top element */
 }
 /* }}} */
@@ -1023,6 +1038,10 @@ SPL_METHOD(SplHeap, current)
 {
 	spl_heap_object *intern  = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zval            *element = (zval *)intern->heap->elements[0];
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!intern->heap->count || !element) {
 		RETURN_NULL();
@@ -1038,6 +1057,10 @@ SPL_METHOD(SplPriorityQueue, current)
 {
 	spl_heap_object  *intern  = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zval            **element = (zval **)&intern->heap->elements[0];
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!intern->heap->count || !*element) {
 		RETURN_NULL();
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index f55a199..40c747f 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c 301065 2010-07-07 22:46:54Z felipe $ */
+/* $Id: spl_iterators.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -562,6 +562,10 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
 SPL_METHOD(RecursiveIteratorIterator, rewind)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_recursive_it_rewind_ex(object, getThis() TSRMLS_CC);
 } /* }}} */
@@ -571,6 +575,10 @@ SPL_METHOD(RecursiveIteratorIterator, rewind)
 SPL_METHOD(RecursiveIteratorIterator, valid)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	RETURN_BOOL(spl_recursive_it_valid_ex(object, getThis() TSRMLS_CC) == SUCCESS);
 } /* }}} */
@@ -581,6 +589,10 @@ SPL_METHOD(RecursiveIteratorIterator, key)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zend_object_iterator      *iterator = object->iterators[object->level].iterator;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (iterator->funcs->get_current_key) {
 		char *str_key;
@@ -609,6 +621,10 @@ SPL_METHOD(RecursiveIteratorIterator, current)
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zend_object_iterator      *iterator = object->iterators[object->level].iterator;
 	zval                      **data;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	iterator->funcs->get_current_data(iterator, &data TSRMLS_CC);
 	if (data && *data) {
@@ -621,6 +637,10 @@ SPL_METHOD(RecursiveIteratorIterator, current)
 SPL_METHOD(RecursiveIteratorIterator, next)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_recursive_it_move_forward_ex(object, getThis() TSRMLS_CC);
 } /* }}} */
@@ -631,6 +651,10 @@ SPL_METHOD(RecursiveIteratorIterator, getDepth)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(object->level);
 } /* }}} */
 
@@ -657,6 +681,10 @@ SPL_METHOD(RecursiveIteratorIterator, getInnerIterator)
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	long  level = object->level;
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_ZVAL(object->iterators[level].zobject, 1, 0);
 } /* }}} */
 
@@ -664,6 +692,9 @@ SPL_METHOD(RecursiveIteratorIterator, getInnerIterator)
    Called when iteration begins (after first rewind() call) */
 SPL_METHOD(RecursiveIteratorIterator, beginIteration)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -671,6 +702,9 @@ SPL_METHOD(RecursiveIteratorIterator, beginIteration)
    Called when iteration ends (when valid() first returns false */
 SPL_METHOD(RecursiveIteratorIterator, endIteration)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -681,6 +715,10 @@ SPL_METHOD(RecursiveIteratorIterator, callHasChildren)
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zend_class_entry *ce = object->iterators[object->level].ce;
 	zval *retval, *zobject;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zobject = object->iterators[object->level].zobject;
 	if (!zobject) {
@@ -702,6 +740,10 @@ SPL_METHOD(RecursiveIteratorIterator, callGetChildren)
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	zend_class_entry *ce = object->iterators[object->level].ce;
 	zval *retval, *zobject;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zobject = object->iterators[object->level].zobject;
 	if (!zobject) {
@@ -718,6 +760,9 @@ SPL_METHOD(RecursiveIteratorIterator, callGetChildren)
    Called when recursing one level down */
 SPL_METHOD(RecursiveIteratorIterator, beginChildren)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -725,6 +770,9 @@ SPL_METHOD(RecursiveIteratorIterator, beginChildren)
    Called when end recursing one level */
 SPL_METHOD(RecursiveIteratorIterator, endChildren)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -732,6 +780,9 @@ SPL_METHOD(RecursiveIteratorIterator, endChildren)
    Called when the next element is available */
 SPL_METHOD(RecursiveIteratorIterator, nextElement)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -758,6 +809,10 @@ SPL_METHOD(RecursiveIteratorIterator, getMaxDepth)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (object->max_depth == -1) {
 		RETURN_FALSE;
 	} else {
@@ -973,7 +1028,7 @@ SPL_METHOD(RecursiveTreeIterator, __construct)
 	spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_RecursiveTreeIterator, zend_ce_iterator, RIT_RecursiveTreeIterator);
 } /* }}} */
 
-/* {{{ proto void RecursiveTreeIterator::setPrefixPart() throws OutOfRangeException
+/* {{{ proto void RecursiveTreeIterator::setPrefixPart(int part, string prefix) throws OutOfRangeException
    Sets prefix parts as used in getPrefix() */
 SPL_METHOD(RecursiveTreeIterator, setPrefixPart)
 {
@@ -1000,6 +1055,9 @@ SPL_METHOD(RecursiveTreeIterator, getPrefix)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	spl_recursive_tree_iterator_get_prefix(object, return_value TSRMLS_CC);
 } /* }}} */
 
@@ -1009,6 +1067,10 @@ SPL_METHOD(RecursiveTreeIterator, getEntry)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	spl_recursive_tree_iterator_get_entry(object, return_value TSRMLS_CC);
 } /* }}} */
 
@@ -1018,6 +1080,10 @@ SPL_METHOD(RecursiveTreeIterator, getPostfix)
 {
 	spl_recursive_it_object   *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	spl_recursive_tree_iterator_get_postfix(object, return_value TSRMLS_CC);
 } /* }}} */
 
@@ -1029,6 +1095,10 @@ SPL_METHOD(RecursiveTreeIterator, current)
 	zval                       prefix, entry, postfix;
 	char                      *str, *ptr;
 	size_t                     str_len;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (object->flags & RTIT_BYPASS_CURRENT) {
 		zend_object_iterator      *iterator = object->iterators[object->level].iterator;
@@ -1074,6 +1144,10 @@ SPL_METHOD(RecursiveTreeIterator, key)
 	zval                       prefix, key, postfix, key_copy;
 	char                      *str, *ptr;
 	size_t                     str_len;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (iterator->funcs->get_current_key) {
 		char *str_key;
@@ -1440,6 +1514,10 @@ SPL_METHOD(dual_it, getInnerIterator)
 	spl_dual_it_object   *intern;
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (intern->inner.zobject) {
 		RETVAL_ZVAL(intern->inner.zobject, 1, 0);
@@ -1540,6 +1618,11 @@ SPL_METHOD(dual_it, rewind)
 	spl_dual_it_object   *intern;
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	spl_dual_it_rewind(intern TSRMLS_CC);
 	spl_dual_it_fetch(intern, 1 TSRMLS_CC);
 } /* }}} */
@@ -1553,6 +1636,10 @@ SPL_METHOD(dual_it, valid)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	RETURN_BOOL(intern->current.data);
@@ -1570,6 +1657,10 @@ SPL_METHOD(dual_it, key)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	if (intern->current.data) {
@@ -1593,6 +1684,10 @@ SPL_METHOD(dual_it, key)
 SPL_METHOD(dual_it, current)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1610,6 +1705,10 @@ SPL_METHOD(dual_it, current)
 SPL_METHOD(dual_it, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1655,6 +1754,10 @@ static inline void spl_filter_it_next(zval *zthis, spl_dual_it_object *intern TS
 SPL_METHOD(FilterIterator, rewind)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	spl_filter_it_rewind(getThis(), intern TSRMLS_CC);
@@ -1665,6 +1768,10 @@ SPL_METHOD(FilterIterator, rewind)
 SPL_METHOD(FilterIterator, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	spl_filter_it_next(getThis(), intern TSRMLS_CC);
@@ -1683,6 +1790,10 @@ SPL_METHOD(RecursiveFilterIterator, hasChildren)
 {
 	spl_dual_it_object   *intern;
 	zval                 *retval;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1700,6 +1811,10 @@ SPL_METHOD(RecursiveFilterIterator, getChildren)
 {
 	spl_dual_it_object   *intern;
 	zval                 *retval;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -1733,9 +1848,13 @@ SPL_METHOD(RegexIterator, accept)
 {
 	spl_dual_it_object *intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	char       *subject, tmp[32], *result;
-	int        subject_len, use_copy, count, result_len;
+	int        subject_len, use_copy, count = 0, result_len;
 	zval       subject_copy, zcount, *replacement;
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (intern->current.data == NULL) {
 		RETURN_FALSE;
 	}
@@ -1797,7 +1916,7 @@ SPL_METHOD(RegexIterator, accept)
 
 	case REGIT_MODE_REPLACE:
 		replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1 TSRMLS_CC);
-		result = php_pcre_replace_impl(intern->u.regex.pce, subject, subject_len, replacement, 0, &result_len, 0, NULL TSRMLS_CC);
+		result = php_pcre_replace_impl(intern->u.regex.pce, subject, subject_len, replacement, 0, &result_len, -1, &count TSRMLS_CC);
 		
 		if (intern->u.regex.flags & REGIT_USE_KEY) {
 			if (intern->current.key_type != HASH_KEY_IS_LONG) {
@@ -1811,6 +1930,7 @@ SPL_METHOD(RegexIterator, accept)
 			MAKE_STD_ZVAL(intern->current.data);
 			ZVAL_STRINGL(intern->current.data, result, result_len, 0);
 		}
+		RETVAL_BOOL(count > 0);
 	}
 
 	if (intern->u.regex.flags & REGIT_INVERTED) {
@@ -1828,6 +1948,10 @@ SPL_METHOD(RegexIterator, getMode)
 {
 	spl_dual_it_object *intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(intern->u.regex.mode);
 } /* }}} */
 
@@ -1856,6 +1980,10 @@ SPL_METHOD(RegexIterator, getFlags)
 {
 	spl_dual_it_object *intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(intern->u.regex.flags);
 } /* }}} */
 
@@ -1878,6 +2006,10 @@ SPL_METHOD(RegexIterator, setFlags)
 SPL_METHOD(RegexIterator, getPregFlags)
 {
 	spl_dual_it_object *intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (intern->u.regex.use_flags) {
 		RETURN_LONG(intern->u.regex.preg_flags);
@@ -1914,6 +2046,10 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
 {
 	spl_dual_it_object   *intern;
 	zval                 *retval, *regex;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2354,6 +2490,10 @@ SPL_METHOD(CachingIterator, __construct)
 SPL_METHOD(CachingIterator, rewind)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2365,6 +2505,10 @@ SPL_METHOD(CachingIterator, rewind)
 SPL_METHOD(CachingIterator, valid)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2376,6 +2520,10 @@ SPL_METHOD(CachingIterator, valid)
 SPL_METHOD(CachingIterator, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2387,6 +2535,10 @@ SPL_METHOD(CachingIterator, next)
 SPL_METHOD(CachingIterator, hasNext)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2531,6 +2683,10 @@ SPL_METHOD(CachingIterator, getCache)
 {
 	spl_dual_it_object   *intern;
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	if (!(intern->u.caching.flags & CIT_FULL_CACHE))	{
@@ -2548,6 +2704,10 @@ SPL_METHOD(CachingIterator, getFlags)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	RETURN_LONG(intern->u.caching.flags);
@@ -2593,6 +2753,10 @@ SPL_METHOD(CachingIterator, count)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	if (!(intern->u.caching.flags & CIT_FULL_CACHE))	{
@@ -2656,6 +2820,10 @@ SPL_METHOD(RecursiveCachingIterator, hasChildren)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	RETURN_BOOL(intern->u.caching.zchildren);
@@ -2666,6 +2834,10 @@ SPL_METHOD(RecursiveCachingIterator, hasChildren)
 SPL_METHOD(RecursiveCachingIterator, getChildren)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2721,6 +2893,9 @@ SPL_METHOD(NoRewindIterator, __construct)
    Prevent a call to inner iterators rewind() */
 SPL_METHOD(NoRewindIterator, rewind)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	/* nothing to do */
 } /* }}} */
 
@@ -2729,6 +2904,10 @@ SPL_METHOD(NoRewindIterator, rewind)
 SPL_METHOD(NoRewindIterator, valid)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	RETURN_BOOL(intern->inner.iterator->funcs->valid(intern->inner.iterator TSRMLS_CC) == SUCCESS);
@@ -2739,6 +2918,10 @@ SPL_METHOD(NoRewindIterator, valid)
 SPL_METHOD(NoRewindIterator, key)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2767,6 +2950,10 @@ SPL_METHOD(NoRewindIterator, current)
 {
 	spl_dual_it_object   *intern;
 	zval **data;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, &data TSRMLS_CC);
@@ -2780,6 +2967,10 @@ SPL_METHOD(NoRewindIterator, current)
 SPL_METHOD(NoRewindIterator, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	intern->inner.iterator->funcs->move_forward(intern->inner.iterator TSRMLS_CC);
@@ -2812,6 +3003,10 @@ SPL_METHOD(InfiniteIterator, __construct)
 SPL_METHOD(InfiniteIterator, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -2836,12 +3031,18 @@ static const zend_function_entry spl_funcs_InfiniteIterator[] = {
    Does nothing  */
 SPL_METHOD(EmptyIterator, rewind)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 } /* }}} */
 
 /* {{{ proto false EmptyIterator::valid()
    Return false */
 SPL_METHOD(EmptyIterator, valid)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	RETURN_FALSE;
 } /* }}} */
 
@@ -2849,6 +3050,9 @@ SPL_METHOD(EmptyIterator, valid)
    Throws exception BadMethodCallException */
 SPL_METHOD(EmptyIterator, key)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	zend_throw_exception(spl_ce_BadMethodCallException, "Accessing the key of an EmptyIterator", 0 TSRMLS_CC);
 } /* }}} */
 
@@ -2856,6 +3060,9 @@ SPL_METHOD(EmptyIterator, key)
    Throws exception BadMethodCallException */
 SPL_METHOD(EmptyIterator, current)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	zend_throw_exception(spl_ce_BadMethodCallException, "Accessing the value of an EmptyIterator", 0 TSRMLS_CC);
 } /* }}} */
 
@@ -2863,6 +3070,9 @@ SPL_METHOD(EmptyIterator, current)
    Does nothing */
 SPL_METHOD(EmptyIterator, next)
 {
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 } /* }}} */
 
 static const zend_function_entry spl_funcs_EmptyIterator[] = {
@@ -2962,6 +3172,10 @@ SPL_METHOD(AppendIterator, append)
 SPL_METHOD(AppendIterator, rewind)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
@@ -2977,6 +3191,10 @@ SPL_METHOD(AppendIterator, valid)
 {
 	spl_dual_it_object   *intern;
 
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
 	RETURN_BOOL(intern->current.data);
@@ -2987,6 +3205,10 @@ SPL_METHOD(AppendIterator, valid)
 SPL_METHOD(AppendIterator, next)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
@@ -2998,6 +3220,10 @@ SPL_METHOD(AppendIterator, next)
 SPL_METHOD(AppendIterator, getIteratorIndex)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
@@ -3010,6 +3236,10 @@ SPL_METHOD(AppendIterator, getIteratorIndex)
 SPL_METHOD(AppendIterator, getArrayIterator)
 {
 	spl_dual_it_object   *intern;
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 2902972..cd5fb9f 100755
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_observer.c 300843 2010-06-29 00:58:31Z stas $ */
+/* $Id: spl_observer.c 305335 2010-11-14 18:40:08Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -166,17 +166,17 @@ void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *obj, zval *in
 #endif
 } /* }}} */
 
-void spl_object_storage_detach(spl_SplObjectStorage *intern, zval *obj TSRMLS_DC) /* {{{ */
+int spl_object_storage_detach(spl_SplObjectStorage *intern, zval *obj TSRMLS_DC) /* {{{ */
 {
 #if HAVE_PACKED_OBJECT_VALUE
-	zend_hash_del(&intern->storage, (char*)&Z_OBJVAL_P(obj), sizeof(zend_object_value));
+	return zend_hash_del(&intern->storage, (char*)&Z_OBJVAL_P(obj), sizeof(zend_object_value));
 #else
 	{
 		zend_object_value zvalue;
 		memset(&zvalue, 0, sizeof(zend_object_value));
 		zvalue.handle = Z_OBJ_HANDLE_P(obj);
 		zvalue.handlers = Z_OBJ_HT_P(obj);
-		zend_hash_del(&intern->storage, (char*)&zvalue, sizeof(zend_object_value));
+		return zend_hash_del(&intern->storage, (char*)&zvalue, sizeof(zend_object_value));
 	}
 #endif
 } /* }}}*/
@@ -255,6 +255,8 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
 	*is_temp = 0;
 
 	props = Z_OBJPROP_P(obj);
+	zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
+
 	if (intern->debug_info == NULL) {
 		ALLOC_HASHTABLE(intern->debug_info);
 		ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(props) + 1, 0);
@@ -269,10 +271,11 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
 		zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
 		while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
 				php_spl_object_hash(element->obj, md5str TSRMLS_CC);
-				Z_ADDREF_P(element->obj);
-				Z_ADDREF_P(element->inf);
 				MAKE_STD_ZVAL(tmp);
 				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"), element->obj);
 				add_assoc_zval_ex(tmp, "inf", sizeof("inf"), element->inf);
 				add_assoc_zval_ex(storage, md5str, 33, tmp);
@@ -288,6 +291,56 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
 }
 /* }}} */
 
+/* overriden for garbage collection
+ * This is very hacky, but unfortunately the garbage collector can only query objects for
+ * dependencies through get_properties */
+static HashTable *spl_object_storage_get_properties(zval *obj TSRMLS_DC) /* {{{ */
+{
+	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(obj TSRMLS_CC);
+	spl_SplObjectStorageElement *element;
+	HashTable *props;
+	HashPosition pos;
+	zval *gcdata_arr = NULL,
+		 **gcdata_arr_pp;
+
+	props = std_object_handlers.get_properties(obj TSRMLS_CC);
+	
+	if (!GC_G(gc_active)) {
+		zend_hash_del(props, "\x00gcdata", sizeof("\x00gcdata"));
+		return props;
+	}
+
+	if (props->nApplyCount > 0) {
+		return props;
+	}
+
+	/* clean \x00gcdata, as it may be out of date */
+	if (zend_hash_find(props, "\x00gcdata", sizeof("\x00gcdata"), (void**) &gcdata_arr_pp) == SUCCESS) {
+		gcdata_arr = *gcdata_arr_pp;
+		zend_hash_clean(Z_ARRVAL_P(gcdata_arr));
+	}
+
+	if (gcdata_arr == NULL) {
+		MAKE_STD_ZVAL(gcdata_arr);
+		array_init(gcdata_arr);
+		/* don't decrease refcount of members when destroying */
+		Z_ARRVAL_P(gcdata_arr)->pDestructor = NULL;
+
+		/* name starts with \x00 to make tampering in user-land more difficult */
+		zend_hash_add(props, "\x00gcdata", sizeof("\x00gcdata"), &gcdata_arr, sizeof(gcdata_arr), NULL);
+	}
+
+	zend_hash_internal_pointer_reset_ex(&intern->storage, &pos);
+	while (zend_hash_get_current_data_ex(&intern->storage, (void **)&element, &pos) == SUCCESS) {
+		add_next_index_zval(gcdata_arr, element->obj);
+		add_next_index_zval(gcdata_arr, element->inf);
+		zend_hash_move_forward_ex(&intern->storage, &pos);
+	}
+
+	return props;
+}
+/* }}} */
+
 static int spl_object_storage_compare_info(spl_SplObjectStorageElement *e1, spl_SplObjectStorageElement *e2 TSRMLS_DC) /* {{{ */
 {
 	zval result;
@@ -412,7 +465,6 @@ SPL_METHOD(SplObjectStorage, removeAll)
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage *)zend_object_store_get_object(getThis() TSRMLS_CC);
 	spl_SplObjectStorage *other;
 	spl_SplObjectStorageElement *element;
-	HashPosition pos;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
 		return;
@@ -420,10 +472,11 @@ SPL_METHOD(SplObjectStorage, removeAll)
 
 	other = (spl_SplObjectStorage *)zend_object_store_get_object(obj TSRMLS_CC);
 
-	zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
-	while (zend_hash_get_current_data_ex(&other->storage, (void **)&element, &pos) == SUCCESS) {
-		spl_object_storage_detach(intern, element->obj TSRMLS_CC);
-		zend_hash_move_forward_ex(&other->storage, &pos);
+	zend_hash_internal_pointer_reset(&other->storage);
+	while (zend_hash_get_current_data(&other->storage, (void **)&element) == SUCCESS) {
+		if (spl_object_storage_detach(intern, element->obj TSRMLS_CC) == FAILURE) {
+			zend_hash_move_forward(&other->storage);
+		}
 	}
 
 	zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
@@ -451,6 +504,10 @@ SPL_METHOD(SplObjectStorage, count)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(zend_hash_num_elements(&intern->storage));
 } /* }}} */
 
@@ -460,6 +517,10 @@ SPL_METHOD(SplObjectStorage, rewind)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
 	intern->index = 0;
 } /* }}} */
@@ -470,6 +531,10 @@ SPL_METHOD(SplObjectStorage, valid)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_BOOL(zend_hash_has_more_elements_ex(&intern->storage, &intern->pos) == SUCCESS);
 } /* }}} */
 
@@ -479,6 +544,10 @@ SPL_METHOD(SplObjectStorage, key)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	RETURN_LONG(intern->index);
 } /* }}} */
 
@@ -489,6 +558,10 @@ SPL_METHOD(SplObjectStorage, current)
 	spl_SplObjectStorageElement *element;
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == FAILURE) {
 		return;
 	}
@@ -501,6 +574,10 @@ SPL_METHOD(SplObjectStorage, getInfo)
 {
 	spl_SplObjectStorageElement *element;
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	
 	if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == FAILURE) {
 		return;
@@ -534,6 +611,10 @@ SPL_METHOD(SplObjectStorage, next)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+	
 	zend_hash_move_forward_ex(&intern->storage, &intern->pos);
 	intern->index++;
 } /* }}} */
@@ -550,8 +631,12 @@ SPL_METHOD(SplObjectStorage, serialize)
 	php_serialize_data_t var_hash;
 	smart_str buf = {0};
 
-	PHP_VAR_SERIALIZE_INIT(var_hash);
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
+	PHP_VAR_SERIALIZE_INIT(var_hash);
+	
 	/* storage */
 	smart_str_appendl(&buf, "x:i:", 4);
 	smart_str_append_long(&buf, zend_hash_num_elements(&intern->storage));
@@ -799,6 +884,10 @@ SPL_METHOD(MultipleIterator, __construct)
 SPL_METHOD(MultipleIterator, getFlags)
 {
 	spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 	RETURN_LONG(intern->flags);
 }
 /* }}} */
@@ -862,6 +951,10 @@ SPL_METHOD(MultipleIterator, rewind)
 	zval                        *it;
 
 	intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
 	while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
@@ -881,6 +974,10 @@ SPL_METHOD(MultipleIterator, next)
 	zval                        *it;
 
 	intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
 	while (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == SUCCESS && !EG(exception)) {
@@ -901,6 +998,10 @@ SPL_METHOD(MultipleIterator, valid)
 	long                         expect, valid;
 
 	intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	if (!zend_hash_num_elements(&intern->storage)) {
 		RETURN_FALSE;
@@ -1005,6 +1106,10 @@ SPL_METHOD(MultipleIterator, current)
 {
 	spl_SplObjectStorage        *intern;
 	intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT, return_value TSRMLS_CC);
 }
@@ -1016,6 +1121,10 @@ SPL_METHOD(MultipleIterator, key)
 {
 	spl_SplObjectStorage        *intern;
 	intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
 	spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value TSRMLS_CC);
 }
@@ -1064,6 +1173,7 @@ PHP_MINIT_FUNCTION(spl_observer)
 	REGISTER_SPL_STD_CLASS_EX(SplObjectStorage, spl_SplObjectStorage_new, spl_funcs_SplObjectStorage);
 	memcpy(&spl_handler_SplObjectStorage, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
+	spl_handler_SplObjectStorage.get_properties  = spl_object_storage_get_properties;
 	spl_handler_SplObjectStorage.get_debug_info  = spl_object_storage_debug_info;
 	spl_handler_SplObjectStorage.compare_objects = spl_object_storage_compare_objects;
 	spl_handler_SplObjectStorage.clone_obj       = spl_object_storage_clone;
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
new file mode 100644
index 0000000..b3b6c7c
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SplFileObject::fgetcsv with default escape character
+--FILE--
+<?php
+$fp = fopen('SplFileObject::fgetcsv.csv', 'w+');
+fwrite($fp, '"aa\"","bb","\"c"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject::fgetcsv.csv');
+var_dump($fo->fgetcsv());
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject::fgetcsv.csv');
+?>
+--EXPECTF--
+array(3) {
+  [0]=>
+  string(4) "aa\""
+  [1]=>
+  string(2) "bb"
+  [2]=>
+  string(3) "\"c"
+}
diff --git a/ext/spl/tests/arrayObject_count_basic1.phpt b/ext/spl/tests/arrayObject_count_basic1.phpt
index 1a3b84d..a003c2c 100644
--- a/ext/spl/tests/arrayObject_count_basic1.phpt
+++ b/ext/spl/tests/arrayObject_count_basic1.phpt
@@ -67,7 +67,9 @@ int(99)
 int(2)
 int(99)
 int(1)
-int(1)
+
+Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
 ==ArrayIterator==
 int(99)
 int(0)
@@ -77,4 +79,6 @@ int(99)
 int(2)
 int(99)
 int(1)
-int(1)
\ No newline at end of file
+
+Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
\ No newline at end of file
diff --git a/ext/spl/tests/bug50579.phpt b/ext/spl/tests/bug50579.phpt
new file mode 100644
index 0000000..e32262a
--- /dev/null
+++ b/ext/spl/tests/bug50579.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #50579 (RegexIterator::REPLACE doesn't work)
+--FILE--
+<?php
+
+class foo extends ArrayIterator {
+	public function __construct( ) {
+		parent::__construct(array(
+		'test1'=>'test888', 
+		'test2'=>'what?', 
+		'test3'=>'test999'));
+	}
+}
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = '[$0]';
+foreach ($i as $name=>$value) {
+	echo $name . '=>' . $value . "\n";
+}
+  
+$i->replacement = '$1';
+foreach ($i as $name=>$value) {
+	echo $name . '=>' . $value . "\n";
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = '[$1]';
+foreach ($i as $name=>$value) {
+	echo $name . '=>' . $value . "\n";
+}
+
+?>
+--EXPECTF--
+test1=>[test888]
+test3=>[test999]
+test1=>888
+test3=>999
+test1=>[888]
+test3=>[999]
diff --git a/ext/spl/tests/bug52573.phpt b/ext/spl/tests/bug52573.phpt
new file mode 100644
index 0000000..54587fa
--- /dev/null
+++ b/ext/spl/tests/bug52573.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #52573 (SplFileObject::fscanf Segmentation fault)
+--FILE--
+<?php // test
+
+$result = null;
+$f = new SplFileObject(__FILE__, 'r');
+var_dump($f->fscanf('<?php // %s', $result));
+var_dump($result);
+var_dump($f->fscanf('<?php // %s'));
+?>
+--EXPECTF--
+int(1)
+string(4) "test"
+array(1) {
+  [0]=>
+  NULL
+}
diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt
new file mode 100644
index 0000000..b0ea3aa
--- /dev/null
+++ b/ext/spl/tests/bug53071.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
+--FILE--
+<?php
+class myClass
+{
+	public $member;
+}
+function LimitedScope()
+{
+	$myA = new myClass();
+	$myB = new SplObjectStorage();
+	$myC = new myClass();
+	$myC->member = $myA; // myC has a referece to myA
+	$myB->Attach($myC);  // myB attaches myC
+	$myA->member = $myB; // myA has myB, comleting the cycle
+}
+LimitedScope();
+var_dump(gc_collect_cycles());
+
+echo "Done.\n";
+
+?>
+--EXPECTF--
+int(5)
+Done.
diff --git a/ext/spl/tests/bug53144.phpt b/ext/spl/tests/bug53144.phpt
new file mode 100644
index 0000000..7cf179b
--- /dev/null
+++ b/ext/spl/tests/bug53144.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #53144 (Segfault in SplObjectStorage::removeAll)
+--FILE--
+<?php
+
+$o1 = new StdClass;
+$o2 = new StdClass;
+
+$b = new SplObjectStorage();
+$b[$o1] = "bar";
+$b[$o2] = "baz";
+
+var_dump(count($b));
+$b->removeAll($b);
+var_dump(count($b));
+
+?>
+--EXPECTF--
+int(2)
+int(0)
\ No newline at end of file
diff --git a/ext/spl/tests/bug53362.phpt b/ext/spl/tests/bug53362.phpt
new file mode 100644
index 0000000..70ba6e2
--- /dev/null
+++ b/ext/spl/tests/bug53362.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #53362 (Segmentation fault when extending SplFixedArray)
+--FILE--
+<?php
+
+class obj extends SplFixedArray{
+	public function offsetSet($offset, $value) {
+		var_dump($offset);
+	}
+}
+
+$obj = new obj;
+
+$obj[]=2;
+$obj[]=2;
+$obj[]=2;
+
+?>
+--EXPECTF--
+NULL
+NULL
+NULL
diff --git a/ext/spl/tests/fileobject_005.phpt b/ext/spl/tests/fileobject_005.phpt
index b3882e9..fa9e6db 100644
--- a/ext/spl/tests/fileobject_005.phpt
+++ b/ext/spl/tests/fileobject_005.phpt
@@ -33,8 +33,10 @@ unlink($path);
 ?>
 --EXPECTF--
 bool(true)
-string(4) "blah"
+
+Warning: SplFileObject::fgets() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
 
 Warning: SplFileObject::ftruncate() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
-==DONE==
+==DONE==
\ No newline at end of file
diff --git a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
index 399d9a3..cee557e 100755
--- a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
+++ b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
@@ -8,7 +8,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms
 ?>
 --FILE--
 <?php
-$link = 'test_link';
+$link = __DIR__ . '/test_link';
 symlink(__FILE__, $link );
 $fileInfo = new SplFileInfo($link);
 
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c
index c180f81..964c9a7 100644
--- a/ext/sqlite/sqlite.c
+++ b/ext/sqlite/sqlite.c
@@ -17,7 +17,7 @@
    |          Marcus Boerger <helly at php.net>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c 298697 2010-04-28 12:10:10Z iliaa $
+   $Id: sqlite.c 305507 2010-11-18 15:22:22Z pajoye $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -1458,7 +1458,7 @@ PHP_MINFO_FUNCTION(sqlite)
 {
 	php_info_print_table_start();
 	php_info_print_table_header(2, "SQLite support", "enabled");
-	php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c 298697 2010-04-28 12:10:10Z iliaa $");
+	php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c 305507 2010-11-18 15:22:22Z pajoye $");
 	php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
 	php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
 	php_info_print_table_end();
@@ -1560,6 +1560,9 @@ PHP_FUNCTION(sqlite_popen)
 		ZVAL_NULL(errmsg);
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
 	if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
 		/* resolve the fully-qualified path name to use as the hash key */
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
@@ -1637,6 +1640,9 @@ PHP_FUNCTION(sqlite_open)
 		ZVAL_NULL(errmsg);
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
 	if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
 		/* resolve the fully-qualified path name to use as the hash key */
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
@@ -1690,6 +1696,10 @@ PHP_FUNCTION(sqlite_factory)
 		ZVAL_NULL(errmsg);
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
 		/* resolve the fully-qualified path name to use as the hash key */
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c
index 45ee79c..55fcebc 100644
--- a/ext/sqlite3/libsqlite/sqlite3.c
+++ b/ext/sqlite3/libsqlite/sqlite3.c
@@ -4,7 +4,7 @@
 
 /******************************************************************************
 ** This file is an amalgamation of many separate C source files from SQLite
-** version 3.6.23.1.  By combining all the individual C code files into this 
+** version 3.7.3.  By combining all the individual C code files into this 
 ** single large file, the entire code can be compiled as a one translation
 ** unit.  This allows many compilers to do optimizations that would not be
 ** possible if the files were compiled separately.  Performance improvements
@@ -195,6 +195,14 @@
 #endif
 
 /*
+** The default number of frames to accumulate in the log file before
+** checkpointing the database in WAL mode.
+*/
+#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
+# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000
+#endif
+
+/*
 ** The maximum number of attached databases.  This must be between 0
 ** and 30.  The upper bound on 30 is because a 32-bit integer bitmap
 ** is used internally to track attached databases.
@@ -211,20 +219,21 @@
 # define SQLITE_MAX_VARIABLE_NUMBER 999
 #endif
 
-/* Maximum page size.  The upper bound on this value is 32768.  This a limit
-** imposed by the necessity of storing the value in a 2-byte unsigned integer
-** and the fact that the page size must be a power of 2.
+/* Maximum page size.  The upper bound on this value is 65536.  This a limit
+** imposed by the use of 16-bit offsets within each page.
 **
-** If this limit is changed, then the compiled library is technically
-** incompatible with an SQLite library compiled with a different limit. If
-** a process operating on a database with a page-size of 65536 bytes 
-** crashes, then an instance of SQLite compiled with the default page-size 
-** limit will not be able to rollback the aborted transaction. This could
-** lead to database corruption.
+** Earlier versions of SQLite allowed the user to change this value at
+** compile time. This is no longer permitted, on the grounds that it creates
+** a library that is technically incompatible with an SQLite library 
+** compiled with a different limit. If a process operating on a database 
+** with a page-size of 65536 bytes crashes, then an instance of SQLite 
+** compiled with the default page-size limit will not be able to rollback 
+** the aborted transaction. This could lead to database corruption.
 */
-#ifndef SQLITE_MAX_PAGE_SIZE
-# define SQLITE_MAX_PAGE_SIZE 32768
+#ifdef SQLITE_MAX_PAGE_SIZE
+# undef SQLITE_MAX_PAGE_SIZE
 #endif
+#define SQLITE_MAX_PAGE_SIZE 65536
 
 
 /*
@@ -327,7 +336,7 @@
 ** The correct "ANSI" way to do this is to use the intptr_t type. 
 ** Unfortunately, that typedef is not available on all compilers, or
 ** if it is available, it requires an #include of specific headers
-** that very from one machine to the next.
+** that vary from one machine to the next.
 **
 ** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on
 ** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).
@@ -349,15 +358,21 @@
 #endif
 
 /*
-** The SQLITE_THREADSAFE macro must be defined as either 0 or 1.
+** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
+** 0 means mutexes are permanently disable and the library is never
+** threadsafe.  1 means the library is serialized which is the highest
+** level of threadsafety.  2 means the libary is multithreaded - multiple
+** threads can use SQLite as long as no two threads try to use the same
+** database connection at the same time.
+**
 ** Older versions of SQLite used an optional THREADSAFE macro.
-** We support that for legacy
+** We support that for legacy.
 */
 #if !defined(SQLITE_THREADSAFE)
 #if defined(THREADSAFE)
 # define SQLITE_THREADSAFE THREADSAFE
 #else
-# define SQLITE_THREADSAFE 1
+# define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */
 #endif
 #endif
 
@@ -508,6 +523,13 @@ SQLITE_PRIVATE   void sqlite3Coverage(int);
 #endif
 
 /*
+** Return true (non-zero) if the input is a integer that is too large
+** to fit in 32-bits.  This macro is used inside of various testcase()
+** macros to verify that we have tested SQLite for large-file support.
+*/
+#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)
+
+/*
 ** The macro unlikely() is a hint that surrounds a boolean
 ** expression that is usually false.  Macro likely() surrounds
 ** a boolean expression that is usually true.  GCC is able to
@@ -622,7 +644,7 @@ extern "C" {
 **
 ** Since version 3.6.18, SQLite source code has been stored in the
 ** <a href="http://www.fossil-scm.org/">Fossil configuration management
-** system</a>.  ^The SQLITE_SOURCE_ID macro evalutes to
+** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
 ** a string which identifies a particular check-in of SQLite
 ** within its configuration management system.  ^The SQLITE_SOURCE_ID
 ** string contains the date and time of the check-in (UTC) and an SHA1
@@ -632,9 +654,9 @@ extern "C" {
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.6.23.1"
-#define SQLITE_VERSION_NUMBER 3006023
-#define SQLITE_SOURCE_ID      "2010-03-26 22:28:06 b078b588d617e07886ad156e9f54ade6d823568e"
+#define SQLITE_VERSION        "3.7.3"
+#define SQLITE_VERSION_NUMBER 3007003
+#define SQLITE_SOURCE_ID      "2010-10-08 02:34:02 2677848087c9c090efb17c1893e77d6136a9111d"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
@@ -671,7 +693,6 @@ SQLITE_API const char *sqlite3_libversion(void);
 SQLITE_API const char *sqlite3_sourceid(void);
 SQLITE_API int sqlite3_libversion_number(void);
 
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
 /*
 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
 **
@@ -680,7 +701,7 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** compile time.  ^The SQLITE_ prefix may be omitted from the 
 ** option name passed to sqlite3_compileoption_used().  
 **
-** ^The sqlite3_compileoption_get() function allows interating
+** ^The sqlite3_compileoption_get() function allows iterating
 ** over the list of options that were defined at compile time by
 ** returning the N-th compile time option string.  ^If N is out of range,
 ** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
@@ -688,15 +709,16 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** sqlite3_compileoption_get().
 **
 ** ^Support for the diagnostic functions sqlite3_compileoption_used()
-** and sqlite3_compileoption_get() may be omitted by specifing the 
+** and sqlite3_compileoption_get() may be omitted by specifying the 
 ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
 **
 ** See also: SQL functions [sqlite_compileoption_used()] and
 ** [sqlite_compileoption_get()] and the [compile_options pragma].
 */
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
 SQLITE_API const char *sqlite3_compileoption_get(int N);
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
+#endif
 
 /*
 ** CAPI3REF: Test To See If The Library Is Threadsafe
@@ -793,7 +815,7 @@ typedef sqlite_uint64 sqlite3_uint64;
 **
 ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
 ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
-** successfullly destroyed and all associated resources are deallocated.
+** successfully destroyed and all associated resources are deallocated.
 **
 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
@@ -918,7 +940,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */
 #define SQLITE_FULL        13   /* Insertion failed because database is full */
 #define SQLITE_CANTOPEN    14   /* Unable to open the database file */
-#define SQLITE_PROTOCOL    15   /* NOT USED. Database lock protocol error */
+#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
 #define SQLITE_EMPTY       16   /* Database is empty */
 #define SQLITE_SCHEMA      17   /* The database schema changed */
 #define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
@@ -974,7 +996,12 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
 #define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
 #define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
-#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED | (1<<8) )
+#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
+#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
+#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
+#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
+#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
+#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
 
 /*
 ** CAPI3REF: Flags For File Open Operations
@@ -1001,11 +1028,12 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
 #define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
 #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
+#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
 
 /*
 ** CAPI3REF: Device Characteristics
 **
-** The xDeviceCapabilities method of the [sqlite3_io_methods]
+** The xDeviceCharacteristics method of the [sqlite3_io_methods]
 ** object returns an integer which is a vector of the these
 ** bit values expressing I/O characteristics of the mass storage
 ** device that holds the file that the [sqlite3_io_methods]
@@ -1022,17 +1050,18 @@ SQLITE_API int sqlite3_exec(
 ** information is written to disk in the same order as calls
 ** to xWrite().
 */
-#define SQLITE_IOCAP_ATOMIC          0x00000001
-#define SQLITE_IOCAP_ATOMIC512       0x00000002
-#define SQLITE_IOCAP_ATOMIC1K        0x00000004
-#define SQLITE_IOCAP_ATOMIC2K        0x00000008
-#define SQLITE_IOCAP_ATOMIC4K        0x00000010
-#define SQLITE_IOCAP_ATOMIC8K        0x00000020
-#define SQLITE_IOCAP_ATOMIC16K       0x00000040
-#define SQLITE_IOCAP_ATOMIC32K       0x00000080
-#define SQLITE_IOCAP_ATOMIC64K       0x00000100
-#define SQLITE_IOCAP_SAFE_APPEND     0x00000200
-#define SQLITE_IOCAP_SEQUENTIAL      0x00000400
+#define SQLITE_IOCAP_ATOMIC                 0x00000001
+#define SQLITE_IOCAP_ATOMIC512              0x00000002
+#define SQLITE_IOCAP_ATOMIC1K               0x00000004
+#define SQLITE_IOCAP_ATOMIC2K               0x00000008
+#define SQLITE_IOCAP_ATOMIC4K               0x00000010
+#define SQLITE_IOCAP_ATOMIC8K               0x00000020
+#define SQLITE_IOCAP_ATOMIC16K              0x00000040
+#define SQLITE_IOCAP_ATOMIC32K              0x00000080
+#define SQLITE_IOCAP_ATOMIC64K              0x00000100
+#define SQLITE_IOCAP_SAFE_APPEND            0x00000200
+#define SQLITE_IOCAP_SEQUENTIAL             0x00000400
+#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800
 
 /*
 ** CAPI3REF: File Locking Levels
@@ -1183,6 +1212,12 @@ struct sqlite3_io_methods {
   int (*xFileControl)(sqlite3_file*, int op, void *pArg);
   int (*xSectorSize)(sqlite3_file*);
   int (*xDeviceCharacteristics)(sqlite3_file*);
+  /* Methods above are valid for version 1 */
+  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
+  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
+  void (*xShmBarrier)(sqlite3_file*);
+  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
+  /* Methods above are valid for version 2 */
   /* Additional methods may be added in future releases */
 };
 
@@ -1200,11 +1235,28 @@ struct sqlite3_io_methods {
 ** into an integer that the pArg argument points to. This capability
 ** is used during testing and only needs to be supported when SQLITE_TEST
 ** is defined.
+**
+** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
+** layer a hint of how large the database file will grow to be during the
+** current transaction.  This hint is not guaranteed to be accurate but it
+** is often close.  The underlying VFS might choose to preallocate database
+** file space based on this hint in order to help writes to the database
+** file run faster.
+**
+** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
+** extends and truncates the database file in chunks of a size specified
+** by the user. The fourth argument to [sqlite3_file_control()] should 
+** point to an integer (type int) containing the new chunk-size to use
+** for the nominated database. Allocating database file space in large
+** chunks (say 1MB at a time), may reduce file-system fragmentation and
+** improve performance on some systems.
 */
 #define SQLITE_FCNTL_LOCKSTATE        1
 #define SQLITE_GET_LOCKPROXYFILE      2
 #define SQLITE_SET_LOCKPROXYFILE      3
 #define SQLITE_LAST_ERRNO             4
+#define SQLITE_FCNTL_SIZE_HINT        5
+#define SQLITE_FCNTL_CHUNK_SIZE       6
 
 /*
 ** CAPI3REF: Mutex Handle
@@ -1252,15 +1304,19 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** The zName field holds the name of the VFS module.  The name must
 ** be unique across all VFS modules.
 **
-** SQLite will guarantee that the zFilename parameter to xOpen
+** ^SQLite guarantees that the zFilename parameter to xOpen
 ** is either a NULL pointer or string obtained
-** from xFullPathname().  SQLite further guarantees that
+** from xFullPathname() with an optional suffix added.
+** ^If a suffix is added to the zFilename parameter, it will
+** consist of a single "-" character followed by no more than
+** 10 alphanumeric and/or "-" characters.
+** ^SQLite further guarantees that
 ** the string will be valid and unchanged until xClose() is
 ** called. Because of the previous sentence,
 ** the [sqlite3_file] can safely store a pointer to the
 ** filename if it needs to remember the filename for some reason.
-** If the zFilename parameter is xOpen is a NULL pointer then xOpen
-** must invent its own temporary name for the file.  Whenever the 
+** If the zFilename parameter to xOpen is a NULL pointer then xOpen
+** must invent its own temporary name for the file.  ^Whenever the 
 ** xFilename parameter is NULL it will also be the case that the
 ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
 **
@@ -1271,7 +1327,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** If xOpen() opens a file read-only then it sets *pOutFlags to
 ** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
 **
-** SQLite will also add one of the following flags to the xOpen()
+** ^(SQLite will also add one of the following flags to the xOpen()
 ** call, depending on the object being opened:
 **
 ** <ul>
@@ -1282,7 +1338,8 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** <li>  [SQLITE_OPEN_TRANSIENT_DB]
 ** <li>  [SQLITE_OPEN_SUBJOURNAL]
 ** <li>  [SQLITE_OPEN_MASTER_JOURNAL]
-** </ul>
+** <li>  [SQLITE_OPEN_WAL]
+** </ul>)^
 **
 ** The file I/O implementation can use the object type flags to
 ** change the way it deals with files.  For example, an application
@@ -1301,10 +1358,11 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** </ul>
 **
 ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
-** deleted when it is closed.  The [SQLITE_OPEN_DELETEONCLOSE]
-** will be set for TEMP  databases, journals and for subjournals.
+** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
+** will be set for TEMP databases and their journals, transient
+** databases, and subjournals.
 **
-** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
+** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
 ** with the [SQLITE_OPEN_CREATE] flag, which are both directly
 ** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
 ** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 
@@ -1313,7 +1371,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** It is <i>not</i> used to indicate the file should be opened 
 ** for exclusive access.
 **
-** At least szOsFile bytes of memory are allocated by SQLite
+** ^At least szOsFile bytes of memory are allocated by SQLite
 ** to hold the  [sqlite3_file] structure passed as the third
 ** argument to xOpen.  The xOpen method does not have to
 ** allocate the structure; it should just fill it in.  Note that
@@ -1323,33 +1381,40 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** element will be valid after xOpen returns regardless of the success
 ** or failure of the xOpen call.
 **
-** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
+** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
 ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
 ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
 ** to test whether a file is at least readable.   The file can be a
 ** directory.
 **
-** SQLite will always allocate at least mxPathname+1 bytes for the
+** ^SQLite will always allocate at least mxPathname+1 bytes for the
 ** output buffer xFullPathname.  The exact size of the output buffer
 ** is also passed as a parameter to both  methods. If the output buffer
 ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
 ** handled as a fatal error by SQLite, vfs implementations should endeavor
 ** to prevent this by setting mxPathname to a sufficiently large value.
 **
-** The xRandomness(), xSleep(), and xCurrentTime() interfaces
-** are not strictly a part of the filesystem, but they are
+** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
+** interfaces are not strictly a part of the filesystem, but they are
 ** included in the VFS structure for completeness.
 ** The xRandomness() function attempts to return nBytes bytes
 ** of good-quality randomness into zOut.  The return value is
 ** the actual number of bytes of randomness obtained.
 ** The xSleep() method causes the calling thread to sleep for at
-** least the number of microseconds given.  The xCurrentTime()
-** method returns a Julian Day Number for the current date and time.
-**
+** least the number of microseconds given.  ^The xCurrentTime()
+** method returns a Julian Day Number for the current date and time as
+** a floating point value.
+** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
+** Day Number multipled by 86400000 (the number of milliseconds in 
+** a 24-hour day).  
+** ^SQLite will use the xCurrentTimeInt64() method to get the current
+** date and time if that method is available (if iVersion is 2 or 
+** greater and the function pointer is not NULL) and will fall back
+** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
 */
 typedef struct sqlite3_vfs sqlite3_vfs;
 struct sqlite3_vfs {
-  int iVersion;            /* Structure version number */
+  int iVersion;            /* Structure version number (currently 2) */
   int szOsFile;            /* Size of subclassed sqlite3_file */
   int mxPathname;          /* Maximum file pathname length */
   sqlite3_vfs *pNext;      /* Next registered VFS */
@@ -1368,8 +1433,16 @@ struct sqlite3_vfs {
   int (*xSleep)(sqlite3_vfs*, int microseconds);
   int (*xCurrentTime)(sqlite3_vfs*, double*);
   int (*xGetLastError)(sqlite3_vfs*, int, char *);
-  /* New fields may be appended in figure versions.  The iVersion
-  ** value will increment whenever this happens. */
+  /*
+  ** The methods above are in version 1 of the sqlite_vfs object
+  ** definition.  Those that follow are added in version 2 or later
+  */
+  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
+  /*
+  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
+  ** New fields may be appended in figure versions.  The iVersion
+  ** value will increment whenever this happens. 
+  */
 };
 
 /*
@@ -1381,13 +1454,58 @@ struct sqlite3_vfs {
 ** With SQLITE_ACCESS_EXISTS, the xAccess method
 ** simply checks whether the file exists.
 ** With SQLITE_ACCESS_READWRITE, the xAccess method
-** checks whether the file is both readable and writable.
+** checks whether the named directory is both readable and writable
+** (in other words, if files can be added, removed, and renamed within
+** the directory).
+** The SQLITE_ACCESS_READWRITE constant is currently used only by the
+** [temp_store_directory pragma], though this could change in a future
+** release of SQLite.
 ** With SQLITE_ACCESS_READ, the xAccess method
-** checks whether the file is readable.
+** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is
+** currently unused, though it might be used in a future release of
+** SQLite.
 */
 #define SQLITE_ACCESS_EXISTS    0
-#define SQLITE_ACCESS_READWRITE 1
-#define SQLITE_ACCESS_READ      2
+#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */
+#define SQLITE_ACCESS_READ      2   /* Unused */
+
+/*
+** CAPI3REF: Flags for the xShmLock VFS method
+**
+** These integer constants define the various locking operations
+** allowed by the xShmLock method of [sqlite3_io_methods].  The
+** following are the only legal combinations of flags to the
+** xShmLock method:
+**
+** <ul>
+** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
+** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
+** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
+** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
+** </ul>
+**
+** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
+** was given no the corresponding lock.  
+**
+** The xShmLock method can transition between unlocked and SHARED or
+** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
+** and EXCLUSIVE.
+*/
+#define SQLITE_SHM_UNLOCK       1
+#define SQLITE_SHM_LOCK         2
+#define SQLITE_SHM_SHARED       4
+#define SQLITE_SHM_EXCLUSIVE    8
+
+/*
+** CAPI3REF: Maximum xShmLock index
+**
+** The xShmLock method on [sqlite3_io_methods] may use values
+** between 0 and this upper bound as its "offset" argument.
+** The SQLite core will never attempt to acquire or release a
+** lock outside of this range
+*/
+#define SQLITE_SHM_NLOCK        8
+
 
 /*
 ** CAPI3REF: Initialize The SQLite Library
@@ -1498,11 +1616,10 @@ SQLITE_API int sqlite3_os_end(void);
 ** ^If the option is unknown or SQLite is unable to set the option
 ** then this routine returns a non-zero [error code].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
+SQLITE_API int sqlite3_config(int, ...);
 
 /*
 ** CAPI3REF: Configure database connections
-** EXPERIMENTAL
 **
 ** The sqlite3_db_config() interface is used to make configuration
 ** changes to a [database connection].  The interface is similar to
@@ -1522,11 +1639,10 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
 ** the call is considered successful.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
+SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
 
 /*
 ** CAPI3REF: Memory Allocation Routines
-** EXPERIMENTAL
 **
 ** An instance of this object defines the interface between SQLite
 ** and low-level memory allocation routines.
@@ -1608,7 +1724,6 @@ struct sqlite3_mem_methods {
 
 /*
 ** CAPI3REF: Configuration Options
-** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
 ** can be passed as the first argument to the [sqlite3_config()] interface.
@@ -1686,7 +1801,7 @@ struct sqlite3_mem_methods {
 **   <ul>
 **   <li> [sqlite3_memory_used()]
 **   <li> [sqlite3_memory_highwater()]
-**   <li> [sqlite3_soft_heap_limit()]
+**   <li> [sqlite3_soft_heap_limit64()]
 **   <li> [sqlite3_status()]
 **   </ul>)^
 ** ^Memory allocation statistics are enabled by default unless SQLite is
@@ -1700,15 +1815,14 @@ struct sqlite3_mem_methods {
 ** aligned memory buffer from which the scrach allocations will be
 ** drawn, the size of each scratch allocation (sz),
 ** and the maximum number of scratch allocations (N).  The sz
-** argument must be a multiple of 16. The sz parameter should be a few bytes
-** larger than the actual scratch space required due to internal overhead.
+** argument must be a multiple of 16.
 ** The first argument must be a pointer to an 8-byte aligned buffer
 ** of at least sz*N bytes of memory.
-** ^SQLite will use no more than one scratch buffer per thread.  So
-** N should be set to the expected maximum number of threads.  ^SQLite will
-** never require a scratch buffer that is more than 6 times the database
-** page size. ^If SQLite needs needs additional scratch memory beyond 
-** what is provided by this configuration option, then 
+** ^SQLite will use no more than two scratch buffers per thread.  So
+** N should be set to twice the expected maximum number of threads.
+** ^SQLite will never require a scratch buffer that is more than 6
+** times the database page size. ^If SQLite needs needs additional
+** scratch memory beyond what is provided by this configuration option, then 
 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 **
 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
@@ -1728,8 +1842,7 @@ struct sqlite3_mem_methods {
 ** memory needs for the first N pages that it adds to cache.  ^If additional
 ** page cache memory is needed beyond what is provided by this option, then
 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** ^The implementation might use one or more of the N buffers to hold 
-** memory accounting information. The pointer in the first argument must
+** The pointer in the first argument must
 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
 ** will be undefined.</dd>
 **
@@ -1794,6 +1907,24 @@ struct sqlite3_mem_methods {
 ** [sqlite3_pcache_methods] object.  SQLite copies of the current
 ** page cache implementation into that object.)^ </dd>
 **
+** <dt>SQLITE_CONFIG_LOG</dt>
+** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
+** function with a call signature of void(*)(void*,int,const char*), 
+** and a pointer to void. ^If the function pointer is not NULL, it is
+** invoked by [sqlite3_log()] to process each logging event.  ^If the
+** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
+** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
+** passed through as the first parameter to the application-defined logger
+** function whenever that function is invoked.  ^The second parameter to
+** the logger function is a copy of the first parameter to the corresponding
+** [sqlite3_log()] call and is intended to be a [result code] or an
+** [extended result code].  ^The third parameter passed to the logger is
+** log message after formatting via [sqlite3_snprintf()].
+** The SQLite logging interface is not reentrant; the logger function
+** supplied by the application must not invoke any SQLite interface.
+** In a multi-threaded application, the application-defined logger
+** function must be threadsafe. </dd>
+**
 ** </dl>
 */
 #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
@@ -1814,8 +1945,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
 
 /*
-** CAPI3REF: Configuration Options
-** EXPERIMENTAL
+** CAPI3REF: Database Connection Configuration Options
 **
 ** These constants are the available integer configuration options that
 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
@@ -1841,8 +1971,14 @@ struct sqlite3_mem_methods {
 ** or equal to the product of the second and third arguments.  The buffer
 ** must be aligned to an 8-byte boundary.  ^If the second argument to
 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
-** rounded down to the next smaller
-** multiple of 8.  See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
+** rounded down to the next smaller multiple of 8.  ^(The lookaside memory
+** configuration for a database connection can only be changed when that
+** connection is not currently using lookaside memory, or in other words
+** when the "current value" returned by
+** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
+** Any attempt to change the lookaside memory configuration when lookaside
+** memory is in use leaves the configuration unchanged and returns 
+** [SQLITE_BUSY].)^</dd>
 **
 ** </dl>
 */
@@ -2147,6 +2283,9 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 /*
 ** CAPI3REF: Convenience Routines For Running Queries
 **
+** This is a legacy interface that is preserved for backwards compatibility.
+** Use of this interface is not recommended.
+**
 ** Definition: A <b>result table</b> is memory data structure created by the
 ** [sqlite3_get_table()] interface.  A result table records the
 ** complete query results from one or more queries.
@@ -2167,7 +2306,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 ** It is not safe to pass a result table directly to [sqlite3_free()].
 ** A result table should be deallocated using [sqlite3_free_table()].
 **
-** As an example of the result table format, suppose a query result
+** ^(As an example of the result table format, suppose a query result
 ** is as follows:
 **
 ** <blockquote><pre>
@@ -2191,7 +2330,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 **        azResult[5] = "28";
 **        azResult[6] = "Cindy";
 **        azResult[7] = "21";
-** </pre></blockquote>
+** </pre></blockquote>)^
 **
 ** ^The sqlite3_get_table() function evaluates one or more
 ** semicolon-separated SQL statements in the zero-terminated UTF-8
@@ -2199,19 +2338,19 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 ** pointer given in its 3rd parameter.
 **
 ** After the application has finished with the result from sqlite3_get_table(),
-** it should pass the result table pointer to sqlite3_free_table() in order to
+** it must pass the result table pointer to sqlite3_free_table() in order to
 ** release the memory that was malloced.  Because of the way the
 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
 ** function must not try to call [sqlite3_free()] directly.  Only
 ** [sqlite3_free_table()] is able to release the memory properly and safely.
 **
-** ^(The sqlite3_get_table() interface is implemented as a wrapper around
+** The sqlite3_get_table() interface is implemented as a wrapper around
 ** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access
 ** to any internal data structures of SQLite.  It uses only the public
 ** interface defined here.  As a consequence, errors that occur in the
 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
 ** reflected in subsequent calls to [sqlite3_errcode()] or
-** [sqlite3_errmsg()].)^
+** [sqlite3_errmsg()].
 */
 SQLITE_API int sqlite3_get_table(
   sqlite3 *db,          /* An open database */
@@ -2363,7 +2502,9 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** is not freed.
 **
 ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
-** is always aligned to at least an 8 byte boundary.
+** is always aligned to at least an 8 byte boundary, or to a
+** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
+** option is used.
 **
 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
@@ -2591,7 +2732,6 @@ SQLITE_API int sqlite3_set_authorizer(
 
 /*
 ** CAPI3REF: Tracing And Profiling Functions
-** EXPERIMENTAL
 **
 ** These routines register callback functions that can be used for
 ** tracing and profiling the execution of SQL statements.
@@ -2607,26 +2747,43 @@ SQLITE_API int sqlite3_set_authorizer(
 ** ^The callback function registered by sqlite3_profile() is invoked
 ** as each SQL statement finishes.  ^The profile callback contains
 ** the original statement text and an estimate of wall-clock time
-** of how long that statement took to run.
-*/
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
+** of how long that statement took to run.  ^The profile callback
+** time is in units of nanoseconds, however the current implementation
+** is only capable of millisecond resolution so the six least significant
+** digits in the time are meaningless.  Future versions of SQLite
+** might provide greater resolution on the profiler callback.  The
+** sqlite3_profile() function is considered experimental and is
+** subject to change in future versions of SQLite.
+*/
+SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
    void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
 
 /*
 ** CAPI3REF: Query Progress Callbacks
 **
-** ^This routine configures a callback function - the
-** progress callback - that is invoked periodically during long
-** running calls to [sqlite3_exec()], [sqlite3_step()] and
-** [sqlite3_get_table()].  An example use for this
+** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
+** function X to be invoked periodically during long running calls to
+** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
+** database connection D.  An example use for this
 ** interface is to keep a GUI updated during a large query.
 **
+** ^The parameter P is passed through as the only parameter to the 
+** callback function X.  ^The parameter N is the number of 
+** [virtual machine instructions] that are evaluated between successive
+** invocations of the callback X.
+**
+** ^Only a single progress handler may be defined at one time per
+** [database connection]; setting a new progress handler cancels the
+** old one.  ^Setting parameter X to NULL disables the progress handler.
+** ^The progress handler is also disabled by setting N to a value less
+** than 1.
+**
 ** ^If the progress callback returns non-zero, the operation is
 ** interrupted.  This feature can be used to implement a
 ** "Cancel" button on a GUI progress dialog box.
 **
-** The progress handler must not do anything that will modify
+** The progress handler callback must not do anything that will modify
 ** the database connection that invoked the progress handler.
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
@@ -2685,7 +2842,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
 ** combinations shown above or one of the combinations shown above combined
 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
-** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
+** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags,
 ** then the behavior is undefined.
 **
 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
@@ -2810,17 +2967,22 @@ typedef struct sqlite3_stmt sqlite3_stmt;
 ** [database connection] whose limit is to be set or queried.  The
 ** second parameter is one of the [limit categories] that define a
 ** class of constructs to be size limited.  The third parameter is the
-** new limit for that construct.  The function returns the old limit.)^
+** new limit for that construct.)^
 **
 ** ^If the new limit is a negative number, the limit is unchanged.
-** ^(For the limit category of SQLITE_LIMIT_XYZ there is a 
+** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a 
 ** [limits | hard upper bound]
-** set by a compile-time C preprocessor macro named 
-** [limits | SQLITE_MAX_XYZ].
+** set at compile-time by a C preprocessor macro called
+** [limits | SQLITE_MAX_<i>NAME</i>].
 ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
 ** ^Attempts to increase a limit above its hard upper bound are
 ** silently truncated to the hard upper bound.
 **
+** ^Regardless of whether or not the limit was changed, the 
+** [sqlite3_limit()] interface returns the prior value of the limit.
+** ^Hence, to find the current value of a limit without changing it,
+** simply invoke this interface with the third parameter set to -1.
+**
 ** Run-time limits are intended for use in applications that manage
 ** both their own internal database and also databases that are controlled
 ** by untrusted external sources.  An example application might be a
@@ -2849,7 +3011,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** <dl>
 ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
-** <dd>The maximum size of any string or BLOB or table row.<dd>)^
+** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
@@ -2867,7 +3029,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
 ** <dd>The maximum number of instructions in a virtual machine program
-** used to implement an SQL statement.</dd>)^
+** used to implement an SQL statement.  This limit is not currently
+** enforced, though that might be added in some future release of
+** SQLite.</dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -2880,8 +3044,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** [GLOB] operators.</dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
-** <dd>The maximum number of variables in an SQL statement that can
-** be bound.</dd>)^
+** <dd>The maximum index number of any [parameter] in an SQL statement.)^
 **
 ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
 ** <dd>The maximum depth of recursion for triggers.</dd>)^
@@ -2953,12 +3116,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** <li>
 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
-** statement and try to run it again.  ^If the schema has changed in
-** a way that makes the statement no longer valid, [sqlite3_step()] will still
-** return [SQLITE_SCHEMA].  But unlike the legacy behavior, [SQLITE_SCHEMA] is
-** now a fatal error.  Calling [sqlite3_prepare_v2()] again will not make the
-** error go away.  Note: use [sqlite3_errmsg()] to find the text
-** of the parsing error that results in an [SQLITE_SCHEMA] return.
+** statement and try to run it again.
 ** </li>
 **
 ** <li>
@@ -2971,11 +3129,16 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** </li>
 **
 ** <li>
-** ^If the value of a [parameter | host parameter] in the WHERE clause might
-** change the query plan for a statement, then the statement may be
-** automatically recompiled (as if there had been a schema change) on the first 
-** [sqlite3_step()] call following any change to the 
-** [sqlite3_bind_text | bindings] of the [parameter]. 
+** ^If the specific value bound to [parameter | host parameter] in the 
+** WHERE clause might influence the choice of query plan for a statement,
+** then the statement will be automatically recompiled, as if there had been 
+** a schema change, on the first  [sqlite3_step()] call following any change
+** to the [sqlite3_bind_text | bindings] of that [parameter]. 
+** ^The specific value of WHERE-clause [parameter] might influence the 
+** choice of query plan if the parameter is the left-hand side of a [LIKE]
+** or [GLOB] operator or if the parameter is compared to an indexed column
+** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled.
+** the 
 ** </li>
 ** </ol>
 */
@@ -3042,7 +3205,7 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 ** then there is no distinction between protected and unprotected
 ** sqlite3_value objects and they can be used interchangeably.  However,
 ** for maximum code portability it is recommended that applications
-** still make the distinction between between protected and unprotected
+** still make the distinction between protected and unprotected
 ** sqlite3_value objects even when not strictly required.
 **
 ** ^The sqlite3_value objects that are passed as parameters into the
@@ -3088,7 +3251,7 @@ typedef struct sqlite3_context sqlite3_context;
 ** </ul>
 **
 ** In the templates above, NNN represents an integer literal,
-** and VVV represents an alphanumeric identifer.)^  ^The values of these
+** and VVV represents an alphanumeric identifier.)^  ^The values of these
 ** parameters (also called "host parameter names" or "SQL parameters")
 ** can be set using the sqlite3_bind_*() routines defined here.
 **
@@ -3237,6 +3400,8 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
 ** ^Return the number of columns in the result set returned by the
 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
 ** statement that does not return data (for example an [UPDATE]).
+**
+** See also: [sqlite3_data_count()]
 */
 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
 
@@ -3402,6 +3567,14 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** be the case that the same database connection is being used by two or
 ** more threads at the same moment in time.
 **
+** For all versions of SQLite up to and including 3.6.23.1, it was required
+** after sqlite3_step() returned anything other than [SQLITE_ROW] that
+** [sqlite3_reset()] be called before any subsequent invocation of
+** sqlite3_step().  Failure to invoke [sqlite3_reset()] in this way would
+** result in an [SQLITE_MISUSE] return from sqlite3_step().  But after
+** version 3.6.23.1, sqlite3_step() began calling [sqlite3_reset()] 
+** automatically in this circumstance rather than returning [SQLITE_MISUSE].  
+**
 ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
 ** API always returns a generic error code, [SQLITE_ERROR], following any
 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call
@@ -3419,8 +3592,14 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*);
 /*
 ** CAPI3REF: Number of columns in a result set
 **
-** ^The sqlite3_data_count(P) the number of columns in the
-** of the result set of [prepared statement] P.
+** ^The sqlite3_data_count(P) interface returns the number of columns in the
+** current row of the result set of [prepared statement] P.
+** ^If prepared statement P does not have results ready to return
+** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
+** interfaces) then sqlite3_data_count(P) returns 0.
+** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
+**
+** See also: [sqlite3_column_count()]
 */
 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 
@@ -3500,18 +3679,26 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** ^If the result is a numeric value then sqlite3_column_bytes() uses
 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
 ** the number of bytes in that string.
-** ^The value returned does not include the zero terminator at the end
-** of the string.  ^For clarity: the value returned is the number of
+** ^If the result is NULL, then sqlite3_column_bytes() returns zero.
+**
+** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
+** routine returns the number of bytes in that BLOB or string.
+** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
+** the string to UTF-16 and then returns the number of bytes.
+** ^If the result is a numeric value then sqlite3_column_bytes16() uses
+** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns
+** the number of bytes in that string.
+** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
+**
+** ^The values returned by [sqlite3_column_bytes()] and 
+** [sqlite3_column_bytes16()] do not include the zero terminators at the end
+** of the string.  ^For clarity: the values returned by
+** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
 ** bytes in the string, not the number of characters.
 **
 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
 ** even empty strings, are always zero terminated.  ^The return
-** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
-** pointer, possibly even a NULL pointer.
-**
-** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
-** but leaves the result in UTF-16 in native byte order instead of UTF-8.
-** ^The zero terminator is not included in this count.
+** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
 **
 ** ^The object returned by [sqlite3_column_value()] is an
 ** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
@@ -3556,10 +3743,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** used in the table for brevity and because they are familiar to most
 ** C programmers.
 **
-** ^Note that when type conversions occur, pointers returned by prior
+** Note that when type conversions occur, pointers returned by prior
 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
 ** sqlite3_column_text16() may be invalidated.
-** ^(Type conversions and pointer invalidations might occur
+** Type conversions and pointer invalidations might occur
 ** in the following cases:
 **
 ** <ul>
@@ -3572,22 +3759,22 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
 **      sqlite3_column_text() is called.  The content must be converted
 **      to UTF-8.</li>
-** </ul>)^
+** </ul>
 **
 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
 ** not invalidate a prior pointer, though of course the content of the buffer
-** that the prior pointer points to will have been modified.  Other kinds
+** that the prior pointer references will have been modified.  Other kinds
 ** of conversion are done in place when it is possible, but sometimes they
 ** are not possible and in those cases prior pointers are invalidated.
 **
-** ^(The safest and easiest to remember policy is to invoke these routines
+** The safest and easiest to remember policy is to invoke these routines
 ** in one of the following ways:
 **
 ** <ul>
 **  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
 **  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
 **  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
-** </ul>)^
+** </ul>
 **
 ** In other words, you should call sqlite3_column_text(),
 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
@@ -3625,17 +3812,26 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 ** CAPI3REF: Destroy A Prepared Statement Object
 **
 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
-** ^If the statement was executed successfully or not executed at all, then
-** SQLITE_OK is returned. ^If execution of the statement failed then an
-** [error code] or [extended error code] is returned.
-**
-** ^This routine can be called at any point during the execution of the
-** [prepared statement].  ^If the virtual machine has not
-** completed execution when this routine is called, that is like
-** encountering an error or an [sqlite3_interrupt | interrupt].
-** ^Incomplete updates may be rolled back and transactions canceled,
-** depending on the circumstances, and the
-** [error code] returned will be [SQLITE_ABORT].
+** ^If the most recent evaluation of the statement encountered no errors or
+** or if the statement is never been evaluated, then sqlite3_finalize() returns
+** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then
+** sqlite3_finalize(S) returns the appropriate [error code] or
+** [extended error code].
+**
+** ^The sqlite3_finalize(S) routine can be called at any point during
+** the life cycle of [prepared statement] S:
+** before statement S is ever evaluated, after
+** one or more calls to [sqlite3_reset()], or after any call
+** to [sqlite3_step()] regardless of whether or not the statement has
+** completed execution.
+**
+** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
+**
+** The application must finalize every [prepared statement] in order to avoid
+** resource leaks.  It is a grievous error for the application to try to use
+** a prepared statement after it has been finalized.  Any use of a prepared
+** statement after it has been finalized can result in undefined and
+** undesirable behavior such as segfaults and heap corruption.
 */
 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
 
@@ -3671,23 +3867,25 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** KEYWORDS: {application-defined SQL function}
 ** KEYWORDS: {application-defined SQL functions}
 **
-** ^These two functions (collectively known as "function creation routines")
+** ^These functions (collectively known as "function creation routines")
 ** are used to add SQL functions or aggregates or to redefine the behavior
-** of existing SQL functions or aggregates.  The only difference between the
-** two is that the second parameter, the name of the (scalar) function or
-** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
-** for sqlite3_create_function16().
+** of existing SQL functions or aggregates.  The only differences between
+** these routines are the text encoding expected for
+** the the second parameter (the name of the function being created)
+** and the presence or absence of a destructor callback for
+** the application data pointer.
 **
 ** ^The first parameter is the [database connection] to which the SQL
 ** function is to be added.  ^If an application uses more than one database
 ** connection then application-defined SQL functions must be added
 ** to each database connection separately.
 **
-** The second parameter is the name of the SQL function to be created or
-** redefined.  ^The length of the name is limited to 255 bytes, exclusive of
-** the zero-terminator.  Note that the name length limit is in bytes, not
-** characters.  ^Any attempt to create a function with a longer name
-** will result in [SQLITE_ERROR] being returned.
+** ^The second parameter is the name of the SQL function to be created or
+** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
+** representation, exclusive of the zero-terminator.  ^Note that the name
+** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  
+** ^Any attempt to create a function with a longer name
+** will result in [SQLITE_MISUSE] being returned.
 **
 ** ^The third parameter (nArg)
 ** is the number of arguments that the SQL function or
@@ -3697,10 +3895,10 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** parameter is less than -1 or greater than 127 then the behavior is
 ** undefined.
 **
-** The fourth parameter, eTextRep, specifies what
+** ^The fourth parameter, eTextRep, specifies what
 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
-** its parameters.  Any SQL function implementation should be able to work
-** work with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be
+** its parameters.  Every SQL function implementation must be able to work
+** with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be
 ** more efficient with one encoding than another.  ^An application may
 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
 ** times with the same function but with different values of eTextRep.
@@ -3712,13 +3910,21 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
 ** function can gain access to this pointer using [sqlite3_user_data()].)^
 **
-** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
+** ^The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
 ** pointers to C-language functions that implement the SQL function or
 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
-** callback only; NULL pointers should be passed as the xStep and xFinal
+** callback only; NULL pointers must be passed as the xStep and xFinal
 ** parameters. ^An aggregate SQL function requires an implementation of xStep
-** and xFinal and NULL should be passed for xFunc. ^To delete an existing
-** SQL function or aggregate, pass NULL for all three function callbacks.
+** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
+** SQL function or aggregate, pass NULL poiners for all three function
+** callbacks.
+**
+** ^If the tenth parameter to sqlite3_create_function_v2() is not NULL,
+** then it is invoked when the function is deleted, either by being
+** overloaded or when the database connection closes.
+** ^When the destructure callback of the tenth parameter is invoked, it
+** is passed a single argument which is a copy of the pointer which was
+** the fifth parameter to sqlite3_create_function_v2().
 **
 ** ^It is permitted to register multiple implementations of the same
 ** functions with the same name but with either differing numbers of
@@ -3734,11 +3940,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** between UTF8 and UTF16.
 **
 ** ^Built-in functions may be overloaded by new application-defined functions.
-** ^The first application-defined function with a given name overrides all
-** built-in functions in the same [database connection] with the same name.
-** ^Subsequent application-defined functions of the same name only override 
-** prior application-defined functions that are an exact match for the
-** number of parameters and preferred encoding.
 **
 ** ^An application-defined function is permitted to call other
 ** SQLite interfaces.  However, such calls must not
@@ -3765,6 +3966,17 @@ SQLITE_API int sqlite3_create_function16(
   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
   void (*xFinal)(sqlite3_context*)
 );
+SQLITE_API int sqlite3_create_function_v2(
+  sqlite3 *db,
+  const char *zFunctionName,
+  int nArg,
+  int eTextRep,
+  void *pApp,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
+  void (*xFinal)(sqlite3_context*),
+  void(*xDestroy)(void*)
+);
 
 /*
 ** CAPI3REF: Text Encodings
@@ -3859,7 +4071,7 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
 /*
 ** CAPI3REF: Obtain Aggregate Function Context
 **
-** Implementions of aggregate SQL functions use this
+** Implementations of aggregate SQL functions use this
 ** routine to allocate memory for storing their state.
 **
 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
@@ -4111,46 +4323,70 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 /*
 ** CAPI3REF: Define New Collating Sequences
 **
-** These functions are used to add new collation sequences to the
-** [database connection] specified as the first argument.
+** ^These functions add, remove, or modify a [collation] associated
+** with the [database connection] specified as the first argument.
 **
-** ^The name of the new collation sequence is specified as a UTF-8 string
+** ^The name of the collation is a UTF-8 string
 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
-** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
-** the name is passed as the second function argument.
-**
-** ^The third argument may be one of the constants [SQLITE_UTF8],
-** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
-** routine expects to be passed pointers to strings encoded using UTF-8,
-** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
-** third argument might also be [SQLITE_UTF16] to indicate that the routine
-** expects pointers to be UTF-16 strings in the native byte order, or the
-** argument can be [SQLITE_UTF16_ALIGNED] if the
-** the routine expects pointers to 16-bit word aligned strings
-** of UTF-16 in the native byte order.
-**
-** A pointer to the user supplied routine must be passed as the fifth
-** argument.  ^If it is NULL, this is the same as deleting the collation
-** sequence (so that SQLite cannot call it anymore).
-** ^Each time the application supplied function is invoked, it is passed
-** as its first parameter a copy of the void* passed as the fourth argument
-** to sqlite3_create_collation() or sqlite3_create_collation16().
-**
-** ^The remaining arguments to the application-supplied routine are two strings,
-** each represented by a (length, data) pair and encoded in the encoding
-** that was passed as the third argument when the collation sequence was
-** registered.  The application defined collation routine should
-** return negative, zero or positive if the first string is less than,
-** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
+** and a UTF-16 string in native byte order for sqlite3_create_collation16().
+** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
+** considered to be the same name.
+**
+** ^(The third argument (eTextRep) must be one of the constants:
+** <ul>
+** <li> [SQLITE_UTF8],
+** <li> [SQLITE_UTF16LE],
+** <li> [SQLITE_UTF16BE],
+** <li> [SQLITE_UTF16], or
+** <li> [SQLITE_UTF16_ALIGNED].
+** </ul>)^
+** ^The eTextRep argument determines the encoding of strings passed
+** to the collating function callback, xCallback.
+** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep
+** force strings to be UTF16 with native byte order.
+** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
+** on an even byte address.
+**
+** ^The fourth argument, pArg, is a application data pointer that is passed
+** through as the first argument to the collating function callback.
+**
+** ^The fifth argument, xCallback, is a pointer to the collating function.
+** ^Multiple collating functions can be registered using the same name but
+** with different eTextRep parameters and SQLite will use whichever
+** function requires the least amount of data transformation.
+** ^If the xCallback argument is NULL then the collating function is
+** deleted.  ^When all collating functions having the same name are deleted,
+** that collation is no longer usable.
+**
+** ^The collating function callback is invoked with a copy of the pArg 
+** application data pointer and with two strings in the encoding specified
+** by the eTextRep argument.  The collating function must return an
+** integer that is negative, zero, or positive
+** if the first string is less than, equal to, or greater than the second,
+** respectively.  A collating function must alway return the same answer
+** given the same inputs.  If two or more collating functions are registered
+** to the same collation name (using different eTextRep values) then all
+** must give an equivalent answer when invoked with equivalent strings.
+** The collating function must obey the following properties for all
+** strings A, B, and C:
+**
+** <ol>
+** <li> If A==B then B==A.
+** <li> If A==B and B==C then A==C.
+** <li> If A<B THEN B>A.
+** <li> If A<B and B<C then A<C.
+** </ol>
+**
+** If a collating function fails any of the above constraints and that
+** collating function is  registered and used, then the behavior of SQLite
+** is undefined.
 **
 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
-** except that it takes an extra argument which is a destructor for
-** the collation.  ^The destructor is called when the collation is
-** destroyed and is passed a copy of the fourth parameter void* pointer
-** of the sqlite3_create_collation_v2().
-** ^Collations are destroyed when they are overridden by later calls to the
-** collation creation functions or when the [database connection] is closed
-** using [sqlite3_close()].
+** with the addition that the xDestroy callback is invoked on pArg when
+** the collating function is deleted.
+** ^Collating functions are deleted when they are overridden by later
+** calls to the collation creation functions or when the
+** [database connection] is closed using [sqlite3_close()].
 **
 ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
 */
@@ -4158,14 +4394,14 @@ SQLITE_API int sqlite3_create_collation(
   sqlite3*, 
   const char *zName, 
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*)
 );
 SQLITE_API int sqlite3_create_collation_v2(
   sqlite3*, 
   const char *zName, 
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*),
   void(*xDestroy)(void*)
 );
@@ -4173,7 +4409,7 @@ SQLITE_API int sqlite3_create_collation16(
   sqlite3*, 
   const void *zName,
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*)
 );
 
@@ -4214,7 +4450,7 @@ SQLITE_API int sqlite3_collation_needed16(
   void(*)(void*,sqlite3*,int eTextRep,const void*)
 );
 
-#if SQLITE_HAS_CODEC
+#ifdef SQLITE_HAS_CODEC
 /*
 ** Specify the key for an encrypted database.  This routine should be
 ** called right after sqlite3_open().
@@ -4262,16 +4498,19 @@ SQLITE_API void sqlite3_activate_cerod(
 /*
 ** CAPI3REF: Suspend Execution For A Short Time
 **
-** ^The sqlite3_sleep() function causes the current thread to suspend execution
+** The sqlite3_sleep() function causes the current thread to suspend execution
 ** for at least a number of milliseconds specified in its parameter.
 **
-** ^If the operating system does not support sleep requests with
+** If the operating system does not support sleep requests with
 ** millisecond time resolution, then the time will be rounded up to
-** the nearest second. ^The number of milliseconds of sleep actually
+** the nearest second. The number of milliseconds of sleep actually
 ** requested from the operating system is returned.
 **
 ** ^SQLite implements this interface by calling the xSleep()
-** method of the default [sqlite3_vfs] object.
+** method of the default [sqlite3_vfs] object.  If the xSleep() method
+** of the default VFS is not implemented correctly, or not implemented at
+** all, then the behavior of sqlite3_sleep() may deviate from the description
+** in the previous paragraphs.
 */
 SQLITE_API int sqlite3_sleep(int);
 
@@ -4397,8 +4636,6 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 ** an error or constraint causes an implicit rollback to occur.
 ** ^The rollback callback is not invoked if a transaction is
 ** automatically rolled back because the database connection is closed.
-** ^The rollback callback is not invoked if a transaction is
-** rolled back because a commit callback returned non-zero.
 **
 ** See also the [sqlite3_update_hook()] interface.
 */
@@ -4495,40 +4732,73 @@ SQLITE_API int sqlite3_enable_shared_cache(int);
 ** pages to improve performance is an example of non-essential memory.
 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
 ** which might be more or less than the amount requested.
+** ^The sqlite3_release_memory() routine is a no-op returning zero
+** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
 */
 SQLITE_API int sqlite3_release_memory(int);
 
 /*
 ** CAPI3REF: Impose A Limit On Heap Size
 **
-** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
-** on the amount of heap memory that may be allocated by SQLite.
-** ^If an internal allocation is requested that would exceed the
-** soft heap limit, [sqlite3_release_memory()] is invoked one or
-** more times to free up some space before the allocation is performed.
+** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
+** soft limit on the amount of heap memory that may be allocated by SQLite.
+** ^SQLite strives to keep heap memory utilization below the soft heap
+** limit by reducing the number of pages held in the page cache
+** as heap memory usages approaches the limit.
+** ^The soft heap limit is "soft" because even though SQLite strives to stay
+** below the limit, it will exceed the limit rather than generate
+** an [SQLITE_NOMEM] error.  In other words, the soft heap limit 
+** is advisory only.
+**
+** ^The return value from sqlite3_soft_heap_limit64() is the size of
+** the soft heap limit prior to the call.  ^If the argument N is negative
+** then no change is made to the soft heap limit.  Hence, the current
+** size of the soft heap limit can be determined by invoking
+** sqlite3_soft_heap_limit64() with a negative argument.
+**
+** ^If the argument N is zero then the soft heap limit is disabled.
 **
-** ^The limit is called "soft" because if [sqlite3_release_memory()]
-** cannot free sufficient memory to prevent the limit from being exceeded,
-** the memory is allocated anyway and the current operation proceeds.
+** ^(The soft heap limit is not enforced in the current implementation
+** if one or more of following conditions are true:
 **
-** ^A negative or zero value for N means that there is no soft heap limit and
-** [sqlite3_release_memory()] will only be called when memory is exhausted.
-** ^The default value for the soft heap limit is zero.
+** <ul>
+** <li> The soft heap limit is set to zero.
+** <li> Memory accounting is disabled using a combination of the
+**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
+**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
+** <li> An alternative page cache implementation is specifed using
+**      [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
+** <li> The page cache allocates from its own memory pool supplied
+**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
+**      from the heap.
+** </ul>)^
 **
-** ^(SQLite makes a best effort to honor the soft heap limit.
-** But if the soft heap limit cannot be honored, execution will
-** continue without error or notification.)^  This is why the limit is
-** called a "soft" limit.  It is advisory only.
+** Beginning with SQLite version 3.7.3, the soft heap limit is enforced
+** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
+** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
+** the soft heap limit is enforced on every memory allocation.  Without
+** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
+** when memory is allocated by the page cache.  Testing suggests that because
+** the page cache is the predominate memory user in SQLite, most
+** applications will achieve adequate soft heap limit enforcement without
+** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
 **
-** Prior to SQLite version 3.5.0, this routine only constrained the memory
-** allocated by a single thread - the same thread in which this routine
-** runs.  Beginning with SQLite version 3.5.0, the soft heap limit is
-** applied to all threads. The value specified for the soft heap limit
-** is an upper bound on the total memory allocation for all threads. In
-** version 3.5.0 there is no mechanism for limiting the heap usage for
-** individual threads.
+** The circumstances under which SQLite will enforce the soft heap limit may
+** changes in future releases of SQLite.
 */
-SQLITE_API void sqlite3_soft_heap_limit(int);
+SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
+
+/*
+** CAPI3REF: Deprecated Soft Heap Limit Interface
+** DEPRECATED
+**
+** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
+** interface.  This routine is provided for historical compatibility
+** only.  All new applications should use the
+** [sqlite3_soft_heap_limit64()] interface rather than this one.
+*/
+SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
+
 
 /*
 ** CAPI3REF: Extract Metadata About A Column Of A Table
@@ -4652,40 +4922,51 @@ SQLITE_API int sqlite3_load_extension(
 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
 
 /*
-** CAPI3REF: Automatically Load An Extensions
+** CAPI3REF: Automatically Load Statically Linked Extensions
 **
-** ^This API can be invoked at program startup in order to register
-** one or more statically linked extensions that will be available
-** to all new [database connections].
+** ^This interface causes the xEntryPoint() function to be invoked for
+** each new [database connection] that is created.  The idea here is that
+** xEntryPoint() is the entry point for a statically linked SQLite extension
+** that is to be automatically loaded into all new database connections.
 **
-** ^(This routine stores a pointer to the extension entry point
-** in an array that is obtained from [sqlite3_malloc()].  That memory
-** is deallocated by [sqlite3_reset_auto_extension()].)^
+** ^(Even though the function prototype shows that xEntryPoint() takes
+** no arguments and returns void, SQLite invokes xEntryPoint() with three
+** arguments and expects and integer result as if the signature of the
+** entry point where as follows:
 **
-** ^This function registers an extension entry point that is
-** automatically invoked whenever a new [database connection]
-** is opened using [sqlite3_open()], [sqlite3_open16()],
-** or [sqlite3_open_v2()].
-** ^Duplicate extensions are detected so calling this routine
-** multiple times with the same extension is harmless.
-** ^Automatic extensions apply across all threads.
+** <blockquote><pre>
+**    int xEntryPoint(
+**      sqlite3 *db,
+**      const char **pzErrMsg,
+**      const struct sqlite3_api_routines *pThunk
+**    );
+** </pre></blockquote>)^
+**
+** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
+** point to an appropriate error message (obtained from [sqlite3_mprintf()])
+** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg
+** is NULL before calling the xEntryPoint().  ^SQLite will invoke
+** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any
+** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],
+** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.
+**
+** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
+** on the list of automatic extensions is a harmless no-op. ^No entry point
+** will be called more than once for each database connection that is opened.
+**
+** See also: [sqlite3_reset_auto_extension()].
 */
 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
 
 /*
 ** CAPI3REF: Reset Automatic Extension Loading
 **
-** ^(This function disables all previously registered automatic
-** extensions. It undoes the effect of all prior
-** [sqlite3_auto_extension()] calls.)^
-**
-** ^This function disables automatic extensions in all threads.
+** ^This interface disables all automatic extensions previously
+** registered using [sqlite3_auto_extension()].
 */
 SQLITE_API void sqlite3_reset_auto_extension(void);
 
 /*
-****** EXPERIMENTAL - subject to change without notice **************
-**
 ** The interface to the virtual-table mechanism is currently considered
 ** to be experimental.  The interface might change in incompatible ways.
 ** If this is a problem for you, do not use the interface at this time.
@@ -4705,7 +4986,6 @@ typedef struct sqlite3_module sqlite3_module;
 /*
 ** CAPI3REF: Virtual Table Object
 ** KEYWORDS: sqlite3_module {virtual table module}
-** EXPERIMENTAL
 **
 ** This structure, sometimes called a a "virtual table module", 
 ** defines the implementation of a [virtual tables].  
@@ -4752,9 +5032,9 @@ struct sqlite3_module {
 /*
 ** CAPI3REF: Virtual Table Indexing Information
 ** KEYWORDS: sqlite3_index_info
-** EXPERIMENTAL
 **
-** The sqlite3_index_info structure and its substructures is used to
+** The sqlite3_index_info structure and its substructures is used as part
+** of the [virtual table] interface to
 ** pass information into and receive the reply from the [xBestIndex]
 ** method of a [virtual table module].  The fields under **Inputs** are the
 ** inputs to xBestIndex and are read-only.  xBestIndex inserts its
@@ -4762,10 +5042,12 @@ struct sqlite3_module {
 **
 ** ^(The aConstraint[] array records WHERE clause constraints of the form:
 **
-** <pre>column OP expr</pre>
+** <blockquote>column OP expr</blockquote>
 **
 ** where OP is =, <, <=, >, or >=.)^  ^(The particular operator is
-** stored in aConstraint[].op.)^  ^(The index of the column is stored in
+** stored in aConstraint[].op using one of the
+** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^
+** ^(The index of the column is stored in
 ** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the
 ** expr on the right-hand side can be evaluated (and thus the constraint
 ** is usable) and false if it cannot.)^
@@ -4825,6 +5107,15 @@ struct sqlite3_index_info {
   int orderByConsumed;       /* True if output is already ordered */
   double estimatedCost;      /* Estimated cost of using this index */
 };
+
+/*
+** CAPI3REF: Virtual Table Constraint Operator Codes
+**
+** These macros defined the allowed values for the
+** [sqlite3_index_info].aConstraint[].op field.  Each value represents
+** an operator that is part of a constraint term in the wHERE clause of
+** a query that uses a [virtual table].
+*/
 #define SQLITE_INDEX_CONSTRAINT_EQ    2
 #define SQLITE_INDEX_CONSTRAINT_GT    4
 #define SQLITE_INDEX_CONSTRAINT_LE    8
@@ -4834,7 +5125,6 @@ struct sqlite3_index_info {
 
 /*
 ** CAPI3REF: Register A Virtual Table Implementation
-** EXPERIMENTAL
 **
 ** ^These routines are used to register a new [virtual table module] name.
 ** ^Module names must be registered before
@@ -4856,13 +5146,13 @@ struct sqlite3_index_info {
 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
 ** destructor.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
+SQLITE_API int sqlite3_create_module(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
   const sqlite3_module *p,   /* Methods for the module */
   void *pClientData          /* Client data for xCreate/xConnect */
 );
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
+SQLITE_API int sqlite3_create_module_v2(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
   const sqlite3_module *p,   /* Methods for the module */
@@ -4873,7 +5163,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
 /*
 ** CAPI3REF: Virtual Table Instance Object
 ** KEYWORDS: sqlite3_vtab
-** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass
 ** of this object to describe a particular instance
@@ -4899,7 +5188,6 @@ struct sqlite3_vtab {
 /*
 ** CAPI3REF: Virtual Table Cursor Object
 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
-** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass of the
 ** following structure to describe cursors that point into the
@@ -4921,18 +5209,16 @@ struct sqlite3_vtab_cursor {
 
 /*
 ** CAPI3REF: Declare The Schema Of A Virtual Table
-** EXPERIMENTAL
 **
 ** ^The [xCreate] and [xConnect] methods of a
 ** [virtual table module] call this interface
 ** to declare the format (the names and datatypes of the columns) of
 ** the virtual tables they implement.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
+SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
 
 /*
 ** CAPI3REF: Overload A Function For A Virtual Table
-** EXPERIMENTAL
 **
 ** ^(Virtual tables can provide alternative implementations of functions
 ** using the [xFindFunction] method of the [virtual table module].  
@@ -4947,7 +5233,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zS
 ** purpose is to be a placeholder function that can be overloaded
 ** by a [virtual table].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
+SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
 
 /*
 ** The interface to the virtual-table mechanism defined above (back up
@@ -4957,8 +5243,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const cha
 **
 ** When the virtual-table mechanism stabilizes, we will declare the
 ** interface fixed, support it indefinitely, and remove this comment.
-**
-****** EXPERIMENTAL - subject to change without notice **************
 */
 
 /*
@@ -5301,7 +5585,6 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 
 /*
 ** CAPI3REF: Mutex Methods Object
-** EXPERIMENTAL
 **
 ** An instance of this structure defines the low-level routines
 ** used to allocate and use mutexes.
@@ -5318,7 +5601,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 **
 ** ^The xMutexInit method defined by this structure is invoked as
 ** part of system initialization by the sqlite3_initialize() function.
-** ^The xMutexInit routine is calle by SQLite exactly once for each
+** ^The xMutexInit routine is called by SQLite exactly once for each
 ** effective call to [sqlite3_initialize()].
 **
 ** ^The xMutexEnd method defined by this structure is invoked as
@@ -5351,7 +5634,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** it is passed a NULL pointer).
 **
 ** The xMutexInit() method must be threadsafe.  ^It must be harmless to
-** invoke xMutexInit() mutiple times within the same process and without
+** invoke xMutexInit() multiple times within the same process and without
 ** intervening calls to xMutexEnd().  Second and subsequent calls to
 ** xMutexInit() must be no-ops.
 **
@@ -5514,14 +5797,15 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 #define SQLITE_TESTCTRL_RESERVE                 14
 #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
 #define SQLITE_TESTCTRL_ISKEYWORD               16
-#define SQLITE_TESTCTRL_LAST                    16
+#define SQLITE_TESTCTRL_PGHDRSZ                 17
+#define SQLITE_TESTCTRL_SCRATCHMALLOC           18
+#define SQLITE_TESTCTRL_LAST                    18
 
 /*
 ** CAPI3REF: SQLite Runtime Status
-** EXPERIMENTAL
 **
 ** ^This interface is used to retrieve runtime status information
-** about the preformance of SQLite, and optionally to reset various
+** about the performance of SQLite, and optionally to reset various
 ** highwater marks.  ^The first argument is an integer code for
 ** the specific parameter to measure.  ^(Recognized integer codes
 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
@@ -5534,7 +5818,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** ^(Other parameters record only the highwater mark and not the current
 ** value.  For these latter parameters nothing is written into *pCurrent.)^
 **
-** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
+** ^The sqlite3_status() routine returns SQLITE_OK on success and a
 ** non-zero [error code] on failure.
 **
 ** This routine is threadsafe but is not atomic.  This routine can be
@@ -5546,12 +5830,11 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 **
 ** See also: [sqlite3_db_status()]
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
 
 
 /*
 ** CAPI3REF: Status Parameters
-** EXPERIMENTAL
 **
 ** These integer constants designate various run-time status parameters
 ** that can be returned by [sqlite3_status()].
@@ -5574,6 +5857,9 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
 ** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
+** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
+** <dd>This parameter records the number of separate memory allocations.</dd>)^
+**
 ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
 ** <dd>This parameter returns the number of pages used out of the
 ** [pagecache memory allocator] that was configured using 
@@ -5582,7 +5868,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 **
 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
 ** <dd>This parameter returns the number of bytes of page cache
-** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
+** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The
 ** returned value includes allocations that overflowed because they
 ** where too large (they were larger than the "sz" parameter to
@@ -5605,7 +5891,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 **
 ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
 ** <dd>This parameter returns the number of bytes of scratch memory
-** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
+** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The values
 ** returned include overflows because the requested allocation was too
 ** larger (that is, because the requested allocation was larger than the
@@ -5635,30 +5921,34 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 #define SQLITE_STATUS_PARSER_STACK         6
 #define SQLITE_STATUS_PAGECACHE_SIZE       7
 #define SQLITE_STATUS_SCRATCH_SIZE         8
+#define SQLITE_STATUS_MALLOC_COUNT         9
 
 /*
 ** CAPI3REF: Database Connection Status
-** EXPERIMENTAL
 **
 ** ^This interface is used to retrieve runtime status information 
 ** about a single [database connection].  ^The first argument is the
 ** database connection object to be interrogated.  ^The second argument
-** is the parameter to interrogate.  ^Currently, the only allowed value
-** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
-** Additional options will likely appear in future releases of SQLite.
+** is an integer constant, taken from the set of
+** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that
+** determines the parameter to interrogate.  The set of 
+** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely
+** to grow in future releases of SQLite.
 **
 ** ^The current value of the requested parameter is written into *pCur
 ** and the highest instantaneous value is written into *pHiwtr.  ^If
 ** the resetFlg is true, then the highest instantaneous value is
 ** reset back down to the current value.
 **
+** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
+** non-zero [error code] on failure.
+**
 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
+SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
 /*
 ** CAPI3REF: Status Parameters for database connections
-** EXPERIMENTAL
 **
 ** These constants are the available integer "verbs" that can be passed as
 ** the second argument to the [sqlite3_db_status()] interface.
@@ -5673,14 +5963,38 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
 ** <dd>This parameter returns the number of lookaside memory slots currently
 ** checked out.</dd>)^
+**
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** memory used by all pager caches associated with the database connection.)^
+** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
+**
+** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** memory used to store the schema for all databases associated
+** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
+** ^The full amount of memory used by the schemas is reported, even if the
+** schema memory is shared with other database connections due to
+** [shared cache mode] being enabled.
+** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
+**
+** ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** and lookaside memory used by all prepared statements associated with
+** the database connection.)^
+** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
+** </dd>
 ** </dl>
 */
 #define SQLITE_DBSTATUS_LOOKASIDE_USED     0
+#define SQLITE_DBSTATUS_CACHE_USED         1
+#define SQLITE_DBSTATUS_SCHEMA_USED        2
+#define SQLITE_DBSTATUS_STMT_USED          3
+#define SQLITE_DBSTATUS_MAX                3   /* Largest defined DBSTATUS */
 
 
 /*
 ** CAPI3REF: Prepared Statement Status
-** EXPERIMENTAL
 **
 ** ^(Each prepared statement maintains various
 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
@@ -5702,11 +6016,10 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 **
 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
+SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
 
 /*
 ** CAPI3REF: Status Parameters for prepared statements
-** EXPERIMENTAL
 **
 ** These preprocessor macros define integer codes that name counter
 ** values associated with the [sqlite3_stmt_status()] interface.
@@ -5724,14 +6037,21 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int
 ** A non-zero value in this counter may indicate an opportunity to
 ** improvement performance through careful use of indices.</dd>
 **
+** <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
+** <dd>^This is the number of rows inserted into transient indices that
+** were created automatically in order to help joins run faster.
+** A non-zero value in this counter may indicate an opportunity to
+** improvement performance by adding permanent indices that do not
+** need to be reinitialized each time the statement is run.</dd>
+**
 ** </dl>
 */
 #define SQLITE_STMTSTATUS_FULLSCAN_STEP     1
 #define SQLITE_STMTSTATUS_SORT              2
+#define SQLITE_STMTSTATUS_AUTOINDEX         3
 
 /*
 ** CAPI3REF: Custom Page Cache Object
-** EXPERIMENTAL
 **
 ** The sqlite3_pcache type is opaque.  It is implemented by
 ** the pluggable module.  The SQLite core has no knowledge of
@@ -5746,36 +6066,45 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 /*
 ** CAPI3REF: Application Defined Page Cache.
 ** KEYWORDS: {page cache}
-** EXPERIMENTAL
 **
 ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
 ** register an alternative page cache implementation by passing in an 
-** instance of the sqlite3_pcache_methods structure.)^ The majority of the 
-** heap memory used by SQLite is used by the page cache to cache data read 
-** from, or ready to be written to, the database file. By implementing a 
-** custom page cache using this API, an application can control more 
-** precisely the amount of memory consumed by SQLite, the way in which 
+** instance of the sqlite3_pcache_methods structure.)^
+** In many applications, most of the heap memory allocated by 
+** SQLite is used for the page cache.
+** By implementing a 
+** custom page cache using this API, an application can better control
+** the amount of memory consumed by SQLite, the way in which 
 ** that memory is allocated and released, and the policies used to 
 ** determine exactly which parts of a database file are cached and for 
 ** how long.
 **
+** The alternative page cache mechanism is an
+** extreme measure that is only needed by the most demanding applications.
+** The built-in page cache is recommended for most uses.
+**
 ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
 ** internal buffer by SQLite within the call to [sqlite3_config].  Hence
 ** the application may discard the parameter after the call to
 ** [sqlite3_config()] returns.)^
 **
-** ^The xInit() method is called once for each call to [sqlite3_initialize()]
+** ^(The xInit() method is called once for each effective 
+** call to [sqlite3_initialize()])^
 ** (usually only once during the lifetime of the process). ^(The xInit()
 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
-** ^The xInit() method can set up up global structures and/or any mutexes
+** The intent of the xInit() method is to set up global data structures 
 ** required by the custom page cache implementation. 
+** ^(If the xInit() method is NULL, then the 
+** built-in default page cache is used instead of the application defined
+** page cache.)^
 **
-** ^The xShutdown() method is called from within [sqlite3_shutdown()], 
-** if the application invokes this API. It can be used to clean up 
+** ^The xShutdown() method is called by [sqlite3_shutdown()].
+** It can be used to clean up 
 ** any outstanding resources before process shutdown, if required.
+** ^The xShutdown() method may be NULL.
 **
-** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe.  ^The
+** ^SQLite automatically serializes calls to the xInit method,
+** so the xInit method need not be threadsafe.  ^The
 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
 ** not need to be threadsafe either.  All other methods must be threadsafe
 ** in multithreaded applications.
@@ -5783,47 +6112,50 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** ^SQLite will never invoke xInit() more than once without an intervening
 ** call to xShutdown().
 **
-** ^The xCreate() method is used to construct a new cache instance.  SQLite
-** will typically create one cache instance for each open database file,
+** ^SQLite invokes the xCreate() method to construct a new cache instance.
+** SQLite will typically create one cache instance for each open database file,
 ** though this is not guaranteed. ^The
 ** first parameter, szPage, is the size in bytes of the pages that must
 ** be allocated by the cache.  ^szPage will not be a power of two.  ^szPage
 ** will the page size of the database file that is to be cached plus an
-** increment (here called "R") of about 100 or 200.  ^SQLite will use the
+** increment (here called "R") of about 100 or 200.  SQLite will use the
 ** extra R bytes on each page to store metadata about the underlying
 ** database page on disk.  The value of R depends
 ** on the SQLite version, the target platform, and how SQLite was compiled.
 ** ^R is constant for a particular build of SQLite.  ^The second argument to
 ** xCreate(), bPurgeable, is true if the cache being created will
 ** be used to cache database pages of a file stored on disk, or
-** false if it is used for an in-memory database. ^The cache implementation
+** false if it is used for an in-memory database. The cache implementation
 ** does not have to do anything special based with the value of bPurgeable;
 ** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will
 ** never invoke xUnpin() except to deliberately delete a page.
-** ^In other words, a cache created with bPurgeable set to false will
+** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
+** false will always have the "discard" flag set to true.  
+** ^Hence, a cache created with bPurgeable false will
 ** never contain any unpinned pages.
 **
 ** ^(The xCachesize() method may be called at any time by SQLite to set the
 ** suggested maximum cache-size (number of pages stored by) the cache
 ** instance passed as the first argument. This is the value configured using
-** the SQLite "[PRAGMA cache_size]" command.)^  ^As with the bPurgeable
+** the SQLite "[PRAGMA cache_size]" command.)^  As with the bPurgeable
 ** parameter, the implementation is not required to do anything with this
 ** value; it is advisory only.
 **
-** ^The xPagecount() method should return the number of pages currently
-** stored in the cache.
+** The xPagecount() method must return the number of pages currently
+** stored in the cache, both pinned and unpinned.
 ** 
-** ^The xFetch() method is used to fetch a page and return a pointer to it. 
-** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
-** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
-** mimimum key value is 1. After it has been retrieved using xFetch, the page 
+** The xFetch() method locates a page in the cache and returns a pointer to 
+** the page, or a NULL pointer.
+** A "page", in this context, means a buffer of szPage bytes aligned at an
+** 8-byte boundary. The page to be fetched is determined by the key. ^The
+** mimimum key value is 1.  After it has been retrieved using xFetch, the page 
 ** is considered to be "pinned".
 **
-** ^If the requested page is already in the page cache, then the page cache
+** If the requested page is already in the page cache, then the page cache
 ** implementation must return a pointer to the page buffer with its content
-** intact.  ^(If the requested page is not already in the cache, then the
-** behavior of the cache implementation is determined by the value of the
-** createFlag parameter passed to xFetch, according to the following table:
+** intact.  If the requested page is not already in the cache, then the
+** behavior of the cache implementation should use the value of the createFlag
+** parameter to help it determined what action to take:
 **
 ** <table border=1 width=85% align=center>
 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5832,36 +6164,35 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 **                 Otherwise return NULL.
 ** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return
 **                 NULL if allocating a new page is effectively impossible.
-** </table>)^
+** </table>
 **
-** SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  If
-** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
+** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite
+** will only use a createFlag of 2 after a prior call with a createFlag of 1
+** failed.)^  In between the to xFetch() calls, SQLite may
 ** attempt to unpin one or more cache pages by spilling the content of
-** pinned pages to disk and synching the operating system disk cache. After
-** attempting to unpin pages, the xFetch() method will be invoked again with
-** a createFlag of 2.
+** pinned pages to disk and synching the operating system disk cache.
 **
 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
-** as its second argument. ^(If the third parameter, discard, is non-zero,
-** then the page should be evicted from the cache. In this case SQLite 
-** assumes that the next time the page is retrieved from the cache using
-** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
-** zero, then the page is considered to be unpinned. ^The cache implementation
+** as its second argument.  If the third parameter, discard, is non-zero,
+** then the page must be evicted from the cache.
+** ^If the discard parameter is
+** zero, then the page may be discarded or retained at the discretion of
+** page cache implementation. ^The page cache implementation
 ** may choose to evict unpinned pages at any time.
 **
-** ^(The cache is not required to perform any reference counting. A single 
+** The cache must not perform any reference counting. A single 
 ** call to xUnpin() unpins the page regardless of the number of prior calls 
-** to xFetch().)^
+** to xFetch().
 **
-** ^The xRekey() method is used to change the key value associated with the
-** page passed as the second argument from oldKey to newKey. ^If the cache
-** previously contains an entry associated with newKey, it should be
+** The xRekey() method is used to change the key value associated with the
+** page passed as the second argument. If the cache
+** previously contains an entry associated with newKey, it must be
 ** discarded. ^Any prior cache entry associated with newKey is guaranteed not
 ** to be pinned.
 **
-** ^When SQLite calls the xTruncate() method, the cache must discard all
+** When SQLite calls the xTruncate() method, the cache must discard all
 ** existing cache entries with page numbers (keys) greater than or equal
-** to the value of the iLimit parameter passed to xTruncate(). ^If any
+** to the value of the iLimit parameter passed to xTruncate(). If any
 ** of these pages are pinned, they are implicitly unpinned, meaning that
 ** they can be safely discarded.
 **
@@ -5888,7 +6219,6 @@ struct sqlite3_pcache_methods {
 
 /*
 ** CAPI3REF: Online Backup Object
-** EXPERIMENTAL
 **
 ** The sqlite3_backup object records state information about an ongoing
 ** online backup operation.  ^The sqlite3_backup object is created by
@@ -5901,7 +6231,6 @@ typedef struct sqlite3_backup sqlite3_backup;
 
 /*
 ** CAPI3REF: Online Backup API.
-** EXPERIMENTAL
 **
 ** The backup API copies the content of one database into another.
 ** It is useful either for creating backups of databases or
@@ -5970,10 +6299,14 @@ typedef struct sqlite3_backup sqlite3_backup;
 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
 **
-** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
-** database was opened read-only or if
-** the destination is an in-memory database with a different page size
-** from the source database.
+** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if
+** <ol>
+** <li> the destination database was opened read-only, or
+** <li> the destination database is using write-ahead-log journaling
+** and the destination and source page sizes differ, or
+** <li> The destination database is an in-memory database and the
+** destination and source page sizes differ.
+** </ol>)^
 **
 ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
 ** the [sqlite3_busy_handler | busy-handler function]
@@ -6035,7 +6368,7 @@ typedef struct sqlite3_backup sqlite3_backup;
 **
 ** ^Each call to sqlite3_backup_step() sets two values inside
 ** the [sqlite3_backup] object: the number of pages still to be backed
-** up and the total number of pages in the source databae file.
+** up and the total number of pages in the source database file.
 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
 ** retrieve these two values, respectively.
 **
@@ -6089,7 +6422,6 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 
 /*
 ** CAPI3REF: Unlock Notification
-** EXPERIMENTAL
 **
 ** ^When running in shared-cache mode, a database operation may fail with
 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
@@ -6132,7 +6464,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** blocked connection already has a registered unlock-notify callback,
 ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
 ** called with a NULL pointer as its second argument, then any existing
-** unlock-notify callback is cancelled. ^The blocked connections 
+** unlock-notify callback is canceled. ^The blocked connections 
 ** unlock-notify callback may also be canceled by closing the blocked
 ** connection using [sqlite3_close()].
 **
@@ -6211,23 +6543,21 @@ SQLITE_API int sqlite3_unlock_notify(
 
 /*
 ** CAPI3REF: String Comparison
-** EXPERIMENTAL
 **
 ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
 ** compare the contents of two buffers containing UTF-8 strings in a
-** case-indendent fashion, using the same definition of case independence 
+** case-independent fashion, using the same definition of case independence 
 ** that SQLite uses internally when comparing identifiers.
 */
 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
 
 /*
 ** CAPI3REF: Error Logging Interface
-** EXPERIMENTAL
 **
 ** ^The [sqlite3_log()] interface writes a message into the error log
 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
 ** ^If logging is enabled, the zFormat string and subsequent arguments are
-** passed through to [sqlite3_vmprintf()] to generate the final output string.
+** used with [sqlite3_snprintf()] to generate the final output string.
 **
 ** The sqlite3_log() interface is intended for use by extensions such as
 ** virtual tables, collating functions, and SQL functions.  While there is
@@ -6245,6 +6575,89 @@ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
 
 /*
+** CAPI3REF: Write-Ahead Log Commit Hook
+**
+** ^The [sqlite3_wal_hook()] function is used to register a callback that
+** will be invoked each time a database connection commits data to a
+** [write-ahead log] (i.e. whenever a transaction is committed in
+** [journal_mode | journal_mode=WAL mode]). 
+**
+** ^The callback is invoked by SQLite after the commit has taken place and 
+** the associated write-lock on the database released, so the implementation 
+** may read, write or [checkpoint] the database as required.
+**
+** ^The first parameter passed to the callback function when it is invoked
+** is a copy of the third parameter passed to sqlite3_wal_hook() when
+** registering the callback. ^The second is a copy of the database handle.
+** ^The third parameter is the name of the database that was written to -
+** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
+** is the number of pages currently in the write-ahead log file,
+** including those that were just committed.
+**
+** The callback function should normally return [SQLITE_OK].  ^If an error
+** code is returned, that error will propagate back up through the
+** SQLite code base to cause the statement that provoked the callback
+** to report an error, though the commit will have still occurred. If the
+** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value
+** that does not correspond to any valid SQLite error code, the results
+** are undefined.
+**
+** A single database handle may have at most a single write-ahead log callback 
+** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
+** previously registered write-ahead log callback. ^Note that the
+** [sqlite3_wal_autocheckpoint()] interface and the
+** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
+** those overwrite any prior [sqlite3_wal_hook()] settings.
+*/
+SQLITE_API void *sqlite3_wal_hook(
+  sqlite3*, 
+  int(*)(void *,sqlite3*,const char*,int),
+  void*
+);
+
+/*
+** CAPI3REF: Configure an auto-checkpoint
+**
+** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
+** [sqlite3_wal_hook()] that causes any database on [database connection] D
+** to automatically [checkpoint]
+** after committing a transaction if there are N or
+** more frames in the [write-ahead log] file.  ^Passing zero or 
+** a negative value as the nFrame parameter disables automatic
+** checkpoints entirely.
+**
+** ^The callback registered by this function replaces any existing callback
+** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback
+** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism
+** configured by this function.
+**
+** ^The [wal_autocheckpoint pragma] can be used to invoke this interface
+** from SQL.
+**
+** ^Every new [database connection] defaults to having the auto-checkpoint
+** enabled with a threshold of 1000 pages.  The use of this interface
+** is only necessary if the default setting is found to be suboptimal
+** for a particular application.
+*/
+SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
+
+/*
+** CAPI3REF: Checkpoint a database
+**
+** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
+** on [database connection] D to be [checkpointed].  ^If X is NULL or an
+** empty string, then a checkpoint is run on all databases of
+** connection D.  ^If the database connection D is not in
+** [WAL | write-ahead log mode] then this interface is a harmless no-op.
+**
+** ^The [wal_checkpoint pragma] can be used to invoke this interface
+** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
+** [wal_autocheckpoint pragma] can be used to cause this interface to be
+** run whenever the WAL reaches a certain size threshold.
+*/
+SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
+
+/*
 ** Undo the hack that converts floating point types to integer for
 ** builds on processors without floating point support.
 */
@@ -6257,6 +6670,62 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
 #endif
 #endif
 
+/*
+** 2010 August 30
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+*/
+
+#ifndef _SQLITE3RTREE_H_
+#define _SQLITE3RTREE_H_
+
+
+#if 0
+extern "C" {
+#endif
+
+typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
+
+/*
+** Register a geometry callback named zGeom that can be used as part of an
+** R-Tree geometry query as follows:
+**
+**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
+*/
+SQLITE_API int sqlite3_rtree_geometry_callback(
+  sqlite3 *db,
+  const char *zGeom,
+  int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
+  void *pContext
+);
+
+
+/*
+** A pointer to a structure of the following type is passed as the first
+** argument to callbacks registered using rtree_geometry_callback().
+*/
+struct sqlite3_rtree_geometry {
+  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */
+  int nParam;                     /* Size of array aParam[] */
+  double *aParam;                 /* Parameters passed to SQL geom function */
+  void *pUser;                    /* Callback implementation user data */
+  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */
+};
+
+
+#if 0
+}  /* end of the 'extern "C"' block */
+#endif
+
+#endif  /* ifndef _SQLITE3RTREE_H_ */
+
 
 /************** End of sqlite3.h *********************************************/
 /************** Continuing where we left off in sqliteInt.h ******************/
@@ -6535,6 +7004,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
 */
 #ifdef SQLITE_OMIT_FLOATING_POINT
 # define double sqlite_int64
+# define float sqlite_int64
 # define LONGDOUBLE_TYPE sqlite_int64
 # ifndef SQLITE_BIG_DBL
 #   define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)
@@ -6826,6 +7296,7 @@ typedef struct Expr Expr;
 typedef struct ExprList ExprList;
 typedef struct ExprSpan ExprSpan;
 typedef struct FKey FKey;
+typedef struct FuncDestructor FuncDestructor;
 typedef struct FuncDef FuncDef;
 typedef struct FuncDefHash FuncDefHash;
 typedef struct IdList IdList;
@@ -6932,12 +7403,11 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
 ** NOTE:  These values must match the corresponding PAGER_ values in
 ** pager.h.
 */
-#define BTREE_OMIT_JOURNAL  1  /* Do not use journal.  No argument */
+#define BTREE_OMIT_JOURNAL  1  /* Do not create or use a rollback journal */
 #define BTREE_NO_READLOCK   2  /* Omit readlocks on readonly files */
-#define BTREE_MEMORY        4  /* In-memory DB.  No argument */
-#define BTREE_READONLY      8  /* Open the database in read-only mode */
-#define BTREE_READWRITE    16  /* Open for both reading and writing */
-#define BTREE_CREATE       32  /* Create the database if it does not exist */
+#define BTREE_MEMORY        4  /* This is an in-memory DB */
+#define BTREE_SINGLE        8  /* The file contains at most 1 b-tree */
+#define BTREE_UNORDERED    16  /* Use of a hash implementation is OK */
 
 SQLITE_PRIVATE int sqlite3BtreeClose(Btree*);
 SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);
@@ -6946,6 +7416,7 @@ SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*);
 SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
 SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
 SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
+SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);
 SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
 SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
 SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
@@ -6972,11 +7443,17 @@ SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);
 SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);
 
 /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
-** of the following flags:
+** of the flags shown below.
+**
+** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.
+** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data
+** is stored in the leaves.  (BTREE_INTKEY is used for SQL tables.)  With
+** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored
+** anywhere - the key is the content.  (BTREE_BLOBKEY is used for SQL
+** indices.)
 */
 #define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */
-#define BTREE_ZERODATA   2    /* Table has keys only - no data */
-#define BTREE_LEAFDATA   4    /* Data stored in leaves only.  Implies INTKEY */
+#define BTREE_BLOBKEY    2    /* Table has keys only - no data */
 
 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
@@ -7050,6 +7527,8 @@ SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
 SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *);
 SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
 
+SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
+
 #ifndef NDEBUG
 SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
 #endif
@@ -7063,6 +7542,10 @@ SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
 SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);
 #endif
 
+#ifndef SQLITE_OMIT_WAL
+SQLITE_PRIVATE   int sqlite3BtreeCheckpoint(Btree*);
+#endif
+
 /*
 ** If we are not using shared cache, then there is no need to
 ** use mutexes to access the BtShared structures.  So make the
@@ -7192,8 +7675,8 @@ struct SubProgram {
   int nOp;                      /* Elements in aOp[] */
   int nMem;                     /* Number of memory cells required */
   int nCsr;                     /* Number of cursors required */
-  int nRef;                     /* Number of pointers to this structure */
   void *token;                  /* id that may be used to recursive triggers */
+  SubProgram *pNext;            /* Next sub-program already visited */
 };
 
 /*
@@ -7340,83 +7823,83 @@ typedef struct VdbeOpList VdbeOpList;
 #define OP_VerifyCookie                        37
 #define OP_OpenRead                            38
 #define OP_OpenWrite                           39
-#define OP_OpenEphemeral                       40
-#define OP_OpenPseudo                          41
-#define OP_Close                               42
-#define OP_SeekLt                              43
-#define OP_SeekLe                              44
-#define OP_SeekGe                              45
-#define OP_SeekGt                              46
-#define OP_Seek                                47
-#define OP_NotFound                            48
-#define OP_Found                               49
-#define OP_IsUnique                            50
-#define OP_NotExists                           51
-#define OP_Sequence                            52
-#define OP_NewRowid                            53
-#define OP_Insert                              54
-#define OP_InsertInt                           55
-#define OP_Delete                              56
-#define OP_ResetCount                          57
-#define OP_RowKey                              58
-#define OP_RowData                             59
-#define OP_Rowid                               60
-#define OP_NullRow                             61
-#define OP_Last                                62
-#define OP_Sort                                63
-#define OP_Rewind                              64
-#define OP_Prev                                65
-#define OP_Next                                66
-#define OP_IdxInsert                           67
-#define OP_IdxDelete                           70
-#define OP_IdxRowid                            71
-#define OP_IdxLT                               72
-#define OP_IdxGE                               81
-#define OP_Destroy                             92
-#define OP_Clear                               95
-#define OP_CreateIndex                         96
-#define OP_CreateTable                         97
-#define OP_ParseSchema                         98
-#define OP_LoadAnalysis                        99
-#define OP_DropTable                          100
-#define OP_DropIndex                          101
-#define OP_DropTrigger                        102
-#define OP_IntegrityCk                        103
-#define OP_RowSetAdd                          104
-#define OP_RowSetRead                         105
-#define OP_RowSetTest                         106
-#define OP_Program                            107
-#define OP_Param                              108
-#define OP_FkCounter                          109
-#define OP_FkIfZero                           110
-#define OP_MemMax                             111
-#define OP_IfPos                              112
-#define OP_IfNeg                              113
-#define OP_IfZero                             114
-#define OP_AggStep                            115
-#define OP_AggFinal                           116
-#define OP_Vacuum                             117
-#define OP_IncrVacuum                         118
-#define OP_Expire                             119
-#define OP_TableLock                          120
-#define OP_VBegin                             121
-#define OP_VCreate                            122
-#define OP_VDestroy                           123
-#define OP_VOpen                              124
-#define OP_VFilter                            125
-#define OP_VColumn                            126
-#define OP_VNext                              127
-#define OP_VRename                            128
-#define OP_VUpdate                            129
-#define OP_Pagecount                          131
-#define OP_Trace                              132
-#define OP_Noop                               133
-#define OP_Explain                            134
+#define OP_OpenAutoindex                       40
+#define OP_OpenEphemeral                       41
+#define OP_OpenPseudo                          42
+#define OP_Close                               43
+#define OP_SeekLt                              44
+#define OP_SeekLe                              45
+#define OP_SeekGe                              46
+#define OP_SeekGt                              47
+#define OP_Seek                                48
+#define OP_NotFound                            49
+#define OP_Found                               50
+#define OP_IsUnique                            51
+#define OP_NotExists                           52
+#define OP_Sequence                            53
+#define OP_NewRowid                            54
+#define OP_Insert                              55
+#define OP_InsertInt                           56
+#define OP_Delete                              57
+#define OP_ResetCount                          58
+#define OP_RowKey                              59
+#define OP_RowData                             60
+#define OP_Rowid                               61
+#define OP_NullRow                             62
+#define OP_Last                                63
+#define OP_Sort                                64
+#define OP_Rewind                              65
+#define OP_Prev                                66
+#define OP_Next                                67
+#define OP_IdxInsert                           70
+#define OP_IdxDelete                           71
+#define OP_IdxRowid                            72
+#define OP_IdxLT                               81
+#define OP_IdxGE                               92
+#define OP_Destroy                             95
+#define OP_Clear                               96
+#define OP_CreateIndex                         97
+#define OP_CreateTable                         98
+#define OP_ParseSchema                         99
+#define OP_LoadAnalysis                       100
+#define OP_DropTable                          101
+#define OP_DropIndex                          102
+#define OP_DropTrigger                        103
+#define OP_IntegrityCk                        104
+#define OP_RowSetAdd                          105
+#define OP_RowSetRead                         106
+#define OP_RowSetTest                         107
+#define OP_Program                            108
+#define OP_Param                              109
+#define OP_FkCounter                          110
+#define OP_FkIfZero                           111
+#define OP_MemMax                             112
+#define OP_IfPos                              113
+#define OP_IfNeg                              114
+#define OP_IfZero                             115
+#define OP_AggStep                            116
+#define OP_AggFinal                           117
+#define OP_Checkpoint                         118
+#define OP_JournalMode                        119
+#define OP_Vacuum                             120
+#define OP_IncrVacuum                         121
+#define OP_Expire                             122
+#define OP_TableLock                          123
+#define OP_VBegin                             124
+#define OP_VCreate                            125
+#define OP_VDestroy                           126
+#define OP_VOpen                              127
+#define OP_VFilter                            128
+#define OP_VColumn                            129
+#define OP_VNext                              131
+#define OP_VRename                            132
+#define OP_VUpdate                            133
+#define OP_Pagecount                          134
+#define OP_Trace                              135
+#define OP_Noop                               136
+#define OP_Explain                            137
 
 /* The following opcode values are never used */
-#define OP_NotUsed_135                        135
-#define OP_NotUsed_136                        136
-#define OP_NotUsed_137                        137
 #define OP_NotUsed_138                        138
 #define OP_NotUsed_139                        139
 #define OP_NotUsed_140                        140
@@ -7435,22 +7918,22 @@ typedef struct VdbeOpList VdbeOpList;
 #define OPFLG_OUT3            0x0040  /* out3:  P3 is an output */
 #define OPFLG_INITIALIZER {\
 /*   0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02,\
-/*   8 */ 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x24,\
+/*   8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x24, 0x24,\
 /*  16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\
 /*  24 */ 0x00, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\
 /*  32 */ 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00,\
-/*  40 */ 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x08,\
-/*  48 */ 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00, 0x00,\
-/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x01,\
-/*  64 */ 0x01, 0x01, 0x01, 0x08, 0x4c, 0x4c, 0x00, 0x02,\
-/*  72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
+/*  40 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\
+/*  48 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00,\
+/*  56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\
+/*  64 */ 0x01, 0x01, 0x01, 0x01, 0x4c, 0x4c, 0x08, 0x00,\
+/*  72 */ 0x02, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\
 /*  80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\
-/*  88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x02, 0x24, 0x02, 0x00,\
-/*  96 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 104 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\
-/* 112 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00,\
-/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,\
-/* 128 */ 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\
+/*  88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x02,\
+/*  96 */ 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 104 */ 0x00, 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01,\
+/* 112 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\
+/* 120 */ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 128 */ 0x01, 0x00, 0x02, 0x01, 0x00, 0x00, 0x02, 0x00,\
 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
 /* 144 */ 0x04, 0x04,}
 
@@ -7481,6 +7964,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
 SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);
 SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
 SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
+SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*);
 SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int);
 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
@@ -7498,7 +7982,6 @@ SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);
 SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
 SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
-SQLITE_PRIVATE void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int);
 SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);
 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);
 #ifndef SQLITE_OMIT_TRACE
@@ -7509,6 +7992,10 @@ SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,
 SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
 
+#ifndef SQLITE_OMIT_TRIGGER
+SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
+#endif
+
 
 #ifndef NDEBUG
 SQLITE_PRIVATE   void sqlite3VdbeComment(Vdbe*, const char*, ...);
@@ -7587,6 +8074,7 @@ typedef struct PgHdr DbPage;
 */
 #define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */
 #define PAGER_NO_READLOCK   0x0002    /* Omit readlocks on readonly files */
+#define PAGER_MEMORY        0x0004    /* In-memory database */
 
 /*
 ** Valid values for the second argument to sqlite3PagerLockingMode().
@@ -7596,14 +8084,15 @@ typedef struct PgHdr DbPage;
 #define PAGER_LOCKINGMODE_EXCLUSIVE   1
 
 /*
-** Valid values for the second argument to sqlite3PagerJournalMode().
+** Numeric constants that encode the journalmode.  
 */
-#define PAGER_JOURNALMODE_QUERY      -1
+#define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */
 #define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */
 #define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */
 #define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */
 #define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */
 #define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */
+#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */
 
 /*
 ** The remainder of this file contains the declarations of the functions
@@ -7626,12 +8115,14 @@ SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
 
 /* Functions used to configure a Pager object. */
 SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
-SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u16*, int);
+SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);
 SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);
 SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);
 SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int);
 SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int);
-SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *, int);
+SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int);
+SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*);
+SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);
 SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
 SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
 
@@ -7651,9 +8142,10 @@ SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *);
 SQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); 
 
 /* Functions used to manage pager transactions and savepoints. */
-SQLITE_PRIVATE int sqlite3PagerPagecount(Pager*, int*);
+SQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*);
 SQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int);
 SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
+SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*);
 SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager);
 SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*);
 SQLITE_PRIVATE int sqlite3PagerRollback(Pager*);
@@ -7661,9 +8153,16 @@ SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
 
+SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager);
+SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
+SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
+SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
+SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
+
 /* Functions used to query pager state and configuration. */
 SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);
 SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);
+SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);
 SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*);
 SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*);
 SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);
@@ -7675,6 +8174,10 @@ SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);
 /* Functions used to truncate the database file. */
 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
 
+#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
+SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);
+#endif
+
 /* Functions to support testing and debugging. */
 #if !defined(NDEBUG) || defined(SQLITE_TEST)
 SQLITE_PRIVATE   Pgno sqlite3PagerPagenumber(DbPage*);
@@ -8076,7 +8579,11 @@ SQLITE_PRIVATE void sqlite3PCacheSetDefault(void);
 ** 1GB boundary.
 **
 */
-#define PENDING_BYTE      sqlite3PendingByte
+#ifdef SQLITE_OMIT_WSD
+# define PENDING_BYTE     (0x40000000)
+#else
+# define PENDING_BYTE      sqlite3PendingByte
+#endif
 #define RESERVED_BYTE     (PENDING_BYTE+1)
 #define SHARED_FIRST      (PENDING_BYTE+2)
 #define SHARED_SIZE       510
@@ -8102,6 +8609,10 @@ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);
 #define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0
 SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);
 SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);
+SQLITE_PRIVATE int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **);
+SQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int, int, int);
+SQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id);
+SQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int);
 
 /* 
 ** Functions for accessing sqlite3_vfs methods 
@@ -8118,7 +8629,7 @@ SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *);
 #endif /* SQLITE_OMIT_LOAD_EXTENSION */
 SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *);
 SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int);
-SQLITE_PRIVATE int sqlite3OsCurrentTime(sqlite3_vfs *, double*);
+SQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);
 
 /*
 ** Convenience functions for opening and closing files using 
@@ -8198,8 +8709,8 @@ SQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *);
 #define sqlite3_mutex_enter(X)
 #define sqlite3_mutex_try(X)      SQLITE_OK
 #define sqlite3_mutex_leave(X)
-#define sqlite3_mutex_held(X)     1
-#define sqlite3_mutex_notheld(X)  1
+#define sqlite3_mutex_held(X)     ((void)(X),1)
+#define sqlite3_mutex_notheld(X)  ((void)(X),1)
 #define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)
 #define sqlite3MutexInit()        SQLITE_OK
 #define sqlite3MutexEnd()
@@ -8226,14 +8737,6 @@ struct Db {
 
 /*
 ** An instance of the following structure stores a database schema.
-**
-** If there are no virtual tables configured in this schema, the
-** Schema.db variable is set to NULL. After the first virtual table
-** has been added, it is set to point to the database connection 
-** used to create the connection. Once a virtual table has been
-** added to the Schema structure and the Schema.db variable populated, 
-** only that database connection may use the Schema to prepare 
-** statements.
 */
 struct Schema {
   int schema_cookie;   /* Database schema version number for this file */
@@ -8246,9 +8749,6 @@ struct Schema {
   u8 enc;              /* Text encoding used by this database */
   u16 flags;           /* Flags associated with this schema */
   int cache_size;      /* Number of pages to use in the cache */
-#ifndef SQLITE_OMIT_VIRTUALTABLE
-  sqlite3 *db;         /* "Owner" connection. See comment above */
-#endif
 };
 
 /*
@@ -8362,7 +8862,6 @@ struct sqlite3 {
   u8 temp_store;                /* 1: file 2: memory 0: default */
   u8 mallocFailed;              /* True if we have seen a malloc failure */
   u8 dfltLockMode;              /* Default locking-mode for attached dbs */
-  u8 dfltJournalMode;           /* Default journal mode for attached dbs */
   signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
   u8 suppressErr;               /* Do not issue error messages if true */
   int nextPagesize;             /* Pagesize after VACUUM if >0 */
@@ -8395,6 +8894,10 @@ struct sqlite3 {
   void (*xRollbackCallback)(void*); /* Invoked at every commit. */
   void *pUpdateArg;
   void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
+#ifndef SQLITE_OMIT_WAL
+  int (*xWalCallback)(void *, sqlite3 *, const char *, int);
+  void *pWalArg;
+#endif
   void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);
   void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);
   void *pCollNeededArg;
@@ -8433,6 +8936,7 @@ struct sqlite3 {
   int nStatement;               /* Number of nested statement-transactions  */
   u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
   i64 nDeferredCons;            /* Net deferred constraints this transaction. */
+  int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
 
 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
   /* The following variables are all protected by the STATIC_MASTER 
@@ -8484,6 +8988,8 @@ struct sqlite3 {
 #define SQLITE_ReverseOrder   0x01000000  /* Reverse unordered SELECTs */
 #define SQLITE_RecTriggers    0x02000000  /* Enable recursive triggers */
 #define SQLITE_ForeignKeys    0x04000000  /* Enforce foreign key constraints  */
+#define SQLITE_AutoIndex      0x08000000  /* Enable automatic indexes */
+#define SQLITE_PreferBuiltin  0x10000000  /* Preference to built-in funcs */
 
 /*
 ** Bits of the sqlite3.flags field that are used by the
@@ -8495,7 +9001,8 @@ struct sqlite3 {
 #define SQLITE_IndexSort      0x04        /* Disable indexes for sorting */
 #define SQLITE_IndexSearch    0x08        /* Disable indexes for searching */
 #define SQLITE_IndexCover     0x10        /* Disable index covering table */
-#define SQLITE_OptMask        0x1f        /* Mask of all disablable opts */
+#define SQLITE_GroupByOrder   0x20        /* Disable GROUPBY cover of ORDERBY */
+#define SQLITE_OptMask        0xff        /* Mask of all disablable opts */
 
 /*
 ** Possible values for the sqlite.magic field.
@@ -8525,6 +9032,27 @@ struct FuncDef {
   void (*xFinalize)(sqlite3_context*);                /* Aggregate finalizer */
   char *zName;         /* SQL name of the function. */
   FuncDef *pHash;      /* Next with a different name but the same hash */
+  FuncDestructor *pDestructor;   /* Reference counted destructor function */
+};
+
+/*
+** This structure encapsulates a user-function destructor callback (as
+** configured using create_function_v2()) and a reference counter. When
+** create_function_v2() is called to create a function with a destructor,
+** a single object of this type is allocated. FuncDestructor.nRef is set to 
+** the number of FuncDef objects created (either 1 or 3, depending on whether
+** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
+** member of each of the new FuncDef objects is set to point to the allocated
+** FuncDestructor.
+**
+** Thereafter, when one of the FuncDef objects is deleted, the reference
+** count on this object is decremented. When it reaches 0, the destructor
+** is invoked and the FuncDestructor structure freed.
+*/
+struct FuncDestructor {
+  int nRef;
+  void (*xDestroy)(void *);
+  void *pUserData;
 };
 
 /*
@@ -8565,15 +9093,15 @@ struct FuncDef {
 */
 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
   {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
-   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0}
+   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
   {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
-   pArg, 0, xFunc, 0, 0, #zName, 0}
+   pArg, 0, xFunc, 0, 0, #zName, 0, 0}
 #define LIKEFUNC(zName, nArg, arg, flags) \
-  {nArg, SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0}
+  {nArg, SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0}
 #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \
   {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \
-   SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0}
+   SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0}
 
 /*
 ** All current savepoints are stored in a linked list starting at
@@ -8787,13 +9315,13 @@ struct VTable {
 ** of a SELECT statement.
 */
 struct Table {
-  sqlite3 *dbMem;      /* DB connection used for lookaside allocations. */
   char *zName;         /* Name of the table or view */
   int iPKey;           /* If not negative, use aCol[iPKey] as the primary key */
   int nCol;            /* Number of columns in this table */
   Column *aCol;        /* Information about each column */
   Index *pIndex;       /* List of SQL indexes on this table. */
   int tnum;            /* Root BTree node for this table (see note above) */
+  unsigned nRowEst;    /* Estimated rows in table - from sqlite_stat1 table */
   Select *pSelect;     /* NULL for tables.  Points to definition if a view. */
   u16 nRef;            /* Number of pointers to this Table */
   u8 tabFlags;         /* Mask of TF_* values */
@@ -8924,9 +9452,9 @@ struct FKey {
 */
 struct KeyInfo {
   sqlite3 *db;        /* The database connection */
-  u8 enc;             /* Text encoding - one of the TEXT_Utf* values */
+  u8 enc;             /* Text encoding - one of the SQLITE_UTF* values */
   u16 nField;         /* Number of entries in aColl[] */
-  u8 *aSortOrder;     /* If defined an aSortOrder[i] is true, sort DESC */
+  u8 *aSortOrder;     /* Sort order for each column.  May be NULL */
   CollSeq *aColl[1];  /* Collating sequence for each term of the key */
 };
 
@@ -9346,6 +9874,9 @@ typedef u64 Bitmask;
 ** and the next table on the list.  The parser builds the list this way.
 ** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each
 ** jointype expresses the join between the table and the previous table.
+**
+** In the colUsed field, the high-order bit (bit 63) is set if the table
+** contains more than 63 columns and the 64-th or later column is used.
 */
 struct SrcList {
   i16 nSrc;        /* Number of tables or subqueries in the FROM clause */
@@ -9457,7 +9988,7 @@ struct WhereLevel {
 #define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */
 #define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */
 #define WHERE_DUPLICATES_OK    0x0008 /* Ok to return a row more than once */
-#define WHERE_OMIT_OPEN        0x0010 /* Table cursor are already open */
+#define WHERE_OMIT_OPEN        0x0010 /* Table cursors are already open */
 #define WHERE_OMIT_CLOSE       0x0020 /* Omit close of table & index cursors */
 #define WHERE_FORCE_TABLE      0x0040 /* Do not use an index-only search */
 #define WHERE_ONETABLE_ONLY    0x0080 /* Only code the 1st table in pTabList */
@@ -9480,6 +10011,7 @@ struct WhereInfo {
   int iBreak;                    /* Jump here to break out of the loop */
   int nLevel;                    /* Number of nested loop */
   struct WhereClause *pWC;       /* Decomposition of the WHERE clause */
+  double savedNQueryLoop;        /* pParse->nQueryLoop outside the WHERE loop */
   WhereLevel a[1];               /* Information about each nest loop in WHERE */
 };
 
@@ -9721,6 +10253,7 @@ struct Parse {
   u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */
   u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */
   u8 disableTriggers;  /* True to disable triggers */
+  double nQueryLoop;   /* Estimated number of iterations of a query */
 
   /* Above is constant between recursions.  Below is reset before and after
   ** each recursion */
@@ -9891,7 +10424,7 @@ struct StrAccum {
   int  nAlloc;         /* Amount of space allocated in zText */
   int  mxAlloc;        /* Maximum allowed string length */
   u8   mallocFailed;   /* Becomes true if any memory allocation fails */
-  u8   useMalloc;      /* True if zText is enlargeable using realloc */
+  u8   useMalloc;      /* 0: none,  1: sqlite3DbMalloc,  2: sqlite3_malloc */
   u8   tooBig;         /* Becomes true if string size exceeds limits */
 };
 
@@ -10043,7 +10576,6 @@ SQLITE_PRIVATE int sqlite3CantopenError(int);
 ** Internal function prototypes
 */
 SQLITE_PRIVATE int sqlite3StrICmp(const char *, const char *);
-SQLITE_PRIVATE int sqlite3IsNumber(const char*, int*, u8);
 SQLITE_PRIVATE int sqlite3Strlen30(const char*);
 #define sqlite3StrNICmp sqlite3_strnicmp
 
@@ -10067,7 +10599,7 @@ SQLITE_PRIVATE void *sqlite3PageMalloc(int);
 SQLITE_PRIVATE void sqlite3PageFree(void*);
 SQLITE_PRIVATE void sqlite3MemSetDefault(void);
 SQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
-SQLITE_PRIVATE int sqlite3MemoryAlarm(void (*)(void*, sqlite3_int64, int), void*, sqlite3_int64);
+SQLITE_PRIVATE int sqlite3HeapNearlyFull(void);
 
 /*
 ** On systems with ample stack space and that support alloca(), make
@@ -10096,7 +10628,8 @@ SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);
 
 
 #ifndef SQLITE_MUTEX_OMIT
-SQLITE_PRIVATE   sqlite3_mutex_methods *sqlite3DefaultMutex(void);
+SQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3DefaultMutex(void);
+SQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3NoopMutex(void);
 SQLITE_PRIVATE   sqlite3_mutex *sqlite3MutexAlloc(int);
 SQLITE_PRIVATE   int sqlite3MutexInit(void);
 SQLITE_PRIVATE   int sqlite3MutexEnd(void);
@@ -10188,7 +10721,7 @@ SQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);
 #endif
 
 SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);
-SQLITE_PRIVATE void sqlite3DeleteTable(Table*);
+SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);
 #ifndef SQLITE_OMIT_AUTOINCREMENT
 SQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);
 SQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);
@@ -10228,6 +10761,7 @@ SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16);
 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
+SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
@@ -10236,7 +10770,6 @@ SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);
 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
-SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse*,int,int);
 SQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int);
 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
@@ -10254,6 +10787,7 @@ SQLITE_PRIVATE void sqlite3Vacuum(Parse*);
 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);
 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);
 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
 SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);
@@ -10355,17 +10889,14 @@ SQLITE_PRIVATE   int sqlite3AuthReadCol(Parse*, const char *, const char *, int)
 #endif
 SQLITE_PRIVATE void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);
 SQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);
-SQLITE_PRIVATE int sqlite3BtreeFactory(sqlite3 *db, const char *zFilename,
-                       int omitJournal, int nCache, int flags, Btree **ppBtree);
 SQLITE_PRIVATE int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
 SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
 SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
 SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
-SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*);
+SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
-SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *, int);
 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
 SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
 SQLITE_PRIVATE int sqlite3Utf8Read(const u8*, const u8**);
@@ -10411,7 +10942,7 @@ SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *);
 SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);
 SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
 SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);
-SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*);
+SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);
 SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...);
 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
@@ -10420,7 +10951,8 @@ SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
 SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
 SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
 SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
-SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Parse *pParse, Expr *, Token *);
+SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Expr*, CollSeq*);
+SQLITE_PRIVATE Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr*, Token*);
 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);
 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
@@ -10441,13 +10973,16 @@ SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
 SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
 SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
+SQLITE_PRIVATE const Token sqlite3IntTokens[];
 SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;
 SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
+#ifndef SQLITE_OMIT_WSD
 SQLITE_PRIVATE int sqlite3PendingByte;
 #endif
+#endif
 SQLITE_PRIVATE void sqlite3RootPageMoved(Db*, int, int);
 SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);
-SQLITE_PRIVATE void sqlite3AlterFunctions(sqlite3*);
+SQLITE_PRIVATE void sqlite3AlterFunctions(void);
 SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
 SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
 SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
@@ -10467,7 +11002,7 @@ SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*);
 SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
 SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);
 SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
-SQLITE_PRIVATE void sqlite3DeleteIndexSamples(Index*);
+SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);
 SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
 SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);
 SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);
@@ -10478,7 +11013,9 @@ SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
 SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
 SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, 
   void (*)(sqlite3_context*,int,sqlite3_value **),
-  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*));
+  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
+  FuncDestructor *pDestructor
+);
 SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
 SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
 
@@ -10529,7 +11066,7 @@ SQLITE_PRIVATE   int sqlite3Utf8To8(unsigned char*);
 #  define sqlite3VtabUnlock(X)
 #  define sqlite3VtabUnlockList(X)
 #else
-SQLITE_PRIVATE    void sqlite3VtabClear(Table*);
+SQLITE_PRIVATE    void sqlite3VtabClear(sqlite3 *db, Table*);
 SQLITE_PRIVATE    int sqlite3VtabSync(sqlite3 *db, char **);
 SQLITE_PRIVATE    int sqlite3VtabRollback(sqlite3 *db);
 SQLITE_PRIVATE    int sqlite3VtabCommit(sqlite3 *db);
@@ -10556,6 +11093,9 @@ SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
 SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*);
+SQLITE_PRIVATE const char *sqlite3JournalModename(int);
+SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int);
+SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
 
 /* Declarations for functions in fkey.c. All of these are replaced by
 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
@@ -10579,9 +11119,9 @@ SQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *);
   #define sqlite3FkRequired(a,b,c,d) 0
 #endif
 #ifndef SQLITE_OMIT_FOREIGN_KEY
-SQLITE_PRIVATE   void sqlite3FkDelete(Table*);
+SQLITE_PRIVATE   void sqlite3FkDelete(sqlite3 *, Table*);
 #else
-  #define sqlite3FkDelete(a)
+  #define sqlite3FkDelete(a,b)
 #endif
 
 
@@ -10662,7 +11202,50 @@ SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);
 # define sqlite3VdbeIOTraceSql(X)
 #endif
 
+/*
+** These routines are available for the mem2.c debugging memory allocator
+** only.  They are used to verify that different "types" of memory
+** allocations are properly tracked by the system.
+**
+** sqlite3MemdebugSetType() sets the "type" of an allocation to one of
+** the MEMTYPE_* macros defined below.  The type must be a bitmask with
+** a single bit set.
+**
+** sqlite3MemdebugHasType() returns true if any of the bits in its second
+** argument match the type set by the previous sqlite3MemdebugSetType().
+** sqlite3MemdebugHasType() is intended for use inside assert() statements.
+**
+** sqlite3MemdebugNoType() returns true if none of the bits in its second
+** argument match the type set by the previous sqlite3MemdebugSetType().
+**
+** Perhaps the most important point is the difference between MEMTYPE_HEAP
+** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means
+** it might have been allocated by lookaside, except the allocation was
+** too large or lookaside was already full.  It is important to verify
+** that allocations that might have been satisfied by lookaside are not
+** passed back to non-lookaside free() routines.  Asserts such as the
+** example above are placed on the non-lookaside free() routines to verify
+** this constraint. 
+**
+** All of this is no-op for a production build.  It only comes into
+** play when the SQLITE_MEMDEBUG compile-time option is used.
+*/
+#ifdef SQLITE_MEMDEBUG
+SQLITE_PRIVATE   void sqlite3MemdebugSetType(void*,u8);
+SQLITE_PRIVATE   int sqlite3MemdebugHasType(void*,u8);
+SQLITE_PRIVATE   int sqlite3MemdebugNoType(void*,u8);
+#else
+# define sqlite3MemdebugSetType(X,Y)  /* no-op */
+# define sqlite3MemdebugHasType(X,Y)  1
+# define sqlite3MemdebugNoType(X,Y)   1
 #endif
+#define MEMTYPE_HEAP       0x01  /* General heap allocations */
+#define MEMTYPE_LOOKASIDE  0x02  /* Might have been lookaside memory */
+#define MEMTYPE_SCRATCH    0x04  /* Scratch allocations */
+#define MEMTYPE_PCACHE     0x08  /* Page cache allocations */
+#define MEMTYPE_DB         0x10  /* Uses sqlite3DbMalloc, not sqlite_malloc */
+
+#endif /* _SQLITEINT_H_ */
 
 /************** End of sqliteInt.h *******************************************/
 /************** Begin file global.c ******************************************/
@@ -10844,6 +11427,15 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
 SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
 
 /*
+** Constant tokens for values 0 and 1.
+*/
+SQLITE_PRIVATE const Token sqlite3IntTokens[] = {
+   { "0", 1 },
+   { "1", 1 }
+};
+
+
+/*
 ** The value of the "pending" byte must be 0x40000000 (1 byte past the
 ** 1-gibabyte boundary) in a compatible database.  SQLite never uses
 ** the database page that contains the pending byte.  It never attempts
@@ -10861,7 +11453,9 @@ SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
 ** Changing the pending byte during operating results in undefined
 ** and dileterious behavior.
 */
+#ifndef SQLITE_OMIT_WSD
 SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
+#endif
 
 /*
 ** Properties of opcodes.  The OPFLG_INITIALIZER macro is
@@ -11045,6 +11639,9 @@ static const char * const azCompileOpt[] = {
 #ifdef SQLITE_OMIT_AUTOINIT
   "OMIT_AUTOINIT",
 #endif
+#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
+  "OMIT_AUTOMATIC_INDEX",
+#endif
 #ifdef SQLITE_OMIT_AUTOVACUUM
   "OMIT_AUTOVACUUM",
 #endif
@@ -11066,9 +11663,11 @@ static const char * const azCompileOpt[] = {
 #ifdef SQLITE_OMIT_CHECK
   "OMIT_CHECK",
 #endif
-#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
-  "OMIT_COMPILEOPTION_DIAGS",
-#endif
+/* // redundant
+** #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
+**   "OMIT_COMPILEOPTION_DIAGS",
+** #endif
+*/
 #ifdef SQLITE_OMIT_COMPLETE
   "OMIT_COMPLETE",
 #endif
@@ -11102,9 +11701,6 @@ static const char * const azCompileOpt[] = {
 #ifdef SQLITE_OMIT_GET_TABLE
   "OMIT_GET_TABLE",
 #endif
-#ifdef SQLITE_OMIT_GLOBALRECOVER
-  "OMIT_GLOBALRECOVER",
-#endif
 #ifdef SQLITE_OMIT_INCRBLOB
   "OMIT_INCRBLOB",
 #endif
@@ -11183,6 +11779,9 @@ static const char * const azCompileOpt[] = {
 #ifdef SQLITE_OMIT_VIRTUALTABLE
   "OMIT_VIRTUALTABLE",
 #endif
+#ifdef SQLITE_OMIT_WAL
+  "OMIT_WAL",
+#endif
 #ifdef SQLITE_OMIT_WSD
   "OMIT_WSD",
 #endif
@@ -11275,14 +11874,454 @@ SQLITE_API const char *sqlite3_compileoption_get(int N){
 ** This module implements the sqlite3_status() interface and related
 ** functionality.
 */
+/************** Include vdbeInt.h in the middle of status.c ******************/
+/************** Begin file vdbeInt.h *****************************************/
+/*
+** 2003 September 6
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This is the header file for information that is private to the
+** VDBE.  This information used to all be at the top of the single
+** source code file "vdbe.c".  When that file became too big (over
+** 6000 lines long) it was split up into several smaller files and
+** this header information was factored out.
+*/
+#ifndef _VDBEINT_H_
+#define _VDBEINT_H_
+
+/*
+** SQL is translated into a sequence of instructions to be
+** executed by a virtual machine.  Each instruction is an instance
+** of the following structure.
+*/
+typedef struct VdbeOp Op;
+
+/*
+** Boolean values
+*/
+typedef unsigned char Bool;
+
+/*
+** A cursor is a pointer into a single BTree within a database file.
+** The cursor can seek to a BTree entry with a particular key, or
+** loop over all entries of the Btree.  You can also insert new BTree
+** entries or retrieve the key or data from the entry that the cursor
+** is currently pointing to.
+** 
+** Every cursor that the virtual machine has open is represented by an
+** instance of the following structure.
+**
+** If the VdbeCursor.isTriggerRow flag is set it means that this cursor is
+** really a single row that represents the NEW or OLD pseudo-table of
+** a row trigger.  The data for the row is stored in VdbeCursor.pData and
+** the rowid is in VdbeCursor.iKey.
+*/
+struct VdbeCursor {
+  BtCursor *pCursor;    /* The cursor structure of the backend */
+  int iDb;              /* Index of cursor database in db->aDb[] (or -1) */
+  i64 lastRowid;        /* Last rowid from a Next or NextIdx operation */
+  Bool zeroed;          /* True if zeroed out and ready for reuse */
+  Bool rowidIsValid;    /* True if lastRowid is valid */
+  Bool atFirst;         /* True if pointing to first entry */
+  Bool useRandomRowid;  /* Generate new record numbers semi-randomly */
+  Bool nullRow;         /* True if pointing to a row with no data */
+  Bool deferredMoveto;  /* A call to sqlite3BtreeMoveto() is needed */
+  Bool isTable;         /* True if a table requiring integer keys */
+  Bool isIndex;         /* True if an index containing keys only - no data */
+  Bool isOrdered;       /* True if the underlying table is BTREE_UNORDERED */
+  i64 movetoTarget;     /* Argument to the deferred sqlite3BtreeMoveto() */
+  Btree *pBt;           /* Separate file holding temporary table */
+  int pseudoTableReg;   /* Register holding pseudotable content. */
+  KeyInfo *pKeyInfo;    /* Info about index keys needed by index cursors */
+  int nField;           /* Number of fields in the header */
+  i64 seqCount;         /* Sequence counter */
+  sqlite3_vtab_cursor *pVtabCursor;  /* The cursor for a virtual table */
+  const sqlite3_module *pModule;     /* Module for cursor pVtabCursor */
+
+  /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or 
+  ** OP_IsUnique opcode on this cursor. */
+  int seekResult;
+
+  /* Cached information about the header for the data record that the
+  ** cursor is currently pointing to.  Only valid if cacheStatus matches
+  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of
+  ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that
+  ** the cache is out of date.
+  **
+  ** aRow might point to (ephemeral) data for the current row, or it might
+  ** be NULL.
+  */
+  u32 cacheStatus;      /* Cache is valid if this matches Vdbe.cacheCtr */
+  int payloadSize;      /* Total number of bytes in the record */
+  u32 *aType;           /* Type values for all entries in the record */
+  u32 *aOffset;         /* Cached offsets to the start of each columns data */
+  u8 *aRow;             /* Data for the current row, if all on one page */
+};
+typedef struct VdbeCursor VdbeCursor;
+
+/*
+** When a sub-program is executed (OP_Program), a structure of this type
+** is allocated to store the current value of the program counter, as
+** well as the current memory cell array and various other frame specific
+** values stored in the Vdbe struct. When the sub-program is finished, 
+** these values are copied back to the Vdbe from the VdbeFrame structure,
+** restoring the state of the VM to as it was before the sub-program
+** began executing.
+**
+** Frames are stored in a linked list headed at Vdbe.pParent. Vdbe.pParent
+** is the parent of the current frame, or zero if the current frame
+** is the main Vdbe program.
+*/
+typedef struct VdbeFrame VdbeFrame;
+struct VdbeFrame {
+  Vdbe *v;                /* VM this frame belongs to */
+  int pc;                 /* Program Counter */
+  Op *aOp;                /* Program instructions */
+  int nOp;                /* Size of aOp array */
+  Mem *aMem;              /* Array of memory cells */
+  int nMem;               /* Number of entries in aMem */
+  VdbeCursor **apCsr;     /* Element of Vdbe cursors */
+  u16 nCursor;            /* Number of entries in apCsr */
+  void *token;            /* Copy of SubProgram.token */
+  int nChildMem;          /* Number of memory cells for child frame */
+  int nChildCsr;          /* Number of cursors for child frame */
+  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */
+  int nChange;            /* Statement changes (Vdbe.nChanges)     */
+  VdbeFrame *pParent;     /* Parent of this frame */
+};
+
+#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
+
+/*
+** A value for VdbeCursor.cacheValid that means the cache is always invalid.
+*/
+#define CACHE_STALE 0
+
+/*
+** Internally, the vdbe manipulates nearly all SQL values as Mem
+** structures. Each Mem struct may cache multiple representations (string,
+** integer etc.) of the same value.  A value (and therefore Mem structure)
+** has the following properties:
+**
+** Each value has a manifest type. The manifest type of the value stored
+** in a Mem struct is returned by the MemType(Mem*) macro. The type is
+** one of SQLITE_NULL, SQLITE_INTEGER, SQLITE_REAL, SQLITE_TEXT or
+** SQLITE_BLOB.
+*/
+struct Mem {
+  union {
+    i64 i;              /* Integer value. */
+    int nZero;          /* Used when bit MEM_Zero is set in flags */
+    FuncDef *pDef;      /* Used only when flags==MEM_Agg */
+    RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */
+    VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */
+  } u;
+  double r;           /* Real value */
+  sqlite3 *db;        /* The associated database connection */
+  char *z;            /* String or BLOB value */
+  int n;              /* Number of characters in string value, excluding '\0' */
+  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
+  u8  type;           /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */
+  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
+#ifdef SQLITE_DEBUG
+  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
+  void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */
+#endif
+  void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */
+  char *zMalloc;      /* Dynamic buffer allocated by sqlite3_malloc() */
+};
+
+/* One or more of the following flags are set to indicate the validOK
+** representations of the value stored in the Mem struct.
+**
+** If the MEM_Null flag is set, then the value is an SQL NULL value.
+** No other flags may be set in this case.
+**
+** If the MEM_Str flag is set then Mem.z points at a string representation.
+** Usually this is encoded in the same unicode encoding as the main
+** database (see below for exceptions). If the MEM_Term flag is also
+** set, then the string is nul terminated. The MEM_Int and MEM_Real 
+** flags may coexist with the MEM_Str flag.
+**
+** Multiple of these values can appear in Mem.flags.  But only one
+** at a time can appear in Mem.type.
+*/
+#define MEM_Null      0x0001   /* Value is NULL */
+#define MEM_Str       0x0002   /* Value is a string */
+#define MEM_Int       0x0004   /* Value is an integer */
+#define MEM_Real      0x0008   /* Value is a real number */
+#define MEM_Blob      0x0010   /* Value is a BLOB */
+#define MEM_RowSet    0x0020   /* Value is a RowSet object */
+#define MEM_Frame     0x0040   /* Value is a VdbeFrame object */
+#define MEM_Invalid   0x0080   /* Value is undefined */
+#define MEM_TypeMask  0x00ff   /* Mask of type bits */
+
+/* Whenever Mem contains a valid string or blob representation, one of
+** the following flags must be set to determine the memory management
+** policy for Mem.z.  The MEM_Term flag tells us whether or not the
+** string is \000 or \u0000 terminated
+*/
+#define MEM_Term      0x0200   /* String rep is nul terminated */
+#define MEM_Dyn       0x0400   /* Need to call sqliteFree() on Mem.z */
+#define MEM_Static    0x0800   /* Mem.z points to a static string */
+#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */
+#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */
+#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */
+#ifdef SQLITE_OMIT_INCRBLOB
+  #undef MEM_Zero
+  #define MEM_Zero 0x0000
+#endif
+
+/*
+** Clear any existing type flags from a Mem and replace them with f
+*/
+#define MemSetTypeFlag(p, f) \
+   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)
+
+/*
+** Return true if a memory cell is not marked as invalid.  This macro
+** is for use inside assert() statements only.
+*/
+#ifdef SQLITE_DEBUG
+#define memIsValid(M)  ((M)->flags & MEM_Invalid)==0
+#endif
+
+
+/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
+** additional information about auxiliary information bound to arguments
+** of the function.  This is used to implement the sqlite3_get_auxdata()
+** and sqlite3_set_auxdata() APIs.  The "auxdata" is some auxiliary data
+** that can be associated with a constant argument to a function.  This
+** allows functions such as "regexp" to compile their constant regular
+** expression argument once and reused the compiled code for multiple
+** invocations.
+*/
+struct VdbeFunc {
+  FuncDef *pFunc;               /* The definition of the function */
+  int nAux;                     /* Number of entries allocated for apAux[] */
+  struct AuxData {
+    void *pAux;                   /* Aux data for the i-th argument */
+    void (*xDelete)(void *);      /* Destructor for the aux data */
+  } apAux[1];                   /* One slot for each function argument */
+};
+
+/*
+** The "context" argument for a installable function.  A pointer to an
+** instance of this structure is the first argument to the routines used
+** implement the SQL functions.
+**
+** There is a typedef for this structure in sqlite.h.  So all routines,
+** even the public interface to SQLite, can use a pointer to this structure.
+** But this file is the only place where the internal details of this
+** structure are known.
+**
+** This structure is defined inside of vdbeInt.h because it uses substructures
+** (Mem) which are only defined there.
+*/
+struct sqlite3_context {
+  FuncDef *pFunc;       /* Pointer to function information.  MUST BE FIRST */
+  VdbeFunc *pVdbeFunc;  /* Auxilary data, if created. */
+  Mem s;                /* The return value is stored here */
+  Mem *pMem;            /* Memory cell used to store aggregate context */
+  int isError;          /* Error code returned by the function. */
+  CollSeq *pColl;       /* Collating sequence */
+};
+
+/*
+** A Set structure is used for quick testing to see if a value
+** is part of a small set.  Sets are used to implement code like
+** this:
+**            x.y IN ('hi','hoo','hum')
+*/
+typedef struct Set Set;
+struct Set {
+  Hash hash;             /* A set is just a hash table */
+  HashElem *prev;        /* Previously accessed hash elemen */
+};
+
+/*
+** An instance of the virtual machine.  This structure contains the complete
+** state of the virtual machine.
+**
+** The "sqlite3_stmt" structure pointer that is returned by sqlite3_compile()
+** is really a pointer to an instance of this structure.
+**
+** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
+** any virtual table method invocations made by the vdbe program. It is
+** set to 2 for xDestroy method calls and 1 for all other methods. This
+** variable is used for two purposes: to allow xDestroy methods to execute
+** "DROP TABLE" statements and to prevent some nasty side effects of
+** malloc failure when SQLite is invoked recursively by a virtual table 
+** method function.
+*/
+struct Vdbe {
+  sqlite3 *db;            /* The database connection that owns this statement */
+  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */
+  int nOp;                /* Number of instructions in the program */
+  int nOpAlloc;           /* Number of slots allocated for aOp[] */
+  Op *aOp;                /* Space to hold the virtual machine's program */
+  int nLabel;             /* Number of labels used */
+  int nLabelAlloc;        /* Number of slots allocated in aLabel[] */
+  int *aLabel;            /* Space to hold the labels */
+  Mem **apArg;            /* Arguments to currently executing user function */
+  Mem *aColName;          /* Column names to return */
+  Mem *pResultSet;        /* Pointer to an array of results */
+  u16 nResColumn;         /* Number of columns in one row of the result set */
+  u16 nCursor;            /* Number of slots in apCsr[] */
+  VdbeCursor **apCsr;     /* One element of this array for each open cursor */
+  u8 errorAction;         /* Recovery action to do in case of an error */
+  u8 okVar;               /* True if azVar[] has been initialized */
+  ynVar nVar;             /* Number of entries in aVar[] */
+  Mem *aVar;              /* Values for the OP_Variable opcode. */
+  char **azVar;           /* Name of variables */
+  u32 magic;              /* Magic number for sanity checking */
+  int nMem;               /* Number of memory locations currently allocated */
+  Mem *aMem;              /* The memory locations */
+  u32 cacheCtr;           /* VdbeCursor row cache generation counter */
+  int pc;                 /* The program counter */
+  int rc;                 /* Value to return */
+  char *zErrMsg;          /* Error message written here */
+  u8 explain;             /* True if EXPLAIN present on SQL command */
+  u8 changeCntOn;         /* True to update the change-counter */
+  u8 expired;             /* True if the VM needs to be recompiled */
+  u8 runOnlyOnce;         /* Automatically expire on reset */
+  u8 minWriteFileFormat;  /* Minimum file format for writable database files */
+  u8 inVtabMethod;        /* See comments above */
+  u8 usesStmtJournal;     /* True if uses a statement journal */
+  u8 readOnly;            /* True for read-only statements */
+  u8 isPrepareV2;         /* True if prepared with prepare_v2() */
+  int nChange;            /* Number of db changes made since last reset */
+  int btreeMask;          /* Bitmask of db->aDb[] entries referenced */
+  i64 startTime;          /* Time when query started - used for profiling */
+  BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */
+  int aCounter[3];        /* Counters used by sqlite3_stmt_status() */
+  char *zSql;             /* Text of the SQL statement that generated this */
+  void *pFree;            /* Free this when deleting the vdbe */
+  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */
+  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */
+  int iStatement;         /* Statement number (or 0 if has not opened stmt) */
+#ifdef SQLITE_DEBUG
+  FILE *trace;            /* Write an execution trace here, if not NULL */
+#endif
+  VdbeFrame *pFrame;      /* Parent frame */
+  int nFrame;             /* Number of frames in pFrame list */
+  u32 expmask;            /* Binding to these vars invalidates VM */
+  SubProgram *pProgram;   /* Linked list of all sub-programs used by VM */
+};
+
+/*
+** The following are allowed values for Vdbe.magic
+*/
+#define VDBE_MAGIC_INIT     0x26bceaa5    /* Building a VDBE program */
+#define VDBE_MAGIC_RUN      0xbdf20da3    /* VDBE is ready to execute */
+#define VDBE_MAGIC_HALT     0x519c2973    /* VDBE has completed execution */
+#define VDBE_MAGIC_DEAD     0xb606c3c8    /* The VDBE has been deallocated */
+
+/*
+** Function prototypes
+*/
+SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
+void sqliteVdbePopStack(Vdbe*,int);
+SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor*);
+#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
+SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);
+#endif
+SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
+SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
+SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
+SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
+SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
+
+int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
+SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
+SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
+SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
+SQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*);
+SQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);
+SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*);
+SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int);
+SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
+SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
+SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
+SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
+#ifdef SQLITE_OMIT_FLOATING_POINT
+# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
+#else
+SQLITE_PRIVATE   void sqlite3VdbeMemSetDouble(Mem*, double);
+#endif
+SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
+SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
+SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, int);
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
+SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
+SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
+SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
+SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
+SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
+SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
+SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
+SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
+SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
+SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
+SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
+SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
+
+#ifdef SQLITE_DEBUG
+SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe*,Mem*);
+#endif
+
+#ifndef SQLITE_OMIT_FOREIGN_KEY
+SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
+#else
+# define sqlite3VdbeCheckFk(p,i) 0
+#endif
+
+#ifndef SQLITE_OMIT_SHARED_CACHE
+SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
+#else
+# define sqlite3VdbeMutexArrayEnter(p)
+#endif
+
+SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);
+#ifdef SQLITE_DEBUG
+SQLITE_PRIVATE   void sqlite3VdbePrintSql(Vdbe*);
+SQLITE_PRIVATE   void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
+#endif
+SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem);
+
+#ifndef SQLITE_OMIT_INCRBLOB
+SQLITE_PRIVATE   int sqlite3VdbeMemExpandBlob(Mem *);
+#else
+  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
+#endif
+
+#endif /* !defined(_VDBEINT_H_) */
+
+/************** End of vdbeInt.h *********************************************/
+/************** Continuing where we left off in status.c *********************/
 
 /*
 ** Variables in which to record status information.
 */
 typedef struct sqlite3StatType sqlite3StatType;
 static SQLITE_WSD struct sqlite3StatType {
-  int nowValue[9];         /* Current value */
-  int mxValue[9];          /* Maximum value */
+  int nowValue[10];         /* Current value */
+  int mxValue[10];          /* Maximum value */
 } sqlite3Stat = { {0,}, {0,} };
 
 
@@ -11364,6 +12403,8 @@ SQLITE_API int sqlite3_db_status(
   int *pHighwater,      /* Write high-water mark here */
   int resetFlag         /* Reset high-water mark if true */
 ){
+  int rc = SQLITE_OK;   /* Return code */
+  sqlite3_mutex_enter(db->mutex);
   switch( op ){
     case SQLITE_DBSTATUS_LOOKASIDE_USED: {
       *pCurrent = db->lookaside.nOut;
@@ -11373,11 +12414,97 @@ SQLITE_API int sqlite3_db_status(
       }
       break;
     }
+
+    /* 
+    ** Return an approximation for the amount of memory currently used
+    ** by all pagers associated with the given database connection.  The
+    ** highwater mark is meaningless and is returned as zero.
+    */
+    case SQLITE_DBSTATUS_CACHE_USED: {
+      int totalUsed = 0;
+      int i;
+      sqlite3BtreeEnterAll(db);
+      for(i=0; i<db->nDb; i++){
+        Btree *pBt = db->aDb[i].pBt;
+        if( pBt ){
+          Pager *pPager = sqlite3BtreePager(pBt);
+          totalUsed += sqlite3PagerMemUsed(pPager);
+        }
+      }
+      sqlite3BtreeLeaveAll(db);
+      *pCurrent = totalUsed;
+      *pHighwater = 0;
+      break;
+    }
+
+    /*
+    ** *pCurrent gets an accurate estimate of the amount of memory used
+    ** to store the schema for all databases (main, temp, and any ATTACHed
+    ** databases.  *pHighwater is set to zero.
+    */
+    case SQLITE_DBSTATUS_SCHEMA_USED: {
+      int i;                      /* Used to iterate through schemas */
+      int nByte = 0;              /* Used to accumulate return value */
+
+      db->pnBytesFreed = &nByte;
+      for(i=0; i<db->nDb; i++){
+        Schema *pSchema = db->aDb[i].pSchema;
+        if( ALWAYS(pSchema!=0) ){
+          HashElem *p;
+
+          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (
+              pSchema->tblHash.count 
+            + pSchema->trigHash.count
+            + pSchema->idxHash.count
+            + pSchema->fkeyHash.count
+          );
+          nByte += sqlite3MallocSize(pSchema->tblHash.ht);
+          nByte += sqlite3MallocSize(pSchema->trigHash.ht);
+          nByte += sqlite3MallocSize(pSchema->idxHash.ht);
+          nByte += sqlite3MallocSize(pSchema->fkeyHash.ht);
+
+          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){
+            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
+          }
+          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){
+            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));
+          }
+        }
+      }
+      db->pnBytesFreed = 0;
+
+      *pHighwater = 0;
+      *pCurrent = nByte;
+      break;
+    }
+
+    /*
+    ** *pCurrent gets an accurate estimate of the amount of memory used
+    ** to store all prepared statements.
+    ** *pHighwater is set to zero.
+    */
+    case SQLITE_DBSTATUS_STMT_USED: {
+      struct Vdbe *pVdbe;         /* Used to iterate through VMs */
+      int nByte = 0;              /* Used to accumulate return value */
+
+      db->pnBytesFreed = &nByte;
+      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){
+        sqlite3VdbeDeleteObject(db, pVdbe);
+      }
+      db->pnBytesFreed = 0;
+
+      *pHighwater = 0;
+      *pCurrent = nByte;
+
+      break;
+    }
+
     default: {
-      return SQLITE_ERROR;
+      rc = SQLITE_ERROR;
     }
   }
-  return SQLITE_OK;
+  sqlite3_mutex_leave(db->mutex);
+  return rc;
 }
 
 /************** End of status.c **********************************************/
@@ -11515,12 +12642,6 @@ end_getDigits:
 }
 
 /*
-** Read text from z[] and convert into a floating point number.  Return
-** the number of digits converted.
-*/
-#define getValue sqlite3AtoF
-
-/*
 ** Parse a timezone extension on the end of a date-time.
 ** The extension is of the form:
 **
@@ -11695,10 +12816,8 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){
 ** Set the time to the current time reported by the VFS
 */
 static void setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
-  double r;
   sqlite3 *db = sqlite3_context_db_handle(context);
-  sqlite3OsCurrentTime(db->pVfs, &r);
-  p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);
+  sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD);
   p->validJD = 1;
 }
 
@@ -11723,7 +12842,7 @@ static int parseDateOrTime(
   const char *zDate, 
   DateTime *p
 ){
-  int isRealNum;    /* Return from sqlite3IsNumber().  Not used */
+  double r;
   if( parseYyyyMmDd(zDate,p)==0 ){
     return 0;
   }else if( parseHhMmSs(zDate, p)==0 ){
@@ -11731,9 +12850,7 @@ static int parseDateOrTime(
   }else if( sqlite3StrICmp(zDate,"now")==0){
     setDateTimeToCurrent(context, p);
     return 0;
-  }else if( sqlite3IsNumber(zDate, &isRealNum, SQLITE_UTF8) ){
-    double r;
-    getValue(zDate, &r);
+  }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){
     p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);
     p->validJD = 1;
     return 0;
@@ -11954,8 +13071,9 @@ static int parseModifier(const char *zMod, DateTime *p){
       ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the
       ** date is already on the appropriate weekday, this is a no-op.
       */
-      if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
-                 && (n=(int)r)==r && n>=0 && r<7 ){
+      if( strncmp(z, "weekday ", 8)==0
+               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)
+               && (n=(int)r)==r && n>=0 && r<7 ){
         sqlite3_int64 Z;
         computeYMD_HMS(p);
         p->validTZ = 0;
@@ -12010,8 +13128,11 @@ static int parseModifier(const char *zMod, DateTime *p){
     case '8':
     case '9': {
       double rRounder;
-      n = getValue(z, &r);
-      assert( n>=1 );
+      for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){}
+      if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){
+        rc = 1;
+        break;
+      }
       if( z[n]==':' ){
         /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the
         ** specified number of hours, minutes, seconds, and fractional seconds
@@ -12419,22 +13540,15 @@ static void currentTimeFunc(
   time_t t;
   char *zFormat = (char *)sqlite3_user_data(context);
   sqlite3 *db;
-  double rT;
+  sqlite3_int64 iT;
   char zBuf[20];
 
   UNUSED_PARAMETER(argc);
   UNUSED_PARAMETER(argv);
 
   db = sqlite3_context_db_handle(context);
-  sqlite3OsCurrentTime(db->pVfs, &rT);
-#ifndef SQLITE_OMIT_FLOATING_POINT
-  t = 86400.0*(rT - 2440587.5) + 0.5;
-#else
-  /* without floating point support, rT will have
-  ** already lost fractional day precision.
-  */
-  t = 86400 * (rT - 2440587) - 43200;
-#endif
+  sqlite3OsCurrentTimeInt64(db->pVfs, &iT);
+  t = iT/1000 - 10000*(sqlite3_int64)21086676;
 #ifdef HAVE_GMTIME_R
   {
     struct tm sNow;
@@ -12523,8 +13637,10 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
 **     sqlite3OsLock()
 **
 */
-#if defined(SQLITE_TEST) && (SQLITE_OS_WIN==0)
-  #define DO_OS_MALLOC_TEST(x) if (!x || !sqlite3IsMemJournal(x)) {     \
+#if defined(SQLITE_TEST)
+SQLITE_API int sqlite3_memdebug_vfs_oom_test = 1;
+  #define DO_OS_MALLOC_TEST(x)                                       \
+  if (sqlite3_memdebug_vfs_oom_test && (!x || !sqlite3IsMemJournal(x))) {  \
     void *pTstAlloc = sqlite3Malloc(10);                             \
     if (!pTstAlloc) return SQLITE_IOERR_NOMEM;                       \
     sqlite3_free(pTstAlloc);                                         \
@@ -12587,6 +13703,24 @@ SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){
 SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){
   return id->pMethods->xDeviceCharacteristics(id);
 }
+SQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int offset, int n, int flags){
+  return id->pMethods->xShmLock(id, offset, n, flags);
+}
+SQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id){
+  id->pMethods->xShmBarrier(id);
+}
+SQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){
+  return id->pMethods->xShmUnmap(id, deleteFlag);
+}
+SQLITE_PRIVATE int sqlite3OsShmMap(
+  sqlite3_file *id,               /* Database file handle */
+  int iPage,
+  int pgsz,
+  int bExtend,                    /* True to extend file if necessary */
+  void volatile **pp              /* OUT: Pointer to mapping */
+){
+  return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);
+}
 
 /*
 ** The next group of routines are convenience wrappers around the
@@ -12601,11 +13735,11 @@ SQLITE_PRIVATE int sqlite3OsOpen(
 ){
   int rc;
   DO_OS_MALLOC_TEST(0);
-  /* 0x7f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
+  /* 0x87f3f is a mask of SQLITE_OPEN_ flags that are valid to be passed
   ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,
   ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
   ** reaching the VFS. */
-  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x7f3f, pFlagsOut);
+  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f3f, pFlagsOut);
   assert( rc==SQLITE_OK || pFile->pMethods==0 );
   return rc;
 }
@@ -12650,8 +13784,22 @@ SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufO
 SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){
   return pVfs->xSleep(pVfs, nMicro);
 }
-SQLITE_PRIVATE int sqlite3OsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
-  return pVfs->xCurrentTime(pVfs, pTimeOut);
+SQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
+  int rc;
+  /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()
+  ** method to get the current date and time if that method is available
+  ** (if iVersion is 2 or greater and the function pointer is not NULL) and
+  ** will fall back to xCurrentTime() if xCurrentTimeInt64() is
+  ** unavailable.
+  */
+  if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){
+    rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut);
+  }else{
+    double r;
+    rc = pVfs->xCurrentTime(pVfs, &r);
+    *pTimeOut = (sqlite3_int64)(r*86400000.0);
+  }
+  return rc;
 }
 
 SQLITE_PRIVATE int sqlite3OsOpenMalloc(
@@ -13027,7 +14175,7 @@ static int sqlite3MemSize(void *pPrior){
 static void *sqlite3MemRealloc(void *pPrior, int nByte){
   sqlite3_int64 *p = (sqlite3_int64*)pPrior;
   assert( pPrior!=0 && nByte>0 );
-  nByte = ROUND8(nByte);
+  assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */
   p--;
   p = realloc(p, nByte+8 );
   if( p ){
@@ -13146,7 +14294,8 @@ struct MemBlockHdr {
   struct MemBlockHdr *pNext, *pPrev;  /* Linked list of all unfreed memory */
   char nBacktrace;                    /* Number of backtraces on this alloc */
   char nBacktraceSlots;               /* Available backtrace slots */
-  short nTitle;                       /* Bytes of title; includes '\0' */
+  u8 nTitle;                          /* Bytes of title; includes '\0' */
+  u8 eType;                           /* Allocation type code */
   int iForeGuard;                     /* Guard word for sanity */
 };
 
@@ -13354,6 +14503,7 @@ static void *sqlite3MemMalloc(int nByte){
     }
     mem.pLast = pHdr;
     pHdr->iForeGuard = FOREGUARD;
+    pHdr->eType = MEMTYPE_HEAP;
     pHdr->nBacktraceSlots = mem.nBacktrace;
     pHdr->nTitle = mem.nTitle;
     if( mem.nBacktrace ){
@@ -13431,6 +14581,7 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){
   struct MemBlockHdr *pOldHdr;
   void *pNew;
   assert( mem.disallow==0 );
+  assert( (nByte & 7)==0 );     /* EV: R-46199-30249 */
   pOldHdr = sqlite3MemsysGetHeader(pPrior);
   pNew = sqlite3MemMalloc(nByte);
   if( pNew ){
@@ -13462,6 +14613,62 @@ SQLITE_PRIVATE void sqlite3MemSetDefault(void){
 }
 
 /*
+** Set the "type" of an allocation.
+*/
+SQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){
+  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){
+    struct MemBlockHdr *pHdr;
+    pHdr = sqlite3MemsysGetHeader(p);
+    assert( pHdr->iForeGuard==FOREGUARD );
+    pHdr->eType = eType;
+  }
+}
+
+/*
+** Return TRUE if the mask of type in eType matches the type of the
+** allocation p.  Also return true if p==NULL.
+**
+** This routine is designed for use within an assert() statement, to
+** verify the type of an allocation.  For example:
+**
+**     assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );
+*/
+SQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){
+  int rc = 1;
+  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){
+    struct MemBlockHdr *pHdr;
+    pHdr = sqlite3MemsysGetHeader(p);
+    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */
+    if( (pHdr->eType&eType)==0 ){
+      rc = 0;
+    }
+  }
+  return rc;
+}
+
+/*
+** Return TRUE if the mask of type in eType matches no bits of the type of the
+** allocation p.  Also return true if p==NULL.
+**
+** This routine is designed for use within an assert() statement, to
+** verify the type of an allocation.  For example:
+**
+**     assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );
+*/
+SQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){
+  int rc = 1;
+  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){
+    struct MemBlockHdr *pHdr;
+    pHdr = sqlite3MemsysGetHeader(p);
+    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */
+    if( (pHdr->eType&eType)!=0 ){
+      rc = 0;
+    }
+  }
+  return rc;
+}
+
+/*
 ** Set the number of backtrace levels kept for each allocation.
 ** A value of zero turns off backtracing.  The number is always rounded
 ** up to a multiple of 2.
@@ -14644,7 +15851,7 @@ static void *memsys5Realloc(void *pPrior, int nBytes){
   int nOld;
   void *p;
   assert( pPrior!=0 );
-  assert( (nBytes&(nBytes-1))==0 );
+  assert( (nBytes&(nBytes-1))==0 );  /* EV: R-46199-30249 */
   assert( nBytes>=0 );
   if( nBytes==0 ){
     return 0;
@@ -14862,23 +16069,26 @@ static SQLITE_WSD int mutexIsInit = 0;
 */
 SQLITE_PRIVATE int sqlite3MutexInit(void){ 
   int rc = SQLITE_OK;
-  if( sqlite3GlobalConfig.bCoreMutex ){
-    if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){
-      /* If the xMutexAlloc method has not been set, then the user did not
-      ** install a mutex implementation via sqlite3_config() prior to 
-      ** sqlite3_initialize() being called. This block copies pointers to
-      ** the default implementation into the sqlite3GlobalConfig structure.
-      */
-      sqlite3_mutex_methods *pFrom = sqlite3DefaultMutex();
-      sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;
+  if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){
+    /* If the xMutexAlloc method has not been set, then the user did not
+    ** install a mutex implementation via sqlite3_config() prior to 
+    ** sqlite3_initialize() being called. This block copies pointers to
+    ** the default implementation into the sqlite3GlobalConfig structure.
+    */
+    sqlite3_mutex_methods const *pFrom;
+    sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;
 
-      memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc));
-      memcpy(&pTo->xMutexFree, &pFrom->xMutexFree,
-             sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
-      pTo->xMutexAlloc = pFrom->xMutexAlloc;
+    if( sqlite3GlobalConfig.bCoreMutex ){
+      pFrom = sqlite3DefaultMutex();
+    }else{
+      pFrom = sqlite3NoopMutex();
     }
-    rc = sqlite3GlobalConfig.mutex.xMutexInit();
+    memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc));
+    memcpy(&pTo->xMutexFree, &pFrom->xMutexFree,
+           sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
+    pTo->xMutexAlloc = pFrom->xMutexAlloc;
   }
+  rc = sqlite3GlobalConfig.mutex.xMutexInit();
 
 #ifdef SQLITE_DEBUG
   GLOBAL(int, mutexIsInit) = 1;
@@ -15010,25 +16220,30 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
 ** called correctly.
 */
 
+#ifndef SQLITE_MUTEX_OMIT
 
-#if defined(SQLITE_MUTEX_NOOP) && !defined(SQLITE_DEBUG)
+#ifndef SQLITE_DEBUG
 /*
 ** Stub routines for all mutex methods.
 **
 ** This routines provide no mutual exclusion or error checking.
 */
-static int noopMutexHeld(sqlite3_mutex *p){ return 1; }
-static int noopMutexNotheld(sqlite3_mutex *p){ return 1; }
 static int noopMutexInit(void){ return SQLITE_OK; }
 static int noopMutexEnd(void){ return SQLITE_OK; }
-static sqlite3_mutex *noopMutexAlloc(int id){ return (sqlite3_mutex*)8; }
-static void noopMutexFree(sqlite3_mutex *p){ return; }
-static void noopMutexEnter(sqlite3_mutex *p){ return; }
-static int noopMutexTry(sqlite3_mutex *p){ return SQLITE_OK; }
-static void noopMutexLeave(sqlite3_mutex *p){ return; }
-
-SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
-  static sqlite3_mutex_methods sMutex = {
+static sqlite3_mutex *noopMutexAlloc(int id){ 
+  UNUSED_PARAMETER(id);
+  return (sqlite3_mutex*)8; 
+}
+static void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
+static void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
+static int noopMutexTry(sqlite3_mutex *p){
+  UNUSED_PARAMETER(p);
+  return SQLITE_OK;
+}
+static void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }
+
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){
+  static const sqlite3_mutex_methods sMutex = {
     noopMutexInit,
     noopMutexEnd,
     noopMutexAlloc,
@@ -15037,15 +16252,15 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
     noopMutexTry,
     noopMutexLeave,
 
-    noopMutexHeld,
-    noopMutexNotheld
+    0,
+    0,
   };
 
   return &sMutex;
 }
-#endif /* defined(SQLITE_MUTEX_NOOP) && !defined(SQLITE_DEBUG) */
+#endif /* !SQLITE_DEBUG */
 
-#if defined(SQLITE_MUTEX_NOOP) && defined(SQLITE_DEBUG)
+#ifdef SQLITE_DEBUG
 /*
 ** In this implementation, error checking is provided for testing
 ** and debugging purposes.  The mutexes still do not provide any
@@ -15055,19 +16270,21 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 /*
 ** The mutex object
 */
-struct sqlite3_mutex {
+typedef struct sqlite3_debug_mutex {
   int id;     /* The mutex type */
   int cnt;    /* Number of entries without a matching leave */
-};
+} sqlite3_debug_mutex;
 
 /*
 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
 ** intended for use inside assert() statements.
 */
-static int debugMutexHeld(sqlite3_mutex *p){
+static int debugMutexHeld(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
   return p==0 || p->cnt>0;
 }
-static int debugMutexNotheld(sqlite3_mutex *p){
+static int debugMutexNotheld(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
   return p==0 || p->cnt==0;
 }
 
@@ -15083,8 +16300,8 @@ static int debugMutexEnd(void){ return SQLITE_OK; }
 ** that means that a mutex could not be allocated. 
 */
 static sqlite3_mutex *debugMutexAlloc(int id){
-  static sqlite3_mutex aStatic[6];
-  sqlite3_mutex *pNew = 0;
+  static sqlite3_debug_mutex aStatic[6];
+  sqlite3_debug_mutex *pNew = 0;
   switch( id ){
     case SQLITE_MUTEX_FAST:
     case SQLITE_MUTEX_RECURSIVE: {
@@ -15103,13 +16320,14 @@ static sqlite3_mutex *debugMutexAlloc(int id){
       break;
     }
   }
-  return pNew;
+  return (sqlite3_mutex*)pNew;
 }
 
 /*
 ** This routine deallocates a previously allocated mutex.
 */
-static void debugMutexFree(sqlite3_mutex *p){
+static void debugMutexFree(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
   assert( p->cnt==0 );
   assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
   sqlite3_free(p);
@@ -15126,12 +16344,14 @@ static void debugMutexFree(sqlite3_mutex *p){
 ** can enter.  If the same thread tries to enter any other kind of mutex
 ** more than once, the behavior is undefined.
 */
-static void debugMutexEnter(sqlite3_mutex *p){
-  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
+static void debugMutexEnter(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
+  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
   p->cnt++;
 }
-static int debugMutexTry(sqlite3_mutex *p){
-  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
+static int debugMutexTry(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
+  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
   p->cnt++;
   return SQLITE_OK;
 }
@@ -15142,14 +16362,15 @@ static int debugMutexTry(sqlite3_mutex *p){
 ** is undefined if the mutex is not currently entered or
 ** is not currently allocated.  SQLite will never do either.
 */
-static void debugMutexLeave(sqlite3_mutex *p){
-  assert( debugMutexHeld(p) );
+static void debugMutexLeave(sqlite3_mutex *pX){
+  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
+  assert( debugMutexHeld(pX) );
   p->cnt--;
-  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(p) );
+  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );
 }
 
-SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
-  static sqlite3_mutex_methods sMutex = {
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){
+  static const sqlite3_mutex_methods sMutex = {
     debugMutexInit,
     debugMutexEnd,
     debugMutexAlloc,
@@ -15164,7 +16385,18 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 
   return &sMutex;
 }
-#endif /* defined(SQLITE_MUTEX_NOOP) && defined(SQLITE_DEBUG) */
+#endif /* SQLITE_DEBUG */
+
+/*
+** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation
+** is used regardless of the run-time threadsafety setting.
+*/
+#ifdef SQLITE_MUTEX_NOOP
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
+  return sqlite3NoopMutex();
+}
+#endif /* SQLITE_MUTEX_NOOP */
+#endif /* SQLITE_MUTEX_OMIT */
 
 /************** End of mutex_noop.c ******************************************/
 /************** Begin file mutex_os2.c ***************************************/
@@ -15420,8 +16652,8 @@ static void os2MutexLeave(sqlite3_mutex *p){
   DosReleaseMutexSem(p->mutex);
 }
 
-SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
-  static sqlite3_mutex_methods sMutex = {
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
+  static const sqlite3_mutex_methods sMutex = {
     os2MutexInit,
     os2MutexEnd,
     os2MutexAlloc,
@@ -15466,23 +16698,33 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 
 #include <pthread.h>
 
+/*
+** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields
+** are necessary under two condidtions:  (1) Debug builds and (2) using
+** home-grown mutexes.  Encapsulate these conditions into a single #define.
+*/
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX)
+# define SQLITE_MUTEX_NREF 1
+#else
+# define SQLITE_MUTEX_NREF 0
+#endif
 
 /*
 ** Each recursive mutex is an instance of the following structure.
 */
 struct sqlite3_mutex {
   pthread_mutex_t mutex;     /* Mutex controlling the lock */
+#if SQLITE_MUTEX_NREF
   int id;                    /* Mutex type */
-  int nRef;                  /* Number of entrances */
-  pthread_t owner;           /* Thread that is within this mutex */
-#ifdef SQLITE_DEBUG
+  volatile int nRef;         /* Number of entrances */
+  volatile pthread_t owner;  /* Thread that is within this mutex */
   int trace;                 /* True to trace changes */
 #endif
 };
-#ifdef SQLITE_DEBUG
+#if SQLITE_MUTEX_NREF
 #define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0, (pthread_t)0, 0 }
 #else
-#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0, (pthread_t)0 }
+#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
 #endif
 
 /*
@@ -15584,14 +16826,18 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
         pthread_mutex_init(&p->mutex, &recursiveAttr);
         pthread_mutexattr_destroy(&recursiveAttr);
 #endif
+#if SQLITE_MUTEX_NREF
         p->id = iType;
+#endif
       }
       break;
     }
     case SQLITE_MUTEX_FAST: {
       p = sqlite3MallocZero( sizeof(*p) );
       if( p ){
+#if SQLITE_MUTEX_NREF
         p->id = iType;
+#endif
         pthread_mutex_init(&p->mutex, 0);
       }
       break;
@@ -15600,7 +16846,9 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
       assert( iType-2 >= 0 );
       assert( iType-2 < ArraySize(staticMutexes) );
       p = &staticMutexes[iType-2];
+#if SQLITE_MUTEX_NREF
       p->id = iType;
+#endif
       break;
     }
   }
@@ -15660,9 +16908,12 @@ static void pthreadMutexEnter(sqlite3_mutex *p){
   /* Use the built-in recursive mutexes if they are available.
   */
   pthread_mutex_lock(&p->mutex);
+#if SQLITE_MUTEX_NREF
+  assert( p->nRef>0 || p->owner==0 );
   p->owner = pthread_self();
   p->nRef++;
 #endif
+#endif
 
 #ifdef SQLITE_DEBUG
   if( p->trace ){
@@ -15703,8 +16954,10 @@ static int pthreadMutexTry(sqlite3_mutex *p){
   /* Use the built-in recursive mutexes if they are available.
   */
   if( pthread_mutex_trylock(&p->mutex)==0 ){
+#if SQLITE_MUTEX_NREF
     p->owner = pthread_self();
     p->nRef++;
+#endif
     rc = SQLITE_OK;
   }else{
     rc = SQLITE_BUSY;
@@ -15727,7 +16980,10 @@ static int pthreadMutexTry(sqlite3_mutex *p){
 */
 static void pthreadMutexLeave(sqlite3_mutex *p){
   assert( pthreadMutexHeld(p) );
+#if SQLITE_MUTEX_NREF
   p->nRef--;
+  if( p->nRef==0 ) p->owner = 0;
+#endif
   assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
 
 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
@@ -15745,8 +17001,8 @@ static void pthreadMutexLeave(sqlite3_mutex *p){
 #endif
 }
 
-SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
-  static sqlite3_mutex_methods sMutex = {
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
+  static const sqlite3_mutex_methods sMutex = {
     pthreadMutexInit,
     pthreadMutexEnd,
     pthreadMutexAlloc,
@@ -15796,9 +17052,9 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 struct sqlite3_mutex {
   CRITICAL_SECTION mutex;    /* Mutex controlling the lock */
   int id;                    /* Mutex type */
-  int nRef;                  /* Number of enterances */
-  DWORD owner;               /* Thread holding this mutex */
 #ifdef SQLITE_DEBUG
+  volatile int nRef;         /* Number of enterances */
+  volatile DWORD owner;      /* Thread holding this mutex */
   int trace;                 /* True to trace changes */
 #endif
 };
@@ -15806,7 +17062,7 @@ struct sqlite3_mutex {
 #ifdef SQLITE_DEBUG
 #define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 }
 #else
-#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0 }
+#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 }
 #endif
 
 /*
@@ -15962,7 +17218,9 @@ static sqlite3_mutex *winMutexAlloc(int iType){
     case SQLITE_MUTEX_RECURSIVE: {
       p = sqlite3MallocZero( sizeof(*p) );
       if( p ){  
+#ifdef SQLITE_DEBUG
         p->id = iType;
+#endif
         InitializeCriticalSection(&p->mutex);
       }
       break;
@@ -15972,7 +17230,9 @@ static sqlite3_mutex *winMutexAlloc(int iType){
       assert( iType-2 >= 0 );
       assert( iType-2 < ArraySize(winMutex_staticMutexes) );
       p = &winMutex_staticMutexes[iType-2];
+#ifdef SQLITE_DEBUG
       p->id = iType;
+#endif
       break;
     }
   }
@@ -15987,7 +17247,7 @@ static sqlite3_mutex *winMutexAlloc(int iType){
 */
 static void winMutexFree(sqlite3_mutex *p){
   assert( p );
-  assert( p->nRef==0 );
+  assert( p->nRef==0 && p->owner==0 );
   assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
   DeleteCriticalSection(&p->mutex);
   sqlite3_free(p);
@@ -16005,12 +17265,15 @@ static void winMutexFree(sqlite3_mutex *p){
 ** more than once, the behavior is undefined.
 */
 static void winMutexEnter(sqlite3_mutex *p){
+#ifdef SQLITE_DEBUG
   DWORD tid = GetCurrentThreadId(); 
   assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
+#endif
   EnterCriticalSection(&p->mutex);
+#ifdef SQLITE_DEBUG
+  assert( p->nRef>0 || p->owner==0 );
   p->owner = tid; 
   p->nRef++;
-#ifdef SQLITE_DEBUG
   if( p->trace ){
     printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
   }
@@ -16059,11 +17322,12 @@ static int winMutexTry(sqlite3_mutex *p){
 static void winMutexLeave(sqlite3_mutex *p){
 #ifndef NDEBUG
   DWORD tid = GetCurrentThreadId();
-#endif
   assert( p->nRef>0 );
   assert( p->owner==tid );
   p->nRef--;
+  if( p->nRef==0 ) p->owner = 0;
   assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
+#endif
   LeaveCriticalSection(&p->mutex);
 #ifdef SQLITE_DEBUG
   if( p->trace ){
@@ -16072,8 +17336,8 @@ static void winMutexLeave(sqlite3_mutex *p){
 #endif
 }
 
-SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
-  static sqlite3_mutex_methods sMutex = {
+SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
+  static const sqlite3_mutex_methods sMutex = {
     winMutexInit,
     winMutexEnd,
     winMutexAlloc,
@@ -16112,69 +17376,34 @@ SQLITE_PRIVATE sqlite3_mutex_methods *sqlite3DefaultMutex(void){
 */
 
 /*
-** This routine runs when the memory allocator sees that the
-** total memory allocation is about to exceed the soft heap
-** limit.
-*/
-static void softHeapLimitEnforcer(
-  void *NotUsed, 
-  sqlite3_int64 NotUsed2,
-  int allocSize
-){
-  UNUSED_PARAMETER2(NotUsed, NotUsed2);
-  sqlite3_release_memory(allocSize);
-}
-
-/*
-** Set the soft heap-size limit for the library. Passing a zero or 
-** negative value indicates no limit.
-*/
-SQLITE_API void sqlite3_soft_heap_limit(int n){
-  sqlite3_uint64 iLimit;
-  int overage;
-  if( n<0 ){
-    iLimit = 0;
-  }else{
-    iLimit = n;
-  }
-#ifndef SQLITE_OMIT_AUTOINIT
-  sqlite3_initialize();
-#endif
-  if( iLimit>0 ){
-    sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, iLimit);
-  }else{
-    sqlite3MemoryAlarm(0, 0, 0);
-  }
-  overage = (int)(sqlite3_memory_used() - (i64)n);
-  if( overage>0 ){
-    sqlite3_release_memory(overage);
-  }
-}
-
-/*
 ** Attempt to release up to n bytes of non-essential memory currently
 ** held by SQLite. An example of non-essential memory is memory used to
 ** cache database pages that are not currently in use.
 */
 SQLITE_API int sqlite3_release_memory(int n){
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
-  int nRet = 0;
-  nRet += sqlite3PcacheReleaseMemory(n-nRet);
-  return nRet;
+  return sqlite3PcacheReleaseMemory(n);
 #else
+  /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
+  ** is a no-op returning zero if SQLite is not compiled with
+  ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */
   UNUSED_PARAMETER(n);
-  return SQLITE_OK;
+  return 0;
 #endif
 }
 
 /*
+** An instance of the following object records the location of
+** each unused scratch buffer.
+*/
+typedef struct ScratchFreeslot {
+  struct ScratchFreeslot *pNext;   /* Next unused scratch buffer */
+} ScratchFreeslot;
+
+/*
 ** State information local to the memory allocation subsystem.
 */
 static SQLITE_WSD struct Mem0Global {
-  /* Number of free pages for scratch and page-cache memory */
-  u32 nScratchFree;
-  u32 nPageFree;
-
   sqlite3_mutex *mutex;         /* Mutex to serialize access */
 
   /*
@@ -16188,17 +17417,100 @@ static SQLITE_WSD struct Mem0Global {
   void *alarmArg;
 
   /*
-  ** Pointers to the end of sqlite3GlobalConfig.pScratch and
-  ** sqlite3GlobalConfig.pPage to a block of memory that records
-  ** which pages are available.
+  ** Pointers to the end of sqlite3GlobalConfig.pScratch memory
+  ** (so that a range test can be used to determine if an allocation
+  ** being freed came from pScratch) and a pointer to the list of
+  ** unused scratch allocations.
+  */
+  void *pScratchEnd;
+  ScratchFreeslot *pScratchFree;
+  u32 nScratchFree;
+
+  /*
+  ** True if heap is nearly "full" where "full" is defined by the
+  ** sqlite3_soft_heap_limit() setting.
   */
-  u32 *aScratchFree;
-  u32 *aPageFree;
+  int nearlyFull;
 } mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
 #define mem0 GLOBAL(struct Mem0Global, mem0)
 
 /*
+** This routine runs when the memory allocator sees that the
+** total memory allocation is about to exceed the soft heap
+** limit.
+*/
+static void softHeapLimitEnforcer(
+  void *NotUsed, 
+  sqlite3_int64 NotUsed2,
+  int allocSize
+){
+  UNUSED_PARAMETER2(NotUsed, NotUsed2);
+  sqlite3_release_memory(allocSize);
+}
+
+/*
+** Change the alarm callback
+*/
+static int sqlite3MemoryAlarm(
+  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
+  void *pArg,
+  sqlite3_int64 iThreshold
+){
+  int nUsed;
+  sqlite3_mutex_enter(mem0.mutex);
+  mem0.alarmCallback = xCallback;
+  mem0.alarmArg = pArg;
+  mem0.alarmThreshold = iThreshold;
+  nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
+  mem0.nearlyFull = (iThreshold>0 && iThreshold<=nUsed);
+  sqlite3_mutex_leave(mem0.mutex);
+  return SQLITE_OK;
+}
+
+#ifndef SQLITE_OMIT_DEPRECATED
+/*
+** Deprecated external interface.  Internal/core SQLite code
+** should call sqlite3MemoryAlarm.
+*/
+SQLITE_API int sqlite3_memory_alarm(
+  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
+  void *pArg,
+  sqlite3_int64 iThreshold
+){
+  return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
+}
+#endif
+
+/*
+** Set the soft heap-size limit for the library. Passing a zero or 
+** negative value indicates no limit.
+*/
+SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
+  sqlite3_int64 priorLimit;
+  sqlite3_int64 excess;
+#ifndef SQLITE_OMIT_AUTOINIT
+  sqlite3_initialize();
+#endif
+  sqlite3_mutex_enter(mem0.mutex);
+  priorLimit = mem0.alarmThreshold;
+  sqlite3_mutex_leave(mem0.mutex);
+  if( n<0 ) return priorLimit;
+  if( n>0 ){
+    sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n);
+  }else{
+    sqlite3MemoryAlarm(0, 0, 0);
+  }
+  excess = sqlite3_memory_used() - n;
+  if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
+  return priorLimit;
+}
+SQLITE_API void sqlite3_soft_heap_limit(int n){
+  if( n<0 ) n = 0;
+  sqlite3_soft_heap_limit64(n);
+}
+
+/*
 ** Initialize the memory allocation subsystem.
 */
 SQLITE_PRIVATE int sqlite3MallocInit(void){
@@ -16210,37 +17522,46 @@ SQLITE_PRIVATE int sqlite3MallocInit(void){
     mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
   }
   if( sqlite3GlobalConfig.pScratch && sqlite3GlobalConfig.szScratch>=100
-      && sqlite3GlobalConfig.nScratch>=0 ){
-    int i;
-    sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch-4);
-    mem0.aScratchFree = (u32*)&((char*)sqlite3GlobalConfig.pScratch)
-                  [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch];
-    for(i=0; i<sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
-    mem0.nScratchFree = sqlite3GlobalConfig.nScratch;
+      && sqlite3GlobalConfig.nScratch>0 ){
+    int i, n, sz;
+    ScratchFreeslot *pSlot;
+    sz = ROUNDDOWN8(sqlite3GlobalConfig.szScratch);
+    sqlite3GlobalConfig.szScratch = sz;
+    pSlot = (ScratchFreeslot*)sqlite3GlobalConfig.pScratch;
+    n = sqlite3GlobalConfig.nScratch;
+    mem0.pScratchFree = pSlot;
+    mem0.nScratchFree = n;
+    for(i=0; i<n-1; i++){
+      pSlot->pNext = (ScratchFreeslot*)(sz+(char*)pSlot);
+      pSlot = pSlot->pNext;
+    }
+    pSlot->pNext = 0;
+    mem0.pScratchEnd = (void*)&pSlot[1];
   }else{
+    mem0.pScratchEnd = 0;
     sqlite3GlobalConfig.pScratch = 0;
     sqlite3GlobalConfig.szScratch = 0;
+    sqlite3GlobalConfig.nScratch = 0;
   }
-  if( sqlite3GlobalConfig.pPage && sqlite3GlobalConfig.szPage>=512
-      && sqlite3GlobalConfig.nPage>=1 ){
-    int i;
-    int overhead;
-    int sz = ROUNDDOWN8(sqlite3GlobalConfig.szPage);
-    int n = sqlite3GlobalConfig.nPage;
-    overhead = (4*n + sz - 1)/sz;
-    sqlite3GlobalConfig.nPage -= overhead;
-    mem0.aPageFree = (u32*)&((char*)sqlite3GlobalConfig.pPage)
-                  [sqlite3GlobalConfig.szPage*sqlite3GlobalConfig.nPage];
-    for(i=0; i<sqlite3GlobalConfig.nPage; i++){ mem0.aPageFree[i] = i; }
-    mem0.nPageFree = sqlite3GlobalConfig.nPage;
-  }else{
+  if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512
+      || sqlite3GlobalConfig.nPage<1 ){
     sqlite3GlobalConfig.pPage = 0;
     sqlite3GlobalConfig.szPage = 0;
+    sqlite3GlobalConfig.nPage = 0;
   }
   return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
 }
 
 /*
+** Return true if the heap is currently under memory pressure - in other
+** words if the amount of heap used is close to the limit set by
+** sqlite3_soft_heap_limit().
+*/
+SQLITE_PRIVATE int sqlite3HeapNearlyFull(void){
+  return mem0.nearlyFull;
+}
+
+/*
 ** Deinitialize the memory allocation subsystem.
 */
 SQLITE_PRIVATE void sqlite3MallocEnd(void){
@@ -16275,36 +17596,6 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
 }
 
 /*
-** Change the alarm callback
-*/
-SQLITE_PRIVATE int sqlite3MemoryAlarm(
-  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
-  void *pArg,
-  sqlite3_int64 iThreshold
-){
-  sqlite3_mutex_enter(mem0.mutex);
-  mem0.alarmCallback = xCallback;
-  mem0.alarmArg = pArg;
-  mem0.alarmThreshold = iThreshold;
-  sqlite3_mutex_leave(mem0.mutex);
-  return SQLITE_OK;
-}
-
-#ifndef SQLITE_OMIT_DEPRECATED
-/*
-** Deprecated external interface.  Internal/core SQLite code
-** should call sqlite3MemoryAlarm.
-*/
-SQLITE_API int sqlite3_memory_alarm(
-  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
-  void *pArg,
-  sqlite3_int64 iThreshold
-){
-  return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
-}
-#endif
-
-/*
 ** Trigger the alarm 
 */
 static void sqlite3MallocAlarm(int nByte){
@@ -16336,17 +17627,23 @@ static int mallocWithAlarm(int n, void **pp){
   if( mem0.alarmCallback!=0 ){
     int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
     if( nUsed+nFull >= mem0.alarmThreshold ){
+      mem0.nearlyFull = 1;
       sqlite3MallocAlarm(nFull);
+    }else{
+      mem0.nearlyFull = 0;
     }
   }
   p = sqlite3GlobalConfig.m.xMalloc(nFull);
+#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   if( p==0 && mem0.alarmCallback ){
     sqlite3MallocAlarm(nFull);
     p = sqlite3GlobalConfig.m.xMalloc(nFull);
   }
+#endif
   if( p ){
     nFull = sqlite3MallocSize(p);
     sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
+    sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);
   }
   *pp = p;
   return nFull;
@@ -16358,7 +17655,9 @@ static int mallocWithAlarm(int n, void **pp){
 */
 SQLITE_PRIVATE void *sqlite3Malloc(int n){
   void *p;
-  if( n<=0 || n>=0x7fffff00 ){
+  if( n<=0               /* IMP: R-65312-04917 */ 
+   || n>=0x7fffff00
+  ){
     /* A memory allocation of a number of bytes which is near the maximum
     ** signed integer value might cause an integer overflow inside of the
     ** xMalloc().  Hence we limit the maximum size to 0x7fffff00, giving
@@ -16372,6 +17671,7 @@ SQLITE_PRIVATE void *sqlite3Malloc(int n){
   }else{
     p = sqlite3GlobalConfig.m.xMalloc(n);
   }
+  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-04675-44850 */
   return p;
 }
 
@@ -16410,88 +17710,79 @@ SQLITE_PRIVATE void *sqlite3ScratchMalloc(int n){
   void *p;
   assert( n>0 );
 
-#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-  /* Verify that no more than one scratch allocation per thread
-  ** is outstanding at one time.  (This is only checked in the
-  ** single-threaded case since checking in the multi-threaded case
-  ** would be much more complicated.) */
-  assert( scratchAllocOut==0 );
-#endif
-
-  if( sqlite3GlobalConfig.szScratch<n ){
-    goto scratch_overflow;
-  }else{  
-    sqlite3_mutex_enter(mem0.mutex);
-    if( mem0.nScratchFree==0 ){
+  sqlite3_mutex_enter(mem0.mutex);
+  if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){
+    p = mem0.pScratchFree;
+    mem0.pScratchFree = mem0.pScratchFree->pNext;
+    mem0.nScratchFree--;
+    sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
+    sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
+    sqlite3_mutex_leave(mem0.mutex);
+  }else{
+    if( sqlite3GlobalConfig.bMemstat ){
+      sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
+      n = mallocWithAlarm(n, &p);
+      if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);
       sqlite3_mutex_leave(mem0.mutex);
-      goto scratch_overflow;
     }else{
-      int i;
-      i = mem0.aScratchFree[--mem0.nScratchFree];
-      i *= sqlite3GlobalConfig.szScratch;
-      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
-      sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
       sqlite3_mutex_leave(mem0.mutex);
-      p = (void*)&((char*)sqlite3GlobalConfig.pScratch)[i];
-      assert(  (((u8*)p - (u8*)0) & 7)==0 );
+      p = sqlite3GlobalConfig.m.xMalloc(n);
     }
+    sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
   }
-#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-  scratchAllocOut = p!=0;
-#endif
+  assert( sqlite3_mutex_notheld(mem0.mutex) );
 
-  return p;
 
-scratch_overflow:
-  if( sqlite3GlobalConfig.bMemstat ){
-    sqlite3_mutex_enter(mem0.mutex);
-    sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
-    n = mallocWithAlarm(n, &p);
-    if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);
-    sqlite3_mutex_leave(mem0.mutex);
-  }else{
-    p = sqlite3GlobalConfig.m.xMalloc(n);
-  }
 #if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-  scratchAllocOut = p!=0;
+  /* Verify that no more than two scratch allocations per thread
+  ** are outstanding at one time.  (This is only checked in the
+  ** single-threaded case since checking in the multi-threaded case
+  ** would be much more complicated.) */
+  assert( scratchAllocOut<=1 );
+  if( p ) scratchAllocOut++;
 #endif
-  return p;    
+
+  return p;
 }
 SQLITE_PRIVATE void sqlite3ScratchFree(void *p){
   if( p ){
 
 #if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
-    /* Verify that no more than one scratch allocation per thread
+    /* Verify that no more than two scratch allocation per thread
     ** is outstanding at one time.  (This is only checked in the
     ** single-threaded case since checking in the multi-threaded case
     ** would be much more complicated.) */
-    assert( scratchAllocOut==1 );
-    scratchAllocOut = 0;
+    assert( scratchAllocOut>=1 && scratchAllocOut<=2 );
+    scratchAllocOut--;
 #endif
 
-    if( sqlite3GlobalConfig.pScratch==0
-           || p<sqlite3GlobalConfig.pScratch
-           || p>=(void*)mem0.aScratchFree ){
+    if( p>=sqlite3GlobalConfig.pScratch && p<mem0.pScratchEnd ){
+      /* Release memory from the SQLITE_CONFIG_SCRATCH allocation */
+      ScratchFreeslot *pSlot;
+      pSlot = (ScratchFreeslot*)p;
+      sqlite3_mutex_enter(mem0.mutex);
+      pSlot->pNext = mem0.pScratchFree;
+      mem0.pScratchFree = pSlot;
+      mem0.nScratchFree++;
+      assert( mem0.nScratchFree<=sqlite3GlobalConfig.nScratch );
+      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
+      sqlite3_mutex_leave(mem0.mutex);
+    }else{
+      /* Release memory back to the heap */
+      assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
+      assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );
+      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
       if( sqlite3GlobalConfig.bMemstat ){
         int iSize = sqlite3MallocSize(p);
         sqlite3_mutex_enter(mem0.mutex);
         sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);
         sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);
+        sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
         sqlite3GlobalConfig.m.xFree(p);
         sqlite3_mutex_leave(mem0.mutex);
       }else{
         sqlite3GlobalConfig.m.xFree(p);
       }
-    }else{
-      int i;
-      i = (int)((u8*)p - (u8*)sqlite3GlobalConfig.pScratch);
-      i /= sqlite3GlobalConfig.szScratch;
-      assert( i>=0 && i<sqlite3GlobalConfig.nScratch );
-      sqlite3_mutex_enter(mem0.mutex);
-      assert( mem0.nScratchFree<(u32)sqlite3GlobalConfig.nScratch );
-      mem0.aScratchFree[mem0.nScratchFree++] = i;
-      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
-      sqlite3_mutex_leave(mem0.mutex);
     }
   }
 }
@@ -16501,7 +17792,7 @@ SQLITE_PRIVATE void sqlite3ScratchFree(void *p){
 */
 #ifndef SQLITE_OMIT_LOOKASIDE
 static int isLookaside(sqlite3 *db, void *p){
-  return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;
+  return p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;
 }
 #else
 #define isLookaside(A,B) 0
@@ -16512,13 +17803,18 @@ static int isLookaside(sqlite3 *db, void *p){
 ** sqlite3Malloc() or sqlite3_malloc().
 */
 SQLITE_PRIVATE int sqlite3MallocSize(void *p){
+  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
+  assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );
   return sqlite3GlobalConfig.m.xSize(p);
 }
 SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
   assert( db==0 || sqlite3_mutex_held(db->mutex) );
-  if( isLookaside(db, p) ){
+  if( db && isLookaside(db, p) ){
     return db->lookaside.sz;
   }else{
+    assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );
+    assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );
+    assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
     return sqlite3GlobalConfig.m.xSize(p);
   }
 }
@@ -16527,10 +17823,13 @@ SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
 ** Free memory previously obtained from sqlite3Malloc().
 */
 SQLITE_API void sqlite3_free(void *p){
-  if( p==0 ) return;
+  if( p==0 ) return;  /* IMP: R-49053-54554 */
+  assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );
+  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
   if( sqlite3GlobalConfig.bMemstat ){
     sqlite3_mutex_enter(mem0.mutex);
     sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));
+    sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
     sqlite3GlobalConfig.m.xFree(p);
     sqlite3_mutex_leave(mem0.mutex);
   }else{
@@ -16544,14 +17843,24 @@ SQLITE_API void sqlite3_free(void *p){
 */
 SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){
   assert( db==0 || sqlite3_mutex_held(db->mutex) );
-  if( isLookaside(db, p) ){
-    LookasideSlot *pBuf = (LookasideSlot*)p;
-    pBuf->pNext = db->lookaside.pFree;
-    db->lookaside.pFree = pBuf;
-    db->lookaside.nOut--;
-  }else{
-    sqlite3_free(p);
+  if( db ){
+    if( db->pnBytesFreed ){
+      *db->pnBytesFreed += sqlite3DbMallocSize(db, p);
+      return;
+    }
+    if( isLookaside(db, p) ){
+      LookasideSlot *pBuf = (LookasideSlot*)p;
+      pBuf->pNext = db->lookaside.pFree;
+      db->lookaside.pFree = pBuf;
+      db->lookaside.nOut--;
+      return;
+    }
   }
+  assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );
+  assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );
+  assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
+  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
+  sqlite3_free(p);
 }
 
 /*
@@ -16561,10 +17870,10 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){
   int nOld, nNew;
   void *pNew;
   if( pOld==0 ){
-    return sqlite3Malloc(nBytes);
+    return sqlite3Malloc(nBytes); /* IMP: R-28354-25769 */
   }
   if( nBytes<=0 ){
-    sqlite3_free(pOld);
+    sqlite3_free(pOld); /* IMP: R-31593-10574 */
     return 0;
   }
   if( nBytes>=0x7fffff00 ){
@@ -16572,6 +17881,9 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){
     return 0;
   }
   nOld = sqlite3MallocSize(pOld);
+  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second
+  ** argument to xRealloc is always a value returned by a prior call to
+  ** xRoundup. */
   nNew = sqlite3GlobalConfig.m.xRoundup(nBytes);
   if( nOld==nNew ){
     pNew = pOld;
@@ -16582,6 +17894,8 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){
           mem0.alarmThreshold ){
       sqlite3MallocAlarm(nNew-nOld);
     }
+    assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
+    assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );
     pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
     if( pNew==0 && mem0.alarmCallback ){
       sqlite3MallocAlarm(nBytes);
@@ -16595,6 +17909,7 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){
   }else{
     pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
   }
+  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-04675-44850 */
   return pNew;
 }
 
@@ -16654,6 +17969,7 @@ SQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, int n){
 SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){
   void *p;
   assert( db==0 || sqlite3_mutex_held(db->mutex) );
+  assert( db==0 || db->pnBytesFreed==0 );
 #ifndef SQLITE_OMIT_LOOKASIDE
   if( db ){
     LookasideSlot *pBuf;
@@ -16679,6 +17995,8 @@ SQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){
   if( !p && db ){
     db->mallocFailed = 1;
   }
+  sqlite3MemdebugSetType(p, MEMTYPE_DB |
+         ((db && db->lookaside.bEnabled) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
   return p;
 }
 
@@ -16704,10 +18022,16 @@ SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){
         sqlite3DbFree(db, p);
       }
     }else{
+      assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );
+      assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );
+      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
       pNew = sqlite3_realloc(p, n);
       if( !pNew ){
+        sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP);
         db->mallocFailed = 1;
       }
+      sqlite3MemdebugSetType(pNew, MEMTYPE_DB | 
+            (db->lookaside.bEnabled ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
     }
   }
   return pNew;
@@ -17580,7 +18904,11 @@ SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
       }else{
         p->nAlloc = (int)szNew;
       }
-      zNew = sqlite3DbMallocRaw(p->db, p->nAlloc );
+      if( p->useMalloc==1 ){
+        zNew = sqlite3DbMallocRaw(p->db, p->nAlloc );
+      }else{
+        zNew = sqlite3_malloc(p->nAlloc);
+      }
       if( zNew ){
         memcpy(zNew, p->zText, p->nChar);
         sqlite3StrAccumReset(p);
@@ -17605,7 +18933,11 @@ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
   if( p->zText ){
     p->zText[p->nChar] = 0;
     if( p->useMalloc && p->zText==p->zBase ){
-      p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
+      if( p->useMalloc==1 ){
+        p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
+      }else{
+        p->zText = sqlite3_malloc(p->nChar+1);
+      }
       if( p->zText ){
         memcpy(p->zText, p->zBase, p->nChar+1);
       }else{
@@ -17621,7 +18953,11 @@ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
 */
 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
   if( p->zText!=p->zBase ){
-    sqlite3DbFree(p->db, p->zText);
+    if( p->useMalloc==1 ){
+      sqlite3DbFree(p->db, p->zText);
+    }else{
+      sqlite3_free(p->zText);
+    }
   }
   p->zText = 0;
 }
@@ -17703,6 +19039,7 @@ SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
   if( sqlite3_initialize() ) return 0;
 #endif
   sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
+  acc.useMalloc = 2;
   sqlite3VXPrintf(&acc, 0, zFormat, ap);
   z = sqlite3StrAccumFinish(&acc);
   return z;
@@ -17996,429 +19333,6 @@ SQLITE_PRIVATE void sqlite3PrngResetState(void){
 **     0xfe 0xff   big-endian utf-16 follows
 **
 */
-/************** Include vdbeInt.h in the middle of utf.c *********************/
-/************** Begin file vdbeInt.h *****************************************/
-/*
-** 2003 September 6
-**
-** The author disclaims copyright to this source code.  In place of
-** a legal notice, here is a blessing:
-**
-**    May you do good and not evil.
-**    May you find forgiveness for yourself and forgive others.
-**    May you share freely, never taking more than you give.
-**
-*************************************************************************
-** This is the header file for information that is private to the
-** VDBE.  This information used to all be at the top of the single
-** source code file "vdbe.c".  When that file became too big (over
-** 6000 lines long) it was split up into several smaller files and
-** this header information was factored out.
-*/
-#ifndef _VDBEINT_H_
-#define _VDBEINT_H_
-
-/*
-** SQL is translated into a sequence of instructions to be
-** executed by a virtual machine.  Each instruction is an instance
-** of the following structure.
-*/
-typedef struct VdbeOp Op;
-
-/*
-** Boolean values
-*/
-typedef unsigned char Bool;
-
-/*
-** A cursor is a pointer into a single BTree within a database file.
-** The cursor can seek to a BTree entry with a particular key, or
-** loop over all entries of the Btree.  You can also insert new BTree
-** entries or retrieve the key or data from the entry that the cursor
-** is currently pointing to.
-** 
-** Every cursor that the virtual machine has open is represented by an
-** instance of the following structure.
-**
-** If the VdbeCursor.isTriggerRow flag is set it means that this cursor is
-** really a single row that represents the NEW or OLD pseudo-table of
-** a row trigger.  The data for the row is stored in VdbeCursor.pData and
-** the rowid is in VdbeCursor.iKey.
-*/
-struct VdbeCursor {
-  BtCursor *pCursor;    /* The cursor structure of the backend */
-  int iDb;              /* Index of cursor database in db->aDb[] (or -1) */
-  i64 lastRowid;        /* Last rowid from a Next or NextIdx operation */
-  Bool zeroed;          /* True if zeroed out and ready for reuse */
-  Bool rowidIsValid;    /* True if lastRowid is valid */
-  Bool atFirst;         /* True if pointing to first entry */
-  Bool useRandomRowid;  /* Generate new record numbers semi-randomly */
-  Bool nullRow;         /* True if pointing to a row with no data */
-  Bool deferredMoveto;  /* A call to sqlite3BtreeMoveto() is needed */
-  Bool isTable;         /* True if a table requiring integer keys */
-  Bool isIndex;         /* True if an index containing keys only - no data */
-  i64 movetoTarget;     /* Argument to the deferred sqlite3BtreeMoveto() */
-  Btree *pBt;           /* Separate file holding temporary table */
-  int pseudoTableReg;   /* Register holding pseudotable content. */
-  KeyInfo *pKeyInfo;    /* Info about index keys needed by index cursors */
-  int nField;           /* Number of fields in the header */
-  i64 seqCount;         /* Sequence counter */
-  sqlite3_vtab_cursor *pVtabCursor;  /* The cursor for a virtual table */
-  const sqlite3_module *pModule;     /* Module for cursor pVtabCursor */
-
-  /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or 
-  ** OP_IsUnique opcode on this cursor. */
-  int seekResult;
-
-  /* Cached information about the header for the data record that the
-  ** cursor is currently pointing to.  Only valid if cacheStatus matches
-  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of
-  ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that
-  ** the cache is out of date.
-  **
-  ** aRow might point to (ephemeral) data for the current row, or it might
-  ** be NULL.
-  */
-  u32 cacheStatus;      /* Cache is valid if this matches Vdbe.cacheCtr */
-  int payloadSize;      /* Total number of bytes in the record */
-  u32 *aType;           /* Type values for all entries in the record */
-  u32 *aOffset;         /* Cached offsets to the start of each columns data */
-  u8 *aRow;             /* Data for the current row, if all on one page */
-};
-typedef struct VdbeCursor VdbeCursor;
-
-/*
-** When a sub-program is executed (OP_Program), a structure of this type
-** is allocated to store the current value of the program counter, as
-** well as the current memory cell array and various other frame specific
-** values stored in the Vdbe struct. When the sub-program is finished, 
-** these values are copied back to the Vdbe from the VdbeFrame structure,
-** restoring the state of the VM to as it was before the sub-program
-** began executing.
-**
-** Frames are stored in a linked list headed at Vdbe.pParent. Vdbe.pParent
-** is the parent of the current frame, or zero if the current frame
-** is the main Vdbe program.
-*/
-typedef struct VdbeFrame VdbeFrame;
-struct VdbeFrame {
-  Vdbe *v;                /* VM this frame belongs to */
-  int pc;                 /* Program Counter */
-  Op *aOp;                /* Program instructions */
-  int nOp;                /* Size of aOp array */
-  Mem *aMem;              /* Array of memory cells */
-  int nMem;               /* Number of entries in aMem */
-  VdbeCursor **apCsr;     /* Element of Vdbe cursors */
-  u16 nCursor;            /* Number of entries in apCsr */
-  void *token;            /* Copy of SubProgram.token */
-  int nChildMem;          /* Number of memory cells for child frame */
-  int nChildCsr;          /* Number of cursors for child frame */
-  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */
-  int nChange;            /* Statement changes (Vdbe.nChanges)     */
-  VdbeFrame *pParent;     /* Parent of this frame */
-};
-
-#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
-
-/*
-** A value for VdbeCursor.cacheValid that means the cache is always invalid.
-*/
-#define CACHE_STALE 0
-
-/*
-** Internally, the vdbe manipulates nearly all SQL values as Mem
-** structures. Each Mem struct may cache multiple representations (string,
-** integer etc.) of the same value.  A value (and therefore Mem structure)
-** has the following properties:
-**
-** Each value has a manifest type. The manifest type of the value stored
-** in a Mem struct is returned by the MemType(Mem*) macro. The type is
-** one of SQLITE_NULL, SQLITE_INTEGER, SQLITE_REAL, SQLITE_TEXT or
-** SQLITE_BLOB.
-*/
-struct Mem {
-  union {
-    i64 i;              /* Integer value. */
-    int nZero;          /* Used when bit MEM_Zero is set in flags */
-    FuncDef *pDef;      /* Used only when flags==MEM_Agg */
-    RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */
-    VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */
-  } u;
-  double r;           /* Real value */
-  sqlite3 *db;        /* The associated database connection */
-  char *z;            /* String or BLOB value */
-  int n;              /* Number of characters in string value, excluding '\0' */
-  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */
-  u8  type;           /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */
-  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */
-  void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */
-  char *zMalloc;      /* Dynamic buffer allocated by sqlite3_malloc() */
-};
-
-/* One or more of the following flags are set to indicate the validOK
-** representations of the value stored in the Mem struct.
-**
-** If the MEM_Null flag is set, then the value is an SQL NULL value.
-** No other flags may be set in this case.
-**
-** If the MEM_Str flag is set then Mem.z points at a string representation.
-** Usually this is encoded in the same unicode encoding as the main
-** database (see below for exceptions). If the MEM_Term flag is also
-** set, then the string is nul terminated. The MEM_Int and MEM_Real 
-** flags may coexist with the MEM_Str flag.
-**
-** Multiple of these values can appear in Mem.flags.  But only one
-** at a time can appear in Mem.type.
-*/
-#define MEM_Null      0x0001   /* Value is NULL */
-#define MEM_Str       0x0002   /* Value is a string */
-#define MEM_Int       0x0004   /* Value is an integer */
-#define MEM_Real      0x0008   /* Value is a real number */
-#define MEM_Blob      0x0010   /* Value is a BLOB */
-#define MEM_RowSet    0x0020   /* Value is a RowSet object */
-#define MEM_Frame     0x0040   /* Value is a VdbeFrame object */
-#define MEM_TypeMask  0x00ff   /* Mask of type bits */
-
-/* Whenever Mem contains a valid string or blob representation, one of
-** the following flags must be set to determine the memory management
-** policy for Mem.z.  The MEM_Term flag tells us whether or not the
-** string is \000 or \u0000 terminated
-*/
-#define MEM_Term      0x0200   /* String rep is nul terminated */
-#define MEM_Dyn       0x0400   /* Need to call sqliteFree() on Mem.z */
-#define MEM_Static    0x0800   /* Mem.z points to a static string */
-#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */
-#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */
-#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */
-
-#ifdef SQLITE_OMIT_INCRBLOB
-  #undef MEM_Zero
-  #define MEM_Zero 0x0000
-#endif
-
-
-/*
-** Clear any existing type flags from a Mem and replace them with f
-*/
-#define MemSetTypeFlag(p, f) \
-   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)
-
-
-/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains
-** additional information about auxiliary information bound to arguments
-** of the function.  This is used to implement the sqlite3_get_auxdata()
-** and sqlite3_set_auxdata() APIs.  The "auxdata" is some auxiliary data
-** that can be associated with a constant argument to a function.  This
-** allows functions such as "regexp" to compile their constant regular
-** expression argument once and reused the compiled code for multiple
-** invocations.
-*/
-struct VdbeFunc {
-  FuncDef *pFunc;               /* The definition of the function */
-  int nAux;                     /* Number of entries allocated for apAux[] */
-  struct AuxData {
-    void *pAux;                   /* Aux data for the i-th argument */
-    void (*xDelete)(void *);      /* Destructor for the aux data */
-  } apAux[1];                   /* One slot for each function argument */
-};
-
-/*
-** The "context" argument for a installable function.  A pointer to an
-** instance of this structure is the first argument to the routines used
-** implement the SQL functions.
-**
-** There is a typedef for this structure in sqlite.h.  So all routines,
-** even the public interface to SQLite, can use a pointer to this structure.
-** But this file is the only place where the internal details of this
-** structure are known.
-**
-** This structure is defined inside of vdbeInt.h because it uses substructures
-** (Mem) which are only defined there.
-*/
-struct sqlite3_context {
-  FuncDef *pFunc;       /* Pointer to function information.  MUST BE FIRST */
-  VdbeFunc *pVdbeFunc;  /* Auxilary data, if created. */
-  Mem s;                /* The return value is stored here */
-  Mem *pMem;            /* Memory cell used to store aggregate context */
-  int isError;          /* Error code returned by the function. */
-  CollSeq *pColl;       /* Collating sequence */
-};
-
-/*
-** A Set structure is used for quick testing to see if a value
-** is part of a small set.  Sets are used to implement code like
-** this:
-**            x.y IN ('hi','hoo','hum')
-*/
-typedef struct Set Set;
-struct Set {
-  Hash hash;             /* A set is just a hash table */
-  HashElem *prev;        /* Previously accessed hash elemen */
-};
-
-/*
-** An instance of the virtual machine.  This structure contains the complete
-** state of the virtual machine.
-**
-** The "sqlite3_stmt" structure pointer that is returned by sqlite3_compile()
-** is really a pointer to an instance of this structure.
-**
-** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
-** any virtual table method invocations made by the vdbe program. It is
-** set to 2 for xDestroy method calls and 1 for all other methods. This
-** variable is used for two purposes: to allow xDestroy methods to execute
-** "DROP TABLE" statements and to prevent some nasty side effects of
-** malloc failure when SQLite is invoked recursively by a virtual table 
-** method function.
-*/
-struct Vdbe {
-  sqlite3 *db;            /* The database connection that owns this statement */
-  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */
-  int nOp;                /* Number of instructions in the program */
-  int nOpAlloc;           /* Number of slots allocated for aOp[] */
-  Op *aOp;                /* Space to hold the virtual machine's program */
-  int nLabel;             /* Number of labels used */
-  int nLabelAlloc;        /* Number of slots allocated in aLabel[] */
-  int *aLabel;            /* Space to hold the labels */
-  Mem **apArg;            /* Arguments to currently executing user function */
-  Mem *aColName;          /* Column names to return */
-  Mem *pResultSet;        /* Pointer to an array of results */
-  u16 nResColumn;         /* Number of columns in one row of the result set */
-  u16 nCursor;            /* Number of slots in apCsr[] */
-  VdbeCursor **apCsr;     /* One element of this array for each open cursor */
-  u8 errorAction;         /* Recovery action to do in case of an error */
-  u8 okVar;               /* True if azVar[] has been initialized */
-  ynVar nVar;             /* Number of entries in aVar[] */
-  Mem *aVar;              /* Values for the OP_Variable opcode. */
-  char **azVar;           /* Name of variables */
-  u32 magic;              /* Magic number for sanity checking */
-  int nMem;               /* Number of memory locations currently allocated */
-  Mem *aMem;              /* The memory locations */
-  u32 cacheCtr;           /* VdbeCursor row cache generation counter */
-  int pc;                 /* The program counter */
-  int rc;                 /* Value to return */
-  char *zErrMsg;          /* Error message written here */
-  u8 explain;             /* True if EXPLAIN present on SQL command */
-  u8 changeCntOn;         /* True to update the change-counter */
-  u8 expired;             /* True if the VM needs to be recompiled */
-  u8 runOnlyOnce;         /* Automatically expire on reset */
-  u8 minWriteFileFormat;  /* Minimum file format for writable database files */
-  u8 inVtabMethod;        /* See comments above */
-  u8 usesStmtJournal;     /* True if uses a statement journal */
-  u8 readOnly;            /* True for read-only statements */
-  u8 isPrepareV2;         /* True if prepared with prepare_v2() */
-  int nChange;            /* Number of db changes made since last reset */
-  int btreeMask;          /* Bitmask of db->aDb[] entries referenced */
-  i64 startTime;          /* Time when query started - used for profiling */
-  BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */
-  int aCounter[2];        /* Counters used by sqlite3_stmt_status() */
-  char *zSql;             /* Text of the SQL statement that generated this */
-  void *pFree;            /* Free this when deleting the vdbe */
-  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */
-  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */
-  int iStatement;         /* Statement number (or 0 if has not opened stmt) */
-#ifdef SQLITE_DEBUG
-  FILE *trace;            /* Write an execution trace here, if not NULL */
-#endif
-  VdbeFrame *pFrame;      /* Parent frame */
-  int nFrame;             /* Number of frames in pFrame list */
-  u32 expmask;            /* Binding to these vars invalidates VM */
-};
-
-/*
-** The following are allowed values for Vdbe.magic
-*/
-#define VDBE_MAGIC_INIT     0x26bceaa5    /* Building a VDBE program */
-#define VDBE_MAGIC_RUN      0xbdf20da3    /* VDBE is ready to execute */
-#define VDBE_MAGIC_HALT     0x519c2973    /* VDBE has completed execution */
-#define VDBE_MAGIC_DEAD     0xb606c3c8    /* The VDBE has been deallocated */
-
-/*
-** Function prototypes
-*/
-SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);
-void sqliteVdbePopStack(Vdbe*,int);
-SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor*);
-#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
-SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);
-#endif
-SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
-SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);
-SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
-SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);
-
-int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
-SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
-SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
-SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
-SQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*);
-SQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);
-SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*);
-SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int);
-SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);
-SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);
-SQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
-SQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);
-#ifdef SQLITE_OMIT_FLOATING_POINT
-# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
-#else
-SQLITE_PRIVATE   void sqlite3VdbeMemSetDouble(Mem*, double);
-#endif
-SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);
-SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);
-SQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, int);
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
-SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
-SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);
-SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);
-SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);
-SQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);
-SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
-SQLITE_PRIVATE const char *sqlite3OpcodeName(int);
-SQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
-SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);
-SQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);
-SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);
-SQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);
-
-#ifndef SQLITE_OMIT_FOREIGN_KEY
-SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
-#else
-# define sqlite3VdbeCheckFk(p,i) 0
-#endif
-
-#ifndef SQLITE_OMIT_SHARED_CACHE
-SQLITE_PRIVATE void sqlite3VdbeMutexArrayEnter(Vdbe *p);
-#else
-# define sqlite3VdbeMutexArrayEnter(p)
-#endif
-
-SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);
-#ifdef SQLITE_DEBUG
-SQLITE_PRIVATE   void sqlite3VdbePrintSql(Vdbe*);
-SQLITE_PRIVATE   void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);
-#endif
-SQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem);
-
-#ifndef SQLITE_OMIT_INCRBLOB
-SQLITE_PRIVATE   int sqlite3VdbeMemExpandBlob(Mem *);
-#else
-  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK
-#endif
-
-#endif /* !defined(_VDBEINT_H_) */
-
-/************** End of vdbeInt.h *********************************************/
-/************** Continuing where we left off in utf.c ************************/
 
 #ifndef SQLITE_AMALGAMATION
 /*
@@ -19159,6 +20073,12 @@ SQLITE_PRIVATE int sqlite3Dequote(char *z){
 /*
 ** Some systems have stricmp().  Others have strcasecmp().  Because
 ** there is no consistency, we will define our own.
+**
+** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows
+** applications and extensions to compare the contents of two buffers
+** containing UTF-8 strings in a case-independent fashion, using the same
+** definition of case independence that SQLite uses internally when
+** comparing identifiers.
 */
 SQLITE_PRIVATE int sqlite3StrICmp(const char *zLeft, const char *zRight){
   register unsigned char *a, *b;
@@ -19176,121 +20096,111 @@ SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
 }
 
 /*
-** Return TRUE if z is a pure numeric string.  Return FALSE and leave
-** *realnum unchanged if the string contains any character which is not
-** part of a number.
+** The string z[] is an text representation of a real number.
+** Convert this string to a double and write it into *pResult.
 **
-** If the string is pure numeric, set *realnum to TRUE if the string
-** contains the '.' character or an "E+000" style exponentiation suffix.
-** Otherwise set *realnum to FALSE.  Note that just becaue *realnum is
-** false does not mean that the number can be successfully converted into
-** an integer - it might be too big.
+** The string z[] is length bytes in length (bytes, not characters) and
+** uses the encoding enc.  The string is not necessarily zero-terminated.
 **
-** An empty string is considered non-numeric.
-*/
-SQLITE_PRIVATE int sqlite3IsNumber(const char *z, int *realnum, u8 enc){
-  int incr = (enc==SQLITE_UTF8?1:2);
-  if( enc==SQLITE_UTF16BE ) z++;
-  if( *z=='-' || *z=='+' ) z += incr;
-  if( !sqlite3Isdigit(*z) ){
-    return 0;
-  }
-  z += incr;
-  *realnum = 0;
-  while( sqlite3Isdigit(*z) ){ z += incr; }
-#ifndef SQLITE_OMIT_FLOATING_POINT
-  if( *z=='.' ){
-    z += incr;
-    if( !sqlite3Isdigit(*z) ) return 0;
-    while( sqlite3Isdigit(*z) ){ z += incr; }
-    *realnum = 1;
-  }
-  if( *z=='e' || *z=='E' ){
-    z += incr;
-    if( *z=='+' || *z=='-' ) z += incr;
-    if( !sqlite3Isdigit(*z) ) return 0;
-    while( sqlite3Isdigit(*z) ){ z += incr; }
-    *realnum = 1;
-  }
-#endif
-  return *z==0;
-}
-
-/*
-** The string z[] is an ASCII representation of a real number.
-** Convert this string to a double.
+** Return TRUE if the result is a valid real number (or integer) and FALSE
+** if the string is empty or contains extraneous text.  Valid numbers
+** are in one of these formats:
+**
+**    [+-]digits[E[+-]digits]
+**    [+-]digits.[digits][E[+-]digits]
+**    [+-].digits[E[+-]digits]
 **
-** This routine assumes that z[] really is a valid number.  If it
-** is not, the result is undefined.
+** Leading and trailing whitespace is ignored for the purpose of determining
+** validity.
 **
-** This routine is used instead of the library atof() function because
-** the library atof() might want to use "," as the decimal point instead
-** of "." depending on how locale is set.  But that would cause problems
-** for SQL.  So this routine always uses "." regardless of locale.
+** If some prefix of the input string is a valid number, this routine
+** returns FALSE but it still converts the prefix and writes the result
+** into *pResult.
 */
-SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){
+SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
 #ifndef SQLITE_OMIT_FLOATING_POINT
-  const char *zBegin = z;
+  int incr = (enc==SQLITE_UTF8?1:2);
+  const char *zEnd = z + length;
   /* sign * significand * (10 ^ (esign * exponent)) */
-  int sign = 1;   /* sign of significand */
-  i64 s = 0;      /* significand */
-  int d = 0;      /* adjust exponent for shifting decimal point */
-  int esign = 1;  /* sign of exponent */
-  int e = 0;      /* exponent */
+  int sign = 1;    /* sign of significand */
+  i64 s = 0;       /* significand */
+  int d = 0;       /* adjust exponent for shifting decimal point */
+  int esign = 1;   /* sign of exponent */
+  int e = 0;       /* exponent */
+  int eValid = 1;  /* True exponent is either not used or is well-formed */
   double result;
   int nDigits = 0;
 
+  *pResult = 0.0;   /* Default return value, in case of an error */
+
+  if( enc==SQLITE_UTF16BE ) z++;
+
   /* skip leading spaces */
-  while( sqlite3Isspace(*z) ) z++;
+  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
+  if( z>=zEnd ) return 0;
+
   /* get sign of significand */
   if( *z=='-' ){
     sign = -1;
-    z++;
+    z+=incr;
   }else if( *z=='+' ){
-    z++;
+    z+=incr;
   }
+
   /* skip leading zeroes */
-  while( z[0]=='0' ) z++, nDigits++;
+  while( z<zEnd && z[0]=='0' ) z+=incr, nDigits++;
 
   /* copy max significant digits to significand */
-  while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
+  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
     s = s*10 + (*z - '0');
-    z++, nDigits++;
+    z+=incr, nDigits++;
   }
+
   /* skip non-significant significand digits
   ** (increase exponent by d to shift decimal left) */
-  while( sqlite3Isdigit(*z) ) z++, nDigits++, d++;
+  while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++;
+  if( z>=zEnd ) goto do_atof_calc;
 
   /* if decimal point is present */
   if( *z=='.' ){
-    z++;
+    z+=incr;
     /* copy digits from after decimal to significand
     ** (decrease exponent by d to shift decimal right) */
-    while( sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
+    while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
       s = s*10 + (*z - '0');
-      z++, nDigits++, d--;
+      z+=incr, nDigits++, d--;
     }
     /* skip non-significant digits */
-    while( sqlite3Isdigit(*z) ) z++, nDigits++;
+    while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++;
   }
+  if( z>=zEnd ) goto do_atof_calc;
 
   /* if exponent is present */
   if( *z=='e' || *z=='E' ){
-    z++;
+    z+=incr;
+    eValid = 0;
+    if( z>=zEnd ) goto do_atof_calc;
     /* get sign of exponent */
     if( *z=='-' ){
       esign = -1;
-      z++;
+      z+=incr;
     }else if( *z=='+' ){
-      z++;
+      z+=incr;
     }
     /* copy digits to exponent */
-    while( sqlite3Isdigit(*z) ){
+    while( z<zEnd && sqlite3Isdigit(*z) ){
       e = e*10 + (*z - '0');
-      z++;
+      z+=incr;
+      eValid = 1;
     }
   }
 
+  /* skip trailing spaces */
+  if( nDigits && eValid ){
+    while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;
+  }
+
+do_atof_calc:
   /* adjust exponent by d, and update sign */
   e = (e*esign) + d;
   if( e<0 ) {
@@ -19349,10 +20259,10 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){
   /* store the result */
   *pResult = result;
 
-  /* return number of characters used */
-  return (int)(z - zBegin);
+  /* return true if number and no extra non-whitespace chracters after */
+  return z>=zEnd && nDigits>0 && eValid;
 #else
-  return sqlite3Atoi64(z, pResult);
+  return !sqlite3Atoi64(z, pResult, length, enc);
 #endif /* SQLITE_OMIT_FLOATING_POINT */
 }
 
@@ -19360,20 +20270,26 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult){
 ** Compare the 19-character string zNum against the text representation
 ** value 2^63:  9223372036854775808.  Return negative, zero, or positive
 ** if zNum is less than, equal to, or greater than the string.
+** Note that zNum must contain exactly 19 characters.
 **
 ** Unlike memcmp() this routine is guaranteed to return the difference
 ** in the values of the last digit if the only difference is in the
 ** last digit.  So, for example,
 **
-**      compare2pow63("9223372036854775800")
+**      compare2pow63("9223372036854775800", 1)
 **
 ** will return -8.
 */
-static int compare2pow63(const char *zNum){
-  int c;
-  c = memcmp(zNum,"922337203685477580",18)*10;
+static int compare2pow63(const char *zNum, int incr){
+  int c = 0;
+  int i;
+                    /* 012345678901234567 */
+  const char *pow63 = "922337203685477580";
+  for(i=0; c==0 && i<18; i++){
+    c = (zNum[i*incr]-pow63[i])*10;
+  }
   if( c==0 ){
-    c = zNum[18] - '8';
+    c = zNum[18*incr] - '8';
     testcase( c==(-1) );
     testcase( c==0 );
     testcase( c==(+1) );
@@ -19383,94 +20299,60 @@ static int compare2pow63(const char *zNum){
 
 
 /*
-** Return TRUE if zNum is a 64-bit signed integer and write
-** the value of the integer into *pNum.  If zNum is not an integer
-** or is an integer that is too large to be expressed with 64 bits,
-** then return false.
+** Convert zNum to a 64-bit signed integer and write
+** the value of the integer into *pNum.
+** If zNum is exactly 9223372036854665808, return 2.
+** This is a special case as the context will determine
+** if it is too big (used as a negative).
+** If zNum is not an integer or is an integer that 
+** is too large to be expressed with 64 bits,
+** then return 1.  Otherwise return 0.
 **
-** When this routine was originally written it dealt with only
-** 32-bit numbers.  At that time, it was much faster than the
-** atoi() library routine in RedHat 7.2.
+** length is the number of bytes in the string (bytes, not characters).
+** The string is not necessarily zero-terminated.  The encoding is
+** given by enc.
 */
-SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum){
+SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){
+  int incr = (enc==SQLITE_UTF8?1:2);
   i64 v = 0;
-  int neg;
-  int i, c;
+  int neg = 0; /* assume positive */
+  int i;
+  int c = 0;
   const char *zStart;
-  while( sqlite3Isspace(*zNum) ) zNum++;
+  const char *zEnd = zNum + length;
+  if( enc==SQLITE_UTF16BE ) zNum++;
+  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;
+  if( zNum>=zEnd ) goto do_atoi_calc;
   if( *zNum=='-' ){
     neg = 1;
-    zNum++;
+    zNum+=incr;
   }else if( *zNum=='+' ){
-    neg = 0;
-    zNum++;
-  }else{
-    neg = 0;
+    zNum+=incr;
   }
+do_atoi_calc:
   zStart = zNum;
-  while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */
-  for(i=0; (c=zNum[i])>='0' && c<='9'; i++){
+  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */
+  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){
     v = v*10 + c - '0';
   }
   *pNum = neg ? -v : v;
   testcase( i==18 );
   testcase( i==19 );
   testcase( i==20 );
-  if( c!=0 || (i==0 && zStart==zNum) || i>19 ){
+  if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr ){
     /* zNum is empty or contains non-numeric text or is longer
-    ** than 19 digits (thus guaranting that it is too large) */
-    return 0;
-  }else if( i<19 ){
-    /* Less than 19 digits, so we know that it fits in 64 bits */
+    ** than 19 digits (thus guaranteeing that it is too large) */
     return 1;
+  }else if( i<19*incr ){
+    /* Less than 19 digits, so we know that it fits in 64 bits */
+    return 0;
   }else{
     /* 19-digit numbers must be no larger than 9223372036854775807 if positive
     ** or 9223372036854775808 if negative.  Note that 9223372036854665808
-    ** is 2^63. */
-    return compare2pow63(zNum)<neg;
-  }
-}
-
-/*
-** The string zNum represents an unsigned integer.  The zNum string
-** consists of one or more digit characters and is terminated by
-** a zero character.  Any stray characters in zNum result in undefined
-** behavior.
-**
-** If the unsigned integer that zNum represents will fit in a
-** 64-bit signed integer, return TRUE.  Otherwise return FALSE.
-**
-** If the negFlag parameter is true, that means that zNum really represents
-** a negative number.  (The leading "-" is omitted from zNum.)  This
-** parameter is needed to determine a boundary case.  A string
-** of "9223373036854775808" returns false if negFlag is false or true
-** if negFlag is true.
-**
-** Leading zeros are ignored.
-*/
-SQLITE_PRIVATE int sqlite3FitsIn64Bits(const char *zNum, int negFlag){
-  int i;
-  int neg = 0;
-
-  assert( zNum[0]>='0' && zNum[0]<='9' ); /* zNum is an unsigned number */
-
-  if( negFlag ) neg = 1-neg;
-  while( *zNum=='0' ){
-    zNum++;   /* Skip leading zeros.  Ticket #2454 */
-  }
-  for(i=0; zNum[i]; i++){ assert( zNum[i]>='0' && zNum[i]<='9' ); }
-  testcase( i==18 );
-  testcase( i==19 );
-  testcase( i==20 );
-  if( i<19 ){
-    /* Guaranteed to fit if less than 19 digits */
-    return 1;
-  }else if( i>19 ){
-    /* Guaranteed to be too big if greater than 19 digits */
-    return 0;
-  }else{
-    /* Compare against 2^63. */
-    return compare2pow63(zNum)<neg;
+    ** is 2^63. Return 1 if to large */
+    c=compare2pow63(zNum, incr);
+    if( c==0 && neg==0 ) return 2; /* too big, exactly 9223372036854665808 */
+    return c<neg ? 0 : 1;
   }
 }
 
@@ -20351,39 +21233,39 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
      /*  37 */ "VerifyCookie",
      /*  38 */ "OpenRead",
      /*  39 */ "OpenWrite",
-     /*  40 */ "OpenEphemeral",
-     /*  41 */ "OpenPseudo",
-     /*  42 */ "Close",
-     /*  43 */ "SeekLt",
-     /*  44 */ "SeekLe",
-     /*  45 */ "SeekGe",
-     /*  46 */ "SeekGt",
-     /*  47 */ "Seek",
-     /*  48 */ "NotFound",
-     /*  49 */ "Found",
-     /*  50 */ "IsUnique",
-     /*  51 */ "NotExists",
-     /*  52 */ "Sequence",
-     /*  53 */ "NewRowid",
-     /*  54 */ "Insert",
-     /*  55 */ "InsertInt",
-     /*  56 */ "Delete",
-     /*  57 */ "ResetCount",
-     /*  58 */ "RowKey",
-     /*  59 */ "RowData",
-     /*  60 */ "Rowid",
-     /*  61 */ "NullRow",
-     /*  62 */ "Last",
-     /*  63 */ "Sort",
-     /*  64 */ "Rewind",
-     /*  65 */ "Prev",
-     /*  66 */ "Next",
-     /*  67 */ "IdxInsert",
+     /*  40 */ "OpenAutoindex",
+     /*  41 */ "OpenEphemeral",
+     /*  42 */ "OpenPseudo",
+     /*  43 */ "Close",
+     /*  44 */ "SeekLt",
+     /*  45 */ "SeekLe",
+     /*  46 */ "SeekGe",
+     /*  47 */ "SeekGt",
+     /*  48 */ "Seek",
+     /*  49 */ "NotFound",
+     /*  50 */ "Found",
+     /*  51 */ "IsUnique",
+     /*  52 */ "NotExists",
+     /*  53 */ "Sequence",
+     /*  54 */ "NewRowid",
+     /*  55 */ "Insert",
+     /*  56 */ "InsertInt",
+     /*  57 */ "Delete",
+     /*  58 */ "ResetCount",
+     /*  59 */ "RowKey",
+     /*  60 */ "RowData",
+     /*  61 */ "Rowid",
+     /*  62 */ "NullRow",
+     /*  63 */ "Last",
+     /*  64 */ "Sort",
+     /*  65 */ "Rewind",
+     /*  66 */ "Prev",
+     /*  67 */ "Next",
      /*  68 */ "Or",
      /*  69 */ "And",
-     /*  70 */ "IdxDelete",
-     /*  71 */ "IdxRowid",
-     /*  72 */ "IdxLT",
+     /*  70 */ "IdxInsert",
+     /*  71 */ "IdxDelete",
+     /*  72 */ "IdxRowid",
      /*  73 */ "IsNull",
      /*  74 */ "NotNull",
      /*  75 */ "Ne",
@@ -20392,7 +21274,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
      /*  78 */ "Le",
      /*  79 */ "Lt",
      /*  80 */ "Ge",
-     /*  81 */ "IdxGE",
+     /*  81 */ "IdxLT",
      /*  82 */ "BitAnd",
      /*  83 */ "BitOr",
      /*  84 */ "ShiftLeft",
@@ -20403,52 +21285,52 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
      /*  89 */ "Divide",
      /*  90 */ "Remainder",
      /*  91 */ "Concat",
-     /*  92 */ "Destroy",
+     /*  92 */ "IdxGE",
      /*  93 */ "BitNot",
      /*  94 */ "String8",
-     /*  95 */ "Clear",
-     /*  96 */ "CreateIndex",
-     /*  97 */ "CreateTable",
-     /*  98 */ "ParseSchema",
-     /*  99 */ "LoadAnalysis",
-     /* 100 */ "DropTable",
-     /* 101 */ "DropIndex",
-     /* 102 */ "DropTrigger",
-     /* 103 */ "IntegrityCk",
-     /* 104 */ "RowSetAdd",
-     /* 105 */ "RowSetRead",
-     /* 106 */ "RowSetTest",
-     /* 107 */ "Program",
-     /* 108 */ "Param",
-     /* 109 */ "FkCounter",
-     /* 110 */ "FkIfZero",
-     /* 111 */ "MemMax",
-     /* 112 */ "IfPos",
-     /* 113 */ "IfNeg",
-     /* 114 */ "IfZero",
-     /* 115 */ "AggStep",
-     /* 116 */ "AggFinal",
-     /* 117 */ "Vacuum",
-     /* 118 */ "IncrVacuum",
-     /* 119 */ "Expire",
-     /* 120 */ "TableLock",
-     /* 121 */ "VBegin",
-     /* 122 */ "VCreate",
-     /* 123 */ "VDestroy",
-     /* 124 */ "VOpen",
-     /* 125 */ "VFilter",
-     /* 126 */ "VColumn",
-     /* 127 */ "VNext",
-     /* 128 */ "VRename",
-     /* 129 */ "VUpdate",
+     /*  95 */ "Destroy",
+     /*  96 */ "Clear",
+     /*  97 */ "CreateIndex",
+     /*  98 */ "CreateTable",
+     /*  99 */ "ParseSchema",
+     /* 100 */ "LoadAnalysis",
+     /* 101 */ "DropTable",
+     /* 102 */ "DropIndex",
+     /* 103 */ "DropTrigger",
+     /* 104 */ "IntegrityCk",
+     /* 105 */ "RowSetAdd",
+     /* 106 */ "RowSetRead",
+     /* 107 */ "RowSetTest",
+     /* 108 */ "Program",
+     /* 109 */ "Param",
+     /* 110 */ "FkCounter",
+     /* 111 */ "FkIfZero",
+     /* 112 */ "MemMax",
+     /* 113 */ "IfPos",
+     /* 114 */ "IfNeg",
+     /* 115 */ "IfZero",
+     /* 116 */ "AggStep",
+     /* 117 */ "AggFinal",
+     /* 118 */ "Checkpoint",
+     /* 119 */ "JournalMode",
+     /* 120 */ "Vacuum",
+     /* 121 */ "IncrVacuum",
+     /* 122 */ "Expire",
+     /* 123 */ "TableLock",
+     /* 124 */ "VBegin",
+     /* 125 */ "VCreate",
+     /* 126 */ "VDestroy",
+     /* 127 */ "VOpen",
+     /* 128 */ "VFilter",
+     /* 129 */ "VColumn",
      /* 130 */ "Real",
-     /* 131 */ "Pagecount",
-     /* 132 */ "Trace",
-     /* 133 */ "Noop",
-     /* 134 */ "Explain",
-     /* 135 */ "NotUsed_135",
-     /* 136 */ "NotUsed_136",
-     /* 137 */ "NotUsed_137",
+     /* 131 */ "VNext",
+     /* 132 */ "VRename",
+     /* 133 */ "VUpdate",
+     /* 134 */ "Pagecount",
+     /* 135 */ "Trace",
+     /* 136 */ "Noop",
+     /* 137 */ "Explain",
      /* 138 */ "NotUsed_138",
      /* 139 */ "NotUsed_139",
      /* 140 */ "NotUsed_140",
@@ -20553,23 +21435,9 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
 
 #ifdef SQLITE_DEBUG
 SQLITE_PRIVATE int sqlite3OSTrace = 0;
-#define OSTRACE1(X)         if( sqlite3OSTrace ) sqlite3DebugPrintf(X)
-#define OSTRACE2(X,Y)       if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y)
-#define OSTRACE3(X,Y,Z)     if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)   if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B) if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
 #else
-#define OSTRACE1(X)
-#define OSTRACE2(X,Y)
-#define OSTRACE3(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)
 #endif
 
 /*
@@ -20765,7 +21633,7 @@ static int os2Close( sqlite3_file *id ){
   APIRET rc = NO_ERROR;
   os2File *pFile;
   if( id && (pFile = (os2File*)id) != 0 ){
-    OSTRACE2( "CLOSE %d\n", pFile->h );
+    OSTRACE(( "CLOSE %d\n", pFile->h ));
     rc = DosClose( pFile->h );
     pFile->locktype = NO_LOCK;
     if( pFile->pathToDel != NULL ){
@@ -20796,7 +21664,7 @@ static int os2Read(
   os2File *pFile = (os2File*)id;
   assert( id!=0 );
   SimulateIOError( return SQLITE_IOERR_READ );
-  OSTRACE3( "READ %d lock=%d\n", pFile->h, pFile->locktype );
+  OSTRACE(( "READ %d lock=%d\n", pFile->h, pFile->locktype ));
   if( DosSetFilePtr(pFile->h, offset, FILE_BEGIN, &fileLocation) != NO_ERROR ){
     return SQLITE_IOERR;
   }
@@ -20829,7 +21697,7 @@ static int os2Write(
   assert( id!=0 );
   SimulateIOError( return SQLITE_IOERR_WRITE );
   SimulateDiskfullError( return SQLITE_FULL );
-  OSTRACE3( "WRITE %d lock=%d\n", pFile->h, pFile->locktype );
+  OSTRACE(( "WRITE %d lock=%d\n", pFile->h, pFile->locktype ));
   if( DosSetFilePtr(pFile->h, offset, FILE_BEGIN, &fileLocation) != NO_ERROR ){
     return SQLITE_IOERR;
   }
@@ -20851,7 +21719,7 @@ static int os2Write(
 static int os2Truncate( sqlite3_file *id, i64 nByte ){
   APIRET rc = NO_ERROR;
   os2File *pFile = (os2File*)id;
-  OSTRACE3( "TRUNCATE %d %lld\n", pFile->h, nByte );
+  OSTRACE(( "TRUNCATE %d %lld\n", pFile->h, nByte ));
   SimulateIOError( return SQLITE_IOERR_TRUNCATE );
   rc = DosSetFileSize( pFile->h, nByte );
   return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR_TRUNCATE;
@@ -20871,7 +21739,7 @@ SQLITE_API int sqlite3_fullsync_count = 0;
 */
 static int os2Sync( sqlite3_file *id, int flags ){
   os2File *pFile = (os2File*)id;
-  OSTRACE3( "SYNC %d lock=%d\n", pFile->h, pFile->locktype );
+  OSTRACE(( "SYNC %d lock=%d\n", pFile->h, pFile->locktype ));
 #ifdef SQLITE_TEST
   if( flags & SQLITE_SYNC_FULL){
     sqlite3_fullsync_count++;
@@ -20921,7 +21789,7 @@ static int getReadLock( os2File *pFile ){
   UnlockArea.lOffset = 0L;
   UnlockArea.lRange = 0L;
   res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 1L );
-  OSTRACE3( "GETREADLOCK %d res=%d\n", pFile->h, res );
+  OSTRACE(( "GETREADLOCK %d res=%d\n", pFile->h, res ));
   return res;
 }
 
@@ -20939,7 +21807,7 @@ static int unlockReadLock( os2File *id ){
   UnlockArea.lOffset = SHARED_FIRST;
   UnlockArea.lRange = SHARED_SIZE;
   res = DosSetFileLocks( id->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 1L );
-  OSTRACE3( "UNLOCK-READLOCK file handle=%d res=%d?\n", id->h, res );
+  OSTRACE(( "UNLOCK-READLOCK file handle=%d res=%d?\n", id->h, res ));
   return res;
 }
 
@@ -20980,14 +21848,14 @@ static int os2Lock( sqlite3_file *id, int locktype ){
   memset(&LockArea, 0, sizeof(LockArea));
   memset(&UnlockArea, 0, sizeof(UnlockArea));
   assert( pFile!=0 );
-  OSTRACE4( "LOCK %d %d was %d\n", pFile->h, locktype, pFile->locktype );
+  OSTRACE(( "LOCK %d %d was %d\n", pFile->h, locktype, pFile->locktype ));
 
   /* If there is already a lock of this type or more restrictive on the
   ** os2File, do nothing. Don't use the end_lock: exit path, as
   ** sqlite3_mutex_enter() hasn't been called yet.
   */
   if( pFile->locktype>=locktype ){
-    OSTRACE3( "LOCK %d %d ok (already held)\n", pFile->h, locktype );
+    OSTRACE(( "LOCK %d %d ok (already held)\n", pFile->h, locktype ));
     return SQLITE_OK;
   }
 
@@ -21014,7 +21882,7 @@ static int os2Lock( sqlite3_file *id, int locktype ){
     res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, 100L, 0L );
     if( res == NO_ERROR ){
       gotPendingLock = 1;
-      OSTRACE3( "LOCK %d pending lock boolean set.  res=%d\n", pFile->h, res );
+      OSTRACE(( "LOCK %d pending lock boolean set.  res=%d\n", pFile->h, res ));
     }
   }
 
@@ -21026,7 +21894,7 @@ static int os2Lock( sqlite3_file *id, int locktype ){
     if( res == NO_ERROR ){
       newLocktype = SHARED_LOCK;
     }
-    OSTRACE3( "LOCK %d acquire shared lock. res=%d\n", pFile->h, res );
+    OSTRACE(( "LOCK %d acquire shared lock. res=%d\n", pFile->h, res ));
   }
 
   /* Acquire a RESERVED lock
@@ -21041,7 +21909,7 @@ static int os2Lock( sqlite3_file *id, int locktype ){
     if( res == NO_ERROR ){
       newLocktype = RESERVED_LOCK;
     }
-    OSTRACE3( "LOCK %d acquire reserved lock. res=%d\n", pFile->h, res );
+    OSTRACE(( "LOCK %d acquire reserved lock. res=%d\n", pFile->h, res ));
   }
 
   /* Acquire a PENDING lock
@@ -21049,7 +21917,8 @@ static int os2Lock( sqlite3_file *id, int locktype ){
   if( locktype==EXCLUSIVE_LOCK && res == NO_ERROR ){
     newLocktype = PENDING_LOCK;
     gotPendingLock = 0;
-    OSTRACE2( "LOCK %d acquire pending lock. pending lock boolean unset.\n", pFile->h );
+    OSTRACE(( "LOCK %d acquire pending lock. pending lock boolean unset.\n",
+               pFile->h ));
   }
 
   /* Acquire an EXCLUSIVE lock
@@ -21057,7 +21926,7 @@ static int os2Lock( sqlite3_file *id, int locktype ){
   if( locktype==EXCLUSIVE_LOCK && res == NO_ERROR ){
     assert( pFile->locktype>=SHARED_LOCK );
     res = unlockReadLock(pFile);
-    OSTRACE2( "unreadlock = %d\n", res );
+    OSTRACE(( "unreadlock = %d\n", res ));
     LockArea.lOffset = SHARED_FIRST;
     LockArea.lRange = SHARED_SIZE;
     UnlockArea.lOffset = 0L;
@@ -21066,10 +21935,10 @@ static int os2Lock( sqlite3_file *id, int locktype ){
     if( res == NO_ERROR ){
       newLocktype = EXCLUSIVE_LOCK;
     }else{
-      OSTRACE2( "OS/2 error-code = %d\n", res );
+      OSTRACE(( "OS/2 error-code = %d\n", res ));
       getReadLock(pFile);
     }
-    OSTRACE3( "LOCK %d acquire exclusive lock.  res=%d\n", pFile->h, res );
+    OSTRACE(( "LOCK %d acquire exclusive lock.  res=%d\n", pFile->h, res ));
   }
 
   /* If we are holding a PENDING lock that ought to be released, then
@@ -21082,7 +21951,7 @@ static int os2Lock( sqlite3_file *id, int locktype ){
     UnlockArea.lOffset = PENDING_BYTE;
     UnlockArea.lRange = 1L;
     r = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-    OSTRACE3( "LOCK %d unlocking pending/is shared. r=%d\n", pFile->h, r );
+    OSTRACE(( "LOCK %d unlocking pending/is shared. r=%d\n", pFile->h, r ));
   }
 
   /* Update the state of the lock has held in the file descriptor then
@@ -21091,12 +21960,12 @@ static int os2Lock( sqlite3_file *id, int locktype ){
   if( res == NO_ERROR ){
     rc = SQLITE_OK;
   }else{
-    OSTRACE4( "LOCK FAILED %d trying for %d but got %d\n", pFile->h,
-              locktype, newLocktype );
+    OSTRACE(( "LOCK FAILED %d trying for %d but got %d\n", pFile->h,
+              locktype, newLocktype ));
     rc = SQLITE_BUSY;
   }
   pFile->locktype = newLocktype;
-  OSTRACE3( "LOCK %d now %d\n", pFile->h, pFile->locktype );
+  OSTRACE(( "LOCK %d now %d\n", pFile->h, pFile->locktype ));
   return rc;
 }
 
@@ -21111,7 +21980,7 @@ static int os2CheckReservedLock( sqlite3_file *id, int *pOut ){
   assert( pFile!=0 );
   if( pFile->locktype>=RESERVED_LOCK ){
     r = 1;
-    OSTRACE3( "TEST WR-LOCK %d %d (local)\n", pFile->h, r );
+    OSTRACE(( "TEST WR-LOCK %d %d (local)\n", pFile->h, r ));
   }else{
     FILELOCK  LockArea,
               UnlockArea;
@@ -21123,7 +21992,7 @@ static int os2CheckReservedLock( sqlite3_file *id, int *pOut ){
     UnlockArea.lOffset = 0L;
     UnlockArea.lRange = 0L;
     rc = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-    OSTRACE3( "TEST WR-LOCK %d lock reserved byte rc=%d\n", pFile->h, rc );
+    OSTRACE(( "TEST WR-LOCK %d lock reserved byte rc=%d\n", pFile->h, rc ));
     if( rc == NO_ERROR ){
       APIRET rcu = NO_ERROR; /* return code for unlocking */
       LockArea.lOffset = 0L;
@@ -21131,10 +22000,10 @@ static int os2CheckReservedLock( sqlite3_file *id, int *pOut ){
       UnlockArea.lOffset = RESERVED_BYTE;
       UnlockArea.lRange = 1L;
       rcu = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-      OSTRACE3( "TEST WR-LOCK %d unlock reserved byte r=%d\n", pFile->h, rcu );
+      OSTRACE(( "TEST WR-LOCK %d unlock reserved byte r=%d\n", pFile->h, rcu ));
     }
     r = !(rc == NO_ERROR);
-    OSTRACE3( "TEST WR-LOCK %d %d (remote)\n", pFile->h, r );
+    OSTRACE(( "TEST WR-LOCK %d %d (remote)\n", pFile->h, r ));
   }
   *pOut = r;
   return SQLITE_OK;
@@ -21162,7 +22031,7 @@ static int os2Unlock( sqlite3_file *id, int locktype ){
   memset(&UnlockArea, 0, sizeof(UnlockArea));
   assert( pFile!=0 );
   assert( locktype<=SHARED_LOCK );
-  OSTRACE4( "UNLOCK %d to %d was %d\n", pFile->h, locktype, pFile->locktype );
+  OSTRACE(( "UNLOCK %d to %d was %d\n", pFile->h, locktype, pFile->locktype ));
   type = pFile->locktype;
   if( type>=EXCLUSIVE_LOCK ){
     LockArea.lOffset = 0L;
@@ -21170,11 +22039,11 @@ static int os2Unlock( sqlite3_file *id, int locktype ){
     UnlockArea.lOffset = SHARED_FIRST;
     UnlockArea.lRange = SHARED_SIZE;
     res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-    OSTRACE3( "UNLOCK %d exclusive lock res=%d\n", pFile->h, res );
+    OSTRACE(( "UNLOCK %d exclusive lock res=%d\n", pFile->h, res ));
     if( locktype==SHARED_LOCK && getReadLock(pFile) != NO_ERROR ){
       /* This should never happen.  We should always be able to
       ** reacquire the read lock */
-      OSTRACE3( "UNLOCK %d to %d getReadLock() failed\n", pFile->h, locktype );
+      OSTRACE(( "UNLOCK %d to %d getReadLock() failed\n", pFile->h, locktype ));
       rc = SQLITE_IOERR_UNLOCK;
     }
   }
@@ -21184,11 +22053,12 @@ static int os2Unlock( sqlite3_file *id, int locktype ){
     UnlockArea.lOffset = RESERVED_BYTE;
     UnlockArea.lRange = 1L;
     res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-    OSTRACE3( "UNLOCK %d reserved res=%d\n", pFile->h, res );
+    OSTRACE(( "UNLOCK %d reserved res=%d\n", pFile->h, res ));
   }
   if( locktype==NO_LOCK && type>=SHARED_LOCK ){
     res = unlockReadLock(pFile);
-    OSTRACE5( "UNLOCK %d is %d want %d res=%d\n", pFile->h, type, locktype, res );
+    OSTRACE(( "UNLOCK %d is %d want %d res=%d\n",
+              pFile->h, type, locktype, res ));
   }
   if( type>=PENDING_LOCK ){
     LockArea.lOffset = 0L;
@@ -21196,10 +22066,10 @@ static int os2Unlock( sqlite3_file *id, int locktype ){
     UnlockArea.lOffset = PENDING_BYTE;
     UnlockArea.lRange = 1L;
     res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L );
-    OSTRACE3( "UNLOCK %d pending res=%d\n", pFile->h, res );
+    OSTRACE(( "UNLOCK %d pending res=%d\n", pFile->h, res ));
   }
   pFile->locktype = locktype;
-  OSTRACE3( "UNLOCK %d now %d\n", pFile->h, pFile->locktype );
+  OSTRACE(( "UNLOCK %d now %d\n", pFile->h, pFile->locktype ));
   return rc;
 }
 
@@ -21210,7 +22080,8 @@ static int os2FileControl(sqlite3_file *id, int op, void *pArg){
   switch( op ){
     case SQLITE_FCNTL_LOCKSTATE: {
       *(int*)pArg = ((os2File*)id)->locktype;
-      OSTRACE3( "FCNTL_LOCKSTATE %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
+      OSTRACE(( "FCNTL_LOCKSTATE %d lock=%d\n",
+                ((os2File*)id)->h, ((os2File*)id)->locktype ));
       return SQLITE_OK;
     }
   }
@@ -21397,7 +22268,7 @@ static int getTempname(int nBuf, char *zBuf ){
     zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
   }
   zBuf[j] = 0;
-  OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
+  OSTRACE(( "TEMP FILENAME: %s\n", zBuf ));
   return SQLITE_OK;
 }
 
@@ -21460,30 +22331,30 @@ static int os2Open(
 
   memset( pFile, 0, sizeof(*pFile) );
 
-  OSTRACE2( "OPEN want %d\n", flags );
+  OSTRACE(( "OPEN want %d\n", flags ));
 
   if( flags & SQLITE_OPEN_READWRITE ){
     ulOpenMode |= OPEN_ACCESS_READWRITE;
-    OSTRACE1( "OPEN read/write\n" );
+    OSTRACE(( "OPEN read/write\n" ));
   }else{
     ulOpenMode |= OPEN_ACCESS_READONLY;
-    OSTRACE1( "OPEN read only\n" );
+    OSTRACE(( "OPEN read only\n" ));
   }
 
   if( flags & SQLITE_OPEN_CREATE ){
     ulOpenFlags |= OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
-    OSTRACE1( "OPEN open new/create\n" );
+    OSTRACE(( "OPEN open new/create\n" ));
   }else{
     ulOpenFlags |= OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
-    OSTRACE1( "OPEN open existing\n" );
+    OSTRACE(( "OPEN open existing\n" ));
   }
 
   if( flags & SQLITE_OPEN_MAIN_DB ){
     ulOpenMode |= OPEN_SHARE_DENYNONE;
-    OSTRACE1( "OPEN share read/write\n" );
+    OSTRACE(( "OPEN share read/write\n" ));
   }else{
     ulOpenMode |= OPEN_SHARE_DENYWRITE;
-    OSTRACE1( "OPEN share read only\n" );
+    OSTRACE(( "OPEN share read only\n" ));
   }
 
   if( flags & SQLITE_OPEN_DELETEONCLOSE ){
@@ -21493,10 +22364,10 @@ static int os2Open(
 #endif
     os2FullPathname( pVfs, zName, CCHMAXPATH, pathUtf8 );
     pFile->pathToDel = convertUtf8PathToCp( pathUtf8 );
-    OSTRACE1( "OPEN hidden/delete on close file attributes\n" );
+    OSTRACE(( "OPEN hidden/delete on close file attributes\n" ));
   }else{
     pFile->pathToDel = NULL;
-    OSTRACE1( "OPEN normal file attribute\n" );
+    OSTRACE(( "OPEN normal file attribute\n" ));
   }
 
   /* always open in random access mode for possibly better speed */
@@ -21515,13 +22386,14 @@ static int os2Open(
                 (PEAOP2)NULL );
   free( zNameCp );
   if( rc != NO_ERROR ){
-    OSTRACE7( "OPEN Invalid handle rc=%d: zName=%s, ulAction=%#lx, ulAttr=%#lx, ulFlags=%#lx, ulMode=%#lx\n",
-              rc, zName, ulAction, ulFileAttribute, ulOpenFlags, ulOpenMode );
+    OSTRACE(( "OPEN Invalid handle rc=%d: zName=%s, ulAction=%#lx, ulAttr=%#lx, ulFlags=%#lx, ulMode=%#lx\n",
+              rc, zName, ulAction, ulFileAttribute, ulOpenFlags, ulOpenMode ));
     if( pFile->pathToDel )
       free( pFile->pathToDel );
     pFile->pathToDel = NULL;
     if( flags & SQLITE_OPEN_READWRITE ){
-      OSTRACE2( "OPEN %d Invalid handle\n", ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE) );
+      OSTRACE(( "OPEN %d Invalid handle\n",
+                ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE) ));
       return os2Open( pVfs, zName, id,
                       ((flags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE),
                       pOutFlags );
@@ -21537,7 +22409,7 @@ static int os2Open(
   pFile->pMethod = &os2IoMethod;
   pFile->h = h;
   OpenCounter(+1);
-  OSTRACE3( "OPEN %d pOutFlags=%d\n", pFile->h, pOutFlags );
+  OSTRACE(( "OPEN %d pOutFlags=%d\n", pFile->h, pOutFlags ));
   return SQLITE_OK;
 }
 
@@ -21554,7 +22426,7 @@ static int os2Delete(
   SimulateIOError( return SQLITE_IOERR_DELETE );
   rc = DosDelete( (PSZ)zFilenameCp );
   free( zFilenameCp );
-  OSTRACE2( "DELETE \"%s\"\n", zFilename );
+  OSTRACE(( "DELETE \"%s\"\n", zFilename ));
   return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR_DELETE;
 }
 
@@ -21575,17 +22447,17 @@ static int os2Access(
   rc = DosQueryPathInfo( (PSZ)zFilenameCp, FIL_STANDARD,
                          &fsts3ConfigInfo, sizeof(FILESTATUS3) );
   free( zFilenameCp );
-  OSTRACE4( "ACCESS fsts3ConfigInfo.attrFile=%d flags=%d rc=%d\n",
-            fsts3ConfigInfo.attrFile, flags, rc );
+  OSTRACE(( "ACCESS fsts3ConfigInfo.attrFile=%d flags=%d rc=%d\n",
+            fsts3ConfigInfo.attrFile, flags, rc ));
   switch( flags ){
     case SQLITE_ACCESS_READ:
     case SQLITE_ACCESS_EXISTS:
       rc = (rc == NO_ERROR);
-      OSTRACE3( "ACCESS %s access of read and exists  rc=%d\n", zFilename, rc );
+      OSTRACE(( "ACCESS %s access of read and exists  rc=%d\n", zFilename, rc));
       break;
     case SQLITE_ACCESS_READWRITE:
       rc = (rc == NO_ERROR) && ( (fsts3ConfigInfo.attrFile & FILE_READONLY) == 0 );
-      OSTRACE3( "ACCESS %s access of read/write  rc=%d\n", zFilename, rc );
+      OSTRACE(( "ACCESS %s access of read/write  rc=%d\n", zFilename, rc ));
       break;
     default:
       assert( !"Invalid flags argument" );
@@ -21795,7 +22667,7 @@ SQLITE_API int sqlite3_os_init(void){
     os2Randomness,     /* xRandomness */
     os2Sleep,          /* xSleep */
     os2CurrentTime,    /* xCurrentTime */
-    os2GetLastError    /* xGetLastError */
+    os2GetLastError,   /* xGetLastError */
   };
   sqlite3_vfs_register(&os2Vfs, 1);
   initUconvObjects();
@@ -21929,6 +22801,7 @@ SQLITE_API int sqlite3_os_end(void){
 #include <unistd.h>
 #include <sys/time.h>
 #include <errno.h>
+#include <sys/mman.h>
 
 #if SQLITE_ENABLE_LOCKING_STYLE
 # include <sys/ioctl.h>
@@ -21983,6 +22856,11 @@ SQLITE_API int sqlite3_os_end(void){
 */
 #define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))
 
+/* Forward references */
+typedef struct unixShm unixShm;               /* Connection shared memory */
+typedef struct unixShmNode unixShmNode;       /* Shared memory instance */
+typedef struct unixInodeInfo unixInodeInfo;   /* An i-node */
+typedef struct UnixUnusedFd UnixUnusedFd;     /* An unused file descriptor */
 
 /*
 ** Sometimes, after a file handle is closed by SQLite, the file descriptor
@@ -21990,7 +22868,6 @@ SQLITE_API int sqlite3_os_end(void){
 ** structure are used to store the file descriptor while waiting for an
 ** opportunity to either close or reuse it.
 */
-typedef struct UnixUnusedFd UnixUnusedFd;
 struct UnixUnusedFd {
   int fd;                   /* File descriptor to close */
   int flags;                /* Flags this file descriptor was opened with */
@@ -22004,27 +22881,26 @@ struct UnixUnusedFd {
 typedef struct unixFile unixFile;
 struct unixFile {
   sqlite3_io_methods const *pMethod;  /* Always the first entry */
-  struct unixOpenCnt *pOpen;       /* Info about all open fd's on this inode */
-  struct unixLockInfo *pLock;      /* Info about locks on this inode */
-  int h;                           /* The file descriptor */
-  int dirfd;                       /* File descriptor for the directory */
-  unsigned char locktype;          /* The type of lock held on this fd */
-  int lastErrno;                   /* The unix errno from the last I/O error */
-  void *lockingContext;            /* Locking style specific state */
-  UnixUnusedFd *pUnused;           /* Pre-allocated UnixUnusedFd */
-  int fileFlags;                   /* Miscellanous flags */
+  unixInodeInfo *pInode;              /* Info about locks on this inode */
+  int h;                              /* The file descriptor */
+  int dirfd;                          /* File descriptor for the directory */
+  unsigned char eFileLock;            /* The type of lock held on this fd */
+  int lastErrno;                      /* The unix errno from last I/O error */
+  void *lockingContext;               /* Locking style specific state */
+  UnixUnusedFd *pUnused;              /* Pre-allocated UnixUnusedFd */
+  int fileFlags;                      /* Miscellanous flags */
+  const char *zPath;                  /* Name of the file */
+  unixShm *pShm;                      /* Shared memory segment information */
+  int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
 #if SQLITE_ENABLE_LOCKING_STYLE
-  int openFlags;                   /* The flags specified at open() */
+  int openFlags;                      /* The flags specified at open() */
 #endif
 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
-  unsigned fsFlags;                 /* cached details from statfs() */
-#endif
-#if SQLITE_THREADSAFE && defined(__linux__)
-  pthread_t tid;                   /* The thread that "owns" this unixFile */
+  unsigned fsFlags;                   /* cached details from statfs() */
 #endif
 #if OS_VXWORKS
-  int isDelete;                    /* Delete on close if true */
-  struct vxworksFileId *pId;       /* Unique file ID */
+  int isDelete;                       /* Delete on close if true */
+  struct vxworksFileId *pId;          /* Unique file ID */
 #endif
 #ifndef NDEBUG
   /* The next group of variables are used to track whether or not the
@@ -22089,23 +22965,9 @@ struct unixFile {
 
 #ifdef SQLITE_DEBUG
 SQLITE_PRIVATE int sqlite3OSTrace = 0;
-#define OSTRACE1(X)         if( sqlite3OSTrace ) sqlite3DebugPrintf(X)
-#define OSTRACE2(X,Y)       if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y)
-#define OSTRACE3(X,Y,Z)     if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)   if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B) if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
 #else
-#define OSTRACE1(X)
-#define OSTRACE2(X,Y)
-#define OSTRACE3(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)
 #endif
 
 /*
@@ -22315,7 +23177,7 @@ SQLITE_API int sqlite3_open_file_count = 0;
 
 /*
 ** Helper functions to obtain and relinquish the global mutex. The
-** global mutex is used to protect the unixOpenCnt, unixLockInfo and
+** global mutex is used to protect the unixInodeInfo and
 ** vxworksFileId objects used by this file, all of which may be 
 ** shared by multiple threads.
 **
@@ -22346,8 +23208,8 @@ static int unixMutexHeld(void) {
 ** binaries. This returns the string represetation of the supplied
 ** integer lock-type.
 */
-static const char *locktypeName(int locktype){
-  switch( locktype ){
+static const char *azFileLock(int eFileLock){
+  switch( eFileLock ){
     case NO_LOCK: return "NONE";
     case SHARED_LOCK: return "SHARED";
     case RESERVED_LOCK: return "RESERVED";
@@ -22684,13 +23546,12 @@ static void vxworksReleaseFileId(struct vxworksFileId *pId){
 **
 ** If you close a file descriptor that points to a file that has locks,
 ** all locks on that file that are owned by the current process are
-** released.  To work around this problem, each unixFile structure contains
-** a pointer to an unixOpenCnt structure.  There is one unixOpenCnt structure
-** per open inode, which means that multiple unixFile can point to a single
-** unixOpenCnt.  When an attempt is made to close an unixFile, if there are
+** released.  To work around this problem, each unixInodeInfo object
+** maintains a count of the number of pending locks on tha inode.
+** When an attempt is made to close an unixFile, if there are
 ** other unixFile open on the same inode that are holding locks, the call
 ** to close() the file descriptor is deferred until all of the locks clear.
-** The unixOpenCnt structure keeps a list of file descriptors that need to
+** The unixInodeInfo structure keeps a list of file descriptors that need to
 ** be closed and that list is walked (and cleared) when the last lock
 ** clears.
 **
@@ -22705,46 +23566,19 @@ static void vxworksReleaseFileId(struct vxworksFileId *pId){
 ** in thread B.  But there is no way to know at compile-time which
 ** threading library is being used.  So there is no way to know at
 ** compile-time whether or not thread A can override locks on thread B.
-** We have to do a run-time check to discover the behavior of the
+** One has to do a run-time check to discover the behavior of the
 ** current process.
 **
-** On systems where thread A is unable to modify locks created by
-** thread B, we have to keep track of which thread created each
-** lock.  Hence there is an extra field in the key to the unixLockInfo
-** structure to record this information.  And on those systems it
-** is illegal to begin a transaction in one thread and finish it
-** in another.  For this latter restriction, there is no work-around.
-** It is a limitation of LinuxThreads.
-*/
-
-/*
-** Set or check the unixFile.tid field.  This field is set when an unixFile
-** is first opened.  All subsequent uses of the unixFile verify that the
-** same thread is operating on the unixFile.  Some operating systems do
-** not allow locks to be overridden by other threads and that restriction
-** means that sqlite3* database handles cannot be moved from one thread
-** to another while locks are held.
-**
-** Version 3.3.1 (2006-01-15):  unixFile can be moved from one thread to
-** another as long as we are running on a system that supports threads
-** overriding each others locks (which is now the most common behavior)
-** or if no locks are held.  But the unixFile.pLock field needs to be
-** recomputed because its key includes the thread-id.  See the 
-** transferOwnership() function below for additional information
-*/
-#if SQLITE_THREADSAFE && defined(__linux__)
-# define SET_THREADID(X)   (X)->tid = pthread_self()
-# define CHECK_THREADID(X) (threadsOverrideEachOthersLocks==0 && \
-                            !pthread_equal((X)->tid, pthread_self()))
-#else
-# define SET_THREADID(X)
-# define CHECK_THREADID(X) 0
-#endif
+** SQLite used to support LinuxThreads.  But support for LinuxThreads
+** was dropped beginning with version 3.7.0.  SQLite will still work with
+** LinuxThreads provided that (1) there is no more than one connection 
+** per database file in the same process and (2) database connections
+** do not move across threads.
+*/
 
 /*
 ** An instance of the following structure serves as the key used
-** to locate a particular unixOpenCnt structure given its inode.  This
-** is the same as the unixLockKey except that the thread ID is omitted.
+** to locate a particular unixInodeInfo object.
 */
 struct unixFileId {
   dev_t dev;                  /* Device number */
@@ -22756,23 +23590,6 @@ struct unixFileId {
 };
 
 /*
-** An instance of the following structure serves as the key used
-** to locate a particular unixLockInfo structure given its inode.
-**
-** If threads cannot override each others locks (LinuxThreads), then we
-** set the unixLockKey.tid field to the thread ID.  If threads can override
-** each others locks (Posix and NPTL) then tid is always set to zero.
-** tid is omitted if we compile without threading support or on an OS
-** other than linux.
-*/
-struct unixLockKey {
-  struct unixFileId fid;  /* Unique identifier for the file */
-#if SQLITE_THREADSAFE && defined(__linux__)
-  pthread_t tid;  /* Thread ID of lock owner. Zero if not using LinuxThreads */
-#endif
-};
-
-/*
 ** An instance of the following structure is allocated for each open
 ** inode.  Or, on LinuxThreads, there is one of these structures for
 ** each inode opened by each thread.
@@ -22781,230 +23598,109 @@ struct unixLockKey {
 ** structure contains a pointer to an instance of this object and this
 ** object keeps a count of the number of unixFile pointing to it.
 */
-struct unixLockInfo {
-  struct unixLockKey lockKey;     /* The lookup key */
-  int cnt;                        /* Number of SHARED locks held */
-  int locktype;                   /* One of SHARED_LOCK, RESERVED_LOCK etc. */
+struct unixInodeInfo {
+  struct unixFileId fileId;       /* The lookup key */
+  int nShared;                    /* Number of SHARED locks held */
+  int eFileLock;                  /* One of SHARED_LOCK, RESERVED_LOCK etc. */
   int nRef;                       /* Number of pointers to this structure */
+  unixShmNode *pShmNode;          /* Shared memory associated with this inode */
+  int nLock;                      /* Number of outstanding file locks */
+  UnixUnusedFd *pUnused;          /* Unused file descriptors to close */
+  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */
+  unixInodeInfo *pPrev;           /*    .... doubly linked */
 #if defined(SQLITE_ENABLE_LOCKING_STYLE)
   unsigned long long sharedByte;  /* for AFP simulated shared lock */
 #endif
-  struct unixLockInfo *pNext;     /* List of all unixLockInfo objects */
-  struct unixLockInfo *pPrev;     /*    .... doubly linked */
-};
-
-/*
-** An instance of the following structure is allocated for each open
-** inode.  This structure keeps track of the number of locks on that
-** inode.  If a close is attempted against an inode that is holding
-** locks, the close is deferred until all locks clear by adding the
-** file descriptor to be closed to the pending list.
-**
-** TODO:  Consider changing this so that there is only a single file
-** descriptor for each open file, even when it is opened multiple times.
-** The close() system call would only occur when the last database
-** using the file closes.
-*/
-struct unixOpenCnt {
-  struct unixFileId fileId;   /* The lookup key */
-  int nRef;                   /* Number of pointers to this structure */
-  int nLock;                  /* Number of outstanding locks */
-  UnixUnusedFd *pUnused;      /* Unused file descriptors to close */
 #if OS_VXWORKS
-  sem_t *pSem;                     /* Named POSIX semaphore */
-  char aSemName[MAX_PATHNAME+2];   /* Name of that semaphore */
+  sem_t *pSem;                    /* Named POSIX semaphore */
+  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */
 #endif
-  struct unixOpenCnt *pNext, *pPrev;   /* List of all unixOpenCnt objects */
 };
 
 /*
-** Lists of all unixLockInfo and unixOpenCnt objects.  These used to be hash
-** tables.  But the number of objects is rarely more than a dozen and
-** never exceeds a few thousand.  And lookup is not on a critical
-** path so a simple linked list will suffice.
-*/
-static struct unixLockInfo *lockList = 0;
-static struct unixOpenCnt *openList = 0;
-
-/*
-** This variable remembers whether or not threads can override each others
-** locks.
-**
-**    0:  No.  Threads cannot override each others locks.  (LinuxThreads)
-**    1:  Yes.  Threads can override each others locks.  (Posix & NLPT)
-**   -1:  We don't know yet.
-**
-** On some systems, we know at compile-time if threads can override each
-** others locks.  On those systems, the SQLITE_THREAD_OVERRIDE_LOCK macro
-** will be set appropriately.  On other systems, we have to check at
-** runtime.  On these latter systems, SQLTIE_THREAD_OVERRIDE_LOCK is
-** undefined.
-**
-** This variable normally has file scope only.  But during testing, we make
-** it a global so that the test code can change its value in order to verify
-** that the right stuff happens in either case.
-*/
-#if SQLITE_THREADSAFE && defined(__linux__)
-#  ifndef SQLITE_THREAD_OVERRIDE_LOCK
-#    define SQLITE_THREAD_OVERRIDE_LOCK -1
-#  endif
-#  ifdef SQLITE_TEST
-int threadsOverrideEachOthersLocks = SQLITE_THREAD_OVERRIDE_LOCK;
-#  else
-static int threadsOverrideEachOthersLocks = SQLITE_THREAD_OVERRIDE_LOCK;
-#  endif
-#endif
-
-/*
-** This structure holds information passed into individual test
-** threads by the testThreadLockingBehavior() routine.
+** A lists of all unixInodeInfo objects.
 */
-struct threadTestData {
-  int fd;                /* File to be locked */
-  struct flock lock;     /* The locking operation */
-  int result;            /* Result of the locking operation */
-};
+static unixInodeInfo *inodeList = 0;
 
-#if SQLITE_THREADSAFE && defined(__linux__)
 /*
-** This function is used as the main routine for a thread launched by
-** testThreadLockingBehavior(). It tests whether the shared-lock obtained
-** by the main thread in testThreadLockingBehavior() conflicts with a
-** hypothetical write-lock obtained by this thread on the same file.
+** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
+** If all such file descriptors are closed without error, the list is
+** cleared and SQLITE_OK returned.
 **
-** The write-lock is not actually acquired, as this is not possible if 
-** the file is open in read-only mode (see ticket #3472).
+** Otherwise, if an error occurs, then successfully closed file descriptor
+** entries are removed from the list, and SQLITE_IOERR_CLOSE returned. 
+** not deleted and SQLITE_IOERR_CLOSE returned.
 */ 
-static void *threadLockingTest(void *pArg){
-  struct threadTestData *pData = (struct threadTestData*)pArg;
-  pData->result = fcntl(pData->fd, F_GETLK, &pData->lock);
-  return pArg;
-}
-#endif /* SQLITE_THREADSAFE && defined(__linux__) */
-
-
-#if SQLITE_THREADSAFE && defined(__linux__)
-/*
-** This procedure attempts to determine whether or not threads
-** can override each others locks then sets the 
-** threadsOverrideEachOthersLocks variable appropriately.
-*/
-static void testThreadLockingBehavior(int fd_orig){
-  int fd;
-  int rc;
-  struct threadTestData d;
-  struct flock l;
-  pthread_t t;
-
-  fd = dup(fd_orig);
-  if( fd<0 ) return;
-  memset(&l, 0, sizeof(l));
-  l.l_type = F_RDLCK;
-  l.l_len = 1;
-  l.l_start = 0;
-  l.l_whence = SEEK_SET;
-  rc = fcntl(fd_orig, F_SETLK, &l);
-  if( rc!=0 ) return;
-  memset(&d, 0, sizeof(d));
-  d.fd = fd;
-  d.lock = l;
-  d.lock.l_type = F_WRLCK;
-  if( pthread_create(&t, 0, threadLockingTest, &d)==0 ){
-    pthread_join(t, 0);
-  }
-  close(fd);
-  if( d.result!=0 ) return;
-  threadsOverrideEachOthersLocks = (d.lock.l_type==F_UNLCK);
-}
-#endif /* SQLITE_THREADSAFE && defined(__linux__) */
-
-/*
-** Release a unixLockInfo structure previously allocated by findLockInfo().
-**
-** The mutex entered using the unixEnterMutex() function must be held
-** when this function is called.
-*/
-static void releaseLockInfo(struct unixLockInfo *pLock){
-  assert( unixMutexHeld() );
-  if( pLock ){
-    pLock->nRef--;
-    if( pLock->nRef==0 ){
-      if( pLock->pPrev ){
-        assert( pLock->pPrev->pNext==pLock );
-        pLock->pPrev->pNext = pLock->pNext;
-      }else{
-        assert( lockList==pLock );
-        lockList = pLock->pNext;
-      }
-      if( pLock->pNext ){
-        assert( pLock->pNext->pPrev==pLock );
-        pLock->pNext->pPrev = pLock->pPrev;
-      }
-      sqlite3_free(pLock);
+static int closePendingFds(unixFile *pFile){
+  int rc = SQLITE_OK;
+  unixInodeInfo *pInode = pFile->pInode;
+  UnixUnusedFd *pError = 0;
+  UnixUnusedFd *p;
+  UnixUnusedFd *pNext;
+  for(p=pInode->pUnused; p; p=pNext){
+    pNext = p->pNext;
+    if( close(p->fd) ){
+      pFile->lastErrno = errno;
+      rc = SQLITE_IOERR_CLOSE;
+      p->pNext = pError;
+      pError = p;
+    }else{
+      sqlite3_free(p);
     }
   }
+  pInode->pUnused = pError;
+  return rc;
 }
 
 /*
-** Release a unixOpenCnt structure previously allocated by findLockInfo().
+** Release a unixInodeInfo structure previously allocated by findInodeInfo().
 **
 ** The mutex entered using the unixEnterMutex() function must be held
 ** when this function is called.
 */
-static void releaseOpenCnt(struct unixOpenCnt *pOpen){
+static void releaseInodeInfo(unixFile *pFile){
+  unixInodeInfo *pInode = pFile->pInode;
   assert( unixMutexHeld() );
-  if( pOpen ){
-    pOpen->nRef--;
-    if( pOpen->nRef==0 ){
-      if( pOpen->pPrev ){
-        assert( pOpen->pPrev->pNext==pOpen );
-        pOpen->pPrev->pNext = pOpen->pNext;
+  if( pInode ){
+    pInode->nRef--;
+    if( pInode->nRef==0 ){
+      assert( pInode->pShmNode==0 );
+      closePendingFds(pFile);
+      if( pInode->pPrev ){
+        assert( pInode->pPrev->pNext==pInode );
+        pInode->pPrev->pNext = pInode->pNext;
       }else{
-        assert( openList==pOpen );
-        openList = pOpen->pNext;
+        assert( inodeList==pInode );
+        inodeList = pInode->pNext;
       }
-      if( pOpen->pNext ){
-        assert( pOpen->pNext->pPrev==pOpen );
-        pOpen->pNext->pPrev = pOpen->pPrev;
+      if( pInode->pNext ){
+        assert( pInode->pNext->pPrev==pInode );
+        pInode->pNext->pPrev = pInode->pPrev;
       }
-#if SQLITE_THREADSAFE && defined(__linux__)
-      assert( !pOpen->pUnused || threadsOverrideEachOthersLocks==0 );
-#endif
-
-      /* If pOpen->pUnused is not null, then memory and file-descriptors
-      ** are leaked.
-      **
-      ** This will only happen if, under Linuxthreads, the user has opened
-      ** a transaction in one thread, then attempts to close the database
-      ** handle from another thread (without first unlocking the db file).
-      ** This is a misuse.  */
-      sqlite3_free(pOpen);
+      sqlite3_free(pInode);
     }
   }
 }
 
 /*
-** Given a file descriptor, locate unixLockInfo and unixOpenCnt structures that
-** describes that file descriptor.  Create new ones if necessary.  The
-** return values might be uninitialized if an error occurs.
+** Given a file descriptor, locate the unixInodeInfo object that
+** describes that file descriptor.  Create a new one if necessary.  The
+** return value might be uninitialized if an error occurs.
 **
 ** The mutex entered using the unixEnterMutex() function must be held
 ** when this function is called.
 **
 ** Return an appropriate error code.
 */
-static int findLockInfo(
+static int findInodeInfo(
   unixFile *pFile,               /* Unix file with file desc used in the key */
-  struct unixLockInfo **ppLock,  /* Return the unixLockInfo structure here */
-  struct unixOpenCnt **ppOpen    /* Return the unixOpenCnt structure here */
+  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */
 ){
   int rc;                        /* System call return code */
   int fd;                        /* The file descriptor for pFile */
-  struct unixLockKey lockKey;    /* Lookup key for the unixLockInfo structure */
-  struct unixFileId fileId;      /* Lookup key for the unixOpenCnt struct */
+  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */
   struct stat statbuf;           /* Low-level file information */
-  struct unixLockInfo *pLock = 0;/* Candidate unixLockInfo object */
-  struct unixOpenCnt *pOpen;     /* Candidate unixOpenCnt object */
+  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */
 
   assert( unixMutexHeld() );
 
@@ -23046,122 +23742,35 @@ static int findLockInfo(
   }
 #endif
 
-  memset(&lockKey, 0, sizeof(lockKey));
-  lockKey.fid.dev = statbuf.st_dev;
+  memset(&fileId, 0, sizeof(fileId));
+  fileId.dev = statbuf.st_dev;
 #if OS_VXWORKS
-  lockKey.fid.pId = pFile->pId;
+  fileId.pId = pFile->pId;
 #else
-  lockKey.fid.ino = statbuf.st_ino;
-#endif
-#if SQLITE_THREADSAFE && defined(__linux__)
-  if( threadsOverrideEachOthersLocks<0 ){
-    testThreadLockingBehavior(fd);
-  }
-  lockKey.tid = threadsOverrideEachOthersLocks ? 0 : pthread_self();
-#endif
-  fileId = lockKey.fid;
-  if( ppLock!=0 ){
-    pLock = lockList;
-    while( pLock && memcmp(&lockKey, &pLock->lockKey, sizeof(lockKey)) ){
-      pLock = pLock->pNext;
-    }
-    if( pLock==0 ){
-      pLock = sqlite3_malloc( sizeof(*pLock) );
-      if( pLock==0 ){
-        rc = SQLITE_NOMEM;
-        goto exit_findlockinfo;
-      }
-      memcpy(&pLock->lockKey,&lockKey,sizeof(lockKey));
-      pLock->nRef = 1;
-      pLock->cnt = 0;
-      pLock->locktype = 0;
-#if defined(SQLITE_ENABLE_LOCKING_STYLE)
-      pLock->sharedByte = 0;
+  fileId.ino = statbuf.st_ino;
 #endif
-      pLock->pNext = lockList;
-      pLock->pPrev = 0;
-      if( lockList ) lockList->pPrev = pLock;
-      lockList = pLock;
-    }else{
-      pLock->nRef++;
-    }
-    *ppLock = pLock;
+  pInode = inodeList;
+  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
+    pInode = pInode->pNext;
   }
-  if( ppOpen!=0 ){
-    pOpen = openList;
-    while( pOpen && memcmp(&fileId, &pOpen->fileId, sizeof(fileId)) ){
-      pOpen = pOpen->pNext;
-    }
-    if( pOpen==0 ){
-      pOpen = sqlite3_malloc( sizeof(*pOpen) );
-      if( pOpen==0 ){
-        releaseLockInfo(pLock);
-        rc = SQLITE_NOMEM;
-        goto exit_findlockinfo;
-      }
-      memset(pOpen, 0, sizeof(*pOpen));
-      pOpen->fileId = fileId;
-      pOpen->nRef = 1;
-      pOpen->pNext = openList;
-      if( openList ) openList->pPrev = pOpen;
-      openList = pOpen;
-    }else{
-      pOpen->nRef++;
+  if( pInode==0 ){
+    pInode = sqlite3_malloc( sizeof(*pInode) );
+    if( pInode==0 ){
+      return SQLITE_NOMEM;
     }
-    *ppOpen = pOpen;
-  }
-
-exit_findlockinfo:
-  return rc;
-}
-
-/*
-** If we are currently in a different thread than the thread that the
-** unixFile argument belongs to, then transfer ownership of the unixFile
-** over to the current thread.
-**
-** A unixFile is only owned by a thread on systems that use LinuxThreads.
-**
-** Ownership transfer is only allowed if the unixFile is currently unlocked.
-** If the unixFile is locked and an ownership is wrong, then return
-** SQLITE_MISUSE.  SQLITE_OK is returned if everything works.
-*/
-#if SQLITE_THREADSAFE && defined(__linux__)
-static int transferOwnership(unixFile *pFile){
-  int rc;
-  pthread_t hSelf;
-  if( threadsOverrideEachOthersLocks ){
-    /* Ownership transfers not needed on this system */
-    return SQLITE_OK;
-  }
-  hSelf = pthread_self();
-  if( pthread_equal(pFile->tid, hSelf) ){
-    /* We are still in the same thread */
-    OSTRACE1("No-transfer, same thread\n");
-    return SQLITE_OK;
-  }
-  if( pFile->locktype!=NO_LOCK ){
-    /* We cannot change ownership while we are holding a lock! */
-    return SQLITE_MISUSE_BKPT;
-  }
-  OSTRACE4("Transfer ownership of %d from %d to %d\n",
-            pFile->h, pFile->tid, hSelf);
-  pFile->tid = hSelf;
-  if (pFile->pLock != NULL) {
-    releaseLockInfo(pFile->pLock);
-    rc = findLockInfo(pFile, &pFile->pLock, 0);
-    OSTRACE5("LOCK    %d is now %s(%s,%d)\n", pFile->h,
-           locktypeName(pFile->locktype),
-           locktypeName(pFile->pLock->locktype), pFile->pLock->cnt);
-    return rc;
-  } else {
-    return SQLITE_OK;
+    memset(pInode, 0, sizeof(*pInode));
+    memcpy(&pInode->fileId, &fileId, sizeof(fileId));
+    pInode->nRef = 1;
+    pInode->pNext = inodeList;
+    pInode->pPrev = 0;
+    if( inodeList ) inodeList->pPrev = pInode;
+    inodeList = pInode;
+  }else{
+    pInode->nRef++;
   }
+  *ppInode = pInode;
+  return SQLITE_OK;
 }
-#else  /* if not SQLITE_THREADSAFE */
-  /* On single-threaded builds, ownership transfer is a no-op */
-# define transferOwnership(X) SQLITE_OK
-#endif /* SQLITE_THREADSAFE */
 
 
 /*
@@ -23178,10 +23787,10 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
   SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
 
   assert( pFile );
-  unixEnterMutex(); /* Because pFile->pLock is shared across threads */
+  unixEnterMutex(); /* Because pFile->pInode is shared across threads */
 
   /* Check if a thread in this process holds such a lock */
-  if( pFile->pLock->locktype>SHARED_LOCK ){
+  if( pFile->pInode->eFileLock>SHARED_LOCK ){
     reserved = 1;
   }
 
@@ -23205,14 +23814,14 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
 #endif
   
   unixLeaveMutex();
-  OSTRACE4("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved);
+  OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved));
 
   *pResOut = reserved;
   return rc;
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -23235,7 +23844,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
-static int unixLock(sqlite3_file *id, int locktype){
+static int unixLock(sqlite3_file *id, int eFileLock){
   /* The following describes the implementation of the various locks and
   ** lock transitions in terms of the POSIX advisory shared and exclusive
   ** lock primitives (called read-locks and write-locks below, to avoid
@@ -23276,23 +23885,23 @@ static int unixLock(sqlite3_file *id, int locktype){
   */
   int rc = SQLITE_OK;
   unixFile *pFile = (unixFile*)id;
-  struct unixLockInfo *pLock = pFile->pLock;
+  unixInodeInfo *pInode = pFile->pInode;
   struct flock lock;
   int s = 0;
   int tErrno = 0;
 
   assert( pFile );
-  OSTRACE7("LOCK    %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
-      locktypeName(locktype), locktypeName(pFile->locktype),
-      locktypeName(pLock->locktype), pLock->cnt , getpid());
+  OSTRACE(("LOCK    %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
+      azFileLock(eFileLock), azFileLock(pFile->eFileLock),
+      azFileLock(pInode->eFileLock), pInode->nShared , getpid()));
 
   /* If there is already a lock of this type or more restrictive on the
   ** unixFile, do nothing. Don't use the end_lock: exit path, as
   ** unixEnterMutex() hasn't been called yet.
   */
-  if( pFile->locktype>=locktype ){
-    OSTRACE3("LOCK    %d %s ok (already held) (unix)\n", pFile->h,
-            locktypeName(locktype));
+  if( pFile->eFileLock>=eFileLock ){
+    OSTRACE(("LOCK    %d %s ok (already held) (unix)\n", pFile->h,
+            azFileLock(eFileLock)));
     return SQLITE_OK;
   }
 
@@ -23301,28 +23910,20 @@ static int unixLock(sqlite3_file *id, int locktype){
   **  (2) SQLite never explicitly requests a pendig lock.
   **  (3) A shared lock is always held when a reserve lock is requested.
   */
-  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );
-  assert( locktype!=PENDING_LOCK );
-  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );
+  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
+  assert( eFileLock!=PENDING_LOCK );
+  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );
 
-  /* This mutex is needed because pFile->pLock is shared across threads
+  /* This mutex is needed because pFile->pInode is shared across threads
   */
   unixEnterMutex();
-
-  /* Make sure the current thread owns the pFile.
-  */
-  rc = transferOwnership(pFile);
-  if( rc!=SQLITE_OK ){
-    unixLeaveMutex();
-    return rc;
-  }
-  pLock = pFile->pLock;
+  pInode = pFile->pInode;
 
   /* If some thread using this PID has a lock via a different unixFile*
   ** handle that precludes the requested lock, return BUSY.
   */
-  if( (pFile->locktype!=pLock->locktype && 
-          (pLock->locktype>=PENDING_LOCK || locktype>SHARED_LOCK))
+  if( (pFile->eFileLock!=pInode->eFileLock && 
+          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
   ){
     rc = SQLITE_BUSY;
     goto end_lock;
@@ -23332,14 +23933,14 @@ static int unixLock(sqlite3_file *id, int locktype){
   ** has a SHARED or RESERVED lock, then increment reference counts and
   ** return SQLITE_OK.
   */
-  if( locktype==SHARED_LOCK && 
-      (pLock->locktype==SHARED_LOCK || pLock->locktype==RESERVED_LOCK) ){
-    assert( locktype==SHARED_LOCK );
-    assert( pFile->locktype==0 );
-    assert( pLock->cnt>0 );
-    pFile->locktype = SHARED_LOCK;
-    pLock->cnt++;
-    pFile->pOpen->nLock++;
+  if( eFileLock==SHARED_LOCK && 
+      (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){
+    assert( eFileLock==SHARED_LOCK );
+    assert( pFile->eFileLock==0 );
+    assert( pInode->nShared>0 );
+    pFile->eFileLock = SHARED_LOCK;
+    pInode->nShared++;
+    pInode->nLock++;
     goto end_lock;
   }
 
@@ -23350,10 +23951,10 @@ static int unixLock(sqlite3_file *id, int locktype){
   */
   lock.l_len = 1L;
   lock.l_whence = SEEK_SET;
-  if( locktype==SHARED_LOCK 
-      || (locktype==EXCLUSIVE_LOCK && pFile->locktype<PENDING_LOCK)
+  if( eFileLock==SHARED_LOCK 
+      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)
   ){
-    lock.l_type = (locktype==SHARED_LOCK?F_RDLCK:F_WRLCK);
+    lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);
     lock.l_start = PENDING_BYTE;
     s = fcntl(pFile->h, F_SETLK, &lock);
     if( s==(-1) ){
@@ -23370,9 +23971,9 @@ static int unixLock(sqlite3_file *id, int locktype){
   /* If control gets to this point, then actually go ahead and make
   ** operating system calls for the specified lock.
   */
-  if( locktype==SHARED_LOCK ){
-    assert( pLock->cnt==0 );
-    assert( pLock->locktype==0 );
+  if( eFileLock==SHARED_LOCK ){
+    assert( pInode->nShared==0 );
+    assert( pInode->eFileLock==0 );
 
     /* Now get the read-lock */
     lock.l_start = SHARED_FIRST;
@@ -23401,11 +24002,11 @@ static int unixLock(sqlite3_file *id, int locktype){
         pFile->lastErrno = tErrno;
       }
     }else{
-      pFile->locktype = SHARED_LOCK;
-      pFile->pOpen->nLock++;
-      pLock->cnt = 1;
+      pFile->eFileLock = SHARED_LOCK;
+      pInode->nLock++;
+      pInode->nShared = 1;
     }
-  }else if( locktype==EXCLUSIVE_LOCK && pLock->cnt>1 ){
+  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){
     /* We are trying for an exclusive lock but another thread in this
     ** same process is still holding a shared lock. */
     rc = SQLITE_BUSY;
@@ -23414,9 +24015,9 @@ static int unixLock(sqlite3_file *id, int locktype){
     ** assumed that there is a SHARED or greater lock on the file
     ** already.
     */
-    assert( 0!=pFile->locktype );
+    assert( 0!=pFile->eFileLock );
     lock.l_type = F_WRLCK;
-    switch( locktype ){
+    switch( eFileLock ){
       case RESERVED_LOCK:
         lock.l_start = RESERVED_BYTE;
         break;
@@ -23445,8 +24046,8 @@ static int unixLock(sqlite3_file *id, int locktype){
   ** write operation (not a hot journal rollback).
   */
   if( rc==SQLITE_OK
-   && pFile->locktype<=SHARED_LOCK
-   && locktype==RESERVED_LOCK
+   && pFile->eFileLock<=SHARED_LOCK
+   && eFileLock==RESERVED_LOCK
   ){
     pFile->transCntrChng = 0;
     pFile->dbUpdate = 0;
@@ -23456,47 +24057,17 @@ static int unixLock(sqlite3_file *id, int locktype){
 
 
   if( rc==SQLITE_OK ){
-    pFile->locktype = locktype;
-    pLock->locktype = locktype;
-  }else if( locktype==EXCLUSIVE_LOCK ){
-    pFile->locktype = PENDING_LOCK;
-    pLock->locktype = PENDING_LOCK;
+    pFile->eFileLock = eFileLock;
+    pInode->eFileLock = eFileLock;
+  }else if( eFileLock==EXCLUSIVE_LOCK ){
+    pFile->eFileLock = PENDING_LOCK;
+    pInode->eFileLock = PENDING_LOCK;
   }
 
 end_lock:
   unixLeaveMutex();
-  OSTRACE4("LOCK    %d %s %s (unix)\n", pFile->h, locktypeName(locktype), 
-      rc==SQLITE_OK ? "ok" : "failed");
-  return rc;
-}
-
-/*
-** Close all file descriptors accumuated in the unixOpenCnt->pUnused list.
-** If all such file descriptors are closed without error, the list is
-** cleared and SQLITE_OK returned.
-**
-** Otherwise, if an error occurs, then successfully closed file descriptor
-** entries are removed from the list, and SQLITE_IOERR_CLOSE returned. 
-** not deleted and SQLITE_IOERR_CLOSE returned.
-*/ 
-static int closePendingFds(unixFile *pFile){
-  int rc = SQLITE_OK;
-  struct unixOpenCnt *pOpen = pFile->pOpen;
-  UnixUnusedFd *pError = 0;
-  UnixUnusedFd *p;
-  UnixUnusedFd *pNext;
-  for(p=pOpen->pUnused; p; p=pNext){
-    pNext = p->pNext;
-    if( close(p->fd) ){
-      pFile->lastErrno = errno;
-      rc = SQLITE_IOERR_CLOSE;
-      p->pNext = pError;
-      pError = p;
-    }else{
-      sqlite3_free(p);
-    }
-  }
-  pOpen->pUnused = pError;
+  OSTRACE(("LOCK    %d %s %s (unix)\n", pFile->h, azFileLock(eFileLock), 
+      rc==SQLITE_OK ? "ok" : "failed"));
   return rc;
 }
 
@@ -23505,16 +24076,16 @@ static int closePendingFds(unixFile *pFile){
 ** pUnused list.
 */
 static void setPendingFd(unixFile *pFile){
-  struct unixOpenCnt *pOpen = pFile->pOpen;
+  unixInodeInfo *pInode = pFile->pInode;
   UnixUnusedFd *p = pFile->pUnused;
-  p->pNext = pOpen->pUnused;
-  pOpen->pUnused = p;
+  p->pNext = pInode->pUnused;
+  pInode->pUnused = p;
   pFile->h = -1;
   pFile->pUnused = 0;
 }
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
@@ -23526,31 +24097,29 @@ static void setPendingFd(unixFile *pFile){
 ** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to 
 ** remove the write lock on a region when a read lock is set.
 */
-static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
+static int _posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
   unixFile *pFile = (unixFile*)id;
-  struct unixLockInfo *pLock;
+  unixInodeInfo *pInode;
   struct flock lock;
   int rc = SQLITE_OK;
   int h;
   int tErrno;                      /* Error code from system call errors */
 
   assert( pFile );
-  OSTRACE7("UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, locktype,
-      pFile->locktype, pFile->pLock->locktype, pFile->pLock->cnt, getpid());
+  OSTRACE(("UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
+      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
+      getpid()));
 
-  assert( locktype<=SHARED_LOCK );
-  if( pFile->locktype<=locktype ){
+  assert( eFileLock<=SHARED_LOCK );
+  if( pFile->eFileLock<=eFileLock ){
     return SQLITE_OK;
   }
-  if( CHECK_THREADID(pFile) ){
-    return SQLITE_MISUSE_BKPT;
-  }
   unixEnterMutex();
   h = pFile->h;
-  pLock = pFile->pLock;
-  assert( pLock->cnt!=0 );
-  if( pFile->locktype>SHARED_LOCK ){
-    assert( pLock->locktype==pFile->locktype );
+  pInode = pFile->pInode;
+  assert( pInode->nShared!=0 );
+  if( pFile->eFileLock>SHARED_LOCK ){
+    assert( pInode->eFileLock==pFile->eFileLock );
     SimulateIOErrorBenign(1);
     SimulateIOError( h=(-1) )
     SimulateIOErrorBenign(0);
@@ -23564,9 +24133,11 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
     ** the file has changed and hence might not know to flush their
     ** cache.  The use of a stale cache can lead to database corruption.
     */
+#if 0
     assert( pFile->inNormalWrite==0
          || pFile->dbUpdate==0
          || pFile->transCntrChng==1 );
+#endif
     pFile->inNormalWrite = 0;
 #endif
 
@@ -23579,7 +24150,7 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
     **  3:   [RRRRW]
     **  4:   [RRRR.]
     */
-    if( locktype==SHARED_LOCK ){
+    if( eFileLock==SHARED_LOCK ){
       if( handleNFSUnlock ){
         off_t divSize = SHARED_SIZE - 1;
         
@@ -23639,7 +24210,7 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
     lock.l_start = PENDING_BYTE;
     lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );
     if( fcntl(h, F_SETLK, &lock)!=(-1) ){
-      pLock->locktype = SHARED_LOCK;
+      pInode->eFileLock = SHARED_LOCK;
     }else{
       tErrno = errno;
       rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
@@ -23649,15 +24220,13 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
       goto end_unlock;
     }
   }
-  if( locktype==NO_LOCK ){
-    struct unixOpenCnt *pOpen;
-
+  if( eFileLock==NO_LOCK ){
     /* Decrement the shared lock counter.  Release the lock using an
     ** OS call only when all threads in this same process have released
     ** the lock.
     */
-    pLock->cnt--;
-    if( pLock->cnt==0 ){
+    pInode->nShared--;
+    if( pInode->nShared==0 ){
       lock.l_type = F_UNLCK;
       lock.l_whence = SEEK_SET;
       lock.l_start = lock.l_len = 0L;
@@ -23665,15 +24234,15 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
       SimulateIOError( h=(-1) )
       SimulateIOErrorBenign(0);
       if( fcntl(h, F_SETLK, &lock)!=(-1) ){
-        pLock->locktype = NO_LOCK;
+        pInode->eFileLock = NO_LOCK;
       }else{
         tErrno = errno;
         rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
         if( IS_LOCK_ERROR(rc) ){
           pFile->lastErrno = tErrno;
         }
-        pLock->locktype = NO_LOCK;
-        pFile->locktype = NO_LOCK;
+        pInode->eFileLock = NO_LOCK;
+        pFile->eFileLock = NO_LOCK;
       }
     }
 
@@ -23681,10 +24250,9 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
     ** count reaches zero, close any other file descriptors whose close
     ** was deferred because of outstanding locks.
     */
-    pOpen = pFile->pOpen;
-    pOpen->nLock--;
-    assert( pOpen->nLock>=0 );
-    if( pOpen->nLock==0 ){
+    pInode->nLock--;
+    assert( pInode->nLock>=0 );
+    if( pInode->nLock==0 ){
       int rc2 = closePendingFds(pFile);
       if( rc==SQLITE_OK ){
         rc = rc2;
@@ -23694,19 +24262,19 @@ static int _posixUnlock(sqlite3_file *id, int locktype, int handleNFSUnlock){
 	
 end_unlock:
   unixLeaveMutex();
-  if( rc==SQLITE_OK ) pFile->locktype = locktype;
+  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;
   return rc;
 }
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
-static int unixUnlock(sqlite3_file *id, int locktype){
-  return _posixUnlock(id, locktype, 0);
+static int unixUnlock(sqlite3_file *id, int eFileLock){
+  return _posixUnlock(id, eFileLock, 0);
 }
 
 /*
@@ -23747,7 +24315,7 @@ static int closeUnixFile(sqlite3_file *id){
       pFile->pId = 0;
     }
 #endif
-    OSTRACE2("CLOSE   %-3d\n", pFile->h);
+    OSTRACE(("CLOSE   %-3d\n", pFile->h));
     OpenCounter(-1);
     sqlite3_free(pFile->pUnused);
     memset(pFile, 0, sizeof(unixFile));
@@ -23764,16 +24332,15 @@ static int unixClose(sqlite3_file *id){
     unixFile *pFile = (unixFile *)id;
     unixUnlock(id, NO_LOCK);
     unixEnterMutex();
-    if( pFile->pOpen && pFile->pOpen->nLock ){
+    if( pFile->pInode && pFile->pInode->nLock ){
       /* If there are outstanding locks, do not actually close the file just
       ** yet because that would clear those locks.  Instead, add the file
-      ** descriptor to pOpen->pUnused list.  It will be automatically closed 
+      ** descriptor to pInode->pUnused list.  It will be automatically closed 
       ** when the last lock is cleared.
       */
       setPendingFd(pFile);
     }
-    releaseLockInfo(pFile->pLock);
-    releaseOpenCnt(pFile->pOpen);
+    releaseInodeInfo(pFile);
     rc = closeUnixFile(id);
     unixLeaveMutex();
   }
@@ -23872,7 +24439,7 @@ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
   assert( pFile );
 
   /* Check if a thread in this process holds such a lock */
-  if( pFile->locktype>SHARED_LOCK ){
+  if( pFile->eFileLock>SHARED_LOCK ){
     /* Either this connection or some other connection in the same process
     ** holds a lock on the file.  No need to check further. */
     reserved = 1;
@@ -23881,13 +24448,13 @@ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
     const char *zLockFile = (const char*)pFile->lockingContext;
     reserved = access(zLockFile, 0)==0;
   }
-  OSTRACE4("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved);
+  OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved));
   *pResOut = reserved;
   return rc;
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -23913,7 +24480,7 @@ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
 ** With dotfile locking, we really only support state (4): EXCLUSIVE.
 ** But we track the other locking levels internally.
 */
-static int dotlockLock(sqlite3_file *id, int locktype) {
+static int dotlockLock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   int fd;
   char *zLockFile = (char *)pFile->lockingContext;
@@ -23923,8 +24490,8 @@ static int dotlockLock(sqlite3_file *id, int locktype) {
   /* If we have any lock, then the lock file already exists.  All we have
   ** to do is adjust our internal record of the lock level.
   */
-  if( pFile->locktype > NO_LOCK ){
-    pFile->locktype = locktype;
+  if( pFile->eFileLock > NO_LOCK ){
+    pFile->eFileLock = eFileLock;
 #if !OS_VXWORKS
     /* Always update the timestamp on the old file */
     utimes(zLockFile, NULL);
@@ -23953,12 +24520,12 @@ static int dotlockLock(sqlite3_file *id, int locktype) {
   }
   
   /* got it, set the type and return ok */
-  pFile->locktype = locktype;
+  pFile->eFileLock = eFileLock;
   return rc;
 }
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
@@ -23966,30 +24533,30 @@ static int dotlockLock(sqlite3_file *id, int locktype) {
 **
 ** When the locking level reaches NO_LOCK, delete the lock file.
 */
-static int dotlockUnlock(sqlite3_file *id, int locktype) {
+static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   char *zLockFile = (char *)pFile->lockingContext;
 
   assert( pFile );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d (dotlock)\n", pFile->h, locktype,
-	   pFile->locktype, getpid());
-  assert( locktype<=SHARED_LOCK );
+  OSTRACE(("UNLOCK  %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
+	   pFile->eFileLock, getpid()));
+  assert( eFileLock<=SHARED_LOCK );
   
   /* no-op if possible */
-  if( pFile->locktype==locktype ){
+  if( pFile->eFileLock==eFileLock ){
     return SQLITE_OK;
   }
 
   /* To downgrade to shared, simply update our internal notion of the
   ** lock state.  No need to mess with the file on disk.
   */
-  if( locktype==SHARED_LOCK ){
-    pFile->locktype = SHARED_LOCK;
+  if( eFileLock==SHARED_LOCK ){
+    pFile->eFileLock = SHARED_LOCK;
     return SQLITE_OK;
   }
   
   /* To fully unlock the database, delete the lock file */
-  assert( locktype==NO_LOCK );
+  assert( eFileLock==NO_LOCK );
   if( unlink(zLockFile) ){
     int rc = 0;
     int tErrno = errno;
@@ -24001,7 +24568,7 @@ static int dotlockUnlock(sqlite3_file *id, int locktype) {
     }
     return rc; 
   }
-  pFile->locktype = NO_LOCK;
+  pFile->eFileLock = NO_LOCK;
   return SQLITE_OK;
 }
 
@@ -24054,7 +24621,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
   assert( pFile );
   
   /* Check if a thread in this process holds such a lock */
-  if( pFile->locktype>SHARED_LOCK ){
+  if( pFile->eFileLock>SHARED_LOCK ){
     reserved = 1;
   }
   
@@ -24085,7 +24652,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
       }
     }
   }
-  OSTRACE4("TEST WR-LOCK %d %d %d (flock)\n", pFile->h, rc, reserved);
+  OSTRACE(("TEST WR-LOCK %d %d %d (flock)\n", pFile->h, rc, reserved));
 
 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
   if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){
@@ -24098,7 +24665,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -24126,7 +24693,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
-static int flockLock(sqlite3_file *id, int locktype) {
+static int flockLock(sqlite3_file *id, int eFileLock) {
   int rc = SQLITE_OK;
   unixFile *pFile = (unixFile*)id;
 
@@ -24134,8 +24701,8 @@ static int flockLock(sqlite3_file *id, int locktype) {
 
   /* if we already have a lock, it is exclusive.  
   ** Just adjust level and punt on outta here. */
-  if (pFile->locktype > NO_LOCK) {
-    pFile->locktype = locktype;
+  if (pFile->eFileLock > NO_LOCK) {
+    pFile->eFileLock = eFileLock;
     return SQLITE_OK;
   }
   
@@ -24150,10 +24717,10 @@ static int flockLock(sqlite3_file *id, int locktype) {
     }
   } else {
     /* got it, set the type and return ok */
-    pFile->locktype = locktype;
+    pFile->eFileLock = eFileLock;
   }
-  OSTRACE4("LOCK    %d %s %s (flock)\n", pFile->h, locktypeName(locktype), 
-           rc==SQLITE_OK ? "ok" : "failed");
+  OSTRACE(("LOCK    %d %s %s (flock)\n", pFile->h, azFileLock(eFileLock), 
+           rc==SQLITE_OK ? "ok" : "failed"));
 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
   if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){
     rc = SQLITE_BUSY;
@@ -24164,28 +24731,28 @@ static int flockLock(sqlite3_file *id, int locktype) {
 
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
-static int flockUnlock(sqlite3_file *id, int locktype) {
+static int flockUnlock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   
   assert( pFile );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d (flock)\n", pFile->h, locktype,
-           pFile->locktype, getpid());
-  assert( locktype<=SHARED_LOCK );
+  OSTRACE(("UNLOCK  %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
+           pFile->eFileLock, getpid()));
+  assert( eFileLock<=SHARED_LOCK );
   
   /* no-op if possible */
-  if( pFile->locktype==locktype ){
+  if( pFile->eFileLock==eFileLock ){
     return SQLITE_OK;
   }
   
   /* shared can just be set because we always have an exclusive */
-  if (locktype==SHARED_LOCK) {
-    pFile->locktype = locktype;
+  if (eFileLock==SHARED_LOCK) {
+    pFile->eFileLock = eFileLock;
     return SQLITE_OK;
   }
   
@@ -24205,7 +24772,7 @@ static int flockUnlock(sqlite3_file *id, int locktype) {
     
     return r;
   } else {
-    pFile->locktype = NO_LOCK;
+    pFile->eFileLock = NO_LOCK;
     return SQLITE_OK;
   }
 }
@@ -24253,13 +24820,13 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
   assert( pFile );
 
   /* Check if a thread in this process holds such a lock */
-  if( pFile->locktype>SHARED_LOCK ){
+  if( pFile->eFileLock>SHARED_LOCK ){
     reserved = 1;
   }
   
   /* Otherwise see if some other process holds it. */
   if( !reserved ){
-    sem_t *pSem = pFile->pOpen->pSem;
+    sem_t *pSem = pFile->pInode->pSem;
     struct stat statBuf;
 
     if( sem_trywait(pSem)==-1 ){
@@ -24269,21 +24836,21 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
         pFile->lastErrno = tErrno;
       } else {
         /* someone else has the lock when we are in NO_LOCK */
-        reserved = (pFile->locktype < SHARED_LOCK);
+        reserved = (pFile->eFileLock < SHARED_LOCK);
       }
     }else{
       /* we could have it if we want it */
       sem_post(pSem);
     }
   }
-  OSTRACE4("TEST WR-LOCK %d %d %d (sem)\n", pFile->h, rc, reserved);
+  OSTRACE(("TEST WR-LOCK %d %d %d (sem)\n", pFile->h, rc, reserved));
 
   *pResOut = reserved;
   return rc;
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -24311,16 +24878,16 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
-static int semLock(sqlite3_file *id, int locktype) {
+static int semLock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   int fd;
-  sem_t *pSem = pFile->pOpen->pSem;
+  sem_t *pSem = pFile->pInode->pSem;
   int rc = SQLITE_OK;
 
   /* if we already have a lock, it is exclusive.  
   ** Just adjust level and punt on outta here. */
-  if (pFile->locktype > NO_LOCK) {
-    pFile->locktype = locktype;
+  if (pFile->eFileLock > NO_LOCK) {
+    pFile->eFileLock = eFileLock;
     rc = SQLITE_OK;
     goto sem_end_lock;
   }
@@ -24332,37 +24899,37 @@ static int semLock(sqlite3_file *id, int locktype) {
   }
 
   /* got it, set the type and return ok */
-  pFile->locktype = locktype;
+  pFile->eFileLock = eFileLock;
 
  sem_end_lock:
   return rc;
 }
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
-static int semUnlock(sqlite3_file *id, int locktype) {
+static int semUnlock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
-  sem_t *pSem = pFile->pOpen->pSem;
+  sem_t *pSem = pFile->pInode->pSem;
 
   assert( pFile );
   assert( pSem );
-  OSTRACE5("UNLOCK  %d %d was %d pid=%d (sem)\n", pFile->h, locktype,
-	   pFile->locktype, getpid());
-  assert( locktype<=SHARED_LOCK );
+  OSTRACE(("UNLOCK  %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
+	   pFile->eFileLock, getpid()));
+  assert( eFileLock<=SHARED_LOCK );
   
   /* no-op if possible */
-  if( pFile->locktype==locktype ){
+  if( pFile->eFileLock==eFileLock ){
     return SQLITE_OK;
   }
   
   /* shared can just be set because we always have an exclusive */
-  if (locktype==SHARED_LOCK) {
-    pFile->locktype = locktype;
+  if (eFileLock==SHARED_LOCK) {
+    pFile->eFileLock = eFileLock;
     return SQLITE_OK;
   }
   
@@ -24375,7 +24942,7 @@ static int semUnlock(sqlite3_file *id, int locktype) {
     }
     return rc; 
   }
-  pFile->locktype = NO_LOCK;
+  pFile->eFileLock = NO_LOCK;
   return SQLITE_OK;
 }
 
@@ -24388,8 +24955,7 @@ static int semClose(sqlite3_file *id) {
     semUnlock(id, NO_LOCK);
     assert( pFile );
     unixEnterMutex();
-    releaseLockInfo(pFile->pLock);
-    releaseOpenCnt(pFile->pOpen);
+    releaseInodeInfo(pFile);
     unixLeaveMutex();
     closeUnixFile(id);
   }
@@ -24458,15 +25024,15 @@ static int afpSetLock(
   pb.length = length; 
   pb.fd = pFile->h;
   
-  OSTRACE6("AFPSETLOCK [%s] for %d%s in range %llx:%llx\n", 
+  OSTRACE(("AFPSETLOCK [%s] for %d%s in range %llx:%llx\n", 
     (setLockFlag?"ON":"OFF"), pFile->h, (pb.fd==-1?"[testval-1]":""),
-    offset, length);
+    offset, length));
   err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);
   if ( err==-1 ) {
     int rc;
     int tErrno = errno;
-    OSTRACE4("AFPSETLOCK failed to fsctl() '%s' %d %s\n",
-             path, tErrno, strerror(tErrno));
+    OSTRACE(("AFPSETLOCK failed to fsctl() '%s' %d %s\n",
+             path, tErrno, strerror(tErrno)));
 #ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
     rc = SQLITE_BUSY;
 #else
@@ -24501,10 +25067,10 @@ static int afpCheckReservedLock(sqlite3_file *id, int *pResOut){
     *pResOut = 1;
     return SQLITE_OK;
   }
-  unixEnterMutex(); /* Because pFile->pLock is shared across threads */
+  unixEnterMutex(); /* Because pFile->pInode is shared across threads */
   
   /* Check if a thread in this process holds such a lock */
-  if( pFile->pLock->locktype>SHARED_LOCK ){
+  if( pFile->pInode->eFileLock>SHARED_LOCK ){
     reserved = 1;
   }
   
@@ -24527,14 +25093,14 @@ static int afpCheckReservedLock(sqlite3_file *id, int *pResOut){
   }
   
   unixLeaveMutex();
-  OSTRACE4("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved);
+  OSTRACE(("TEST WR-LOCK %d %d %d (afp)\n", pFile->h, rc, reserved));
   
   *pResOut = reserved;
   return rc;
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -24557,24 +25123,24 @@ static int afpCheckReservedLock(sqlite3_file *id, int *pResOut){
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
-static int afpLock(sqlite3_file *id, int locktype){
+static int afpLock(sqlite3_file *id, int eFileLock){
   int rc = SQLITE_OK;
   unixFile *pFile = (unixFile*)id;
-  struct unixLockInfo *pLock = pFile->pLock;
+  unixInodeInfo *pInode = pFile->pInode;
   afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
   
   assert( pFile );
-  OSTRACE7("LOCK    %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
-           locktypeName(locktype), locktypeName(pFile->locktype),
-           locktypeName(pLock->locktype), pLock->cnt , getpid());
+  OSTRACE(("LOCK    %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
+           azFileLock(eFileLock), azFileLock(pFile->eFileLock),
+           azFileLock(pInode->eFileLock), pInode->nShared , getpid()));
 
   /* If there is already a lock of this type or more restrictive on the
   ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
   ** unixEnterMutex() hasn't been called yet.
   */
-  if( pFile->locktype>=locktype ){
-    OSTRACE3("LOCK    %d %s ok (already held) (afp)\n", pFile->h,
-           locktypeName(locktype));
+  if( pFile->eFileLock>=eFileLock ){
+    OSTRACE(("LOCK    %d %s ok (already held) (afp)\n", pFile->h,
+           azFileLock(eFileLock)));
     return SQLITE_OK;
   }
 
@@ -24583,28 +25149,20 @@ static int afpLock(sqlite3_file *id, int locktype){
   **  (2) SQLite never explicitly requests a pendig lock.
   **  (3) A shared lock is always held when a reserve lock is requested.
   */
-  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );
-  assert( locktype!=PENDING_LOCK );
-  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );
+  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );
+  assert( eFileLock!=PENDING_LOCK );
+  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );
   
-  /* This mutex is needed because pFile->pLock is shared across threads
+  /* This mutex is needed because pFile->pInode is shared across threads
   */
   unixEnterMutex();
-
-  /* Make sure the current thread owns the pFile.
-  */
-  rc = transferOwnership(pFile);
-  if( rc!=SQLITE_OK ){
-    unixLeaveMutex();
-    return rc;
-  }
-  pLock = pFile->pLock;
+  pInode = pFile->pInode;
 
   /* If some thread using this PID has a lock via a different unixFile*
   ** handle that precludes the requested lock, return BUSY.
   */
-  if( (pFile->locktype!=pLock->locktype && 
-       (pLock->locktype>=PENDING_LOCK || locktype>SHARED_LOCK))
+  if( (pFile->eFileLock!=pInode->eFileLock && 
+       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))
      ){
     rc = SQLITE_BUSY;
     goto afp_end_lock;
@@ -24614,14 +25172,14 @@ static int afpLock(sqlite3_file *id, int locktype){
   ** has a SHARED or RESERVED lock, then increment reference counts and
   ** return SQLITE_OK.
   */
-  if( locktype==SHARED_LOCK && 
-     (pLock->locktype==SHARED_LOCK || pLock->locktype==RESERVED_LOCK) ){
-    assert( locktype==SHARED_LOCK );
-    assert( pFile->locktype==0 );
-    assert( pLock->cnt>0 );
-    pFile->locktype = SHARED_LOCK;
-    pLock->cnt++;
-    pFile->pOpen->nLock++;
+  if( eFileLock==SHARED_LOCK && 
+     (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){
+    assert( eFileLock==SHARED_LOCK );
+    assert( pFile->eFileLock==0 );
+    assert( pInode->nShared>0 );
+    pFile->eFileLock = SHARED_LOCK;
+    pInode->nShared++;
+    pInode->nLock++;
     goto afp_end_lock;
   }
     
@@ -24629,8 +25187,8 @@ static int afpLock(sqlite3_file *id, int locktype){
   ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will
   ** be released.
   */
-  if( locktype==SHARED_LOCK 
-      || (locktype==EXCLUSIVE_LOCK && pFile->locktype<PENDING_LOCK)
+  if( eFileLock==SHARED_LOCK 
+      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)
   ){
     int failed;
     failed = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 1);
@@ -24643,20 +25201,20 @@ static int afpLock(sqlite3_file *id, int locktype){
   /* If control gets to this point, then actually go ahead and make
   ** operating system calls for the specified lock.
   */
-  if( locktype==SHARED_LOCK ){
+  if( eFileLock==SHARED_LOCK ){
     int lrc1, lrc2, lrc1Errno;
     long lk, mask;
     
-    assert( pLock->cnt==0 );
-    assert( pLock->locktype==0 );
+    assert( pInode->nShared==0 );
+    assert( pInode->eFileLock==0 );
         
     mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;
     /* Now get the read-lock SHARED_LOCK */
     /* note that the quality of the randomness doesn't matter that much */
     lk = random(); 
-    pLock->sharedByte = (lk & mask)%(SHARED_SIZE - 1);
+    pInode->sharedByte = (lk & mask)%(SHARED_SIZE - 1);
     lrc1 = afpSetLock(context->dbPath, pFile, 
-          SHARED_FIRST+pLock->sharedByte, 1, 1);
+          SHARED_FIRST+pInode->sharedByte, 1, 1);
     if( IS_LOCK_ERROR(lrc1) ){
       lrc1Errno = pFile->lastErrno;
     }
@@ -24673,11 +25231,11 @@ static int afpLock(sqlite3_file *id, int locktype){
     } else if( lrc1 != SQLITE_OK ) {
       rc = lrc1;
     } else {
-      pFile->locktype = SHARED_LOCK;
-      pFile->pOpen->nLock++;
-      pLock->cnt = 1;
+      pFile->eFileLock = SHARED_LOCK;
+      pInode->nLock++;
+      pInode->nShared = 1;
     }
-  }else if( locktype==EXCLUSIVE_LOCK && pLock->cnt>1 ){
+  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){
     /* We are trying for an exclusive lock but another thread in this
      ** same process is still holding a shared lock. */
     rc = SQLITE_BUSY;
@@ -24687,28 +25245,28 @@ static int afpLock(sqlite3_file *id, int locktype){
     ** already.
     */
     int failed = 0;
-    assert( 0!=pFile->locktype );
-    if (locktype >= RESERVED_LOCK && pFile->locktype < RESERVED_LOCK) {
+    assert( 0!=pFile->eFileLock );
+    if (eFileLock >= RESERVED_LOCK && pFile->eFileLock < RESERVED_LOCK) {
         /* Acquire a RESERVED lock */
         failed = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);
       if( !failed ){
         context->reserved = 1;
       }
     }
-    if (!failed && locktype == EXCLUSIVE_LOCK) {
+    if (!failed && eFileLock == EXCLUSIVE_LOCK) {
       /* Acquire an EXCLUSIVE lock */
         
       /* Remove the shared lock before trying the range.  we'll need to 
       ** reestablish the shared lock if we can't get the  afpUnlock
       */
       if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST +
-                         pLock->sharedByte, 1, 0)) ){
+                         pInode->sharedByte, 1, 0)) ){
         int failed2 = SQLITE_OK;
         /* now attemmpt to get the exclusive lock range */
         failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, 
                                SHARED_SIZE, 1);
         if( failed && (failed2 = afpSetLock(context->dbPath, pFile, 
-                       SHARED_FIRST + pLock->sharedByte, 1, 1)) ){
+                       SHARED_FIRST + pInode->sharedByte, 1, 1)) ){
           /* Can't reestablish the shared lock.  Sqlite can't deal, this is
           ** a critical I/O error
           */
@@ -24726,31 +25284,31 @@ static int afpLock(sqlite3_file *id, int locktype){
   }
   
   if( rc==SQLITE_OK ){
-    pFile->locktype = locktype;
-    pLock->locktype = locktype;
-  }else if( locktype==EXCLUSIVE_LOCK ){
-    pFile->locktype = PENDING_LOCK;
-    pLock->locktype = PENDING_LOCK;
+    pFile->eFileLock = eFileLock;
+    pInode->eFileLock = eFileLock;
+  }else if( eFileLock==EXCLUSIVE_LOCK ){
+    pFile->eFileLock = PENDING_LOCK;
+    pInode->eFileLock = PENDING_LOCK;
   }
   
 afp_end_lock:
   unixLeaveMutex();
-  OSTRACE4("LOCK    %d %s %s (afp)\n", pFile->h, locktypeName(locktype), 
-         rc==SQLITE_OK ? "ok" : "failed");
+  OSTRACE(("LOCK    %d %s %s (afp)\n", pFile->h, azFileLock(eFileLock), 
+         rc==SQLITE_OK ? "ok" : "failed"));
   return rc;
 }
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
-static int afpUnlock(sqlite3_file *id, int locktype) {
+static int afpUnlock(sqlite3_file *id, int eFileLock) {
   int rc = SQLITE_OK;
   unixFile *pFile = (unixFile*)id;
-  struct unixLockInfo *pLock;
+  unixInodeInfo *pInode;
   afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
   int skipShared = 0;
 #ifdef SQLITE_TEST
@@ -24758,21 +25316,19 @@ static int afpUnlock(sqlite3_file *id, int locktype) {
 #endif
 
   assert( pFile );
-  OSTRACE7("UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, locktype,
-           pFile->locktype, pFile->pLock->locktype, pFile->pLock->cnt, getpid());
+  OSTRACE(("UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
+           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
+           getpid()));
 
-  assert( locktype<=SHARED_LOCK );
-  if( pFile->locktype<=locktype ){
+  assert( eFileLock<=SHARED_LOCK );
+  if( pFile->eFileLock<=eFileLock ){
     return SQLITE_OK;
   }
-  if( CHECK_THREADID(pFile) ){
-    return SQLITE_MISUSE_BKPT;
-  }
   unixEnterMutex();
-  pLock = pFile->pLock;
-  assert( pLock->cnt!=0 );
-  if( pFile->locktype>SHARED_LOCK ){
-    assert( pLock->locktype==pFile->locktype );
+  pInode = pFile->pInode;
+  assert( pInode->nShared!=0 );
+  if( pFile->eFileLock>SHARED_LOCK ){
+    assert( pInode->eFileLock==pFile->eFileLock );
     SimulateIOErrorBenign(1);
     SimulateIOError( h=(-1) )
     SimulateIOErrorBenign(0);
@@ -24792,38 +25348,38 @@ static int afpUnlock(sqlite3_file *id, int locktype) {
     pFile->inNormalWrite = 0;
 #endif
     
-    if( pFile->locktype==EXCLUSIVE_LOCK ){
+    if( pFile->eFileLock==EXCLUSIVE_LOCK ){
       rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);
-      if( rc==SQLITE_OK && (locktype==SHARED_LOCK || pLock->cnt>1) ){
+      if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){
         /* only re-establish the shared lock if necessary */
-        int sharedLockByte = SHARED_FIRST+pLock->sharedByte;
+        int sharedLockByte = SHARED_FIRST+pInode->sharedByte;
         rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);
       } else {
         skipShared = 1;
       }
     }
-    if( rc==SQLITE_OK && pFile->locktype>=PENDING_LOCK ){
+    if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){
       rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);
     } 
-    if( rc==SQLITE_OK && pFile->locktype>=RESERVED_LOCK && context->reserved ){
+    if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){
       rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);
       if( !rc ){ 
         context->reserved = 0; 
       }
     }
-    if( rc==SQLITE_OK && (locktype==SHARED_LOCK || pLock->cnt>1)){
-      pLock->locktype = SHARED_LOCK;
+    if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){
+      pInode->eFileLock = SHARED_LOCK;
     }
   }
-  if( rc==SQLITE_OK && locktype==NO_LOCK ){
+  if( rc==SQLITE_OK && eFileLock==NO_LOCK ){
 
     /* Decrement the shared lock counter.  Release the lock using an
     ** OS call only when all threads in this same process have released
     ** the lock.
     */
-    unsigned long long sharedLockByte = SHARED_FIRST+pLock->sharedByte;
-    pLock->cnt--;
-    if( pLock->cnt==0 ){
+    unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;
+    pInode->nShared--;
+    if( pInode->nShared==0 ){
       SimulateIOErrorBenign(1);
       SimulateIOError( h=(-1) )
       SimulateIOErrorBenign(0);
@@ -24831,23 +25387,21 @@ static int afpUnlock(sqlite3_file *id, int locktype) {
         rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);
       }
       if( !rc ){
-        pLock->locktype = NO_LOCK;
-        pFile->locktype = NO_LOCK;
+        pInode->eFileLock = NO_LOCK;
+        pFile->eFileLock = NO_LOCK;
       }
     }
     if( rc==SQLITE_OK ){
-      struct unixOpenCnt *pOpen = pFile->pOpen;
-        
-      pOpen->nLock--;
-      assert( pOpen->nLock>=0 );
-      if( pOpen->nLock==0 ){
+      pInode->nLock--;
+      assert( pInode->nLock>=0 );
+      if( pInode->nLock==0 ){
         rc = closePendingFds(pFile);
       }
     }
   }
   
   unixLeaveMutex();
-  if( rc==SQLITE_OK ) pFile->locktype = locktype;
+  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;
   return rc;
 }
 
@@ -24860,16 +25414,15 @@ static int afpClose(sqlite3_file *id) {
     unixFile *pFile = (unixFile*)id;
     afpUnlock(id, NO_LOCK);
     unixEnterMutex();
-    if( pFile->pOpen && pFile->pOpen->nLock ){
+    if( pFile->pInode && pFile->pInode->nLock ){
       /* If there are outstanding locks, do not actually close the file just
       ** yet because that would clear those locks.  Instead, add the file
-      ** descriptor to pOpen->aPending.  It will be automatically closed when
+      ** descriptor to pInode->aPending.  It will be automatically closed when
       ** the last lock is cleared.
       */
       setPendingFd(pFile);
     }
-    releaseLockInfo(pFile->pLock);
-    releaseOpenCnt(pFile->pOpen);
+    releaseInodeInfo(pFile);
     sqlite3_free(pFile->lockingContext);
     rc = closeUnixFile(id);
     unixLeaveMutex();
@@ -24892,14 +25445,14 @@ static int afpClose(sqlite3_file *id) {
 
 #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
 /*
- ** Lower the locking level on file descriptor pFile to locktype.  locktype
+ ** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
  ** must be either NO_LOCK or SHARED_LOCK.
  **
  ** If the locking level of the file descriptor is already at or below
  ** the requested locking level, this routine is a no-op.
  */
-static int nfsUnlock(sqlite3_file *id, int locktype){
-  return _posixUnlock(id, locktype, 1);
+static int nfsUnlock(sqlite3_file *id, int eFileLock){
+  return _posixUnlock(id, eFileLock, 1);
 }
 
 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
@@ -24963,7 +25516,7 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
   if( got<0 ){
     ((unixFile*)id)->lastErrno = errno;
   }
-  OSTRACE5("READ    %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED);
+  OSTRACE(("READ    %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));
   return got;
 }
 
@@ -24984,10 +25537,12 @@ static int unixRead(
 
   /* If this is a database file (not a journal, master-journal or temp
   ** file), the bytes in the locking range should never be read or written. */
+#if 0
   assert( pFile->pUnused==0
        || offset>=PENDING_BYTE+512
        || offset+amt<=PENDING_BYTE 
   );
+#endif
 
   got = seekAndRead(pFile, offset, pBuf, amt);
   if( got==amt ){
@@ -25037,7 +25592,7 @@ static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){
     ((unixFile*)id)->lastErrno = errno;
   }
 
-  OSTRACE5("WRITE   %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED);
+  OSTRACE(("WRITE   %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));
   return got;
 }
 
@@ -25059,10 +25614,12 @@ static int unixWrite(
 
   /* If this is a database file (not a journal, master-journal or temp
   ** file), the bytes in the locking range should never be read or written. */
+#if 0
   assert( pFile->pUnused==0
        || offset>=PENDING_BYTE+512
        || offset+amt<=PENDING_BYTE 
   );
+#endif
 
 #ifndef NDEBUG
   /* If we are doing a normal write to a database file (as opposed to
@@ -25093,6 +25650,7 @@ static int unixWrite(
   }
   SimulateIOError(( wrote=(-1), amt=1 ));
   SimulateDiskfullError(( wrote=0, amt=1 ));
+
   if( amt>0 ){
     if( wrote<0 ){
       /* lastErrno set by seekAndWrite */
@@ -25102,6 +25660,7 @@ static int unixWrite(
       return SQLITE_FULL;
     }
   }
+
   return SQLITE_OK;
 }
 
@@ -25261,7 +25820,7 @@ static int unixSync(sqlite3_file *id, int flags){
   SimulateDiskfullError( return SQLITE_FULL );
 
   assert( pFile );
-  OSTRACE2("SYNC    %-3d\n", pFile->h);
+  OSTRACE(("SYNC    %-3d\n", pFile->h));
   rc = full_fsync(pFile->h, isFullsync, isDataOnly);
   SimulateIOError( rc=1 );
   if( rc ){
@@ -25270,8 +25829,8 @@ static int unixSync(sqlite3_file *id, int flags){
   }
   if( pFile->dirfd>=0 ){
     int err;
-    OSTRACE4("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
-            HAVE_FULLFSYNC, isFullsync);
+    OSTRACE(("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
+            HAVE_FULLFSYNC, isFullsync));
 #ifndef SQLITE_DISABLE_DIRSYNC
     /* The directory sync is only attempted if full_fsync is
     ** turned off or unavailable.  If a full_fsync occurred above,
@@ -25303,12 +25862,23 @@ static int unixSync(sqlite3_file *id, int flags){
 ** Truncate an open file to a specified size
 */
 static int unixTruncate(sqlite3_file *id, i64 nByte){
+  unixFile *pFile = (unixFile *)id;
   int rc;
-  assert( id );
+  assert( pFile );
   SimulateIOError( return SQLITE_IOERR_TRUNCATE );
-  rc = ftruncate(((unixFile*)id)->h, (off_t)nByte);
+
+  /* If the user has configured a chunk-size for this file, truncate the
+  ** file so that it consists of an integer number of chunks (i.e. the
+  ** actual file size after the operation may be larger than the requested
+  ** size).
+  */
+  if( pFile->szChunk ){
+    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
+  }
+
+  rc = ftruncate(pFile->h, (off_t)nByte);
   if( rc ){
-    ((unixFile*)id)->lastErrno = errno;
+    pFile->lastErrno = errno;
     return SQLITE_IOERR_TRUNCATE;
   }else{
 #ifndef NDEBUG
@@ -25319,8 +25889,8 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
     ** when restoring a database using the backup API from a zero-length
     ** source.
     */
-    if( ((unixFile*)id)->inNormalWrite && nByte==0 ){
-      ((unixFile*)id)->transCntrChng = 1;
+    if( pFile->inNormalWrite && nByte==0 ){
+      pFile->transCntrChng = 1;
     }
 #endif
 
@@ -25343,7 +25913,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
   }
   *pSize = buf.st_size;
 
-  /* When opening a zero-size database, the findLockInfo() procedure
+  /* When opening a zero-size database, the findInodeInfo() procedure
   ** writes a single byte into that file in order to work around a bug
   ** in the OS-X msdos filesystem.  In order to avoid problems with upper
   ** layers, we need to report this file size as zero even though it is
@@ -25363,6 +25933,54 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
 static int proxyFileControl(sqlite3_file*,int,void*);
 #endif
 
+/* 
+** This function is called to handle the SQLITE_FCNTL_SIZE_HINT 
+** file-control operation.
+**
+** If the user has configured a chunk-size for this file, it could be
+** that the file needs to be extended at this point. Otherwise, the
+** SQLITE_FCNTL_SIZE_HINT operation is a no-op for Unix.
+*/
+static int fcntlSizeHint(unixFile *pFile, i64 nByte){
+  if( pFile->szChunk ){
+    i64 nSize;                    /* Required file size */
+    struct stat buf;              /* Used to hold return values of fstat() */
+   
+    if( fstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
+
+    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
+    if( nSize>(i64)buf.st_size ){
+#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
+      if( posix_fallocate(pFile->h, buf.st_size, nSize-buf.st_size) ){
+        return SQLITE_IOERR_WRITE;
+      }
+#else
+      /* If the OS does not have posix_fallocate(), fake it. First use
+      ** ftruncate() to set the file size, then write a single byte to
+      ** the last byte in each block within the extended region. This
+      ** is the same technique used by glibc to implement posix_fallocate()
+      ** on systems that do not have a real fallocate() system call.
+      */
+      int nBlk = buf.st_blksize;  /* File-system block size */
+      i64 iWrite;                 /* Next offset to write to */
+      int nWrite;                 /* Return value from seekAndWrite() */
+
+      if( ftruncate(pFile->h, nSize) ){
+        pFile->lastErrno = errno;
+        return SQLITE_IOERR_TRUNCATE;
+      }
+      iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
+      do {
+        nWrite = seekAndWrite(pFile, iWrite, "", 1);
+        iWrite += nBlk;
+      } while( nWrite==1 && iWrite<nSize );
+      if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
+#endif
+    }
+  }
+
+  return SQLITE_OK;
+}
 
 /*
 ** Information and control of an open file handle.
@@ -25370,13 +25988,20 @@ static int proxyFileControl(sqlite3_file*,int,void*);
 static int unixFileControl(sqlite3_file *id, int op, void *pArg){
   switch( op ){
     case SQLITE_FCNTL_LOCKSTATE: {
-      *(int*)pArg = ((unixFile*)id)->locktype;
+      *(int*)pArg = ((unixFile*)id)->eFileLock;
       return SQLITE_OK;
     }
     case SQLITE_LAST_ERRNO: {
       *(int*)pArg = ((unixFile*)id)->lastErrno;
       return SQLITE_OK;
     }
+    case SQLITE_FCNTL_CHUNK_SIZE: {
+      ((unixFile*)id)->szChunk = *(int *)pArg;
+      return SQLITE_OK;
+    }
+    case SQLITE_FCNTL_SIZE_HINT: {
+      return fcntlSizeHint((unixFile *)id, *(i64 *)pArg);
+    }
 #ifndef NDEBUG
     /* The pager calls this method to signal that it has done
     ** a rollback and that the database is therefore unchanged and
@@ -25421,6 +26046,609 @@ static int unixDeviceCharacteristics(sqlite3_file *NotUsed){
   return 0;
 }
 
+#ifndef SQLITE_OMIT_WAL
+
+
+/*
+** Object used to represent an shared memory buffer.  
+**
+** When multiple threads all reference the same wal-index, each thread
+** has its own unixShm object, but they all point to a single instance
+** of this unixShmNode object.  In other words, each wal-index is opened
+** only once per process.
+**
+** Each unixShmNode object is connected to a single unixInodeInfo object.
+** We could coalesce this object into unixInodeInfo, but that would mean
+** every open file that does not use shared memory (in other words, most
+** open files) would have to carry around this extra information.  So
+** the unixInodeInfo object contains a pointer to this unixShmNode object
+** and the unixShmNode object is created only when needed.
+**
+** unixMutexHeld() must be true when creating or destroying
+** this object or while reading or writing the following fields:
+**
+**      nRef
+**
+** The following fields are read-only after the object is created:
+** 
+**      fid
+**      zFilename
+**
+** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and
+** unixMutexHeld() is true when reading or writing any other field
+** in this structure.
+*/
+struct unixShmNode {
+  unixInodeInfo *pInode;     /* unixInodeInfo that owns this SHM node */
+  sqlite3_mutex *mutex;      /* Mutex to access this object */
+  char *zFilename;           /* Name of the mmapped file */
+  int h;                     /* Open file descriptor */
+  int szRegion;              /* Size of shared-memory regions */
+  int nRegion;               /* Size of array apRegion */
+  char **apRegion;           /* Array of mapped shared-memory regions */
+  int nRef;                  /* Number of unixShm objects pointing to this */
+  unixShm *pFirst;           /* All unixShm objects pointing to this */
+#ifdef SQLITE_DEBUG
+  u8 exclMask;               /* Mask of exclusive locks held */
+  u8 sharedMask;             /* Mask of shared locks held */
+  u8 nextShmId;              /* Next available unixShm.id value */
+#endif
+};
+
+/*
+** Structure used internally by this VFS to record the state of an
+** open shared memory connection.
+**
+** The following fields are initialized when this object is created and
+** are read-only thereafter:
+**
+**    unixShm.pFile
+**    unixShm.id
+**
+** All other fields are read/write.  The unixShm.pFile->mutex must be held
+** while accessing any read/write fields.
+*/
+struct unixShm {
+  unixShmNode *pShmNode;     /* The underlying unixShmNode object */
+  unixShm *pNext;            /* Next unixShm with the same unixShmNode */
+  u8 hasMutex;               /* True if holding the unixShmNode mutex */
+  u16 sharedMask;            /* Mask of shared locks held */
+  u16 exclMask;              /* Mask of exclusive locks held */
+#ifdef SQLITE_DEBUG
+  u8 id;                     /* Id of this connection within its unixShmNode */
+#endif
+};
+
+/*
+** Constants used for locking
+*/
+#define UNIX_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)         /* first lock byte */
+#define UNIX_SHM_DMS    (UNIX_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */
+
+/*
+** Apply posix advisory locks for all bytes from ofst through ofst+n-1.
+**
+** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
+** otherwise.
+*/
+static int unixShmSystemLock(
+  unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */
+  int lockType,          /* F_UNLCK, F_RDLCK, or F_WRLCK */
+  int ofst,              /* First byte of the locking range */
+  int n                  /* Number of bytes to lock */
+){
+  struct flock f;       /* The posix advisory locking structure */
+  int rc = SQLITE_OK;   /* Result code form fcntl() */
+
+  /* Access to the unixShmNode object is serialized by the caller */
+  assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
+
+  /* Shared locks never span more than one byte */
+  assert( n==1 || lockType!=F_RDLCK );
+
+  /* Locks are within range */
+  assert( n>=1 && n<SQLITE_SHM_NLOCK );
+
+  /* Initialize the locking parameters */
+  memset(&f, 0, sizeof(f));
+  f.l_type = lockType;
+  f.l_whence = SEEK_SET;
+  f.l_start = ofst;
+  f.l_len = n;
+
+  rc = fcntl(pShmNode->h, F_SETLK, &f);
+  rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
+
+  /* Update the global lock state and do debug tracing */
+#ifdef SQLITE_DEBUG
+  { u16 mask;
+  OSTRACE(("SHM-LOCK "));
+  mask = (1<<(ofst+n)) - (1<<ofst);
+  if( rc==SQLITE_OK ){
+    if( lockType==F_UNLCK ){
+      OSTRACE(("unlock %d ok", ofst));
+      pShmNode->exclMask &= ~mask;
+      pShmNode->sharedMask &= ~mask;
+    }else if( lockType==F_RDLCK ){
+      OSTRACE(("read-lock %d ok", ofst));
+      pShmNode->exclMask &= ~mask;
+      pShmNode->sharedMask |= mask;
+    }else{
+      assert( lockType==F_WRLCK );
+      OSTRACE(("write-lock %d ok", ofst));
+      pShmNode->exclMask |= mask;
+      pShmNode->sharedMask &= ~mask;
+    }
+  }else{
+    if( lockType==F_UNLCK ){
+      OSTRACE(("unlock %d failed", ofst));
+    }else if( lockType==F_RDLCK ){
+      OSTRACE(("read-lock failed"));
+    }else{
+      assert( lockType==F_WRLCK );
+      OSTRACE(("write-lock %d failed", ofst));
+    }
+  }
+  OSTRACE((" - afterwards %03x,%03x\n",
+           pShmNode->sharedMask, pShmNode->exclMask));
+  }
+#endif
+
+  return rc;        
+}
+
+
+/*
+** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0.
+**
+** This is not a VFS shared-memory method; it is a utility function called
+** by VFS shared-memory methods.
+*/
+static void unixShmPurge(unixFile *pFd){
+  unixShmNode *p = pFd->pInode->pShmNode;
+  assert( unixMutexHeld() );
+  if( p && p->nRef==0 ){
+    int i;
+    assert( p->pInode==pFd->pInode );
+    if( p->mutex ) sqlite3_mutex_free(p->mutex);
+    for(i=0; i<p->nRegion; i++){
+      munmap(p->apRegion[i], p->szRegion);
+    }
+    sqlite3_free(p->apRegion);
+    if( p->h>=0 ) close(p->h);
+    p->pInode->pShmNode = 0;
+    sqlite3_free(p);
+  }
+}
+
+/*
+** Open a shared-memory area associated with open database file pDbFd.  
+** This particular implementation uses mmapped files.
+**
+** The file used to implement shared-memory is in the same directory
+** as the open database file and has the same name as the open database
+** file with the "-shm" suffix added.  For example, if the database file
+** is "/home/user1/config.db" then the file that is created and mmapped
+** for shared memory will be called "/home/user1/config.db-shm".  
+**
+** Another approach to is to use files in /dev/shm or /dev/tmp or an
+** some other tmpfs mount. But if a file in a different directory
+** from the database file is used, then differing access permissions
+** or a chroot() might cause two different processes on the same
+** database to end up using different files for shared memory - 
+** meaning that their memory would not really be shared - resulting
+** in database corruption.  Nevertheless, this tmpfs file usage
+** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY="/dev/shm"
+** or the equivalent.  The use of the SQLITE_SHM_DIRECTORY compile-time
+** option results in an incompatible build of SQLite;  builds of SQLite
+** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the
+** same database file at the same time, database corruption will likely
+** result. The SQLITE_SHM_DIRECTORY compile-time option is considered
+** "unsupported" and may go away in a future SQLite release.
+**
+** When opening a new shared-memory file, if no other instances of that
+** file are currently open, in this process or in other processes, then
+** the file must be truncated to zero length or have its header cleared.
+*/
+static int unixOpenSharedMemory(unixFile *pDbFd){
+  struct unixShm *p = 0;          /* The connection to be opened */
+  struct unixShmNode *pShmNode;   /* The underlying mmapped file */
+  int rc;                         /* Result code */
+  unixInodeInfo *pInode;          /* The inode of fd */
+  char *zShmFilename;             /* Name of the file used for SHM */
+  int nShmFilename;               /* Size of the SHM filename in bytes */
+
+  /* Allocate space for the new unixShm object. */
+  p = sqlite3_malloc( sizeof(*p) );
+  if( p==0 ) return SQLITE_NOMEM;
+  memset(p, 0, sizeof(*p));
+  assert( pDbFd->pShm==0 );
+
+  /* Check to see if a unixShmNode object already exists. Reuse an existing
+  ** one if present. Create a new one if necessary.
+  */
+  unixEnterMutex();
+  pInode = pDbFd->pInode;
+  pShmNode = pInode->pShmNode;
+  if( pShmNode==0 ){
+    struct stat sStat;                 /* fstat() info for database file */
+
+    /* Call fstat() to figure out the permissions on the database file. If
+    ** a new *-shm file is created, an attempt will be made to create it
+    ** with the same permissions. The actual permissions the file is created
+    ** with are subject to the current umask setting.
+    */
+    if( fstat(pDbFd->h, &sStat) ){
+      rc = SQLITE_IOERR_FSTAT;
+      goto shm_open_err;
+    }
+
+#ifdef SQLITE_SHM_DIRECTORY
+    nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30;
+#else
+    nShmFilename = 5 + (int)strlen(pDbFd->zPath);
+#endif
+    pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
+    if( pShmNode==0 ){
+      rc = SQLITE_NOMEM;
+      goto shm_open_err;
+    }
+    memset(pShmNode, 0, sizeof(*pShmNode));
+    zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1];
+#ifdef SQLITE_SHM_DIRECTORY
+    sqlite3_snprintf(nShmFilename, zShmFilename, 
+                     SQLITE_SHM_DIRECTORY "/sqlite-shm-%x-%x",
+                     (u32)sStat.st_ino, (u32)sStat.st_dev);
+#else
+    sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", pDbFd->zPath);
+#endif
+    pShmNode->h = -1;
+    pDbFd->pInode->pShmNode = pShmNode;
+    pShmNode->pInode = pDbFd->pInode;
+    pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
+    if( pShmNode->mutex==0 ){
+      rc = SQLITE_NOMEM;
+      goto shm_open_err;
+    }
+
+    pShmNode->h = open(zShmFilename, O_RDWR|O_CREAT, (sStat.st_mode & 0777));
+    if( pShmNode->h<0 ){
+      rc = SQLITE_CANTOPEN_BKPT;
+      goto shm_open_err;
+    }
+
+    /* Check to see if another process is holding the dead-man switch.
+    ** If not, truncate the file to zero length. 
+    */
+    rc = SQLITE_OK;
+    if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
+      if( ftruncate(pShmNode->h, 0) ){
+        rc = SQLITE_IOERR_SHMOPEN;
+      }
+    }
+    if( rc==SQLITE_OK ){
+      rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);
+    }
+    if( rc ) goto shm_open_err;
+  }
+
+  /* Make the new connection a child of the unixShmNode */
+  p->pShmNode = pShmNode;
+#ifdef SQLITE_DEBUG
+  p->id = pShmNode->nextShmId++;
+#endif
+  pShmNode->nRef++;
+  pDbFd->pShm = p;
+  unixLeaveMutex();
+
+  /* The reference count on pShmNode has already been incremented under
+  ** the cover of the unixEnterMutex() mutex and the pointer from the
+  ** new (struct unixShm) object to the pShmNode has been set. All that is
+  ** left to do is to link the new object into the linked list starting
+  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex 
+  ** mutex.
+  */
+  sqlite3_mutex_enter(pShmNode->mutex);
+  p->pNext = pShmNode->pFirst;
+  pShmNode->pFirst = p;
+  sqlite3_mutex_leave(pShmNode->mutex);
+  return SQLITE_OK;
+
+  /* Jump here on any error */
+shm_open_err:
+  unixShmPurge(pDbFd);       /* This call frees pShmNode if required */
+  sqlite3_free(p);
+  unixLeaveMutex();
+  return rc;
+}
+
+/*
+** This function is called to obtain a pointer to region iRegion of the 
+** shared-memory associated with the database file fd. Shared-memory regions 
+** are numbered starting from zero. Each shared-memory region is szRegion 
+** bytes in size.
+**
+** If an error occurs, an error code is returned and *pp is set to NULL.
+**
+** Otherwise, if the bExtend parameter is 0 and the requested shared-memory
+** region has not been allocated (by any client, including one running in a
+** separate process), then *pp is set to NULL and SQLITE_OK returned. If 
+** bExtend is non-zero and the requested shared-memory region has not yet 
+** been allocated, it is allocated by this function.
+**
+** If the shared-memory region has already been allocated or is allocated by
+** this call as described above, then it is mapped into this processes 
+** address space (if it is not already), *pp is set to point to the mapped 
+** memory and SQLITE_OK returned.
+*/
+static int unixShmMap(
+  sqlite3_file *fd,               /* Handle open on database file */
+  int iRegion,                    /* Region to retrieve */
+  int szRegion,                   /* Size of regions */
+  int bExtend,                    /* True to extend file if necessary */
+  void volatile **pp              /* OUT: Mapped memory */
+){
+  unixFile *pDbFd = (unixFile*)fd;
+  unixShm *p;
+  unixShmNode *pShmNode;
+  int rc = SQLITE_OK;
+
+  /* If the shared-memory file has not yet been opened, open it now. */
+  if( pDbFd->pShm==0 ){
+    rc = unixOpenSharedMemory(pDbFd);
+    if( rc!=SQLITE_OK ) return rc;
+  }
+
+  p = pDbFd->pShm;
+  pShmNode = p->pShmNode;
+  sqlite3_mutex_enter(pShmNode->mutex);
+  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
+
+  if( pShmNode->nRegion<=iRegion ){
+    char **apNew;                      /* New apRegion[] array */
+    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */
+    struct stat sStat;                 /* Used by fstat() */
+
+    pShmNode->szRegion = szRegion;
+
+    /* The requested region is not mapped into this processes address space.
+    ** Check to see if it has been allocated (i.e. if the wal-index file is
+    ** large enough to contain the requested region).
+    */
+    if( fstat(pShmNode->h, &sStat) ){
+      rc = SQLITE_IOERR_SHMSIZE;
+      goto shmpage_out;
+    }
+
+    if( sStat.st_size<nByte ){
+      /* The requested memory region does not exist. If bExtend is set to
+      ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.
+      **
+      ** Alternatively, if bExtend is true, use ftruncate() to allocate
+      ** the requested memory region.
+      */
+      if( !bExtend ) goto shmpage_out;
+      if( ftruncate(pShmNode->h, nByte) ){
+        rc = SQLITE_IOERR_SHMSIZE;
+        goto shmpage_out;
+      }
+    }
+
+    /* Map the requested memory region into this processes address space. */
+    apNew = (char **)sqlite3_realloc(
+        pShmNode->apRegion, (iRegion+1)*sizeof(char *)
+    );
+    if( !apNew ){
+      rc = SQLITE_IOERR_NOMEM;
+      goto shmpage_out;
+    }
+    pShmNode->apRegion = apNew;
+    while(pShmNode->nRegion<=iRegion){
+      void *pMem = mmap(0, szRegion, PROT_READ|PROT_WRITE, 
+          MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion
+      );
+      if( pMem==MAP_FAILED ){
+        rc = SQLITE_IOERR;
+        goto shmpage_out;
+      }
+      pShmNode->apRegion[pShmNode->nRegion] = pMem;
+      pShmNode->nRegion++;
+    }
+  }
+
+shmpage_out:
+  if( pShmNode->nRegion>iRegion ){
+    *pp = pShmNode->apRegion[iRegion];
+  }else{
+    *pp = 0;
+  }
+  sqlite3_mutex_leave(pShmNode->mutex);
+  return rc;
+}
+
+/*
+** Change the lock state for a shared-memory segment.
+**
+** Note that the relationship between SHAREd and EXCLUSIVE locks is a little
+** different here than in posix.  In xShmLock(), one can go from unlocked
+** to shared and back or from unlocked to exclusive and back.  But one may
+** not go from shared to exclusive or from exclusive to shared.
+*/
+static int unixShmLock(
+  sqlite3_file *fd,          /* Database file holding the shared memory */
+  int ofst,                  /* First lock to acquire or release */
+  int n,                     /* Number of locks to acquire or release */
+  int flags                  /* What to do with the lock */
+){
+  unixFile *pDbFd = (unixFile*)fd;      /* Connection holding shared memory */
+  unixShm *p = pDbFd->pShm;             /* The shared memory being locked */
+  unixShm *pX;                          /* For looping over all siblings */
+  unixShmNode *pShmNode = p->pShmNode;  /* The underlying file iNode */
+  int rc = SQLITE_OK;                   /* Result code */
+  u16 mask;                             /* Mask of locks to take or release */
+
+  assert( pShmNode==pDbFd->pInode->pShmNode );
+  assert( pShmNode->pInode==pDbFd->pInode );
+  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );
+  assert( n>=1 );
+  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
+       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
+       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
+       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
+  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
+
+  mask = (1<<(ofst+n)) - (1<<ofst);
+  assert( n>1 || mask==(1<<ofst) );
+  sqlite3_mutex_enter(pShmNode->mutex);
+  if( flags & SQLITE_SHM_UNLOCK ){
+    u16 allMask = 0; /* Mask of locks held by siblings */
+
+    /* See if any siblings hold this same lock */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( pX==p ) continue;
+      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );
+      allMask |= pX->sharedMask;
+    }
+
+    /* Unlock the system-level locks */
+    if( (mask & allMask)==0 ){
+      rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);
+    }else{
+      rc = SQLITE_OK;
+    }
+
+    /* Undo the local locks */
+    if( rc==SQLITE_OK ){
+      p->exclMask &= ~mask;
+      p->sharedMask &= ~mask;
+    } 
+  }else if( flags & SQLITE_SHM_SHARED ){
+    u16 allShared = 0;  /* Union of locks held by connections other than "p" */
+
+    /* Find out which shared locks are already held by sibling connections.
+    ** If any sibling already holds an exclusive lock, go ahead and return
+    ** SQLITE_BUSY.
+    */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( (pX->exclMask & mask)!=0 ){
+        rc = SQLITE_BUSY;
+        break;
+      }
+      allShared |= pX->sharedMask;
+    }
+
+    /* Get shared locks at the system level, if necessary */
+    if( rc==SQLITE_OK ){
+      if( (allShared & mask)==0 ){
+        rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);
+      }else{
+        rc = SQLITE_OK;
+      }
+    }
+
+    /* Get the local shared locks */
+    if( rc==SQLITE_OK ){
+      p->sharedMask |= mask;
+    }
+  }else{
+    /* Make sure no sibling connections hold locks that will block this
+    ** lock.  If any do, return SQLITE_BUSY right away.
+    */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){
+        rc = SQLITE_BUSY;
+        break;
+      }
+    }
+  
+    /* Get the exclusive locks at the system level.  Then if successful
+    ** also mark the local connection as being locked.
+    */
+    if( rc==SQLITE_OK ){
+      rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
+      if( rc==SQLITE_OK ){
+        assert( (p->sharedMask & mask)==0 );
+        p->exclMask |= mask;
+      }
+    }
+  }
+  sqlite3_mutex_leave(pShmNode->mutex);
+  OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
+           p->id, getpid(), p->sharedMask, p->exclMask));
+  return rc;
+}
+
+/*
+** Implement a memory barrier or memory fence on shared memory.  
+**
+** All loads and stores begun before the barrier must complete before
+** any load or store begun after the barrier.
+*/
+static void unixShmBarrier(
+  sqlite3_file *fd                /* Database file holding the shared memory */
+){
+  UNUSED_PARAMETER(fd);
+  unixEnterMutex();
+  unixLeaveMutex();
+}
+
+/*
+** Close a connection to shared-memory.  Delete the underlying 
+** storage if deleteFlag is true.
+**
+** If there is no shared memory associated with the connection then this
+** routine is a harmless no-op.
+*/
+static int unixShmUnmap(
+  sqlite3_file *fd,               /* The underlying database file */
+  int deleteFlag                  /* Delete shared-memory if true */
+){
+  unixShm *p;                     /* The connection to be closed */
+  unixShmNode *pShmNode;          /* The underlying shared-memory file */
+  unixShm **pp;                   /* For looping over sibling connections */
+  unixFile *pDbFd;                /* The underlying database file */
+
+  pDbFd = (unixFile*)fd;
+  p = pDbFd->pShm;
+  if( p==0 ) return SQLITE_OK;
+  pShmNode = p->pShmNode;
+
+  assert( pShmNode==pDbFd->pInode->pShmNode );
+  assert( pShmNode->pInode==pDbFd->pInode );
+
+  /* Remove connection p from the set of connections associated
+  ** with pShmNode */
+  sqlite3_mutex_enter(pShmNode->mutex);
+  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
+  *pp = p->pNext;
+
+  /* Free the connection p */
+  sqlite3_free(p);
+  pDbFd->pShm = 0;
+  sqlite3_mutex_leave(pShmNode->mutex);
+
+  /* If pShmNode->nRef has reached 0, then close the underlying
+  ** shared-memory file, too */
+  unixEnterMutex();
+  assert( pShmNode->nRef>0 );
+  pShmNode->nRef--;
+  if( pShmNode->nRef==0 ){
+    if( deleteFlag ) unlink(pShmNode->zFilename);
+    unixShmPurge(pDbFd);
+  }
+  unixLeaveMutex();
+
+  return SQLITE_OK;
+}
+
+
+#else
+# define unixShmMap     0
+# define unixShmLock    0
+# define unixShmBarrier 0
+# define unixShmUnmap   0
+#endif /* #ifndef SQLITE_OMIT_WAL */
+
 /*
 ** Here ends the implementation of all sqlite3_file methods.
 **
@@ -25461,9 +26689,9 @@ static int unixDeviceCharacteristics(sqlite3_file *NotUsed){
 **   *  An I/O method finder function called FINDER that returns a pointer
 **      to the METHOD object in the previous bullet.
 */
-#define IOMETHODS(FINDER, METHOD, CLOSE, LOCK, UNLOCK, CKLOCK)               \
+#define IOMETHODS(FINDER, METHOD, VERSION, CLOSE, LOCK, UNLOCK, CKLOCK)      \
 static const sqlite3_io_methods METHOD = {                                   \
-   1,                          /* iVersion */                                \
+   VERSION,                    /* iVersion */                                \
    CLOSE,                      /* xClose */                                  \
    unixRead,                   /* xRead */                                   \
    unixWrite,                  /* xWrite */                                  \
@@ -25475,7 +26703,11 @@ static const sqlite3_io_methods METHOD = {                                   \
    CKLOCK,                     /* xCheckReservedLock */                      \
    unixFileControl,            /* xFileControl */                            \
    unixSectorSize,             /* xSectorSize */                             \
-   unixDeviceCharacteristics   /* xDeviceCapabilities */                     \
+   unixDeviceCharacteristics,  /* xDeviceCapabilities */                     \
+   unixShmMap,                 /* xShmMap */                                 \
+   unixShmLock,                /* xShmLock */                                \
+   unixShmBarrier,             /* xShmBarrier */                             \
+   unixShmUnmap                /* xShmUnmap */                               \
 };                                                                           \
 static const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){   \
   UNUSED_PARAMETER(z); UNUSED_PARAMETER(p);                                  \
@@ -25492,6 +26724,7 @@ static const sqlite3_io_methods *(*const FINDER)(const char*,unixFile *p)    \
 IOMETHODS(
   posixIoFinder,            /* Finder function name */
   posixIoMethods,           /* sqlite3_io_methods object name */
+  2,                        /* shared memory is enabled */
   unixClose,                /* xClose method */
   unixLock,                 /* xLock method */
   unixUnlock,               /* xUnlock method */
@@ -25500,6 +26733,7 @@ IOMETHODS(
 IOMETHODS(
   nolockIoFinder,           /* Finder function name */
   nolockIoMethods,          /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   nolockClose,              /* xClose method */
   nolockLock,               /* xLock method */
   nolockUnlock,             /* xUnlock method */
@@ -25508,6 +26742,7 @@ IOMETHODS(
 IOMETHODS(
   dotlockIoFinder,          /* Finder function name */
   dotlockIoMethods,         /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   dotlockClose,             /* xClose method */
   dotlockLock,              /* xLock method */
   dotlockUnlock,            /* xUnlock method */
@@ -25518,6 +26753,7 @@ IOMETHODS(
 IOMETHODS(
   flockIoFinder,            /* Finder function name */
   flockIoMethods,           /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   flockClose,               /* xClose method */
   flockLock,                /* xLock method */
   flockUnlock,              /* xUnlock method */
@@ -25529,6 +26765,7 @@ IOMETHODS(
 IOMETHODS(
   semIoFinder,              /* Finder function name */
   semIoMethods,             /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   semClose,                 /* xClose method */
   semLock,                  /* xLock method */
   semUnlock,                /* xUnlock method */
@@ -25540,6 +26777,7 @@ IOMETHODS(
 IOMETHODS(
   afpIoFinder,              /* Finder function name */
   afpIoMethods,             /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   afpClose,                 /* xClose method */
   afpLock,                  /* xLock method */
   afpUnlock,                /* xUnlock method */
@@ -25564,6 +26802,7 @@ static int proxyCheckReservedLock(sqlite3_file*, int*);
 IOMETHODS(
   proxyIoFinder,            /* Finder function name */
   proxyIoMethods,           /* sqlite3_io_methods object name */
+  1,                        /* shared memory is disabled */
   proxyClose,               /* xClose method */
   proxyLock,                /* xLock method */
   proxyUnlock,              /* xUnlock method */
@@ -25576,6 +26815,7 @@ IOMETHODS(
 IOMETHODS(
   nfsIoFinder,               /* Finder function name */
   nfsIoMethods,              /* sqlite3_io_methods object name */
+  1,                         /* shared memory is disabled */
   unixClose,                 /* xClose method */
   unixLock,                  /* xLock method */
   nfsUnlock,                 /* xUnlock method */
@@ -25716,19 +26956,29 @@ static int fillInUnixFile(
   unixFile *pNew = (unixFile *)pId;
   int rc = SQLITE_OK;
 
-  assert( pNew->pLock==NULL );
-  assert( pNew->pOpen==NULL );
+  assert( pNew->pInode==NULL );
 
   /* Parameter isDelete is only used on vxworks. Express this explicitly 
   ** here to prevent compiler warnings about unused parameters.
   */
   UNUSED_PARAMETER(isDelete);
 
-  OSTRACE3("OPEN    %-3d %s\n", h, zFilename);    
+  /* Usually the path zFilename should not be a relative pathname. The
+  ** exception is when opening the proxy "conch" file in builds that
+  ** include the special Apple locking styles.
+  */
+#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
+  assert( zFilename==0 || zFilename[0]=='/' 
+    || pVfs->pAppData==(void*)&autolockIoFinder );
+#else
+  assert( zFilename==0 || zFilename[0]=='/' );
+#endif
+
+  OSTRACE(("OPEN    %-3d %s\n", h, zFilename));
   pNew->h = h;
   pNew->dirfd = dirfd;
-  SET_THREADID(pNew);
   pNew->fileFlags = 0;
+  pNew->zPath = zFilename;
 
 #if OS_VXWORKS
   pNew->pId = vxworksFindFileId(zFilename);
@@ -25756,10 +27006,10 @@ static int fillInUnixFile(
 #endif
   ){
     unixEnterMutex();
-    rc = findLockInfo(pNew, &pNew->pLock, &pNew->pOpen);
+    rc = findInodeInfo(pNew, &pNew->pInode);
     if( rc!=SQLITE_OK ){
-      /* If an error occured in findLockInfo(), close the file descriptor
-      ** immediately, before releasing the mutex. findLockInfo() may fail
+      /* If an error occured in findInodeInfo(), close the file descriptor
+      ** immediately, before releasing the mutex. findInodeInfo() may fail
       ** in two scenarios:
       **
       **   (a) A call to fstat() failed.
@@ -25768,7 +27018,7 @@ static int fillInUnixFile(
       ** Scenario (b) may only occur if the process is holding no other
       ** file descriptors open on the same file. If there were other file
       ** descriptors on this file, then no malloc would be required by
-      ** findLockInfo(). If this is the case, it is quite safe to close
+      ** findInodeInfo(). If this is the case, it is quite safe to close
       ** handle h - as it is guaranteed that no posix locks will be released
       ** by doing so.
       **
@@ -25799,7 +27049,7 @@ static int fillInUnixFile(
       pCtx->reserved = 0;
       srandomdev();
       unixEnterMutex();
-      rc = findLockInfo(pNew, &pNew->pLock, &pNew->pOpen);
+      rc = findInodeInfo(pNew, &pNew->pInode);
       if( rc!=SQLITE_OK ){
         sqlite3_free(pNew->lockingContext);
         close(h);
@@ -25832,18 +27082,18 @@ static int fillInUnixFile(
     ** included in the semLockingContext
     */
     unixEnterMutex();
-    rc = findLockInfo(pNew, &pNew->pLock, &pNew->pOpen);
-    if( (rc==SQLITE_OK) && (pNew->pOpen->pSem==NULL) ){
-      char *zSemName = pNew->pOpen->aSemName;
+    rc = findInodeInfo(pNew, &pNew->pInode);
+    if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){
+      char *zSemName = pNew->pInode->aSemName;
       int n;
       sqlite3_snprintf(MAX_PATHNAME, zSemName, "/%s.sem",
                        pNew->pId->zCanonicalName);
       for( n=1; zSemName[n]; n++ )
         if( zSemName[n]=='/' ) zSemName[n] = '_';
-      pNew->pOpen->pSem = sem_open(zSemName, O_CREAT, 0666, 1);
-      if( pNew->pOpen->pSem == SEM_FAILED ){
+      pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1);
+      if( pNew->pInode->pSem == SEM_FAILED ){
         rc = SQLITE_NOMEM;
-        pNew->pOpen->aSemName[0] = '\0';
+        pNew->pInode->aSemName[0] = '\0';
       }
     }
     unixLeaveMutex();
@@ -25894,7 +27144,7 @@ static int openDirectory(const char *zFilename, int *pFd){
 #ifdef FD_CLOEXEC
       fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
 #endif
-      OSTRACE3("OPENDIR %-3d %s\n", fd, zDirname);
+      OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname));
     }
   }
   *pFd = fd;
@@ -25902,26 +27152,46 @@ static int openDirectory(const char *zFilename, int *pFd){
 }
 
 /*
-** Create a temporary file name in zBuf.  zBuf must be allocated
-** by the calling process and must be big enough to hold at least
-** pVfs->mxPathname bytes.
+** Return the name of a directory in which to put temporary files.
+** If no suitable temporary file directory can be found, return NULL.
 */
-static int getTempname(int nBuf, char *zBuf){
+static const char *unixTempFileDir(void){
   static const char *azDirs[] = {
      0,
      0,
      "/var/tmp",
      "/usr/tmp",
      "/tmp",
-     ".",
+     0        /* List terminator */
   };
+  unsigned int i;
+  struct stat buf;
+  const char *zDir = 0;
+
+  azDirs[0] = sqlite3_temp_directory;
+  if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
+  for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
+    if( zDir==0 ) continue;
+    if( stat(zDir, &buf) ) continue;
+    if( !S_ISDIR(buf.st_mode) ) continue;
+    if( access(zDir, 07) ) continue;
+    break;
+  }
+  return zDir;
+}
+
+/*
+** Create a temporary file name in zBuf.  zBuf must be allocated
+** by the calling process and must be big enough to hold at least
+** pVfs->mxPathname bytes.
+*/
+static int unixGetTempname(int nBuf, char *zBuf){
   static const unsigned char zChars[] =
     "abcdefghijklmnopqrstuvwxyz"
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "0123456789";
   unsigned int i, j;
-  struct stat buf;
-  const char *zDir = ".";
+  const char *zDir;
 
   /* It's odd to simulate an io-error here, but really this is just
   ** using the io-error infrastructure to test that SQLite handles this
@@ -25929,19 +27199,8 @@ static int getTempname(int nBuf, char *zBuf){
   */
   SimulateIOError( return SQLITE_IOERR );
 
-  azDirs[0] = sqlite3_temp_directory;
-  if (NULL == azDirs[1]) {
-    azDirs[1] = getenv("TMPDIR");
-  }
-  
-  for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
-    if( azDirs[i]==0 ) continue;
-    if( stat(azDirs[i], &buf) ) continue;
-    if( !S_ISDIR(buf.st_mode) ) continue;
-    if( access(azDirs[i], 07) ) continue;
-    zDir = azDirs[i];
-    break;
-  }
+  zDir = unixTempFileDir();
+  if( zDir==0 ) zDir = ".";
 
   /* Check that the output buffer is large enough for the temporary file 
   ** name. If it is not, return SQLITE_ERROR.
@@ -26007,17 +27266,17 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
   ** Even if a subsequent open() call does succeed, the consequences of
   ** not searching for a resusable file descriptor are not dire.  */
   if( 0==stat(zPath, &sStat) ){
-    struct unixOpenCnt *pOpen;
+    unixInodeInfo *pInode;
 
     unixEnterMutex();
-    pOpen = openList;
-    while( pOpen && (pOpen->fileId.dev!=sStat.st_dev
-                     || pOpen->fileId.ino!=sStat.st_ino) ){
-       pOpen = pOpen->pNext;
+    pInode = inodeList;
+    while( pInode && (pInode->fileId.dev!=sStat.st_dev
+                     || pInode->fileId.ino!=sStat.st_ino) ){
+       pInode = pInode->pNext;
     }
-    if( pOpen ){
+    if( pInode ){
       UnixUnusedFd **pp;
-      for(pp=&pOpen->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
+      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
       pUnused = *pp;
       if( pUnused ){
         *pp = pUnused->pNext;
@@ -26030,6 +27289,51 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
 }
 
 /*
+** This function is called by unixOpen() to determine the unix permissions
+** to create new files with. If no error occurs, then SQLITE_OK is returned
+** and a value suitable for passing as the third argument to open(2) is
+** written to *pMode. If an IO error occurs, an SQLite error code is 
+** returned and the value of *pMode is not modified.
+**
+** If the file being opened is a temporary file, it is always created with
+** the octal permissions 0600 (read/writable by owner only). If the file
+** is a database or master journal file, it is created with the permissions 
+** mask SQLITE_DEFAULT_FILE_PERMISSIONS.
+**
+** Finally, if the file being opened is a WAL or regular journal file, then 
+** this function queries the file-system for the permissions on the 
+** corresponding database file and sets *pMode to this value. Whenever 
+** possible, WAL and journal files are created using the same permissions 
+** as the associated database file.
+*/
+static int findCreateFileMode(
+  const char *zPath,              /* Path of file (possibly) being created */
+  int flags,                      /* Flags passed as 4th argument to xOpen() */
+  mode_t *pMode                   /* OUT: Permissions to open file with */
+){
+  int rc = SQLITE_OK;             /* Return Code */
+  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
+    char zDb[MAX_PATHNAME+1];     /* Database file path */
+    int nDb;                      /* Number of valid bytes in zDb */
+    struct stat sStat;            /* Output of stat() on database file */
+
+    nDb = sqlite3Strlen30(zPath) - ((flags & SQLITE_OPEN_WAL) ? 4 : 8);
+    memcpy(zDb, zPath, nDb);
+    zDb[nDb] = '\0';
+    if( 0==stat(zDb, &sStat) ){
+      *pMode = sStat.st_mode & 0777;
+    }else{
+      rc = SQLITE_IOERR_FSTAT;
+    }
+  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
+    *pMode = 0600;
+  }else{
+    *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS;
+  }
+  return rc;
+}
+
+/*
 ** Open the file zPath.
 ** 
 ** Previously, the SQLite OS layer used three functions in place of this
@@ -26079,9 +27383,11 @@ static int unixOpen(
   ** a file-descriptor on the directory too. The first time unixSync()
   ** is called the directory file descriptor will be fsync()ed and close()d.
   */
-  int isOpenDirectory = (isCreate && 
-      (eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL)
-  );
+  int isOpenDirectory = (isCreate && (
+        eType==SQLITE_OPEN_MASTER_JOURNAL 
+     || eType==SQLITE_OPEN_MAIN_JOURNAL 
+     || eType==SQLITE_OPEN_WAL
+  ));
 
   /* If argument zPath is a NULL pointer, this function is required to open
   ** a temporary file. Use this buffer to store the file name in.
@@ -26101,17 +27407,18 @@ static int unixOpen(
   assert(isExclusive==0 || isCreate);
   assert(isDelete==0 || isCreate);
 
-  /* The main DB, main journal, and master journal are never automatically
-  ** deleted. Nor are they ever temporary files.  */
+  /* The main DB, main journal, WAL file and master journal are never 
+  ** automatically deleted. Nor are they ever temporary files.  */
   assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );
   assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );
   assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );
+  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );
 
   /* Assert that the upper layer has set one of the "file-type" flags. */
   assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB 
        || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL 
        || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL 
-       || eType==SQLITE_OPEN_TRANSIENT_DB
+       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
   );
 
   memset(p, 0, sizeof(unixFile));
@@ -26131,7 +27438,7 @@ static int unixOpen(
   }else if( !zName ){
     /* If zName is NULL, the upper layer is requesting a temp file. */
     assert(isDelete && !isOpenDirectory);
-    rc = getTempname(MAX_PATHNAME+1, zTmpname);
+    rc = unixGetTempname(MAX_PATHNAME+1, zTmpname);
     if( rc!=SQLITE_OK ){
       return rc;
     }
@@ -26149,9 +27456,15 @@ static int unixOpen(
   openFlags |= (O_LARGEFILE|O_BINARY);
 
   if( fd<0 ){
-    mode_t openMode = (isDelete?0600:SQLITE_DEFAULT_FILE_PERMISSIONS);
+    mode_t openMode;              /* Permissions to create file with */
+    rc = findCreateFileMode(zName, flags, &openMode);
+    if( rc!=SQLITE_OK ){
+      assert( !p->pUnused );
+      assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );
+      return rc;
+    }
     fd = open(zName, openFlags, openMode);
-    OSTRACE4("OPENX   %-3d %s 0%o\n", fd, zName, openFlags);
+    OSTRACE(("OPENX   %-3d %s 0%o\n", fd, zName, openFlags));
     if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){
       /* Failed to open the file for read/write access. Try read-only. */
       flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
@@ -26292,7 +27605,9 @@ static int unixDelete(
   int rc = SQLITE_OK;
   UNUSED_PARAMETER(NotUsed);
   SimulateIOError(return SQLITE_IOERR_DELETE);
-  unlink(zPath);
+  if( unlink(zPath)==(-1) && errno!=ENOENT ){
+    return SQLITE_IOERR_DELETE;
+  }
 #ifndef SQLITE_DISABLE_DIRSYNC
   if( dirSync ){
     int fd;
@@ -26349,6 +27664,12 @@ static int unixAccess(
       assert(!"Invalid flags argument");
   }
   *pResOut = (access(zPath, amode)==0);
+  if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){
+    struct stat buf;
+    if( 0==stat(zPath, &buf) && buf.st_size==0 ){
+      *pResOut = 0;
+    }
+  }
   return SQLITE_OK;
 }
 
@@ -26537,32 +27858,33 @@ SQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1
 #endif
 
 /*
-** Find the current time (in Universal Coordinated Time).  Write the
-** current time and date as a Julian Day number into *prNow and
-** return 0.  Return 1 if the time and date cannot be found.
+** Find the current time (in Universal Coordinated Time).  Write into *piNow
+** the current time and date as a Julian Day number times 86_400_000.  In
+** other words, write into *piNow the number of milliseconds since the Julian
+** epoch of noon in Greenwich on November 24, 4714 B.C according to the
+** proleptic Gregorian calendar.
+**
+** On success, return 0.  Return 1 if the time and date cannot be found.
 */
-static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){
-#if defined(SQLITE_OMIT_FLOATING_POINT)
-  time_t t;
-  time(&t);
-  *prNow = (((sqlite3_int64)t)/8640 + 24405875)/10;
-#elif defined(NO_GETTOD)
+static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){
+  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
+#if defined(NO_GETTOD)
   time_t t;
   time(&t);
-  *prNow = t/86400.0 + 2440587.5;
+  *piNow = ((sqlite3_int64)i)*1000 + unixEpoch;
 #elif OS_VXWORKS
   struct timespec sNow;
   clock_gettime(CLOCK_REALTIME, &sNow);
-  *prNow = 2440587.5 + sNow.tv_sec/86400.0 + sNow.tv_nsec/86400000000000.0;
+  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;
 #else
   struct timeval sNow;
   gettimeofday(&sNow, 0);
-  *prNow = 2440587.5 + sNow.tv_sec/86400.0 + sNow.tv_usec/86400000000.0;
+  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;
 #endif
 
 #ifdef SQLITE_TEST
   if( sqlite3_current_time ){
-    *prNow = sqlite3_current_time/86400.0 + 2440587.5;
+    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;
   }
 #endif
   UNUSED_PARAMETER(NotUsed);
@@ -26570,6 +27892,19 @@ static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){
 }
 
 /*
+** Find the current time (in Universal Coordinated Time).  Write the
+** current time and date as a Julian Day number into *prNow and
+** return 0.  Return 1 if the time and date cannot be found.
+*/
+static int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){
+  sqlite3_int64 i;
+  UNUSED_PARAMETER(NotUsed);
+  unixCurrentTimeInt64(0, &i);
+  *prNow = i/86400000.0;
+  return 0;
+}
+
+/*
 ** We added the xGetLastError() method with the intention of providing
 ** better low-level error messages when operating-system problems come up
 ** during SQLite operation.  But so far, none of that has been implemented
@@ -26583,6 +27918,7 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
   return 0;
 }
 
+
 /*
 ************************ End of sqlite3_vfs methods ***************************
 ******************************************************************************/
@@ -26773,8 +28109,8 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
 # ifdef _CS_DARWIN_USER_TEMP_DIR
   {
     if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
-      OSTRACE4("GETLOCKPATH  failed %s errno=%d pid=%d\n",
-               lPath, errno, getpid());
+      OSTRACE(("GETLOCKPATH  failed %s errno=%d pid=%d\n",
+               lPath, errno, getpid()));
       return SQLITE_IOERR_LOCK;
     }
     len = strlcat(lPath, "sqliteplocks", maxLen);    
@@ -26790,13 +28126,13 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
   
   /* transform the db path to a unique cache name */
   dbLen = (int)strlen(dbPath);
-  for( i=0; i<dbLen && (i+len+7)<maxLen; i++){
+  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){
     char c = dbPath[i];
     lPath[i+len] = (c=='/')?'_':c;
   }
   lPath[i+len]='\0';
   strlcat(lPath, ":auto:", maxLen);
-  OSTRACE3("GETLOCKPATH  proxy lock path=%s pid=%d\n", lPath, getpid());
+  OSTRACE(("GETLOCKPATH  proxy lock path=%s pid=%d\n", lPath, getpid()));
   return SQLITE_OK;
 }
 
@@ -26821,9 +28157,9 @@ static int proxyCreateLockPath(const char *lockPath){
         if( mkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
           int err=errno;
           if( err!=EEXIST ) {
-            OSTRACE5("CREATELOCKPATH  FAILED creating %s, "
+            OSTRACE(("CREATELOCKPATH  FAILED creating %s, "
                      "'%s' proxy lock path=%s pid=%d\n",
-                     buf, strerror(err), lockPath, getpid());
+                     buf, strerror(err), lockPath, getpid()));
             return err;
           }
         }
@@ -26832,7 +28168,7 @@ static int proxyCreateLockPath(const char *lockPath){
     }
     buf[i] = lockPath[i];
   }
-  OSTRACE3("CREATELOCKPATH  proxy lock path=%s pid=%d\n", lockPath, getpid());
+  OSTRACE(("CREATELOCKPATH  proxy lock path=%s pid=%d\n", lockPath, getpid()));
   return 0;
 }
 
@@ -26931,6 +28267,9 @@ SQLITE_API int sqlite3_hostid_num = 0;
 
 #define PROXY_HOSTIDLEN    16  /* conch file host id length */
 
+/* Not always defined in the headers as it ought to be */
+extern int gethostuuid(uuid_t id, const struct timespec *wait);
+
 /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN 
 ** bytes of writable memory.
 */
@@ -26939,6 +28278,8 @@ static int proxyGetHostID(unsigned char *pHostID, int *pError){
   
   assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
   memset(pHostID, 0, PROXY_HOSTIDLEN);
+#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\
+               && __MAC_OS_X_VERSION_MIN_REQUIRED<1050
   if( gethostuuid(pHostID, &timeout) ){
     int err = errno;
     if( pError ){
@@ -26946,6 +28287,7 @@ static int proxyGetHostID(unsigned char *pHostID, int *pError){
     }
     return SQLITE_IOERR;
   }
+#endif
 #ifdef SQLITE_TEST
   /* simulate multiple hosts by creating unique hostid file paths */
   if( sqlite3_hostid_num != 0){
@@ -26980,6 +28322,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){
   char errmsg[64] = "";
   int fd = -1;
   int rc = -1;
+  UNUSED_PARAMETER(myHostID);
 
   /* create a new path by replace the trailing '-conch' with '-break' */
   pathLen = strlcpy(tPath, cPath, MAXPATHLEN);
@@ -27000,7 +28343,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){
     sprintf(errmsg, "create failed (%d)", errno);
     goto end_breaklock;
   }
-  if( pwrite(fd, buf, readLen, 0) != readLen ){
+  if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
     sprintf(errmsg, "write failed (%d)", errno);
     goto end_breaklock;
   }
@@ -27124,8 +28467,8 @@ static int proxyTakeConch(unixFile *pFile){
     int tryOldLockPath = 0;
     int forceNewLockPath = 0;
     
-    OSTRACE4("TAKECONCH  %d for %s pid=%d\n", conchFile->h,
-             (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid());
+    OSTRACE(("TAKECONCH  %d for %s pid=%d\n", conchFile->h,
+             (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid()));
 
     rc = proxyGetHostID(myHostID, &pError);
     if( (rc&0xff)==SQLITE_IOERR ){
@@ -27205,7 +28548,7 @@ static int proxyTakeConch(unixFile *pFile){
       */
       futimes(conchFile->h, NULL);
       if( hostIdMatch && !createConch ){
-        if( conchFile->pLock && conchFile->pLock->cnt>1 ){
+        if( conchFile->pInode && conchFile->pInode->nShared>1 ){
           /* We are trying for an exclusive lock but another thread in this
            ** same process is still holding a shared lock. */
           rc = SQLITE_BUSY;
@@ -27261,7 +28604,7 @@ static int proxyTakeConch(unixFile *pFile){
       conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);
       
     end_takeconch:
-      OSTRACE2("TRANSPROXY: CLOSE  %d\n", pFile->h);
+      OSTRACE(("TRANSPROXY: CLOSE  %d\n", pFile->h));
       if( rc==SQLITE_OK && pFile->openFlags ){
         if( pFile->h>=0 ){
 #ifdef STRICT_CLOSE_ERROR
@@ -27276,7 +28619,7 @@ static int proxyTakeConch(unixFile *pFile){
         pFile->h = -1;
         int fd = open(pCtx->dbPath, pFile->openFlags,
                       SQLITE_DEFAULT_FILE_PERMISSIONS);
-        OSTRACE2("TRANSPROXY: OPEN  %d\n", fd);
+        OSTRACE(("TRANSPROXY: OPEN  %d\n", fd));
         if( fd>=0 ){
           pFile->h = fd;
         }else{
@@ -27318,9 +28661,11 @@ static int proxyTakeConch(unixFile *pFile){
       } else {
         conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
       }
-      OSTRACE3("TAKECONCH  %d %s\n", conchFile->h, rc==SQLITE_OK?"ok":"failed");
+      OSTRACE(("TAKECONCH  %d %s\n", conchFile->h,
+               rc==SQLITE_OK?"ok":"failed"));
       return rc;
-    } while (1); /* in case we need to retry the :auto: lock file - we should never get here except via the 'continue' call. */
+    } while (1); /* in case we need to retry the :auto: lock file - 
+                 ** we should never get here except via the 'continue' call. */
   }
 }
 
@@ -27328,21 +28673,21 @@ static int proxyTakeConch(unixFile *pFile){
 ** If pFile holds a lock on a conch file, then release that lock.
 */
 static int proxyReleaseConch(unixFile *pFile){
-  int rc;                     /* Subroutine return code */
+  int rc = SQLITE_OK;         /* Subroutine return code */
   proxyLockingContext *pCtx;  /* The locking context for the proxy lock */
   unixFile *conchFile;        /* Name of the conch file */
 
   pCtx = (proxyLockingContext *)pFile->lockingContext;
   conchFile = pCtx->conchFile;
-  OSTRACE4("RELEASECONCH  %d for %s pid=%d\n", conchFile->h,
+  OSTRACE(("RELEASECONCH  %d for %s pid=%d\n", conchFile->h,
            (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), 
-           getpid());
+           getpid()));
   if( pCtx->conchHeld>0 ){
     rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
   }
   pCtx->conchHeld = 0;
-  OSTRACE3("RELEASECONCH  %d %s\n", conchFile->h,
-           (rc==SQLITE_OK ? "ok" : "failed"));
+  OSTRACE(("RELEASECONCH  %d %s\n", conchFile->h,
+           (rc==SQLITE_OK ? "ok" : "failed")));
   return rc;
 }
 
@@ -27399,7 +28744,7 @@ static int switchLockProxyPath(unixFile *pFile, const char *path) {
   char *oldPath = pCtx->lockProxyPath;
   int rc = SQLITE_OK;
 
-  if( pFile->locktype!=NO_LOCK ){
+  if( pFile->eFileLock!=NO_LOCK ){
     return SQLITE_BUSY;
   }  
 
@@ -27466,7 +28811,7 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
   char *lockPath=NULL;
   int rc = SQLITE_OK;
   
-  if( pFile->locktype!=NO_LOCK ){
+  if( pFile->eFileLock!=NO_LOCK ){
     return SQLITE_BUSY;
   }
   proxyGetDbPathForUnixFile(pFile, dbPath);
@@ -27476,8 +28821,8 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
     lockPath=(char *)path;
   }
   
-  OSTRACE4("TRANSPROXY  %d for %s pid=%d\n", pFile->h,
-           (lockPath ? lockPath : ":auto:"), getpid());
+  OSTRACE(("TRANSPROXY  %d for %s pid=%d\n", pFile->h,
+           (lockPath ? lockPath : ":auto:"), getpid()));
 
   pCtx = sqlite3_malloc( sizeof(*pCtx) );
   if( pCtx==0 ){
@@ -27533,12 +28878,12 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
       pCtx->conchFile->pMethod->xClose((sqlite3_file *)pCtx->conchFile);
       sqlite3_free(pCtx->conchFile);
     }
-    sqlite3_free(pCtx->lockProxyPath);
+    sqlite3DbFree(0, pCtx->lockProxyPath);
     sqlite3_free(pCtx->conchFilePath); 
     sqlite3_free(pCtx);
   }
-  OSTRACE3("TRANSPROXY  %d %s\n", pFile->h,
-           (rc==SQLITE_OK ? "ok" : "failed"));
+  OSTRACE(("TRANSPROXY  %d %s\n", pFile->h,
+           (rc==SQLITE_OK ? "ok" : "failed")));
   return rc;
 }
 
@@ -27633,7 +28978,7 @@ static int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {
 }
 
 /*
-** Lock the file with the lock specified by parameter locktype - one
+** Lock the file with the lock specified by parameter eFileLock - one
 ** of the following:
 **
 **     (1) SHARED_LOCK
@@ -27656,15 +29001,15 @@ static int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {
 ** This routine will only increase a lock.  Use the sqlite3OsUnlock()
 ** routine to lower a locking level.
 */
-static int proxyLock(sqlite3_file *id, int locktype) {
+static int proxyLock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   int rc = proxyTakeConch(pFile);
   if( rc==SQLITE_OK ){
     proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;
     if( pCtx->conchHeld>0 ){
       unixFile *proxy = pCtx->lockProxy;
-      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, locktype);
-      pFile->locktype = proxy->locktype;
+      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);
+      pFile->eFileLock = proxy->eFileLock;
     }else{
       /* conchHeld < 0 is lockless */
     }
@@ -27674,21 +29019,21 @@ static int proxyLock(sqlite3_file *id, int locktype) {
 
 
 /*
-** Lower the locking level on file descriptor pFile to locktype.  locktype
+** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
-static int proxyUnlock(sqlite3_file *id, int locktype) {
+static int proxyUnlock(sqlite3_file *id, int eFileLock) {
   unixFile *pFile = (unixFile*)id;
   int rc = proxyTakeConch(pFile);
   if( rc==SQLITE_OK ){
     proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;
     if( pCtx->conchHeld>0 ){
       unixFile *proxy = pCtx->lockProxy;
-      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, locktype);
-      pFile->locktype = proxy->locktype;
+      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);
+      pFile->eFileLock = proxy->eFileLock;
     }else{
       /* conchHeld < 0 is lockless */
     }
@@ -27724,9 +29069,9 @@ static int proxyClose(sqlite3_file *id) {
       if( rc ) return rc;
       sqlite3_free(conchFile);
     }
-    sqlite3_free(pCtx->lockProxyPath);
+    sqlite3DbFree(0, pCtx->lockProxyPath);
     sqlite3_free(pCtx->conchFilePath);
-    sqlite3_free(pCtx->dbPath);
+    sqlite3DbFree(0, pCtx->dbPath);
     /* restore the original locking context and pMethod then close it */
     pFile->lockingContext = pCtx->oldLockingContext;
     pFile->pMethod = pCtx->pOldMethod;
@@ -27783,7 +29128,7 @@ SQLITE_API int sqlite3_os_init(void){
   ** that filesystem time.
   */
   #define UNIXVFS(VFSNAME, FINDER) {                        \
-    1,                    /* iVersion */                    \
+    2,                    /* iVersion */                    \
     sizeof(unixFile),     /* szOsFile */                    \
     MAX_PATHNAME,         /* mxPathname */                  \
     0,                    /* pNext */                       \
@@ -27800,7 +29145,8 @@ SQLITE_API int sqlite3_os_init(void){
     unixRandomness,       /* xRandomness */                 \
     unixSleep,            /* xSleep */                      \
     unixCurrentTime,      /* xCurrentTime */                \
-    unixGetLastError      /* xGetLastError */               \
+    unixGetLastError,     /* xGetLastError */               \
+    unixCurrentTimeInt64, /* xCurrentTimeInt64 */           \
   }
 
   /*
@@ -27951,23 +29297,9 @@ SQLITE_API int sqlite3_os_end(void){
 
 #ifdef SQLITE_DEBUG
 SQLITE_PRIVATE int sqlite3OSTrace = 0;
-#define OSTRACE1(X)         if( sqlite3OSTrace ) sqlite3DebugPrintf(X)
-#define OSTRACE2(X,Y)       if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y)
-#define OSTRACE3(X,Y,Z)     if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)   if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B) if( sqlite3OSTrace ) sqlite3DebugPrintf(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D) \
-    if(sqlite3OSTrace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X
 #else
-#define OSTRACE1(X)
-#define OSTRACE2(X,Y)
-#define OSTRACE3(X,Y,Z)
-#define OSTRACE4(X,Y,Z,A)
-#define OSTRACE5(X,Y,Z,A,B)
-#define OSTRACE6(X,Y,Z,A,B,C)
-#define OSTRACE7(X,Y,Z,A,B,C,D)
+#define OSTRACE(X)
 #endif
 
 /*
@@ -28153,6 +29485,10 @@ SQLITE_API int sqlite3_open_file_count = 0;
 # define FormatMessageW(a,b,c,d,e,f,g) 0
 #endif
 
+/* Forward references */
+typedef struct winShm winShm;           /* A connection to shared-memory */
+typedef struct winShmNode winShmNode;   /* A region of shared-memory */
+
 /*
 ** WinCE lacks native support for file locking so we have to fake it
 ** with some code of our own.
@@ -28172,12 +29508,16 @@ typedef struct winceLock {
 */
 typedef struct winFile winFile;
 struct winFile {
-  const sqlite3_io_methods *pMethod;/* Must be first */
+  const sqlite3_io_methods *pMethod; /*** Must be first ***/
+  sqlite3_vfs *pVfs;      /* The VFS used to open this file */
   HANDLE h;               /* Handle for accessing the file */
   unsigned char locktype; /* Type of lock currently held on this file */
   short sharedLockByte;   /* Randomly chosen byte used as a shared lock */
   DWORD lastErrno;        /* The Windows errno from the last I/O error */
   DWORD sectorSize;       /* Sector size of the device file is on */
+  winShm *pShm;           /* Instance of shared memory on this file */
+  const char *zPath;      /* Full pathname of this file */
+  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */
 #if SQLITE_OS_WINCE
   WCHAR *zDeleteOnClose;  /* Name of file to delete when closing */
   HANDLE hMutex;          /* Mutex used to control access to shared lock */  
@@ -28690,6 +30030,42 @@ static BOOL winceLockFileEx(
 ******************************************************************************/
 
 /*
+** Some microsoft compilers lack this definition.
+*/
+#ifndef INVALID_SET_FILE_POINTER
+# define INVALID_SET_FILE_POINTER ((DWORD)-1)
+#endif
+
+/*
+** Move the current position of the file handle passed as the first 
+** argument to offset iOffset within the file. If successful, return 0. 
+** Otherwise, set pFile->lastErrno and return non-zero.
+*/
+static int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){
+  LONG upperBits;                 /* Most sig. 32 bits of new offset */
+  LONG lowerBits;                 /* Least sig. 32 bits of new offset */
+  DWORD dwRet;                    /* Value returned by SetFilePointer() */
+
+  upperBits = (LONG)((iOffset>>32) & 0x7fffffff);
+  lowerBits = (LONG)(iOffset & 0xffffffff);
+
+  /* API oddity: If successful, SetFilePointer() returns a dword 
+  ** containing the lower 32-bits of the new file-offset. Or, if it fails,
+  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, 
+  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine 
+  ** whether an error has actually occured, it is also necessary to call 
+  ** GetLastError().
+  */
+  dwRet = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
+  if( (dwRet==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR) ){
+    pFile->lastErrno = GetLastError();
+    return 1;
+  }
+
+  return 0;
+}
+
+/*
 ** Close a file.
 **
 ** It is reported that an attempt to close a handle might sometimes
@@ -28705,9 +30081,11 @@ static int winClose(sqlite3_file *id){
   winFile *pFile = (winFile*)id;
 
   assert( id!=0 );
-  OSTRACE2("CLOSE %d\n", pFile->h);
+  assert( pFile->pShm==0 );
+  OSTRACE(("CLOSE %d\n", pFile->h));
   do{
     rc = CloseHandle(pFile->h);
+    /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
   }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
 #if SQLITE_OS_WINCE
 #define WINCE_DELETION_ATTEMPTS 3
@@ -28724,18 +30102,12 @@ static int winClose(sqlite3_file *id){
     free(pFile->zDeleteOnClose);
   }
 #endif
+  OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
   OpenCounter(-1);
   return rc ? SQLITE_OK : SQLITE_IOERR;
 }
 
 /*
-** Some microsoft compilers lack this definition.
-*/
-#ifndef INVALID_SET_FILE_POINTER
-# define INVALID_SET_FILE_POINTER ((DWORD)-1)
-#endif
-
-/*
 ** Read data from a file into a buffer.  Return SQLITE_OK if all
 ** bytes were read successfully and SQLITE_IOERR if anything goes
 ** wrong.
@@ -28746,32 +30118,27 @@ static int winRead(
   int amt,                   /* Number of bytes to read */
   sqlite3_int64 offset       /* Begin reading at this offset */
 ){
-  LONG upperBits = (LONG)((offset>>32) & 0x7fffffff);
-  LONG lowerBits = (LONG)(offset & 0xffffffff);
-  DWORD rc;
-  winFile *pFile = (winFile*)id;
-  DWORD error;
-  DWORD got;
+  winFile *pFile = (winFile*)id;  /* file handle */
+  DWORD nRead;                    /* Number of bytes actually read from file */
 
   assert( id!=0 );
   SimulateIOError(return SQLITE_IOERR_READ);
-  OSTRACE3("READ %d lock=%d\n", pFile->h, pFile->locktype);
-  rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
-  if( rc==INVALID_SET_FILE_POINTER && (error=GetLastError())!=NO_ERROR ){
-    pFile->lastErrno = error;
+  OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
+
+  if( seekWinFile(pFile, offset) ){
     return SQLITE_FULL;
   }
-  if( !ReadFile(pFile->h, pBuf, amt, &got, 0) ){
+  if( !ReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
     pFile->lastErrno = GetLastError();
     return SQLITE_IOERR_READ;
   }
-  if( got==(DWORD)amt ){
-    return SQLITE_OK;
-  }else{
+  if( nRead<(DWORD)amt ){
     /* Unread parts of the buffer must be zero-filled */
-    memset(&((char*)pBuf)[got], 0, amt-got);
+    memset(&((char*)pBuf)[nRead], 0, amt-nRead);
     return SQLITE_IOERR_SHORT_READ;
   }
+
+  return SQLITE_OK;
 }
 
 /*
@@ -28779,39 +30146,42 @@ static int winRead(
 ** or some other error code on failure.
 */
 static int winWrite(
-  sqlite3_file *id,         /* File to write into */
-  const void *pBuf,         /* The bytes to be written */
-  int amt,                  /* Number of bytes to write */
-  sqlite3_int64 offset      /* Offset into the file to begin writing at */
+  sqlite3_file *id,               /* File to write into */
+  const void *pBuf,               /* The bytes to be written */
+  int amt,                        /* Number of bytes to write */
+  sqlite3_int64 offset            /* Offset into the file to begin writing at */
 ){
-  LONG upperBits = (LONG)((offset>>32) & 0x7fffffff);
-  LONG lowerBits = (LONG)(offset & 0xffffffff);
-  DWORD rc;
-  winFile *pFile = (winFile*)id;
-  DWORD error;
-  DWORD wrote = 0;
+  int rc;                         /* True if error has occured, else false */
+  winFile *pFile = (winFile*)id;  /* File handle */
 
-  assert( id!=0 );
+  assert( amt>0 );
+  assert( pFile );
   SimulateIOError(return SQLITE_IOERR_WRITE);
   SimulateDiskfullError(return SQLITE_FULL);
-  OSTRACE3("WRITE %d lock=%d\n", pFile->h, pFile->locktype);
-  rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
-  if( rc==INVALID_SET_FILE_POINTER && (error=GetLastError())!=NO_ERROR ){
-    pFile->lastErrno = error;
-    return SQLITE_FULL;
-  }
-  assert( amt>0 );
-  while(
-     amt>0
-     && (rc = WriteFile(pFile->h, pBuf, amt, &wrote, 0))!=0
-     && wrote>0
-  ){
-    amt -= wrote;
-    pBuf = &((char*)pBuf)[wrote];
+
+  OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
+
+  rc = seekWinFile(pFile, offset);
+  if( rc==0 ){
+    u8 *aRem = (u8 *)pBuf;        /* Data yet to be written */
+    int nRem = amt;               /* Number of bytes yet to be written */
+    DWORD nWrite;                 /* Bytes written by each WriteFile() call */
+
+    while( nRem>0 && WriteFile(pFile->h, aRem, nRem, &nWrite, 0) && nWrite>0 ){
+      aRem += nWrite;
+      nRem -= nWrite;
+    }
+    if( nRem>0 ){
+      pFile->lastErrno = GetLastError();
+      rc = 1;
+    }
   }
-  if( !rc || amt>(int)wrote ){
-    pFile->lastErrno = GetLastError();
-    return SQLITE_FULL;
+
+  if( rc ){
+    if( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ){
+      return SQLITE_FULL;
+    }
+    return SQLITE_IOERR_WRITE;
   }
   return SQLITE_OK;
 }
@@ -28820,26 +30190,33 @@ static int winWrite(
 ** Truncate an open file to a specified size
 */
 static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
-  LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
-  LONG lowerBits = (LONG)(nByte & 0xffffffff);
-  DWORD rc;
-  winFile *pFile = (winFile*)id;
-  DWORD error;
+  winFile *pFile = (winFile*)id;  /* File handle object */
+  int rc = SQLITE_OK;             /* Return code for this function */
 
-  assert( id!=0 );
-  OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
+  assert( pFile );
+
+  OSTRACE(("TRUNCATE %d %lld\n", pFile->h, nByte));
   SimulateIOError(return SQLITE_IOERR_TRUNCATE);
-  rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
-  if( rc==INVALID_SET_FILE_POINTER && (error=GetLastError())!=NO_ERROR ){
-    pFile->lastErrno = error;
-    return SQLITE_IOERR_TRUNCATE;
+
+  /* If the user has configured a chunk-size for this file, truncate the
+  ** file so that it consists of an integer number of chunks (i.e. the
+  ** actual file size after the operation may be larger than the requested
+  ** size).
+  */
+  if( pFile->szChunk ){
+    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;
   }
-  /* SetEndOfFile will fail if nByte is negative */
-  if( !SetEndOfFile(pFile->h) ){
+
+  /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
+  if( seekWinFile(pFile, nByte) ){
+    rc = SQLITE_IOERR_TRUNCATE;
+  }else if( 0==SetEndOfFile(pFile->h) ){
     pFile->lastErrno = GetLastError();
-    return SQLITE_IOERR_TRUNCATE;
+    rc = SQLITE_IOERR_TRUNCATE;
   }
-  return SQLITE_OK;
+
+  OSTRACE(("TRUNCATE %d %lld %s\n", pFile->h, nByte, rc ? "failed" : "ok"));
+  return rc;
 }
 
 #ifdef SQLITE_TEST
@@ -28855,14 +30232,20 @@ SQLITE_API int sqlite3_fullsync_count = 0;
 ** Make sure all writes to a particular file are committed to disk.
 */
 static int winSync(sqlite3_file *id, int flags){
-#ifndef SQLITE_NO_SYNC
+#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || defined(SQLITE_DEBUG)
   winFile *pFile = (winFile*)id;
-
-  assert( id!=0 );
-  OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
 #else
   UNUSED_PARAMETER(id);
 #endif
+
+  assert( pFile );
+  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */
+  assert((flags&0x0F)==SQLITE_SYNC_NORMAL
+      || (flags&0x0F)==SQLITE_SYNC_FULL
+  );
+
+  OSTRACE(("SYNC %d lock=%d\n", pFile->h, pFile->locktype));
+
 #ifndef SQLITE_TEST
   UNUSED_PARAMETER(flags);
 #else
@@ -28871,11 +30254,18 @@ static int winSync(sqlite3_file *id, int flags){
   }
   sqlite3_sync_count++;
 #endif
+
+  /* Unix cannot, but some systems may return SQLITE_FULL from here. This
+  ** line is to test that doing so does not cause any problems.
+  */
+  SimulateDiskfullError( return SQLITE_FULL );
+  SimulateIOError( return SQLITE_IOERR; );
+
   /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
   ** no-op
   */
 #ifdef SQLITE_NO_SYNC
-    return SQLITE_OK;
+  return SQLITE_OK;
 #else
   if( FlushFileBuffers(pFile->h) ){
     return SQLITE_OK;
@@ -29000,8 +30390,8 @@ static int winLock(sqlite3_file *id, int locktype){
   DWORD error = NO_ERROR;
 
   assert( id!=0 );
-  OSTRACE5("LOCK %d %d was %d(%d)\n",
-          pFile->h, locktype, pFile->locktype, pFile->sharedLockByte);
+  OSTRACE(("LOCK %d %d was %d(%d)\n",
+           pFile->h, locktype, pFile->locktype, pFile->sharedLockByte));
 
   /* If there is already a lock of this type or more restrictive on the
   ** OsFile, do nothing. Don't use the end_lock: exit path, as
@@ -29031,7 +30421,7 @@ static int winLock(sqlite3_file *id, int locktype){
       /* Try 3 times to get the pending lock.  The pending lock might be
       ** held by another reader process who will release it momentarily.
       */
-      OSTRACE2("could not get a PENDING lock. cnt=%d\n", cnt);
+      OSTRACE(("could not get a PENDING lock. cnt=%d\n", cnt));
       Sleep(1);
     }
     gotPendingLock = res;
@@ -29076,13 +30466,13 @@ static int winLock(sqlite3_file *id, int locktype){
   if( locktype==EXCLUSIVE_LOCK && res ){
     assert( pFile->locktype>=SHARED_LOCK );
     res = unlockReadLock(pFile);
-    OSTRACE2("unreadlock = %d\n", res);
+    OSTRACE(("unreadlock = %d\n", res));
     res = LockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
     if( res ){
       newLocktype = EXCLUSIVE_LOCK;
     }else{
       error = GetLastError();
-      OSTRACE2("error-code = %d\n", error);
+      OSTRACE(("error-code = %d\n", error));
       getReadLock(pFile);
     }
   }
@@ -29100,8 +30490,8 @@ static int winLock(sqlite3_file *id, int locktype){
   if( res ){
     rc = SQLITE_OK;
   }else{
-    OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
-           locktype, newLocktype);
+    OSTRACE(("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
+           locktype, newLocktype));
     pFile->lastErrno = error;
     rc = SQLITE_BUSY;
   }
@@ -29118,17 +30508,19 @@ static int winCheckReservedLock(sqlite3_file *id, int *pResOut){
   int rc;
   winFile *pFile = (winFile*)id;
 
+  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
+
   assert( id!=0 );
   if( pFile->locktype>=RESERVED_LOCK ){
     rc = 1;
-    OSTRACE3("TEST WR-LOCK %d %d (local)\n", pFile->h, rc);
+    OSTRACE(("TEST WR-LOCK %d %d (local)\n", pFile->h, rc));
   }else{
     rc = LockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
     if( rc ){
       UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
     }
     rc = !rc;
-    OSTRACE3("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc);
+    OSTRACE(("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc));
   }
   *pResOut = rc;
   return SQLITE_OK;
@@ -29151,8 +30543,8 @@ static int winUnlock(sqlite3_file *id, int locktype){
   int rc = SQLITE_OK;
   assert( pFile!=0 );
   assert( locktype<=SHARED_LOCK );
-  OSTRACE5("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
-          pFile->locktype, pFile->sharedLockByte);
+  OSTRACE(("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
+          pFile->locktype, pFile->sharedLockByte));
   type = pFile->locktype;
   if( type>=EXCLUSIVE_LOCK ){
     UnlockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
@@ -29188,6 +30580,17 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
       *(int*)pArg = (int)((winFile*)id)->lastErrno;
       return SQLITE_OK;
     }
+    case SQLITE_FCNTL_CHUNK_SIZE: {
+      ((winFile*)id)->szChunk = *(int *)pArg;
+      return SQLITE_OK;
+    }
+    case SQLITE_FCNTL_SIZE_HINT: {
+      sqlite3_int64 sz = *(sqlite3_int64*)pArg;
+      SimulateIOErrorBenign(1);
+      winTruncate(id, sz);
+      SimulateIOErrorBenign(0);
+      return SQLITE_OK;
+    }
   }
   return SQLITE_ERROR;
 }
@@ -29212,34 +30615,673 @@ static int winSectorSize(sqlite3_file *id){
 */
 static int winDeviceCharacteristics(sqlite3_file *id){
   UNUSED_PARAMETER(id);
-  return 0;
+  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN;
+}
+
+#ifndef SQLITE_OMIT_WAL
+
+/* 
+** Windows will only let you create file view mappings
+** on allocation size granularity boundaries.
+** During sqlite3_os_init() we do a GetSystemInfo()
+** to get the granularity size.
+*/
+SYSTEM_INFO winSysInfo;
+
+/*
+** Helper functions to obtain and relinquish the global mutex. The
+** global mutex is used to protect the winLockInfo objects used by 
+** this file, all of which may be shared by multiple threads.
+**
+** Function winShmMutexHeld() is used to assert() that the global mutex 
+** is held when required. This function is only used as part of assert() 
+** statements. e.g.
+**
+**   winShmEnterMutex()
+**     assert( winShmMutexHeld() );
+**   winShmLeaveMutex()
+*/
+static void winShmEnterMutex(void){
+  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
+}
+static void winShmLeaveMutex(void){
+  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
+}
+#ifdef SQLITE_DEBUG
+static int winShmMutexHeld(void) {
+  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
+}
+#endif
+
+/*
+** Object used to represent a single file opened and mmapped to provide
+** shared memory.  When multiple threads all reference the same
+** log-summary, each thread has its own winFile object, but they all
+** point to a single instance of this object.  In other words, each
+** log-summary is opened only once per process.
+**
+** winShmMutexHeld() must be true when creating or destroying
+** this object or while reading or writing the following fields:
+**
+**      nRef
+**      pNext 
+**
+** The following fields are read-only after the object is created:
+** 
+**      fid
+**      zFilename
+**
+** Either winShmNode.mutex must be held or winShmNode.nRef==0 and
+** winShmMutexHeld() is true when reading or writing any other field
+** in this structure.
+**
+*/
+struct winShmNode {
+  sqlite3_mutex *mutex;      /* Mutex to access this object */
+  char *zFilename;           /* Name of the file */
+  winFile hFile;             /* File handle from winOpen */
+
+  int szRegion;              /* Size of shared-memory regions */
+  int nRegion;               /* Size of array apRegion */
+  struct ShmRegion {
+    HANDLE hMap;             /* File handle from CreateFileMapping */
+    void *pMap;
+  } *aRegion;
+  DWORD lastErrno;           /* The Windows errno from the last I/O error */
+
+  int nRef;                  /* Number of winShm objects pointing to this */
+  winShm *pFirst;            /* All winShm objects pointing to this */
+  winShmNode *pNext;         /* Next in list of all winShmNode objects */
+#ifdef SQLITE_DEBUG
+  u8 nextShmId;              /* Next available winShm.id value */
+#endif
+};
+
+/*
+** A global array of all winShmNode objects.
+**
+** The winShmMutexHeld() must be true while reading or writing this list.
+*/
+static winShmNode *winShmNodeList = 0;
+
+/*
+** Structure used internally by this VFS to record the state of an
+** open shared memory connection.
+**
+** The following fields are initialized when this object is created and
+** are read-only thereafter:
+**
+**    winShm.pShmNode
+**    winShm.id
+**
+** All other fields are read/write.  The winShm.pShmNode->mutex must be held
+** while accessing any read/write fields.
+*/
+struct winShm {
+  winShmNode *pShmNode;      /* The underlying winShmNode object */
+  winShm *pNext;             /* Next winShm with the same winShmNode */
+  u8 hasMutex;               /* True if holding the winShmNode mutex */
+  u16 sharedMask;            /* Mask of shared locks held */
+  u16 exclMask;              /* Mask of exclusive locks held */
+#ifdef SQLITE_DEBUG
+  u8 id;                     /* Id of this connection with its winShmNode */
+#endif
+};
+
+/*
+** Constants used for locking
+*/
+#define WIN_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)        /* first lock byte */
+#define WIN_SHM_DMS    (WIN_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */
+
+/*
+** Apply advisory locks for all n bytes beginning at ofst.
+*/
+#define _SHM_UNLCK  1
+#define _SHM_RDLCK  2
+#define _SHM_WRLCK  3
+static int winShmSystemLock(
+  winShmNode *pFile,    /* Apply locks to this open shared-memory segment */
+  int lockType,         /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */
+  int ofst,             /* Offset to first byte to be locked/unlocked */
+  int nByte             /* Number of bytes to lock or unlock */
+){
+  OVERLAPPED ovlp;
+  DWORD dwFlags;
+  int rc = 0;           /* Result code form Lock/UnlockFileEx() */
+
+  /* Access to the winShmNode object is serialized by the caller */
+  assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );
+
+  /* Initialize the locking parameters */
+  dwFlags = LOCKFILE_FAIL_IMMEDIATELY;
+  if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;
+
+  memset(&ovlp, 0, sizeof(OVERLAPPED));
+  ovlp.Offset = ofst;
+
+  /* Release/Acquire the system-level lock */
+  if( lockType==_SHM_UNLCK ){
+    rc = UnlockFileEx(pFile->hFile.h, 0, nByte, 0, &ovlp);
+  }else{
+    rc = LockFileEx(pFile->hFile.h, dwFlags, 0, nByte, 0, &ovlp);
+  }
+  
+  if( rc!= 0 ){
+    rc = SQLITE_OK;
+  }else{
+    pFile->lastErrno =  GetLastError();
+    rc = SQLITE_BUSY;
+  }
+
+  OSTRACE(("SHM-LOCK %d %s %s 0x%08lx\n", 
+           pFile->hFile.h,
+           rc==SQLITE_OK ? "ok" : "failed",
+           lockType==_SHM_UNLCK ? "UnlockFileEx" : "LockFileEx",
+           pFile->lastErrno));
+
+  return rc;
+}
+
+/* Forward references to VFS methods */
+static int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);
+static int winDelete(sqlite3_vfs *,const char*,int);
+
+/*
+** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.
+**
+** This is not a VFS shared-memory method; it is a utility function called
+** by VFS shared-memory methods.
+*/
+static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){
+  winShmNode **pp;
+  winShmNode *p;
+  BOOL bRc;
+  assert( winShmMutexHeld() );
+  pp = &winShmNodeList;
+  while( (p = *pp)!=0 ){
+    if( p->nRef==0 ){
+      int i;
+      if( p->mutex ) sqlite3_mutex_free(p->mutex);
+      for(i=0; i<p->nRegion; i++){
+        bRc = UnmapViewOfFile(p->aRegion[i].pMap);
+        OSTRACE(("SHM-PURGE pid-%d unmap region=%d %s\n",
+                 (int)GetCurrentProcessId(), i,
+                 bRc ? "ok" : "failed"));
+        bRc = CloseHandle(p->aRegion[i].hMap);
+        OSTRACE(("SHM-PURGE pid-%d close region=%d %s\n",
+                 (int)GetCurrentProcessId(), i,
+                 bRc ? "ok" : "failed"));
+      }
+      if( p->hFile.h != INVALID_HANDLE_VALUE ){
+        SimulateIOErrorBenign(1);
+        winClose((sqlite3_file *)&p->hFile);
+        SimulateIOErrorBenign(0);
+      }
+      if( deleteFlag ){
+        SimulateIOErrorBenign(1);
+        winDelete(pVfs, p->zFilename, 0);
+        SimulateIOErrorBenign(0);
+      }
+      *pp = p->pNext;
+      sqlite3_free(p->aRegion);
+      sqlite3_free(p);
+    }else{
+      pp = &p->pNext;
+    }
+  }
+}
+
+/*
+** Open the shared-memory area associated with database file pDbFd.
+**
+** When opening a new shared-memory file, if no other instances of that
+** file are currently open, in this process or in other processes, then
+** the file must be truncated to zero length or have its header cleared.
+*/
+static int winOpenSharedMemory(winFile *pDbFd){
+  struct winShm *p;                  /* The connection to be opened */
+  struct winShmNode *pShmNode = 0;   /* The underlying mmapped file */
+  int rc;                            /* Result code */
+  struct winShmNode *pNew;           /* Newly allocated winShmNode */
+  int nName;                         /* Size of zName in bytes */
+
+  assert( pDbFd->pShm==0 );    /* Not previously opened */
+
+  /* Allocate space for the new sqlite3_shm object.  Also speculatively
+  ** allocate space for a new winShmNode and filename.
+  */
+  p = sqlite3_malloc( sizeof(*p) );
+  if( p==0 ) return SQLITE_NOMEM;
+  memset(p, 0, sizeof(*p));
+  nName = sqlite3Strlen30(pDbFd->zPath);
+  pNew = sqlite3_malloc( sizeof(*pShmNode) + nName + 15 );
+  if( pNew==0 ){
+    sqlite3_free(p);
+    return SQLITE_NOMEM;
+  }
+  memset(pNew, 0, sizeof(*pNew));
+  pNew->zFilename = (char*)&pNew[1];
+  sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath);
+
+  /* Look to see if there is an existing winShmNode that can be used.
+  ** If no matching winShmNode currently exists, create a new one.
+  */
+  winShmEnterMutex();
+  for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){
+    /* TBD need to come up with better match here.  Perhaps
+    ** use FILE_ID_BOTH_DIR_INFO Structure.
+    */
+    if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;
+  }
+  if( pShmNode ){
+    sqlite3_free(pNew);
+  }else{
+    pShmNode = pNew;
+    pNew = 0;
+    ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE;
+    pShmNode->pNext = winShmNodeList;
+    winShmNodeList = pShmNode;
+
+    pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);
+    if( pShmNode->mutex==0 ){
+      rc = SQLITE_NOMEM;
+      goto shm_open_err;
+    }
+
+    rc = winOpen(pDbFd->pVfs,
+                 pShmNode->zFilename,             /* Name of the file (UTF-8) */
+                 (sqlite3_file*)&pShmNode->hFile,  /* File handle here */
+                 SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, /* Mode flags */
+                 0);
+    if( SQLITE_OK!=rc ){
+      rc = SQLITE_CANTOPEN_BKPT;
+      goto shm_open_err;
+    }
+
+    /* Check to see if another process is holding the dead-man switch.
+    ** If not, truncate the file to zero length. 
+    */
+    if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
+      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
+      if( rc!=SQLITE_OK ){
+        rc = SQLITE_IOERR_SHMOPEN;
+      }
+    }
+    if( rc==SQLITE_OK ){
+      winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
+      rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
+    }
+    if( rc ) goto shm_open_err;
+  }
+
+  /* Make the new connection a child of the winShmNode */
+  p->pShmNode = pShmNode;
+#ifdef SQLITE_DEBUG
+  p->id = pShmNode->nextShmId++;
+#endif
+  pShmNode->nRef++;
+  pDbFd->pShm = p;
+  winShmLeaveMutex();
+
+  /* The reference count on pShmNode has already been incremented under
+  ** the cover of the winShmEnterMutex() mutex and the pointer from the
+  ** new (struct winShm) object to the pShmNode has been set. All that is
+  ** left to do is to link the new object into the linked list starting
+  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex 
+  ** mutex.
+  */
+  sqlite3_mutex_enter(pShmNode->mutex);
+  p->pNext = pShmNode->pFirst;
+  pShmNode->pFirst = p;
+  sqlite3_mutex_leave(pShmNode->mutex);
+  return SQLITE_OK;
+
+  /* Jump here on any error */
+shm_open_err:
+  winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
+  winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */
+  sqlite3_free(p);
+  sqlite3_free(pNew);
+  winShmLeaveMutex();
+  return rc;
+}
+
+/*
+** Close a connection to shared-memory.  Delete the underlying 
+** storage if deleteFlag is true.
+*/
+static int winShmUnmap(
+  sqlite3_file *fd,          /* Database holding shared memory */
+  int deleteFlag             /* Delete after closing if true */
+){
+  winFile *pDbFd;       /* Database holding shared-memory */
+  winShm *p;            /* The connection to be closed */
+  winShmNode *pShmNode; /* The underlying shared-memory file */
+  winShm **pp;          /* For looping over sibling connections */
+
+  pDbFd = (winFile*)fd;
+  p = pDbFd->pShm;
+  if( p==0 ) return SQLITE_OK;
+  pShmNode = p->pShmNode;
+
+  /* Remove connection p from the set of connections associated
+  ** with pShmNode */
+  sqlite3_mutex_enter(pShmNode->mutex);
+  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}
+  *pp = p->pNext;
+
+  /* Free the connection p */
+  sqlite3_free(p);
+  pDbFd->pShm = 0;
+  sqlite3_mutex_leave(pShmNode->mutex);
+
+  /* If pShmNode->nRef has reached 0, then close the underlying
+  ** shared-memory file, too */
+  winShmEnterMutex();
+  assert( pShmNode->nRef>0 );
+  pShmNode->nRef--;
+  if( pShmNode->nRef==0 ){
+    winShmPurge(pDbFd->pVfs, deleteFlag);
+  }
+  winShmLeaveMutex();
+
+  return SQLITE_OK;
+}
+
+/*
+** Change the lock state for a shared-memory segment.
+*/
+static int winShmLock(
+  sqlite3_file *fd,          /* Database file holding the shared memory */
+  int ofst,                  /* First lock to acquire or release */
+  int n,                     /* Number of locks to acquire or release */
+  int flags                  /* What to do with the lock */
+){
+  winFile *pDbFd = (winFile*)fd;        /* Connection holding shared memory */
+  winShm *p = pDbFd->pShm;              /* The shared memory being locked */
+  winShm *pX;                           /* For looping over all siblings */
+  winShmNode *pShmNode = p->pShmNode;
+  int rc = SQLITE_OK;                   /* Result code */
+  u16 mask;                             /* Mask of locks to take or release */
+
+  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );
+  assert( n>=1 );
+  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
+       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)
+       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)
+       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );
+  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );
+
+  mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));
+  assert( n>1 || mask==(1<<ofst) );
+  sqlite3_mutex_enter(pShmNode->mutex);
+  if( flags & SQLITE_SHM_UNLOCK ){
+    u16 allMask = 0; /* Mask of locks held by siblings */
+
+    /* See if any siblings hold this same lock */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( pX==p ) continue;
+      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );
+      allMask |= pX->sharedMask;
+    }
+
+    /* Unlock the system-level locks */
+    if( (mask & allMask)==0 ){
+      rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n);
+    }else{
+      rc = SQLITE_OK;
+    }
+
+    /* Undo the local locks */
+    if( rc==SQLITE_OK ){
+      p->exclMask &= ~mask;
+      p->sharedMask &= ~mask;
+    } 
+  }else if( flags & SQLITE_SHM_SHARED ){
+    u16 allShared = 0;  /* Union of locks held by connections other than "p" */
+
+    /* Find out which shared locks are already held by sibling connections.
+    ** If any sibling already holds an exclusive lock, go ahead and return
+    ** SQLITE_BUSY.
+    */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( (pX->exclMask & mask)!=0 ){
+        rc = SQLITE_BUSY;
+        break;
+      }
+      allShared |= pX->sharedMask;
+    }
+
+    /* Get shared locks at the system level, if necessary */
+    if( rc==SQLITE_OK ){
+      if( (allShared & mask)==0 ){
+        rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n);
+      }else{
+        rc = SQLITE_OK;
+      }
+    }
+
+    /* Get the local shared locks */
+    if( rc==SQLITE_OK ){
+      p->sharedMask |= mask;
+    }
+  }else{
+    /* Make sure no sibling connections hold locks that will block this
+    ** lock.  If any do, return SQLITE_BUSY right away.
+    */
+    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){
+      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){
+        rc = SQLITE_BUSY;
+        break;
+      }
+    }
+  
+    /* Get the exclusive locks at the system level.  Then if successful
+    ** also mark the local connection as being locked.
+    */
+    if( rc==SQLITE_OK ){
+      rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);
+      if( rc==SQLITE_OK ){
+        assert( (p->sharedMask & mask)==0 );
+        p->exclMask |= mask;
+      }
+    }
+  }
+  sqlite3_mutex_leave(pShmNode->mutex);
+  OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x %s\n",
+           p->id, (int)GetCurrentProcessId(), p->sharedMask, p->exclMask,
+           rc ? "failed" : "ok"));
+  return rc;
+}
+
+/*
+** Implement a memory barrier or memory fence on shared memory.  
+**
+** All loads and stores begun before the barrier must complete before
+** any load or store begun after the barrier.
+*/
+static void winShmBarrier(
+  sqlite3_file *fd          /* Database holding the shared memory */
+){
+  UNUSED_PARAMETER(fd);
+  /* MemoryBarrier(); // does not work -- do not know why not */
+  winShmEnterMutex();
+  winShmLeaveMutex();
+}
+
+/*
+** This function is called to obtain a pointer to region iRegion of the 
+** shared-memory associated with the database file fd. Shared-memory regions 
+** are numbered starting from zero. Each shared-memory region is szRegion 
+** bytes in size.
+**
+** If an error occurs, an error code is returned and *pp is set to NULL.
+**
+** Otherwise, if the isWrite parameter is 0 and the requested shared-memory
+** region has not been allocated (by any client, including one running in a
+** separate process), then *pp is set to NULL and SQLITE_OK returned. If 
+** isWrite is non-zero and the requested shared-memory region has not yet 
+** been allocated, it is allocated by this function.
+**
+** If the shared-memory region has already been allocated or is allocated by
+** this call as described above, then it is mapped into this processes 
+** address space (if it is not already), *pp is set to point to the mapped 
+** memory and SQLITE_OK returned.
+*/
+static int winShmMap(
+  sqlite3_file *fd,               /* Handle open on database file */
+  int iRegion,                    /* Region to retrieve */
+  int szRegion,                   /* Size of regions */
+  int isWrite,                    /* True to extend file if necessary */
+  void volatile **pp              /* OUT: Mapped memory */
+){
+  winFile *pDbFd = (winFile*)fd;
+  winShm *p = pDbFd->pShm;
+  winShmNode *pShmNode;
+  int rc = SQLITE_OK;
+
+  if( !p ){
+    rc = winOpenSharedMemory(pDbFd);
+    if( rc!=SQLITE_OK ) return rc;
+    p = pDbFd->pShm;
+  }
+  pShmNode = p->pShmNode;
+
+  sqlite3_mutex_enter(pShmNode->mutex);
+  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
+
+  if( pShmNode->nRegion<=iRegion ){
+    struct ShmRegion *apNew;           /* New aRegion[] array */
+    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */
+    sqlite3_int64 sz;                  /* Current size of wal-index file */
+
+    pShmNode->szRegion = szRegion;
+
+    /* The requested region is not mapped into this processes address space.
+    ** Check to see if it has been allocated (i.e. if the wal-index file is
+    ** large enough to contain the requested region).
+    */
+    rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
+    if( rc!=SQLITE_OK ){
+      rc = SQLITE_IOERR_SHMSIZE;
+      goto shmpage_out;
+    }
+
+    if( sz<nByte ){
+      /* The requested memory region does not exist. If isWrite is set to
+      ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.
+      **
+      ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate
+      ** the requested memory region.
+      */
+      if( !isWrite ) goto shmpage_out;
+      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
+      if( rc!=SQLITE_OK ){
+        rc = SQLITE_IOERR_SHMSIZE;
+        goto shmpage_out;
+      }
+    }
+
+    /* Map the requested memory region into this processes address space. */
+    apNew = (struct ShmRegion *)sqlite3_realloc(
+        pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
+    );
+    if( !apNew ){
+      rc = SQLITE_IOERR_NOMEM;
+      goto shmpage_out;
+    }
+    pShmNode->aRegion = apNew;
+
+    while( pShmNode->nRegion<=iRegion ){
+      HANDLE hMap;                /* file-mapping handle */
+      void *pMap = 0;             /* Mapped memory region */
+     
+      hMap = CreateFileMapping(pShmNode->hFile.h, 
+          NULL, PAGE_READWRITE, 0, nByte, NULL
+      );
+      OSTRACE(("SHM-MAP pid-%d create region=%d nbyte=%d %s\n",
+               (int)GetCurrentProcessId(), pShmNode->nRegion, nByte,
+               hMap ? "ok" : "failed"));
+      if( hMap ){
+        int iOffset = pShmNode->nRegion*szRegion;
+        int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
+        pMap = MapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,
+            0, iOffset - iOffsetShift, szRegion + iOffsetShift
+        );
+        OSTRACE(("SHM-MAP pid-%d map region=%d offset=%d size=%d %s\n",
+                 (int)GetCurrentProcessId(), pShmNode->nRegion, iOffset, szRegion,
+                 pMap ? "ok" : "failed"));
+      }
+      if( !pMap ){
+        pShmNode->lastErrno = GetLastError();
+        rc = SQLITE_IOERR;
+        if( hMap ) CloseHandle(hMap);
+        goto shmpage_out;
+      }
+
+      pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;
+      pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;
+      pShmNode->nRegion++;
+    }
+  }
+
+shmpage_out:
+  if( pShmNode->nRegion>iRegion ){
+    int iOffset = iRegion*szRegion;
+    int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
+    char *p = (char *)pShmNode->aRegion[iRegion].pMap;
+    *pp = (void *)&p[iOffsetShift];
+  }else{
+    *pp = 0;
+  }
+  sqlite3_mutex_leave(pShmNode->mutex);
+  return rc;
 }
 
+#else
+# define winShmMap     0
+# define winShmLock    0
+# define winShmBarrier 0
+# define winShmUnmap   0
+#endif /* #ifndef SQLITE_OMIT_WAL */
+
+/*
+** Here ends the implementation of all sqlite3_file methods.
+**
+********************** End sqlite3_file Methods *******************************
+******************************************************************************/
+
 /*
 ** This vector defines all the methods that can operate on an
 ** sqlite3_file for win32.
 */
 static const sqlite3_io_methods winIoMethod = {
-  1,                        /* iVersion */
-  winClose,
-  winRead,
-  winWrite,
-  winTruncate,
-  winSync,
-  winFileSize,
-  winLock,
-  winUnlock,
-  winCheckReservedLock,
-  winFileControl,
-  winSectorSize,
-  winDeviceCharacteristics
+  2,                              /* iVersion */
+  winClose,                       /* xClose */
+  winRead,                        /* xRead */
+  winWrite,                       /* xWrite */
+  winTruncate,                    /* xTruncate */
+  winSync,                        /* xSync */
+  winFileSize,                    /* xFileSize */
+  winLock,                        /* xLock */
+  winUnlock,                      /* xUnlock */
+  winCheckReservedLock,           /* xCheckReservedLock */
+  winFileControl,                 /* xFileControl */
+  winSectorSize,                  /* xSectorSize */
+  winDeviceCharacteristics,       /* xDeviceCharacteristics */
+  winShmMap,                      /* xShmMap */
+  winShmLock,                     /* xShmLock */
+  winShmBarrier,                  /* xShmBarrier */
+  winShmUnmap                     /* xShmUnmap */
 };
 
-/***************************************************************************
-** Here ends the I/O methods that form the sqlite3_io_methods object.
+/****************************************************************************
+**************************** sqlite3_vfs methods ****************************
 **
-** The next block of code implements the VFS methods.
-****************************************************************************/
+** This division contains the implementation of methods on the
+** sqlite3_vfs object.
+*/
 
 /*
 ** Convert a UTF-8 filename into whatever form the underlying
@@ -29273,6 +31315,13 @@ static int getTempname(int nBuf, char *zBuf){
     "0123456789";
   size_t i, j;
   char zTempPath[MAX_PATH+1];
+
+  /* It's odd to simulate an io-error here, but really this is just
+  ** using the io-error infrastructure to test that SQLite handles this
+  ** function failing. 
+  */
+  SimulateIOError( return SQLITE_IOERR );
+
   if( sqlite3_temp_directory ){
     sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
   }else if( isNT() ){
@@ -29304,17 +31353,27 @@ static int getTempname(int nBuf, char *zBuf){
     }
 #endif
   }
+
+  /* Check that the output buffer is large enough for the temporary file 
+  ** name. If it is not, return SQLITE_ERROR.
+  */
+  if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
+    return SQLITE_ERROR;
+  }
+
   for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
   zTempPath[i] = 0;
-  sqlite3_snprintf(nBuf-30, zBuf,
+
+  sqlite3_snprintf(nBuf-17, zBuf,
                    "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
   j = sqlite3Strlen30(zBuf);
-  sqlite3_randomness(20, &zBuf[j]);
-  for(i=0; i<20; i++, j++){
+  sqlite3_randomness(15, &zBuf[j]);
+  for(i=0; i<15; i++, j++){
     zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
   }
   zBuf[j] = 0;
-  OSTRACE2("TEMP FILENAME: %s\n", zBuf);
+
+  OSTRACE(("TEMP FILENAME: %s\n", zBuf));
   return SQLITE_OK; 
 }
 
@@ -29399,18 +31458,72 @@ static int winOpen(
   int isTemp = 0;
 #endif
   winFile *pFile = (winFile*)id;
-  void *zConverted;                 /* Filename in OS encoding */
-  const char *zUtf8Name = zName;    /* Filename in UTF-8 encoding */
-  char zTmpname[MAX_PATH+1];        /* Buffer used to create temp filename */
+  void *zConverted;              /* Filename in OS encoding */
+  const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */
+
+  /* If argument zPath is a NULL pointer, this function is required to open
+  ** a temporary file. Use this buffer to store the file name in.
+  */
+  char zTmpname[MAX_PATH+1];     /* Buffer used to create temp filename */
+
+  int rc = SQLITE_OK;            /* Function Return Code */
+#if !defined(NDEBUG) || SQLITE_OS_WINCE
+  int eType = flags&0xFFFFFF00;  /* Type of file to open */
+#endif
+
+  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);
+  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);
+  int isCreate     = (flags & SQLITE_OPEN_CREATE);
+#ifndef NDEBUG
+  int isReadonly   = (flags & SQLITE_OPEN_READONLY);
+#endif
+  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);
+
+#ifndef NDEBUG
+  int isOpenJournal = (isCreate && (
+        eType==SQLITE_OPEN_MASTER_JOURNAL 
+     || eType==SQLITE_OPEN_MAIN_JOURNAL 
+     || eType==SQLITE_OPEN_WAL
+  ));
+#endif
+
+  /* Check the following statements are true: 
+  **
+  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and 
+  **   (b) if CREATE is set, then READWRITE must also be set, and
+  **   (c) if EXCLUSIVE is set, then CREATE must also be set.
+  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.
+  */
+  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));
+  assert(isCreate==0 || isReadWrite);
+  assert(isExclusive==0 || isCreate);
+  assert(isDelete==0 || isCreate);
+
+  /* The main DB, main journal, WAL file and master journal are never 
+  ** automatically deleted. Nor are they ever temporary files.  */
+  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );
+  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );
+  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );
+  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );
+
+  /* Assert that the upper layer has set one of the "file-type" flags. */
+  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB 
+       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL 
+       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL 
+       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
+  );
 
   assert( id!=0 );
   UNUSED_PARAMETER(pVfs);
 
+  pFile->h = INVALID_HANDLE_VALUE;
+
   /* If the second argument to this function is NULL, generate a 
   ** temporary file name to use 
   */
   if( !zUtf8Name ){
-    int rc = getTempname(MAX_PATH+1, zTmpname);
+    assert(isDelete && !isOpenJournal);
+    rc = getTempname(MAX_PATH+1, zTmpname);
     if( rc!=SQLITE_OK ){
       return rc;
     }
@@ -29423,29 +31536,31 @@ static int winOpen(
     return SQLITE_NOMEM;
   }
 
-  if( flags & SQLITE_OPEN_READWRITE ){
+  if( isReadWrite ){
     dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
   }else{
     dwDesiredAccess = GENERIC_READ;
   }
+
   /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is 
   ** created. SQLite doesn't use it to indicate "exclusive access" 
   ** as it is usually understood.
   */
-  assert(!(flags & SQLITE_OPEN_EXCLUSIVE) || (flags & SQLITE_OPEN_CREATE));
-  if( flags & SQLITE_OPEN_EXCLUSIVE ){
+  if( isExclusive ){
     /* Creates a new file, only if it does not already exist. */
     /* If the file exists, it fails. */
     dwCreationDisposition = CREATE_NEW;
-  }else if( flags & SQLITE_OPEN_CREATE ){
+  }else if( isCreate ){
     /* Open existing file, or create if it doesn't exist */
     dwCreationDisposition = OPEN_ALWAYS;
   }else{
     /* Opens a file, only if it exists. */
     dwCreationDisposition = OPEN_EXISTING;
   }
+
   dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
-  if( flags & SQLITE_OPEN_DELETEONCLOSE ){
+
+  if( isDelete ){
 #if SQLITE_OS_WINCE
     dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;
     isTemp = 1;
@@ -29462,6 +31577,7 @@ static int winOpen(
 #if SQLITE_OS_WINCE
   dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
 #endif
+
   if( isNT() ){
     h = CreateFileW((WCHAR*)zConverted,
        dwDesiredAccess,
@@ -29487,30 +31603,41 @@ static int winOpen(
     );
 #endif
   }
+
+  OSTRACE(("OPEN %d %s 0x%lx %s\n", 
+           h, zName, dwDesiredAccess, 
+           h==INVALID_HANDLE_VALUE ? "failed" : "ok"));
+
   if( h==INVALID_HANDLE_VALUE ){
+    pFile->lastErrno = GetLastError();
     free(zConverted);
-    if( flags & SQLITE_OPEN_READWRITE ){
+    if( isReadWrite ){
       return winOpen(pVfs, zName, id, 
-             ((flags|SQLITE_OPEN_READONLY)&~SQLITE_OPEN_READWRITE), pOutFlags);
+             ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), pOutFlags);
     }else{
       return SQLITE_CANTOPEN_BKPT;
     }
   }
+
   if( pOutFlags ){
-    if( flags & SQLITE_OPEN_READWRITE ){
+    if( isReadWrite ){
       *pOutFlags = SQLITE_OPEN_READWRITE;
     }else{
       *pOutFlags = SQLITE_OPEN_READONLY;
     }
   }
+
   memset(pFile, 0, sizeof(*pFile));
   pFile->pMethod = &winIoMethod;
   pFile->h = h;
   pFile->lastErrno = NO_ERROR;
+  pFile->pVfs = pVfs;
+  pFile->pShm = 0;
+  pFile->zPath = zName;
   pFile->sectorSize = getSectorSize(pVfs, zUtf8Name);
+
 #if SQLITE_OS_WINCE
-  if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==
-               (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)
+  if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB
        && !winceCreateLock(zName, pFile)
   ){
     CloseHandle(h);
@@ -29524,8 +31651,9 @@ static int winOpen(
   {
     free(zConverted);
   }
+
   OpenCounter(+1);
-  return SQLITE_OK;
+  return rc;
 }
 
 /*
@@ -29549,13 +31677,15 @@ static int winDelete(
   int cnt = 0;
   DWORD rc;
   DWORD error = 0;
-  void *zConverted = convertUtf8Filename(zFilename);
+  void *zConverted;
   UNUSED_PARAMETER(pVfs);
   UNUSED_PARAMETER(syncDir);
+
+  SimulateIOError(return SQLITE_IOERR_DELETE);
+  zConverted = convertUtf8Filename(zFilename);
   if( zConverted==0 ){
     return SQLITE_NOMEM;
   }
-  SimulateIOError(return SQLITE_IOERR_DELETE);
   if( isNT() ){
     do{
       DeleteFileW(zConverted);
@@ -29578,7 +31708,10 @@ static int winDelete(
 #endif
   }
   free(zConverted);
-  OSTRACE2("DELETE \"%s\"\n", zFilename);
+  OSTRACE(("DELETE \"%s\" %s\n", zFilename,
+       ( (rc==INVALID_FILE_ATTRIBUTES) && (error==ERROR_FILE_NOT_FOUND)) ?
+         "ok" : "failed" ));
+ 
   return (   (rc == INVALID_FILE_ATTRIBUTES) 
           && (error == ERROR_FILE_NOT_FOUND)) ? SQLITE_OK : SQLITE_IOERR_DELETE;
 }
@@ -29594,13 +31727,38 @@ static int winAccess(
 ){
   DWORD attr;
   int rc = 0;
-  void *zConverted = convertUtf8Filename(zFilename);
+  void *zConverted;
   UNUSED_PARAMETER(pVfs);
+
+  SimulateIOError( return SQLITE_IOERR_ACCESS; );
+  zConverted = convertUtf8Filename(zFilename);
   if( zConverted==0 ){
     return SQLITE_NOMEM;
   }
   if( isNT() ){
-    attr = GetFileAttributesW((WCHAR*)zConverted);
+    WIN32_FILE_ATTRIBUTE_DATA sAttrData;
+    memset(&sAttrData, 0, sizeof(sAttrData));
+    if( GetFileAttributesExW((WCHAR*)zConverted,
+                             GetFileExInfoStandard, 
+                             &sAttrData) ){
+      /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file
+      ** as if it does not exist.
+      */
+      if(    flags==SQLITE_ACCESS_EXISTS
+          && sAttrData.nFileSizeHigh==0 
+          && sAttrData.nFileSizeLow==0 ){
+        attr = INVALID_FILE_ATTRIBUTES;
+      }else{
+        attr = sAttrData.dwFileAttributes;
+      }
+    }else{
+      if( GetLastError()!=ERROR_FILE_NOT_FOUND ){
+        free(zConverted);
+        return SQLITE_IOERR_ACCESS;
+      }else{
+        attr = INVALID_FILE_ATTRIBUTES;
+      }
+    }
 /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
 ** Since the ASCII version of these Windows API do not exist for WINCE,
 ** it's important to not reference them for WINCE builds.
@@ -29640,12 +31798,14 @@ static int winFullPathname(
 ){
   
 #if defined(__CYGWIN__)
+  SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
   cygwin_conv_to_full_win32_path(zRelative, zFull);
   return SQLITE_OK;
 #endif
 
 #if SQLITE_OS_WINCE
+  SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
   /* WinCE has no concept of a relative pathname, or so I am told. */
   sqlite3_snprintf(pVfs->mxPathname, zFull, "%s", zRelative);
@@ -29656,6 +31816,13 @@ static int winFullPathname(
   int nByte;
   void *zConverted;
   char *zOut;
+
+  /* It's odd to simulate an io-error here, but really this is just
+  ** using the io-error infrastructure to test that SQLite handles this
+  ** function failing. This function could fail if, for example, the
+  ** current working directory has been unlinked.
+  */
+  SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
   zConverted = convertUtf8Filename(zRelative);
   if( isNT() ){
@@ -29723,7 +31890,9 @@ static int getSectorSize(
   ** to get the drive letter to look up the sector
   ** size.
   */
+  SimulateIOErrorBenign(1);
   rc = winFullPathname(pVfs, zRelative, MAX_PATH, zFullpath);
+  SimulateIOErrorBenign(0);
   if( rc == SQLITE_OK )
   {
     void *zConverted = convertUtf8Filename(zFullpath);
@@ -29871,34 +32040,32 @@ static int winSleep(sqlite3_vfs *pVfs, int microsec){
 }
 
 /*
-** The following variable, if set to a non-zero value, becomes the result
-** returned from sqlite3OsCurrentTime().  This is used for testing.
+** The following variable, if set to a non-zero value, is interpreted as
+** the number of seconds since 1970 and is used to set the result of
+** sqlite3OsCurrentTime() during testing.
 */
 #ifdef SQLITE_TEST
-SQLITE_API int sqlite3_current_time = 0;
+SQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */
 #endif
 
 /*
-** Find the current time (in Universal Coordinated Time).  Write the
-** current time and date as a Julian Day number into *prNow and
-** return 0.  Return 1 if the time and date cannot be found.
+** Find the current time (in Universal Coordinated Time).  Write into *piNow
+** the current time and date as a Julian Day number times 86_400_000.  In
+** other words, write into *piNow the number of milliseconds since the Julian
+** epoch of noon in Greenwich on November 24, 4714 B.C according to the
+** proleptic Gregorian calendar.
+**
+** On success, return 0.  Return 1 if the time and date cannot be found.
 */
-int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
-  FILETIME ft;
+static int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){
   /* FILETIME structure is a 64-bit value representing the number of 
      100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). 
   */
-  sqlite3_int64 timeW;   /* Whole days */
-  sqlite3_int64 timeF;   /* Fractional Days */
-
-  /* Number of 100-nanosecond intervals in a single day */
-  static const sqlite3_int64 ntuPerDay = 
-      10000000*(sqlite3_int64)86400;
-
-  /* Number of 100-nanosecond intervals in half of a day */
-  static const sqlite3_int64 ntuPerHalfDay = 
-      10000000*(sqlite3_int64)43200;
-
+  FILETIME ft;
+  static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;
+#ifdef SQLITE_TEST
+  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
+#endif
   /* 2^32 - to avoid use of LL and warnings in gcc */
   static const sqlite3_int64 max32BitValue = 
       (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 + (sqlite3_int64)294967296;
@@ -29913,24 +32080,36 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
 #else
   GetSystemTimeAsFileTime( &ft );
 #endif
-  UNUSED_PARAMETER(pVfs);
-  timeW = (((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + (sqlite3_int64)ft.dwLowDateTime;
-  timeF = timeW % ntuPerDay;          /* fractional days (100-nanoseconds) */
-  timeW = timeW / ntuPerDay;          /* whole days */
-  timeW = timeW + 2305813;            /* add whole days (from 2305813.5) */
-  timeF = timeF + ntuPerHalfDay;      /* add half a day (from 2305813.5) */
-  timeW = timeW + (timeF/ntuPerDay);  /* add whole day if half day made one */
-  timeF = timeF % ntuPerDay;          /* compute new fractional days */
-  *prNow = (double)timeW + ((double)timeF / (double)ntuPerDay);
+
+  *piNow = winFiletimeEpoch +
+            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + 
+               (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;
+
 #ifdef SQLITE_TEST
   if( sqlite3_current_time ){
-    *prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
+    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;
   }
 #endif
+  UNUSED_PARAMETER(pVfs);
   return 0;
 }
 
 /*
+** Find the current time (in Universal Coordinated Time).  Write the
+** current time and date as a Julian Day number into *prNow and
+** return 0.  Return 1 if the time and date cannot be found.
+*/
+int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
+  int rc;
+  sqlite3_int64 i;
+  rc = winCurrentTimeInt64(pVfs, &i);
+  if( !rc ){
+    *prNow = i/86400000.0;
+  }
+  return rc;
+}
+
+/*
 ** The idea is that this function works like a combination of
 ** GetLastError() and FormatMessage() on windows (or errno and
 ** strerror_r() on unix). After an error is returned by an OS
@@ -29965,32 +32144,41 @@ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
   return getLastErrorMsg(nBuf, zBuf);
 }
 
+
+
 /*
 ** Initialize and deinitialize the operating system interface.
 */
 SQLITE_API int sqlite3_os_init(void){
   static sqlite3_vfs winVfs = {
-    1,                 /* iVersion */
-    sizeof(winFile),   /* szOsFile */
-    MAX_PATH,          /* mxPathname */
-    0,                 /* pNext */
-    "win32",           /* zName */
-    0,                 /* pAppData */
- 
-    winOpen,           /* xOpen */
-    winDelete,         /* xDelete */
-    winAccess,         /* xAccess */
-    winFullPathname,   /* xFullPathname */
-    winDlOpen,         /* xDlOpen */
-    winDlError,        /* xDlError */
-    winDlSym,          /* xDlSym */
-    winDlClose,        /* xDlClose */
-    winRandomness,     /* xRandomness */
-    winSleep,          /* xSleep */
-    winCurrentTime,    /* xCurrentTime */
-    winGetLastError    /* xGetLastError */
+    2,                   /* iVersion */
+    sizeof(winFile),     /* szOsFile */
+    MAX_PATH,            /* mxPathname */
+    0,                   /* pNext */
+    "win32",             /* zName */
+    0,                   /* pAppData */
+    winOpen,             /* xOpen */
+    winDelete,           /* xDelete */
+    winAccess,           /* xAccess */
+    winFullPathname,     /* xFullPathname */
+    winDlOpen,           /* xDlOpen */
+    winDlError,          /* xDlError */
+    winDlSym,            /* xDlSym */
+    winDlClose,          /* xDlClose */
+    winRandomness,       /* xRandomness */
+    winSleep,            /* xSleep */
+    winCurrentTime,      /* xCurrentTime */
+    winGetLastError,     /* xGetLastError */
+    winCurrentTimeInt64, /* xCurrentTimeInt64 */
   };
 
+#ifndef SQLITE_OMIT_WAL
+  /* get memory map allocation granularity */
+  memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
+  GetSystemInfo(&winSysInfo);
+  assert(winSysInfo.dwAllocationGranularity > 0);
+#endif
+
   sqlite3_vfs_register(&winVfs, 1);
   return SQLITE_OK; 
 }
@@ -30040,7 +32228,7 @@ SQLITE_API int sqlite3_os_end(void){
 */
 
 /* Size of the Bitvec structure in bytes. */
-#define BITVEC_SZ        (sizeof(void*)*128)  /* 512 on 32bit.  1024 on 64bit */
+#define BITVEC_SZ        512
 
 /* Round the union size down to the nearest pointer boundary, since that's how 
 ** it will be aligned within the Bitvec struct. */
@@ -30555,12 +32743,16 @@ static void pcacheUnpin(PgHdr *p){
 */
 SQLITE_PRIVATE int sqlite3PcacheInitialize(void){
   if( sqlite3GlobalConfig.pcache.xInit==0 ){
+    /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the
+    ** built-in default page cache is used instead of the application defined
+    ** page cache. */
     sqlite3PCacheSetDefault();
   }
   return sqlite3GlobalConfig.pcache.xInit(sqlite3GlobalConfig.pcache.pArg);
 }
 SQLITE_PRIVATE void sqlite3PcacheShutdown(void){
   if( sqlite3GlobalConfig.pcache.xShutdown ){
+    /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */
     sqlite3GlobalConfig.pcache.xShutdown(sqlite3GlobalConfig.pcache.pArg);
   }
 }
@@ -30673,15 +32865,17 @@ SQLITE_PRIVATE int sqlite3PcacheFetch(
 
   if( pPage ){
     if( !pPage->pData ){
-      memset(pPage, 0, sizeof(PgHdr) + pCache->szExtra);
-      pPage->pExtra = (void*)&pPage[1];
-      pPage->pData = (void *)&((char *)pPage)[sizeof(PgHdr) + pCache->szExtra];
+      memset(pPage, 0, sizeof(PgHdr));
+      pPage->pData = (void *)&pPage[1];
+      pPage->pExtra = (void*)&((char *)pPage->pData)[pCache->szPage];
+      memset(pPage->pExtra, 0, pCache->szExtra);
       pPage->pCache = pCache;
       pPage->pgno = pgno;
     }
     assert( pPage->pCache==pCache );
     assert( pPage->pgno==pgno );
-    assert( pPage->pExtra==(void *)&pPage[1] );
+    assert( pPage->pData==(void *)&pPage[1] );
+    assert( pPage->pExtra==(void *)&((char *)&pPage[1])[pCache->szPage] );
 
     if( 0==pPage->nRef ){
       pCache->nRef++;
@@ -30820,7 +33014,12 @@ SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){
     PgHdr *pNext;
     for(p=pCache->pDirty; p; p=pNext){
       pNext = p->pDirtyNext;
-      if( p->pgno>pgno ){
+      /* This routine never gets call with a positive pgno except right
+      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,
+      ** it must be that pgno==0.
+      */
+      assert( p->pgno>0 );
+      if( ALWAYS(p->pgno>pgno) ){
         assert( p->flags&PGHDR_DIRTY );
         sqlite3PcacheMakeClean(p);
       }
@@ -31014,8 +33213,13 @@ typedef struct PCache1 PCache1;
 typedef struct PgHdr1 PgHdr1;
 typedef struct PgFreeslot PgFreeslot;
 
-/* Pointers to structures of this type are cast and returned as 
-** opaque sqlite3_pcache* handles
+/* Each page cache is an instance of the following object.  Every
+** open database file (including each in-memory database and each
+** temporary or transient database) has a single page cache which
+** is an instance of this object.
+**
+** Pointers to structures of this type are cast and returned as 
+** opaque sqlite3_pcache* handles.
 */
 struct PCache1 {
   /* Cache configuration parameters. Page size (szPage) and the purgeable
@@ -31075,6 +33279,9 @@ static SQLITE_WSD struct PCacheGlobal {
 
   /* Variables related to SQLITE_CONFIG_PAGECACHE settings. */
   int szSlot;                         /* Size of each free slot */
+  int nSlot;                          /* The number of pcache slots */
+  int nFreeSlot;                      /* Number of unused pcache slots */
+  int nReserve;                       /* Try to keep nFreeSlot above this */
   void *pStart, *pEnd;                /* Bounds of pagecache malloc range */
   PgFreeslot *pFree;                  /* Free page blocks */
   int isInit;                         /* True if initialized */
@@ -31122,6 +33329,8 @@ SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
     PgFreeslot *p;
     sz = ROUNDDOWN8(sz);
     pcache1.szSlot = sz;
+    pcache1.nSlot = pcache1.nFreeSlot = n;
+    pcache1.nReserve = n>90 ? 10 : (n/10 + 1);
     pcache1.pStart = pBuf;
     pcache1.pFree = 0;
     while( n-- ){
@@ -31143,11 +33352,13 @@ SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
 static void *pcache1Alloc(int nByte){
   void *p;
   assert( sqlite3_mutex_held(pcache1.mutex) );
+  sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
   if( nByte<=pcache1.szSlot && pcache1.pFree ){
     assert( pcache1.isInit );
     p = (PgHdr1 *)pcache1.pFree;
     pcache1.pFree = pcache1.pFree->pNext;
-    sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
+    pcache1.nFreeSlot--;
+    assert( pcache1.nFreeSlot>=0 );
     sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
   }else{
 
@@ -31164,6 +33375,7 @@ static void *pcache1Alloc(int nByte){
       int sz = sqlite3MallocSize(p);
       sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
     }
+    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
   }
   return p;
 }
@@ -31180,13 +33392,37 @@ static void pcache1Free(void *p){
     pSlot = (PgFreeslot*)p;
     pSlot->pNext = pcache1.pFree;
     pcache1.pFree = pSlot;
+    pcache1.nFreeSlot++;
+    assert( pcache1.nFreeSlot<=pcache1.nSlot );
   }else{
-    int iSize = sqlite3MallocSize(p);
+    int iSize;
+    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
+    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
+    iSize = sqlite3MallocSize(p);
     sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize);
     sqlite3_free(p);
   }
 }
 
+#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
+/*
+** Return the size of a pcache allocation
+*/
+static int pcache1MemSize(void *p){
+  assert( sqlite3_mutex_held(pcache1.mutex) );
+  if( p>=pcache1.pStart && p<pcache1.pEnd ){
+    return pcache1.szSlot;
+  }else{
+    int iSize;
+    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );
+    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
+    iSize = sqlite3MallocSize(p);
+    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);
+    return iSize;
+  }
+}
+#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */
+
 /*
 ** Allocate a new page object initially associated with cache pCache.
 */
@@ -31243,6 +33479,32 @@ SQLITE_PRIVATE void sqlite3PageFree(void *p){
   pcache1LeaveMutex();
 }
 
+
+/*
+** Return true if it desirable to avoid allocating a new page cache
+** entry.
+**
+** If memory was allocated specifically to the page cache using
+** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then
+** it is desirable to avoid allocating a new page cache entry because
+** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient
+** for all page cache needs and we should not need to spill the
+** allocation onto the heap.
+**
+** Or, the heap is used for all page cache memory put the heap is
+** under memory pressure, then again it is desirable to avoid
+** allocating a new page cache entry in order to avoid stressing
+** the heap even further.
+*/
+static int pcache1UnderMemoryPressure(PCache1 *pCache){
+  assert( sqlite3_mutex_held(pcache1.mutex) );
+  if( pcache1.nSlot && pCache->szPage<=pcache1.szSlot ){
+    return pcache1.nFreeSlot<pcache1.nReserve;
+  }else{
+    return sqlite3HeapNearlyFull();
+  }
+}
+
 /******************************************************************************/
 /******** General Implementation Functions ************************************/
 
@@ -31484,14 +33746,16 @@ static int pcache1Pagecount(sqlite3_pcache *p){
 **   2. If createFlag==0 and the page is not already in the cache, NULL is
 **      returned.
 **
-**   3. If createFlag is 1, and the page is not already in the cache,
-**      and if either of the following are true, return NULL:
+**   3. If createFlag is 1, and the page is not already in the cache, then
+**      return NULL (do not allocate a new page) if any of the following
+**      conditions are true:
 **
 **       (a) the number of pages pinned by the cache is greater than
 **           PCache1.nMax, or
+**
 **       (b) the number of pages pinned by the cache is greater than
 **           the sum of nMax for all purgeable caches, less the sum of 
-**           nMin for all other purgeable caches. 
+**           nMin for all other purgeable caches, or
 **
 **   4. If none of the first three conditions apply and the cache is marked
 **      as purgeable, and if one of the following is true:
@@ -31503,6 +33767,9 @@ static int pcache1Pagecount(sqlite3_pcache *p){
 **           already equal to or greater than the sum of nMax for all
 **           purgeable caches,
 **
+**       (c) The system is under memory pressure and wants to avoid
+**           unnecessary pages cache entry allocations
+**
 **      then attempt to recycle a page from the LRU list. If it is the right
 **      size, return the recycled buffer. Otherwise, free the buffer and
 **      proceed to step 5. 
@@ -31534,6 +33801,7 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
   if( createFlag==1 && (
         nPinned>=(pcache1.nMaxPage+pCache->nMin-pcache1.nMinPage)
      || nPinned>=(pCache->nMax * 9 / 10)
+     || pcache1UnderMemoryPressure(pCache)
   )){
     goto fetch_out;
   }
@@ -31544,7 +33812,9 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
 
   /* Step 4. Try to recycle a page buffer if appropriate. */
   if( pCache->bPurgeable && pcache1.pLruTail && (
-     (pCache->nPage+1>=pCache->nMax) || pcache1.nCurrentPage>=pcache1.nMaxPage
+         (pCache->nPage+1>=pCache->nMax)
+      || pcache1.nCurrentPage>=pcache1.nMaxPage
+      || pcache1UnderMemoryPressure(pCache)
   )){
     pPage = pcache1.pLruTail;
     pcache1RemoveFromHash(pPage);
@@ -31687,6 +33957,7 @@ static void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){
 */
 static void pcache1Destroy(sqlite3_pcache *p){
   PCache1 *pCache = (PCache1 *)p;
+  assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
   pcache1EnterMutex();
   pcache1TruncateUnsafe(pCache, 0);
   pcache1.nMaxPage -= pCache->nMax;
@@ -31703,7 +33974,7 @@ static void pcache1Destroy(sqlite3_pcache *p){
 ** already provided an alternative.
 */
 SQLITE_PRIVATE void sqlite3PCacheSetDefault(void){
-  static sqlite3_pcache_methods defaultMethods = {
+  static const sqlite3_pcache_methods defaultMethods = {
     0,                       /* pArg */
     pcache1Init,             /* xInit */
     pcache1Shutdown,         /* xShutdown */
@@ -31734,8 +34005,8 @@ SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){
   if( pcache1.pStart==0 ){
     PgHdr1 *p;
     pcache1EnterMutex();
-    while( (nReq<0 || nFree<nReq) && (p=pcache1.pLruTail) ){
-      nFree += sqlite3MallocSize(PGHDR1_TO_PAGE(p));
+    while( (nReq<0 || nFree<nReq) && ((p=pcache1.pLruTail)!=0) ){
+      nFree += pcache1MemSize(PGHDR1_TO_PAGE(p));
       pcache1PinPage(p);
       pcache1RemoveFromHash(p);
       pcache1FreePage(p);
@@ -32216,6 +34487,203 @@ SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, u8 iBatch, sqlite3_int64 i
 ** another is writing.
 */
 #ifndef SQLITE_OMIT_DISKIO
+/************** Include wal.h in the middle of pager.c ***********************/
+/************** Begin file wal.h *********************************************/
+/*
+** 2010 February 1
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+** This header file defines the interface to the write-ahead logging 
+** system. Refer to the comments below and the header comment attached to 
+** the implementation of each function in log.c for further details.
+*/
+
+#ifndef _WAL_H_
+#define _WAL_H_
+
+
+#ifdef SQLITE_OMIT_WAL
+# define sqlite3WalOpen(x,y,z)                 0
+# define sqlite3WalClose(w,x,y,z)              0
+# define sqlite3WalBeginReadTransaction(y,z)   0
+# define sqlite3WalEndReadTransaction(z)
+# define sqlite3WalRead(v,w,x,y,z)             0
+# define sqlite3WalDbsize(y)                   0
+# define sqlite3WalBeginWriteTransaction(y)    0
+# define sqlite3WalEndWriteTransaction(x)      0
+# define sqlite3WalUndo(x,y,z)                 0
+# define sqlite3WalSavepoint(y,z)
+# define sqlite3WalSavepointUndo(y,z)          0
+# define sqlite3WalFrames(u,v,w,x,y,z)         0
+# define sqlite3WalCheckpoint(u,v,w,x)         0
+# define sqlite3WalCallback(z)                 0
+# define sqlite3WalExclusiveMode(y,z)          0
+#else
+
+#define WAL_SAVEPOINT_NDATA 4
+
+/* Connection to a write-ahead log (WAL) file. 
+** There is one object of this type for each pager. 
+*/
+typedef struct Wal Wal;
+
+/* Open and close a connection to a write-ahead log. */
+SQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *zName, Wal**);
+SQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);
+
+/* Used by readers to open (lock) and close (unlock) a snapshot.  A 
+** snapshot is like a read-transaction.  It is the state of the database
+** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and
+** preserves the current state even if the other threads or processes
+** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the
+** transaction and releases the lock.
+*/
+SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *);
+SQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal);
+
+/* Read a page from the write-ahead log, if it is present. */
+SQLITE_PRIVATE int sqlite3WalRead(Wal *pWal, Pgno pgno, int *pInWal, int nOut, u8 *pOut);
+
+/* If the WAL is not empty, return the size of the database. */
+SQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal);
+
+/* Obtain or release the WRITER lock. */
+SQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal);
+SQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal);
+
+/* Undo any frames written (but not committed) to the log */
+SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);
+
+/* Return an integer that records the current (uncommitted) write
+** position in the WAL */
+SQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);
+
+/* Move the write position of the WAL back to iFrame.  Called in
+** response to a ROLLBACK TO command. */
+SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);
+
+/* Write a frame or frames to the log. */
+SQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);
+
+/* Copy pages from the log to the database file */ 
+SQLITE_PRIVATE int sqlite3WalCheckpoint(
+  Wal *pWal,                      /* Write-ahead log connection */
+  int sync_flags,                 /* Flags to sync db file with (or 0) */
+  int nBuf,                       /* Size of buffer nBuf */
+  u8 *zBuf                        /* Temporary buffer to use */
+);
+
+/* Return the value to pass to a sqlite3_wal_hook callback, the
+** number of frames in the WAL at the point of the last commit since
+** sqlite3WalCallback() was called.  If no commits have occurred since
+** the last call, then return 0.
+*/
+SQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal);
+
+/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
+** by the pager layer on the database file.
+*/
+SQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op);
+
+#endif /* ifndef SQLITE_OMIT_WAL */
+#endif /* _WAL_H_ */
+
+/************** End of wal.h *************************************************/
+/************** Continuing where we left off in pager.c **********************/
+
+
+/******************* NOTES ON THE DESIGN OF THE PAGER ************************
+**
+** This comment block describes invariants that hold when using a rollback
+** journal.  These invariants do not apply for journal_mode=WAL,
+** journal_mode=MEMORY, or journal_mode=OFF.
+**
+** Within this comment block, a page is deemed to have been synced
+** automatically as soon as it is written when PRAGMA synchronous=OFF.
+** Otherwise, the page is not synced until the xSync method of the VFS
+** is called successfully on the file containing the page.
+**
+** Definition:  A page of the database file is said to be "overwriteable" if
+** one or more of the following are true about the page:
+** 
+**     (a)  The original content of the page as it was at the beginning of
+**          the transaction has been written into the rollback journal and
+**          synced.
+** 
+**     (b)  The page was a freelist leaf page at the start of the transaction.
+** 
+**     (c)  The page number is greater than the largest page that existed in
+**          the database file at the start of the transaction.
+** 
+** (1) A page of the database file is never overwritten unless one of the
+**     following are true:
+** 
+**     (a) The page and all other pages on the same sector are overwriteable.
+** 
+**     (b) The atomic page write optimization is enabled, and the entire
+**         transaction other than the update of the transaction sequence
+**         number consists of a single page change.
+** 
+** (2) The content of a page written into the rollback journal exactly matches
+**     both the content in the database when the rollback journal was written
+**     and the content in the database at the beginning of the current
+**     transaction.
+** 
+** (3) Writes to the database file are an integer multiple of the page size
+**     in length and are aligned on a page boundary.
+** 
+** (4) Reads from the database file are either aligned on a page boundary and
+**     an integer multiple of the page size in length or are taken from the
+**     first 100 bytes of the database file.
+** 
+** (5) All writes to the database file are synced prior to the rollback journal
+**     being deleted, truncated, or zeroed.
+** 
+** (6) If a master journal file is used, then all writes to the database file
+**     are synced prior to the master journal being deleted.
+** 
+** Definition: Two databases (or the same database at two points it time)
+** are said to be "logically equivalent" if they give the same answer to
+** all queries.  Note in particular the the content of freelist leaf
+** pages can be changed arbitarily without effecting the logical equivalence
+** of the database.
+** 
+** (7) At any time, if any subset, including the empty set and the total set,
+**     of the unsynced changes to a rollback journal are removed and the 
+**     journal is rolled back, the resulting database file will be logical
+**     equivalent to the database file at the beginning of the transaction.
+** 
+** (8) When a transaction is rolled back, the xTruncate method of the VFS
+**     is called to restore the database file to the same size it was at
+**     the beginning of the transaction.  (In some VFSes, the xTruncate
+**     method is a no-op, but that does not change the fact the SQLite will
+**     invoke it.)
+** 
+** (9) Whenever the database file is modified, at least one bit in the range
+**     of bytes from 24 through 39 inclusive will be changed prior to releasing
+**     the EXCLUSIVE lock, thus signaling other connections on the same
+**     database to flush their caches.
+**
+** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less
+**      than one billion transactions.
+**
+** (11) A database file is well-formed at the beginning and at the conclusion
+**      of every transaction.
+**
+** (12) An EXCLUSIVE lock is held on the database file when writing to
+**      the database file.
+**
+** (13) A SHARED lock is held on the database file while reading any
+**      content out of the database file.
+**
+******************************************************************************/
 
 /*
 ** Macros for troubleshooting.  Normally turned off
@@ -32240,58 +34708,279 @@ int sqlite3PagerTrace=1;  /* True to enable tracing */
 #define FILEHANDLEID(fd) ((int)fd)
 
 /*
-** The page cache as a whole is always in one of the following
-** states:
-**
-**   PAGER_UNLOCK        The page cache is not currently reading or 
-**                       writing the database file.  There is no
-**                       data held in memory.  This is the initial
-**                       state.
-**
-**   PAGER_SHARED        The page cache is reading the database.
-**                       Writing is not permitted.  There can be
-**                       multiple readers accessing the same database
-**                       file at the same time.
-**
-**   PAGER_RESERVED      This process has reserved the database for writing
-**                       but has not yet made any changes.  Only one process
-**                       at a time can reserve the database.  The original
-**                       database file has not been modified so other
-**                       processes may still be reading the on-disk
-**                       database file.
-**
-**   PAGER_EXCLUSIVE     The page cache is writing the database.
-**                       Access is exclusive.  No other processes or
-**                       threads can be reading or writing while one
-**                       process is writing.
-**
-**   PAGER_SYNCED        The pager moves to this state from PAGER_EXCLUSIVE
-**                       after all dirty pages have been written to the
-**                       database file and the file has been synced to
-**                       disk. All that remains to do is to remove or
-**                       truncate the journal file and the transaction 
-**                       will be committed.
-**
-** The page cache comes up in PAGER_UNLOCK.  The first time a
-** sqlite3PagerGet() occurs, the state transitions to PAGER_SHARED.
-** After all pages have been released using sqlite_page_unref(),
-** the state transitions back to PAGER_UNLOCK.  The first time
-** that sqlite3PagerWrite() is called, the state transitions to
-** PAGER_RESERVED.  (Note that sqlite3PagerWrite() can only be
-** called on an outstanding page which means that the pager must
-** be in PAGER_SHARED before it transitions to PAGER_RESERVED.)
-** PAGER_RESERVED means that there is an open rollback journal.
-** The transition to PAGER_EXCLUSIVE occurs before any changes
-** are made to the database file, though writes to the rollback
-** journal occurs with just PAGER_RESERVED.  After an sqlite3PagerRollback()
-** or sqlite3PagerCommitPhaseTwo(), the state can go back to PAGER_SHARED,
-** or it can stay at PAGER_EXCLUSIVE if we are in exclusive access mode.
-*/
-#define PAGER_UNLOCK      0
-#define PAGER_SHARED      1   /* same as SHARED_LOCK */
-#define PAGER_RESERVED    2   /* same as RESERVED_LOCK */
-#define PAGER_EXCLUSIVE   4   /* same as EXCLUSIVE_LOCK */
-#define PAGER_SYNCED      5
+** The Pager.eState variable stores the current 'state' of a pager. A
+** pager may be in any one of the seven states shown in the following
+** state diagram.
+**
+**                            OPEN <------+------+
+**                              |         |      |
+**                              V         |      |
+**               +---------> READER-------+      |
+**               |              |                |
+**               |              V                |
+**               |<-------WRITER_LOCKED------> ERROR
+**               |              |                ^  
+**               |              V                |
+**               |<------WRITER_CACHEMOD-------->|
+**               |              |                |
+**               |              V                |
+**               |<-------WRITER_DBMOD---------->|
+**               |              |                |
+**               |              V                |
+**               +<------WRITER_FINISHED-------->+
+**
+**
+** List of state transitions and the C [function] that performs each:
+** 
+**   OPEN              -> READER              [sqlite3PagerSharedLock]
+**   READER            -> OPEN                [pager_unlock]
+**
+**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]
+**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]
+**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]
+**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]
+**   WRITER_***        -> READER              [pager_end_transaction]
+**
+**   WRITER_***        -> ERROR               [pager_error]
+**   ERROR             -> OPEN                [pager_unlock]
+** 
+**
+**  OPEN:
+**
+**    The pager starts up in this state. Nothing is guaranteed in this
+**    state - the file may or may not be locked and the database size is
+**    unknown. The database may not be read or written.
+**
+**    * No read or write transaction is active.
+**    * Any lock, or no lock at all, may be held on the database file.
+**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.
+**
+**  READER:
+**
+**    In this state all the requirements for reading the database in 
+**    rollback (non-WAL) mode are met. Unless the pager is (or recently
+**    was) in exclusive-locking mode, a user-level read transaction is 
+**    open. The database size is known in this state.
+**
+**    A connection running with locking_mode=normal enters this state when
+**    it opens a read-transaction on the database and returns to state
+**    OPEN after the read-transaction is completed. However a connection
+**    running in locking_mode=exclusive (including temp databases) remains in
+**    this state even after the read-transaction is closed. The only way
+**    a locking_mode=exclusive connection can transition from READER to OPEN
+**    is via the ERROR state (see below).
+** 
+**    * A read transaction may be active (but a write-transaction cannot).
+**    * A SHARED or greater lock is held on the database file.
+**    * The dbSize variable may be trusted (even if a user-level read 
+**      transaction is not active). The dbOrigSize and dbFileSize variables
+**      may not be trusted at this point.
+**    * If the database is a WAL database, then the WAL connection is open.
+**    * Even if a read-transaction is not open, it is guaranteed that 
+**      there is no hot-journal in the file-system.
+**
+**  WRITER_LOCKED:
+**
+**    The pager moves to this state from READER when a write-transaction
+**    is first opened on the database. In WRITER_LOCKED state, all locks 
+**    required to start a write-transaction are held, but no actual 
+**    modifications to the cache or database have taken place.
+**
+**    In rollback mode, a RESERVED or (if the transaction was opened with 
+**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
+**    moving to this state, but the journal file is not written to or opened 
+**    to in this state. If the transaction is committed or rolled back while 
+**    in WRITER_LOCKED state, all that is required is to unlock the database 
+**    file.
+**
+**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.
+**    If the connection is running with locking_mode=exclusive, an attempt
+**    is made to obtain an EXCLUSIVE lock on the database file.
+**
+**    * A write transaction is active.
+**    * If the connection is open in rollback-mode, a RESERVED or greater 
+**      lock is held on the database file.
+**    * If the connection is open in WAL-mode, a WAL write transaction
+**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully
+**      called).
+**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.
+**    * The contents of the pager cache have not been modified.
+**    * The journal file may or may not be open.
+**    * Nothing (not even the first header) has been written to the journal.
+**
+**  WRITER_CACHEMOD:
+**
+**    A pager moves from WRITER_LOCKED state to this state when a page is
+**    first modified by the upper layer. In rollback mode the journal file
+**    is opened (if it is not already open) and a header written to the
+**    start of it. The database file on disk has not been modified.
+**
+**    * A write transaction is active.
+**    * A RESERVED or greater lock is held on the database file.
+**    * The journal file is open and the first header has been written 
+**      to it, but the header has not been synced to disk.
+**    * The contents of the page cache have been modified.
+**
+**  WRITER_DBMOD:
+**
+**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state
+**    when it modifies the contents of the database file. WAL connections
+**    never enter this state (since they do not modify the database file,
+**    just the log file).
+**
+**    * A write transaction is active.
+**    * An EXCLUSIVE or greater lock is held on the database file.
+**    * The journal file is open and the first header has been written 
+**      and synced to disk.
+**    * The contents of the page cache have been modified (and possibly
+**      written to disk).
+**
+**  WRITER_FINISHED:
+**
+**    It is not possible for a WAL connection to enter this state.
+**
+**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD
+**    state after the entire transaction has been successfully written into the
+**    database file. In this state the transaction may be committed simply
+**    by finalizing the journal file. Once in WRITER_FINISHED state, it is 
+**    not possible to modify the database further. At this point, the upper 
+**    layer must either commit or rollback the transaction.
+**
+**    * A write transaction is active.
+**    * An EXCLUSIVE or greater lock is held on the database file.
+**    * All writing and syncing of journal and database data has finished.
+**      If no error occured, all that remains is to finalize the journal to
+**      commit the transaction. If an error did occur, the caller will need
+**      to rollback the transaction. 
+**
+**  ERROR:
+**
+**    The ERROR state is entered when an IO or disk-full error (including
+**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it 
+**    difficult to be sure that the in-memory pager state (cache contents, 
+**    db size etc.) are consistent with the contents of the file-system.
+**
+**    Temporary pager files may enter the ERROR state, but in-memory pagers
+**    cannot.
+**
+**    For example, if an IO error occurs while performing a rollback, 
+**    the contents of the page-cache may be left in an inconsistent state.
+**    At this point it would be dangerous to change back to READER state
+**    (as usually happens after a rollback). Any subsequent readers might
+**    report database corruption (due to the inconsistent cache), and if
+**    they upgrade to writers, they may inadvertently corrupt the database
+**    file. To avoid this hazard, the pager switches into the ERROR state
+**    instead of READER following such an error.
+**
+**    Once it has entered the ERROR state, any attempt to use the pager
+**    to read or write data returns an error. Eventually, once all 
+**    outstanding transactions have been abandoned, the pager is able to
+**    transition back to OPEN state, discarding the contents of the 
+**    page-cache and any other in-memory state at the same time. Everything
+**    is reloaded from disk (and, if necessary, hot-journal rollback peformed)
+**    when a read-transaction is next opened on the pager (transitioning
+**    the pager into READER state). At that point the system has recovered 
+**    from the error.
+**
+**    Specifically, the pager jumps into the ERROR state if:
+**
+**      1. An error occurs while attempting a rollback. This happens in
+**         function sqlite3PagerRollback().
+**
+**      2. An error occurs while attempting to finalize a journal file
+**         following a commit in function sqlite3PagerCommitPhaseTwo().
+**
+**      3. An error occurs while attempting to write to the journal or
+**         database file in function pagerStress() in order to free up
+**         memory.
+**
+**    In other cases, the error is returned to the b-tree layer. The b-tree
+**    layer then attempts a rollback operation. If the error condition 
+**    persists, the pager enters the ERROR state via condition (1) above.
+**
+**    Condition (3) is necessary because it can be triggered by a read-only
+**    statement executed within a transaction. In this case, if the error
+**    code were simply returned to the user, the b-tree layer would not
+**    automatically attempt a rollback, as it assumes that an error in a
+**    read-only statement cannot leave the pager in an internally inconsistent 
+**    state.
+**
+**    * The Pager.errCode variable is set to something other than SQLITE_OK.
+**    * There are one or more outstanding references to pages (after the
+**      last reference is dropped the pager should move back to OPEN state).
+**    * The pager is not an in-memory pager.
+**    
+**
+** Notes:
+**
+**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
+**     connection is open in WAL mode. A WAL connection is always in one
+**     of the first four states.
+**
+**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN
+**     state. There are two exceptions: immediately after exclusive-mode has
+**     been turned on (and before any read or write transactions are 
+**     executed), and when the pager is leaving the "error state".
+**
+**   * See also: assert_pager_state().
+*/
+#define PAGER_OPEN                  0
+#define PAGER_READER                1
+#define PAGER_WRITER_LOCKED         2
+#define PAGER_WRITER_CACHEMOD       3
+#define PAGER_WRITER_DBMOD          4
+#define PAGER_WRITER_FINISHED       5
+#define PAGER_ERROR                 6
+
+/*
+** The Pager.eLock variable is almost always set to one of the 
+** following locking-states, according to the lock currently held on
+** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
+** This variable is kept up to date as locks are taken and released by
+** the pagerLockDb() and pagerUnlockDb() wrappers.
+**
+** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY
+** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not
+** the operation was successful. In these circumstances pagerLockDb() and
+** pagerUnlockDb() take a conservative approach - eLock is always updated
+** when unlocking the file, and only updated when locking the file if the
+** VFS call is successful. This way, the Pager.eLock variable may be set
+** to a less exclusive (lower) value than the lock that is actually held
+** at the system level, but it is never set to a more exclusive value.
+**
+** This is usually safe. If an xUnlock fails or appears to fail, there may 
+** be a few redundant xLock() calls or a lock may be held for longer than
+** required, but nothing really goes wrong.
+**
+** The exception is when the database file is unlocked as the pager moves
+** from ERROR to OPEN state. At this point there may be a hot-journal file 
+** in the file-system that needs to be rolled back (as part of a OPEN->SHARED
+** transition, by the same pager or any other). If the call to xUnlock()
+** fails at this point and the pager is left holding an EXCLUSIVE lock, this
+** can confuse the call to xCheckReservedLock() call made later as part
+** of hot-journal detection.
+**
+** xCheckReservedLock() is defined as returning true "if there is a RESERVED 
+** lock held by this process or any others". So xCheckReservedLock may 
+** return true because the caller itself is holding an EXCLUSIVE lock (but
+** doesn't know it because of a previous error in xUnlock). If this happens
+** a hot-journal may be mistaken for a journal being created by an active
+** transaction in another process, causing SQLite to read from the database
+** without rolling it back.
+**
+** To work around this, if a call to xUnlock() fails when unlocking the
+** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
+** is only changed back to a real locking state after a successful call
+** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition
+** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK 
+** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
+** lock on the database file before attempting to roll it back. See function
+** PagerSharedLock() for more detail.
+**
+** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in 
+** PAGER_OPEN state.
+*/
+#define UNKNOWN_LOCK                (EXCLUSIVE_LOCK+1)
 
 /*
 ** A macro used for invoking the codec if there is one
@@ -32335,36 +35024,34 @@ struct PagerSavepoint {
   Bitvec *pInSavepoint;        /* Set of pages in this savepoint */
   Pgno nOrig;                  /* Original number of pages in file */
   Pgno iSubRec;                /* Index of first record in sub-journal */
+#ifndef SQLITE_OMIT_WAL
+  u32 aWalData[WAL_SAVEPOINT_NDATA];        /* WAL savepoint context */
+#endif
 };
 
 /*
-** A open page cache is an instance of the following structure.
+** A open page cache is an instance of struct Pager. A description of
+** some of the more important member variables follows:
 **
-** errCode
+** eState
+**
+**   The current 'state' of the pager object. See the comment and state
+**   diagram above for a description of the pager state.
 **
-**   Pager.errCode may be set to SQLITE_IOERR, SQLITE_CORRUPT, or
-**   or SQLITE_FULL. Once one of the first three errors occurs, it persists
-**   and is returned as the result of every major pager API call.  The
-**   SQLITE_FULL return code is slightly different. It persists only until the
-**   next successful rollback is performed on the pager cache. Also,
-**   SQLITE_FULL does not affect the sqlite3PagerGet() and sqlite3PagerLookup()
-**   APIs, they may still be used successfully.
-**
-** dbSizeValid, dbSize, dbOrigSize, dbFileSize
-**
-**   Managing the size of the database file in pages is a little complicated.
-**   The variable Pager.dbSize contains the number of pages that the database
-**   image currently contains. As the database image grows or shrinks this
-**   variable is updated. The variable Pager.dbFileSize contains the number
-**   of pages in the database file. This may be different from Pager.dbSize
-**   if some pages have been appended to the database image but not yet written
-**   out from the cache to the actual file on disk. Or if the image has been
-**   truncated by an incremental-vacuum operation. The Pager.dbOrigSize variable
-**   contains the number of pages in the database image when the current
-**   transaction was opened. The contents of all three of these variables is
-**   only guaranteed to be correct if the boolean Pager.dbSizeValid is true.
-**
-**   TODO: Under what conditions is dbSizeValid set? Cleared?
+** eLock
+**
+**   For a real on-disk database, the current lock held on the database file -
+**   NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
+**
+**   For a temporary or in-memory database (neither of which require any
+**   locks), this variable is always set to EXCLUSIVE_LOCK. Since such
+**   databases always have Pager.exclusiveMode==1, this tricks the pager
+**   logic into thinking that it already has all the locks it will ever
+**   need (and no reason to release them).
+**
+**   In some (obscure) circumstances, this variable may also be set to
+**   UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for
+**   details.
 **
 ** changeCountDone
 **
@@ -32383,60 +35070,123 @@ struct PagerSavepoint {
 **   need only update the change-counter once, for the first transaction
 **   committed.
 **
-** dbModified
-**
-**   The dbModified flag is set whenever a database page is dirtied.
-**   It is cleared at the end of each transaction.
-**
-**   It is used when committing or otherwise ending a transaction. If
-**   the dbModified flag is clear then less work has to be done.
-**
-** journalStarted
-**
-**   This flag is set whenever the the main journal is synced. 
-**
-**   The point of this flag is that it must be set after the 
-**   first journal header in a journal file has been synced to disk.
-**   After this has happened, new pages appended to the database 
-**   do not need the PGHDR_NEED_SYNC flag set, as they do not need
-**   to wait for a journal sync before they can be written out to
-**   the database file (see function pager_write()).
-**   
 ** setMaster
 **
-**   This variable is used to ensure that the master journal file name
-**   (if any) is only written into the journal file once.
-**
-**   When committing a transaction, the master journal file name (if any)
-**   may be written into the journal file while the pager is still in
-**   PAGER_RESERVED state (see CommitPhaseOne() for the action). It
-**   then attempts to upgrade to an exclusive lock. If this attempt
-**   fails, then SQLITE_BUSY may be returned to the user and the user
-**   may attempt to commit the transaction again later (calling
-**   CommitPhaseOne() again). This flag is used to ensure that the 
-**   master journal name is only written to the journal file the first
-**   time CommitPhaseOne() is called.
-**
-** doNotSync
-**
-**   This variable is set and cleared by sqlite3PagerWrite().
-**
-** needSync
-**
-**   TODO: It might be easier to set this variable in writeJournalHdr()
-**   and writeMasterJournal() only. Change its meaning to "unsynced data
-**   has been written to the journal".
+**   When PagerCommitPhaseOne() is called to commit a transaction, it may
+**   (or may not) specify a master-journal name to be written into the 
+**   journal file before it is synced to disk.
+**
+**   Whether or not a journal file contains a master-journal pointer affects 
+**   the way in which the journal file is finalized after the transaction is 
+**   committed or rolled back when running in "journal_mode=PERSIST" mode.
+**   If a journal file does not contain a master-journal pointer, it is
+**   finalized by overwriting the first journal header with zeroes. If
+**   it does contain a master-journal pointer the journal file is finalized 
+**   by truncating it to zero bytes, just as if the connection were 
+**   running in "journal_mode=truncate" mode.
+**
+**   Journal files that contain master journal pointers cannot be finalized
+**   simply by overwriting the first journal-header with zeroes, as the
+**   master journal pointer could interfere with hot-journal rollback of any
+**   subsequently interrupted transaction that reuses the journal file.
+**
+**   The flag is cleared as soon as the journal file is finalized (either
+**   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the
+**   journal file from being successfully finalized, the setMaster flag
+**   is cleared anyway (and the pager will move to ERROR state).
+**
+** doNotSpill, doNotSyncSpill
+**
+**   These two boolean variables control the behaviour of cache-spills
+**   (calls made by the pcache module to the pagerStress() routine to
+**   write cached data to the file-system in order to free up memory).
+**
+**   When doNotSpill is non-zero, writing to the database from pagerStress()
+**   is disabled altogether. This is done in a very obscure case that
+**   comes up during savepoint rollback that requires the pcache module
+**   to allocate a new page to prevent the journal file from being written
+**   while it is being traversed by code in pager_playback().
+** 
+**   If doNotSyncSpill is non-zero, writing to the database from pagerStress()
+**   is permitted, but syncing the journal file is not. This flag is set
+**   by sqlite3PagerWrite() when the file-system sector-size is larger than
+**   the database page-size in order to prevent a journal sync from happening 
+**   in between the journalling of two pages on the same sector. 
 **
 ** subjInMemory
 **
 **   This is a boolean variable. If true, then any required sub-journal
 **   is opened as an in-memory journal file. If false, then in-memory
 **   sub-journals are only used for in-memory pager files.
+**
+**   This variable is updated by the upper layer each time a new 
+**   write-transaction is opened.
+**
+** dbSize, dbOrigSize, dbFileSize
+**
+**   Variable dbSize is set to the number of pages in the database file.
+**   It is valid in PAGER_READER and higher states (all states except for
+**   OPEN and ERROR). 
+**
+**   dbSize is set based on the size of the database file, which may be 
+**   larger than the size of the database (the value stored at offset
+**   28 of the database header by the btree). If the size of the file
+**   is not an integer multiple of the page-size, the value stored in
+**   dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).
+**   Except, any file that is greater than 0 bytes in size is considered
+**   to have at least one page. (i.e. a 1KB file with 2K page-size leads
+**   to dbSize==1).
+**
+**   During a write-transaction, if pages with page-numbers greater than
+**   dbSize are modified in the cache, dbSize is updated accordingly.
+**   Similarly, if the database is truncated using PagerTruncateImage(), 
+**   dbSize is updated.
+**
+**   Variables dbOrigSize and dbFileSize are valid in states 
+**   PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize
+**   variable at the start of the transaction. It is used during rollback,
+**   and to determine whether or not pages need to be journalled before
+**   being modified.
+**
+**   Throughout a write-transaction, dbFileSize contains the size of
+**   the file on disk in pages. It is set to a copy of dbSize when the
+**   write-transaction is first opened, and updated when VFS calls are made
+**   to write or truncate the database file on disk. 
+**
+**   The only reason the dbFileSize variable is required is to suppress 
+**   unnecessary calls to xTruncate() after committing a transaction. If, 
+**   when a transaction is committed, the dbFileSize variable indicates 
+**   that the database file is larger than the database image (Pager.dbSize), 
+**   pager_truncate() is called. The pager_truncate() call uses xFilesize()
+**   to measure the database file on disk, and then truncates it if required.
+**   dbFileSize is not used when rolling back a transaction. In this case
+**   pager_truncate() is called unconditionally (which means there may be
+**   a call to xFilesize() that is not strictly required). In either case,
+**   pager_truncate() may cause the file to become smaller or larger.
+**
+** dbHintSize
+**
+**   The dbHintSize variable is used to limit the number of calls made to
+**   the VFS xFileControl(FCNTL_SIZE_HINT) method. 
+**
+**   dbHintSize is set to a copy of the dbSize variable when a
+**   write-transaction is opened (at the same time as dbFileSize and
+**   dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,
+**   dbHintSize is increased to the number of pages that correspond to the
+**   size-hint passed to the method call. See pager_write_pagelist() for 
+**   details.
+**
+** errCode
+**
+**   The Pager.errCode variable is only ever used in PAGER_ERROR state. It
+**   is set to zero in all other states. In PAGER_ERROR state, Pager.errCode 
+**   is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX 
+**   sub-codes.
 */
 struct Pager {
   sqlite3_vfs *pVfs;          /* OS functions to use for IO */
   u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */
-  u8 journalMode;             /* On of the PAGER_JOURNALMODE_* values */
+  u8 journalMode;             /* One of the PAGER_JOURNALMODE_* values */
   u8 useJournal;              /* Use a rollback journal on this file */
   u8 noReadlock;              /* Do not bother to obtain readlocks */
   u8 noSync;                  /* Do not sync the journal if true */
@@ -32446,29 +35196,26 @@ struct Pager {
   u8 readOnly;                /* True for a read-only database */
   u8 memDb;                   /* True to inhibit all file I/O */
 
-  /* The following block contains those class members that are dynamically
-  ** modified during normal operations. The other variables in this structure
-  ** are either constant throughout the lifetime of the pager, or else
-  ** used to store configuration parameters that affect the way the pager 
-  ** operates.
-  **
-  ** The 'state' variable is described in more detail along with the
-  ** descriptions of the values it may take - PAGER_UNLOCK etc. Many of the
-  ** other variables in this block are described in the comment directly 
-  ** above this class definition.
-  */
-  u8 state;                   /* PAGER_UNLOCK, _SHARED, _RESERVED, etc. */
-  u8 dbModified;              /* True if there are any changes to the Db */
-  u8 needSync;                /* True if an fsync() is needed on the journal */
-  u8 journalStarted;          /* True if header of journal is synced */
+  /**************************************************************************
+  ** The following block contains those class members that change during
+  ** routine opertion.  Class members not in this block are either fixed
+  ** when the pager is first created or else only change when there is a
+  ** significant mode change (such as changing the page_size, locking_mode,
+  ** or the journal_mode).  From another view, these class members describe
+  ** the "state" of the pager, while other class members describe the
+  ** "configuration" of the pager.
+  */
+  u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */
+  u8 eLock;                   /* Current lock held on database file */
   u8 changeCountDone;         /* Set after incrementing the change-counter */
   u8 setMaster;               /* True if a m-j name has been written to jrnl */
-  u8 doNotSync;               /* Boolean. While true, do not spill the cache */
-  u8 dbSizeValid;             /* Set when dbSize is correct */
+  u8 doNotSpill;              /* Do not spill the cache when non-zero */
+  u8 doNotSyncSpill;          /* Do not do a spill that requires jrnl sync */
   u8 subjInMemory;            /* True to use in-memory sub-journals */
   Pgno dbSize;                /* Number of pages in the database */
   Pgno dbOrigSize;            /* dbSize before the current transaction */
   Pgno dbFileSize;            /* Number of pages in the database file */
+  Pgno dbHintSize;            /* Value passed to FCNTL_SIZE_HINT call */
   int errCode;                /* One of several kinds of errors */
   int nRec;                   /* Pages journalled since last j-header written */
   u32 cksumInit;              /* Quasi-random value added to every checksum */
@@ -32479,16 +35226,21 @@ struct Pager {
   sqlite3_file *sjfd;         /* File descriptor for sub-journal */
   i64 journalOff;             /* Current write offset in the journal file */
   i64 journalHdr;             /* Byte offset to previous journal header */
+  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */
   PagerSavepoint *aSavepoint; /* Array of active savepoints */
   int nSavepoint;             /* Number of elements in aSavepoint[] */
   char dbFileVers[16];        /* Changes whenever database file changes */
-  u32 sectorSize;             /* Assumed sector size during rollback */
+  /*
+  ** End of the routinely-changing class members
+  ***************************************************************************/
 
   u16 nExtra;                 /* Add this many bytes to each in-memory page */
   i16 nReserve;               /* Number of unused bytes at end of each page */
   u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */
+  u32 sectorSize;             /* Assumed sector size during rollback */
   int pageSize;               /* Number of bytes in a page */
   Pgno mxPgno;                /* Maximum allowed size of the database */
+  i64 journalSizeLimit;       /* Size limit for persistent journal files */
   char *zFilename;            /* Name of the database file */
   char *zJournal;             /* Name of the journal file */
   int (*xBusyHandler)(void*); /* Function to call when busy */
@@ -32505,9 +35257,11 @@ struct Pager {
   void *pCodec;               /* First argument to xCodec... methods */
 #endif
   char *pTmpSpace;            /* Pager.pageSize bytes of space for tmp use */
-  i64 journalSizeLimit;       /* Size limit for persistent journal files */
   PCache *pPCache;            /* Pointer to page cache object */
-  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */
+#ifndef SQLITE_OMIT_WAL
+  Wal *pWal;                  /* Write-ahead log used by "journal_mode=wal" */
+  char *zWal;                 /* File name for write-ahead log */
+#endif
 };
 
 /*
@@ -32582,22 +35336,221 @@ static const unsigned char aJournalMagic[] = {
 */
 #define PAGER_MAX_PGNO 2147483647
 
+/*
+** The argument to this macro is a file descriptor (type sqlite3_file*).
+** Return 0 if it is not open, or non-zero (but not 1) if it is.
+**
+** This is so that expressions can be written as:
+**
+**   if( isOpen(pPager->jfd) ){ ...
+**
+** instead of
+**
+**   if( pPager->jfd->pMethods ){ ...
+*/
+#define isOpen(pFd) ((pFd)->pMethods)
+
+/*
+** Return true if this pager uses a write-ahead log instead of the usual
+** rollback journal. Otherwise false.
+*/
+#ifndef SQLITE_OMIT_WAL
+static int pagerUseWal(Pager *pPager){
+  return (pPager->pWal!=0);
+}
+#else
+# define pagerUseWal(x) 0
+# define pagerRollbackWal(x) 0
+# define pagerWalFrames(v,w,x,y,z) 0
+# define pagerOpenWalIfPresent(z) SQLITE_OK
+# define pagerBeginReadTransaction(z) SQLITE_OK
+#endif
+
 #ifndef NDEBUG 
 /*
 ** Usage:
 **
 **   assert( assert_pager_state(pPager) );
+**
+** This function runs many asserts to try to find inconsistencies in
+** the internal state of the Pager object.
 */
-static int assert_pager_state(Pager *pPager){
+static int assert_pager_state(Pager *p){
+  Pager *pPager = p;
+
+  /* State must be valid. */
+  assert( p->eState==PAGER_OPEN
+       || p->eState==PAGER_READER
+       || p->eState==PAGER_WRITER_LOCKED
+       || p->eState==PAGER_WRITER_CACHEMOD
+       || p->eState==PAGER_WRITER_DBMOD
+       || p->eState==PAGER_WRITER_FINISHED
+       || p->eState==PAGER_ERROR
+  );
+
+  /* Regardless of the current state, a temp-file connection always behaves
+  ** as if it has an exclusive lock on the database file. It never updates
+  ** the change-counter field, so the changeCountDone flag is always set.
+  */
+  assert( p->tempFile==0 || p->eLock==EXCLUSIVE_LOCK );
+  assert( p->tempFile==0 || pPager->changeCountDone );
+
+  /* If the useJournal flag is clear, the journal-mode must be "OFF". 
+  ** And if the journal-mode is "OFF", the journal file must not be open.
+  */
+  assert( p->journalMode==PAGER_JOURNALMODE_OFF || p->useJournal );
+  assert( p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd) );
+
+  /* Check that MEMDB implies noSync. And an in-memory journal. Since 
+  ** this means an in-memory pager performs no IO at all, it cannot encounter 
+  ** either SQLITE_IOERR or SQLITE_FULL during rollback or while finalizing 
+  ** a journal file. (although the in-memory journal implementation may 
+  ** return SQLITE_IOERR_NOMEM while the journal file is being written). It 
+  ** is therefore not possible for an in-memory pager to enter the ERROR 
+  ** state.
+  */
+  if( MEMDB ){
+    assert( p->noSync );
+    assert( p->journalMode==PAGER_JOURNALMODE_OFF 
+         || p->journalMode==PAGER_JOURNALMODE_MEMORY 
+    );
+    assert( p->eState!=PAGER_ERROR && p->eState!=PAGER_OPEN );
+    assert( pagerUseWal(p)==0 );
+  }
+
+  /* If changeCountDone is set, a RESERVED lock or greater must be held
+  ** on the file.
+  */
+  assert( pPager->changeCountDone==0 || pPager->eLock>=RESERVED_LOCK );
+  assert( p->eLock!=PENDING_LOCK );
+
+  switch( p->eState ){
+    case PAGER_OPEN:
+      assert( !MEMDB );
+      assert( pPager->errCode==SQLITE_OK );
+      assert( sqlite3PcacheRefCount(pPager->pPCache)==0 || pPager->tempFile );
+      break;
+
+    case PAGER_READER:
+      assert( pPager->errCode==SQLITE_OK );
+      assert( p->eLock!=UNKNOWN_LOCK );
+      assert( p->eLock>=SHARED_LOCK || p->noReadlock );
+      break;
+
+    case PAGER_WRITER_LOCKED:
+      assert( p->eLock!=UNKNOWN_LOCK );
+      assert( pPager->errCode==SQLITE_OK );
+      if( !pagerUseWal(pPager) ){
+        assert( p->eLock>=RESERVED_LOCK );
+      }
+      assert( pPager->dbSize==pPager->dbOrigSize );
+      assert( pPager->dbOrigSize==pPager->dbFileSize );
+      assert( pPager->dbOrigSize==pPager->dbHintSize );
+      assert( pPager->setMaster==0 );
+      break;
+
+    case PAGER_WRITER_CACHEMOD:
+      assert( p->eLock!=UNKNOWN_LOCK );
+      assert( pPager->errCode==SQLITE_OK );
+      if( !pagerUseWal(pPager) ){
+        /* It is possible that if journal_mode=wal here that neither the
+        ** journal file nor the WAL file are open. This happens during
+        ** a rollback transaction that switches from journal_mode=off
+        ** to journal_mode=wal.
+        */
+        assert( p->eLock>=RESERVED_LOCK );
+        assert( isOpen(p->jfd) 
+             || p->journalMode==PAGER_JOURNALMODE_OFF 
+             || p->journalMode==PAGER_JOURNALMODE_WAL 
+        );
+      }
+      assert( pPager->dbOrigSize==pPager->dbFileSize );
+      assert( pPager->dbOrigSize==pPager->dbHintSize );
+      break;
+
+    case PAGER_WRITER_DBMOD:
+      assert( p->eLock==EXCLUSIVE_LOCK );
+      assert( pPager->errCode==SQLITE_OK );
+      assert( !pagerUseWal(pPager) );
+      assert( p->eLock>=EXCLUSIVE_LOCK );
+      assert( isOpen(p->jfd) 
+           || p->journalMode==PAGER_JOURNALMODE_OFF 
+           || p->journalMode==PAGER_JOURNALMODE_WAL 
+      );
+      assert( pPager->dbOrigSize<=pPager->dbHintSize );
+      break;
 
-  /* A temp-file is always in PAGER_EXCLUSIVE or PAGER_SYNCED state. */
-  assert( pPager->tempFile==0 || pPager->state>=PAGER_EXCLUSIVE );
+    case PAGER_WRITER_FINISHED:
+      assert( p->eLock==EXCLUSIVE_LOCK );
+      assert( pPager->errCode==SQLITE_OK );
+      assert( !pagerUseWal(pPager) );
+      assert( isOpen(p->jfd) 
+           || p->journalMode==PAGER_JOURNALMODE_OFF 
+           || p->journalMode==PAGER_JOURNALMODE_WAL 
+      );
+      break;
 
-  /* The changeCountDone flag is always set for temp-files */
-  assert( pPager->tempFile==0 || pPager->changeCountDone );
+    case PAGER_ERROR:
+      /* There must be at least one outstanding reference to the pager if
+      ** in ERROR state. Otherwise the pager should have already dropped
+      ** back to OPEN state.
+      */
+      assert( pPager->errCode!=SQLITE_OK );
+      assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );
+      break;
+  }
 
   return 1;
 }
+
+/*
+** Return a pointer to a human readable string in a static buffer
+** containing the state of the Pager object passed as an argument. This
+** is intended to be used within debuggers. For example, as an alternative
+** to "print *pPager" in gdb:
+**
+** (gdb) printf "%s", print_pager_state(pPager)
+*/
+static char *print_pager_state(Pager *p){
+  static char zRet[1024];
+
+  sqlite3_snprintf(1024, zRet,
+      "Filename:      %s\n"
+      "State:         %s errCode=%d\n"
+      "Lock:          %s\n"
+      "Locking mode:  locking_mode=%s\n"
+      "Journal mode:  journal_mode=%s\n"
+      "Backing store: tempFile=%d memDb=%d useJournal=%d\n"
+      "Journal:       journalOff=%lld journalHdr=%lld\n"
+      "Size:          dbsize=%d dbOrigSize=%d dbFileSize=%d\n"
+      , p->zFilename
+      , p->eState==PAGER_OPEN            ? "OPEN" :
+        p->eState==PAGER_READER          ? "READER" :
+        p->eState==PAGER_WRITER_LOCKED   ? "WRITER_LOCKED" :
+        p->eState==PAGER_WRITER_CACHEMOD ? "WRITER_CACHEMOD" :
+        p->eState==PAGER_WRITER_DBMOD    ? "WRITER_DBMOD" :
+        p->eState==PAGER_WRITER_FINISHED ? "WRITER_FINISHED" :
+        p->eState==PAGER_ERROR           ? "ERROR" : "?error?"
+      , (int)p->errCode
+      , p->eLock==NO_LOCK         ? "NO_LOCK" :
+        p->eLock==RESERVED_LOCK   ? "RESERVED" :
+        p->eLock==EXCLUSIVE_LOCK  ? "EXCLUSIVE" :
+        p->eLock==SHARED_LOCK     ? "SHARED" :
+        p->eLock==UNKNOWN_LOCK    ? "UNKNOWN" : "?error?"
+      , p->exclusiveMode ? "exclusive" : "normal"
+      , p->journalMode==PAGER_JOURNALMODE_MEMORY   ? "memory" :
+        p->journalMode==PAGER_JOURNALMODE_OFF      ? "off" :
+        p->journalMode==PAGER_JOURNALMODE_DELETE   ? "delete" :
+        p->journalMode==PAGER_JOURNALMODE_PERSIST  ? "persist" :
+        p->journalMode==PAGER_JOURNALMODE_TRUNCATE ? "truncate" :
+        p->journalMode==PAGER_JOURNALMODE_WAL      ? "wal" : "?error?"
+      , (int)p->tempFile, (int)p->memDb, (int)p->useJournal
+      , p->journalOff, p->journalHdr
+      , (int)p->dbSize, (int)p->dbOrigSize, (int)p->dbFileSize
+  );
+
+  return zRet;
+}
 #endif
 
 /*
@@ -32650,6 +35603,7 @@ static int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){
 */
 #define put32bits(A,B)  sqlite3Put4byte((u8*)A,B)
 
+
 /*
 ** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK
 ** on success or an error code is something goes wrong.
@@ -32661,27 +35615,53 @@ static int write32bits(sqlite3_file *fd, i64 offset, u32 val){
 }
 
 /*
-** The argument to this macro is a file descriptor (type sqlite3_file*).
-** Return 0 if it is not open, or non-zero (but not 1) if it is.
-**
-** This is so that expressions can be written as:
-**
-**   if( isOpen(pPager->jfd) ){ ...
-**
-** instead of
+** Unlock the database file to level eLock, which must be either NO_LOCK
+** or SHARED_LOCK. Regardless of whether or not the call to xUnlock()
+** succeeds, set the Pager.eLock variable to match the (attempted) new lock.
 **
-**   if( pPager->jfd->pMethods ){ ...
+** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is
+** called, do not modify it. See the comment above the #define of 
+** UNKNOWN_LOCK for an explanation of this.
 */
-#define isOpen(pFd) ((pFd)->pMethods)
+static int pagerUnlockDb(Pager *pPager, int eLock){
+  int rc = SQLITE_OK;
+
+  assert( !pPager->exclusiveMode );
+  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );
+  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );
+  if( isOpen(pPager->fd) ){
+    assert( pPager->eLock>=eLock );
+    rc = sqlite3OsUnlock(pPager->fd, eLock);
+    if( pPager->eLock!=UNKNOWN_LOCK ){
+      pPager->eLock = (u8)eLock;
+    }
+    IOTRACE(("UNLOCK %p %d\n", pPager, eLock))
+  }
+  return rc;
+}
 
 /*
-** If file pFd is open, call sqlite3OsUnlock() on it.
+** Lock the database file to level eLock, which must be either SHARED_LOCK,
+** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the
+** Pager.eLock variable to the new locking state. 
+**
+** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is 
+** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. 
+** See the comment above the #define of UNKNOWN_LOCK for an explanation 
+** of this.
 */
-static int osUnlock(sqlite3_file *pFd, int eLock){
-  if( !isOpen(pFd) ){
-    return SQLITE_OK;
+static int pagerLockDb(Pager *pPager, int eLock){
+  int rc = SQLITE_OK;
+
+  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );
+  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){
+    rc = sqlite3OsLock(pPager->fd, eLock);
+    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){
+      pPager->eLock = (u8)eLock;
+      IOTRACE(("LOCK %p %d\n", pPager, eLock))
+    }
   }
-  return sqlite3OsUnlock(pFd, eLock);
+  return rc;
 }
 
 /*
@@ -32757,13 +35737,14 @@ static void pager_set_pagehash(PgHdr *pPage){
 #define CHECK_PAGE(x) checkPage(x)
 static void checkPage(PgHdr *pPg){
   Pager *pPager = pPg->pPager;
-  assert( !pPg->pageHash || pPager->errCode
-      || (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );
+  assert( pPager->eState!=PAGER_ERROR );
+  assert( (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );
 }
 
 #else
 #define pager_datahash(X,Y)  0
 #define pager_pagehash(X)  0
+#define pager_set_pagehash(X)
 #define CHECK_PAGE(x)
 #endif  /* SQLITE_CHECK_PAGES */
 
@@ -32930,7 +35911,7 @@ static int zeroJournalHdr(Pager *pPager, int doTruncate){
 static int writeJournalHdr(Pager *pPager){
   int rc = SQLITE_OK;                 /* Return code */
   char *zHeader = pPager->pTmpSpace;  /* Temporary space used to build header */
-  u32 nHeader = pPager->pageSize;     /* Size of buffer pointed to by zHeader */
+  u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */
   u32 nWrite;                         /* Bytes of header sector written */
   int ii;                             /* Loop counter */
 
@@ -32973,7 +35954,7 @@ static int writeJournalHdr(Pager *pPager){
   **     that garbage data is never appended to the journal file.
   */
   assert( isOpen(pPager->fd) || pPager->noSync );
-  if( (pPager->noSync) || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)
+  if( pPager->noSync || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)
    || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND) 
   ){
     memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));
@@ -33021,6 +36002,7 @@ static int writeJournalHdr(Pager *pPager){
   for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){
     IOTRACE(("JHDR %p %lld %d\n", pPager, pPager->journalHdr, nHeader))
     rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);
+    assert( pPager->journalHdr <= pPager->journalOff );
     pPager->journalOff += nHeader;
   }
 
@@ -33096,7 +36078,6 @@ static int readJournalHdr(
   if( pPager->journalOff==0 ){
     u32 iPageSize;               /* Page-size field of journal header */
     u32 iSectorSize;             /* Sector-size field of journal header */
-    u16 iPageSize16;             /* Copy of iPageSize in 16-bit variable */
 
     /* Read the page-size and sector-size journal header fields. */
     if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))
@@ -33105,6 +36086,14 @@ static int readJournalHdr(
       return rc;
     }
 
+    /* Versions of SQLite prior to 3.5.8 set the page-size field of the
+    ** journal header to zero. In this case, assume that the Pager.pageSize
+    ** variable is already set to the correct page size.
+    */
+    if( iPageSize==0 ){
+      iPageSize = pPager->pageSize;
+    }
+
     /* Check that the values read from the page-size and sector-size fields
     ** are within range. To be 'in range', both values need to be a power
     ** of two greater than or equal to 512 or 32, and not greater than their 
@@ -33126,10 +36115,8 @@ static int readJournalHdr(
     ** Use a testcase() macro to make sure that malloc failure within 
     ** PagerSetPagesize() is tested.
     */
-    iPageSize16 = (u16)iPageSize;
-    rc = sqlite3PagerSetPagesize(pPager, &iPageSize16, -1);
+    rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);
     testcase( rc!=SQLITE_OK );
-    assert( rc!=SQLITE_OK || iPageSize16==(u16)iPageSize );
 
     /* Update the assumed sector-size to match the value used by 
     ** the process that created this journal. If this journal was
@@ -33171,7 +36158,10 @@ static int writeMasterJournal(Pager *pPager, const char *zMaster){
   i64 jrnlSize;                    /* Size of journal file on disk */
   u32 cksum = 0;                   /* Checksum of string zMaster */
 
-  if( !zMaster || pPager->setMaster
+  assert( pPager->setMaster==0 );
+  assert( !pagerUseWal(pPager) );
+
+  if( !zMaster 
    || pPager->journalMode==PAGER_JOURNALMODE_MEMORY 
    || pPager->journalMode==PAGER_JOURNALMODE_OFF 
   ){
@@ -33179,6 +36169,7 @@ static int writeMasterJournal(Pager *pPager, const char *zMaster){
   }
   pPager->setMaster = 1;
   assert( isOpen(pPager->jfd) );
+  assert( pPager->journalHdr <= pPager->journalOff );
 
   /* Calculate the length in bytes and the checksum of zMaster */
   for(nMaster=0; zMaster[nMaster]; nMaster++){
@@ -33206,7 +36197,6 @@ static int writeMasterJournal(Pager *pPager, const char *zMaster){
     return rc;
   }
   pPager->journalOff += (nMaster+20);
-  pPager->needSync = !pPager->noSync;
 
   /* If the pager is in peristent-journal mode, then the physical 
   ** journal-file may extend past the end of the master-journal name
@@ -33242,17 +36232,11 @@ static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){
 }
 
 /*
-** Unless the pager is in error-state, discard all in-memory pages. If
-** the pager is in error-state, then this call is a no-op.
-**
-** TODO: Why can we not reset the pager while in error state?
+** Discard the entire contents of the in-memory page-cache.
 */
 static void pager_reset(Pager *pPager){
-  if( SQLITE_OK==pPager->errCode ){
-    sqlite3BackupRestart(pPager->pBackup);
-    sqlite3PcacheClear(pPager->pPCache);
-    pPager->dbSizeValid = 0;
-  }
+  sqlite3BackupRestart(pPager->pBackup);
+  sqlite3PcacheClear(pPager->pPCache);
 }
 
 /*
@@ -33295,71 +36279,108 @@ static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
 }
 
 /*
-** Unlock the database file. This function is a no-op if the pager
-** is in exclusive mode.
+** This function is a no-op if the pager is in exclusive mode and not
+** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
+** state.
+**
+** If the pager is not in exclusive-access mode, the database file is
+** completely unlocked. If the file is unlocked and the file-system does
+** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is
+** closed (if it is open).
 **
-** If the pager is currently in error state, discard the contents of 
-** the cache and reset the Pager structure internal state. If there is
-** an open journal-file, then the next time a shared-lock is obtained
-** on the pager file (by this or any other process), it will be
-** treated as a hot-journal and rolled back.
+** If the pager is in ERROR state when this function is called, the 
+** contents of the pager cache are discarded before switching back to 
+** the OPEN state. Regardless of whether the pager is in exclusive-mode
+** or not, any journal file left in the file-system will be treated
+** as a hot-journal and rolled back the next time a read-transaction
+** is opened (by this or by any other connection).
 */
 static void pager_unlock(Pager *pPager){
-  if( !pPager->exclusiveMode ){
-    int rc;                      /* Return code */
 
-    /* Always close the journal file when dropping the database lock.
-    ** Otherwise, another connection with journal_mode=delete might
-    ** delete the file out from under us.
-    */
-    sqlite3OsClose(pPager->jfd);
-    sqlite3BitvecDestroy(pPager->pInJournal);
-    pPager->pInJournal = 0;
-    releaseAllSavepoints(pPager);
+  assert( pPager->eState==PAGER_READER 
+       || pPager->eState==PAGER_OPEN 
+       || pPager->eState==PAGER_ERROR 
+  );
 
-    /* If the file is unlocked, somebody else might change it. The
-    ** values stored in Pager.dbSize etc. might become invalid if
-    ** this happens. TODO: Really, this doesn't need to be cleared
-    ** until the change-counter check fails in PagerSharedLock().
-    */
-    pPager->dbSizeValid = 0;
+  sqlite3BitvecDestroy(pPager->pInJournal);
+  pPager->pInJournal = 0;
+  releaseAllSavepoints(pPager);
 
-    rc = osUnlock(pPager->fd, NO_LOCK);
-    if( rc ){
-      pPager->errCode = rc;
+  if( pagerUseWal(pPager) ){
+    assert( !isOpen(pPager->jfd) );
+    sqlite3WalEndReadTransaction(pPager->pWal);
+    pPager->eState = PAGER_OPEN;
+  }else if( !pPager->exclusiveMode ){
+    int rc;                       /* Error code returned by pagerUnlockDb() */
+    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;
+
+    /* If the operating system support deletion of open files, then
+    ** close the journal file when dropping the database lock.  Otherwise
+    ** another connection with journal_mode=delete might delete the file
+    ** out from under us.
+    */
+    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );
+    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );
+    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );
+    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );
+    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );
+    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );
+    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)
+     || 1!=(pPager->journalMode & 5)
+    ){
+      sqlite3OsClose(pPager->jfd);
     }
-    IOTRACE(("UNLOCK %p\n", pPager))
 
-    /* If Pager.errCode is set, the contents of the pager cache cannot be
-    ** trusted. Now that the pager file is unlocked, the contents of the
-    ** cache can be discarded and the error code safely cleared.
+    /* If the pager is in the ERROR state and the call to unlock the database
+    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment
+    ** above the #define for UNKNOWN_LOCK for an explanation of why this
+    ** is necessary.
     */
-    if( pPager->errCode ){
-      if( rc==SQLITE_OK ){
-        pPager->errCode = SQLITE_OK;
-      }
-      pager_reset(pPager);
+    rc = pagerUnlockDb(pPager, NO_LOCK);
+    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){
+      pPager->eLock = UNKNOWN_LOCK;
     }
 
+    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here
+    ** without clearing the error code. This is intentional - the error
+    ** code is cleared and the cache reset in the block below.
+    */
+    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );
     pPager->changeCountDone = 0;
-    pPager->state = PAGER_UNLOCK;
-    pPager->dbModified = 0;
+    pPager->eState = PAGER_OPEN;
   }
+
+  /* If Pager.errCode is set, the contents of the pager cache cannot be
+  ** trusted. Now that there are no outstanding references to the pager,
+  ** it can safely move back to PAGER_OPEN state. This happens in both
+  ** normal and exclusive-locking mode.
+  */
+  if( pPager->errCode ){
+    assert( !MEMDB );
+    pager_reset(pPager);
+    pPager->changeCountDone = pPager->tempFile;
+    pPager->eState = PAGER_OPEN;
+    pPager->errCode = SQLITE_OK;
+  }
+
+  pPager->journalOff = 0;
+  pPager->journalHdr = 0;
+  pPager->setMaster = 0;
 }
 
 /*
-** This function should be called when an IOERR, CORRUPT or FULL error
-** may have occurred. The first argument is a pointer to the pager 
-** structure, the second the error-code about to be returned by a pager 
-** API function. The value returned is a copy of the second argument 
-** to this function. 
+** This function is called whenever an IOERR or FULL error that requires
+** the pager to transition into the ERROR state may ahve occurred.
+** The first argument is a pointer to the pager structure, the second 
+** the error-code about to be returned by a pager API function. The 
+** value returned is a copy of the second argument to this function. 
 **
-** If the second argument is SQLITE_IOERR, SQLITE_CORRUPT, or SQLITE_FULL
-** the error becomes persistent. Until the persisten error is cleared,
-** subsequent API calls on this Pager will immediately return the same 
-** error code.
+** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the
+** IOERR sub-codes, the pager enters the ERROR state and the error code
+** is stored in Pager.errCode. While the pager remains in the ERROR state,
+** all major API calls on the Pager will immediately return Pager.errCode.
 **
-** A persistent error indicates that the contents of the pager-cache 
+** The ERROR state indicates that the contents of the pager-cache 
 ** cannot be trusted. This state can be cleared by completely discarding 
 ** the contents of the pager-cache. If a transaction was active when
 ** the persistent error occurred, then the rollback journal may need
@@ -33376,45 +36397,21 @@ static int pager_error(Pager *pPager, int rc){
   );
   if( rc2==SQLITE_FULL || rc2==SQLITE_IOERR ){
     pPager->errCode = rc;
+    pPager->eState = PAGER_ERROR;
   }
   return rc;
 }
 
 /*
-** Execute a rollback if a transaction is active and unlock the 
-** database file. 
-**
-** If the pager has already entered the error state, do not attempt 
-** the rollback at this time. Instead, pager_unlock() is called. The
-** call to pager_unlock() will discard all in-memory pages, unlock
-** the database file and clear the error state. If this means that
-** there is a hot-journal left in the file-system, the next connection
-** to obtain a shared lock on the pager (which may be this one) will
-** roll it back.
-**
-** If the pager has not already entered the error state, but an IO or
-** malloc error occurs during a rollback, then this will itself cause 
-** the pager to enter the error state. Which will be cleared by the
-** call to pager_unlock(), as described above.
-*/
-static void pagerUnlockAndRollback(Pager *pPager){
-  if( pPager->errCode==SQLITE_OK && pPager->state>=PAGER_RESERVED ){
-    sqlite3BeginBenignMalloc();
-    sqlite3PagerRollback(pPager);
-    sqlite3EndBenignMalloc();
-  }
-  pager_unlock(pPager);
-}
-
-/*
 ** This routine ends a transaction. A transaction is usually ended by 
 ** either a COMMIT or a ROLLBACK operation. This routine may be called 
 ** after rollback of a hot-journal, or if an error occurs while opening
 ** the journal file or writing the very first journal-header of a
 ** database transaction.
 ** 
-** If the pager is in PAGER_SHARED or PAGER_UNLOCK state when this
-** routine is called, it is a no-op (returns SQLITE_OK).
+** This routine is never called in PAGER_ERROR state. If it is called
+** in PAGER_NONE or PAGER_SHARED state and the lock held is less
+** exclusive than a RESERVED lock, it is a no-op.
 **
 ** Otherwise, any active savepoints are released.
 **
@@ -33445,13 +36442,9 @@ static void pagerUnlockAndRollback(Pager *pPager){
 **     DELETE and the pager is in exclusive mode, the method described under
 **     journalMode==PERSIST is used instead.
 **
-** After the journal is finalized, if running in non-exclusive mode, the
-** pager moves to PAGER_SHARED state (and downgrades the lock on the
-** database file accordingly).
-**
-** If the pager is running in exclusive mode and is in PAGER_SYNCED state,
-** it moves to PAGER_EXCLUSIVE. No locks are downgraded when running in
-** exclusive mode.
+** After the journal is finalized, the pager moves to PAGER_READER state.
+** If running in non-exclusive rollback mode, the lock on the file is 
+** downgraded to a SHARED_LOCK.
 **
 ** SQLITE_OK is returned if no error occurs. If an error occurs during
 ** any of the IO operations to finalize the journal file or unlock the
@@ -33466,13 +36459,29 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){
   int rc = SQLITE_OK;      /* Error code from journal finalization operation */
   int rc2 = SQLITE_OK;     /* Error code from db file unlock operation */
 
-  if( pPager->state<PAGER_RESERVED ){
+  /* Do nothing if the pager does not have an open write transaction
+  ** or at least a RESERVED lock. This function may be called when there
+  ** is no write-transaction active but a RESERVED or greater lock is
+  ** held under two circumstances:
+  **
+  **   1. After a successful hot-journal rollback, it is called with
+  **      eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK.
+  **
+  **   2. If a connection with locking_mode=exclusive holding an EXCLUSIVE 
+  **      lock switches back to locking_mode=normal and then executes a
+  **      read-transaction, this function is called with eState==PAGER_READER 
+  **      and eLock==EXCLUSIVE_LOCK when the read-transaction is closed.
+  */
+  assert( assert_pager_state(pPager) );
+  assert( pPager->eState!=PAGER_ERROR );
+  if( pPager->eState<PAGER_WRITER_LOCKED && pPager->eLock<RESERVED_LOCK ){
     return SQLITE_OK;
   }
-  releaseAllSavepoints(pPager);
 
+  releaseAllSavepoints(pPager);
   assert( isOpen(pPager->jfd) || pPager->pInJournal==0 );
   if( isOpen(pPager->jfd) ){
+    assert( !pagerUseWal(pPager) );
 
     /* Finalize the journal file. */
     if( sqlite3IsMemJournal(pPager->jfd) ){
@@ -33485,61 +36494,98 @@ static int pager_end_transaction(Pager *pPager, int hasMaster){
         rc = sqlite3OsTruncate(pPager->jfd, 0);
       }
       pPager->journalOff = 0;
-      pPager->journalStarted = 0;
-    }else if( pPager->exclusiveMode 
-     || pPager->journalMode==PAGER_JOURNALMODE_PERSIST
+    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
+      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)
     ){
       rc = zeroJournalHdr(pPager, hasMaster);
-      pager_error(pPager, rc);
       pPager->journalOff = 0;
-      pPager->journalStarted = 0;
     }else{
       /* This branch may be executed with Pager.journalMode==MEMORY if
       ** a hot-journal was just rolled back. In this case the journal
       ** file should be closed and deleted. If this connection writes to
-      ** the database file, it will do so using an in-memory journal.  */
+      ** the database file, it will do so using an in-memory journal. 
+      */
       assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE 
            || pPager->journalMode==PAGER_JOURNALMODE_MEMORY 
+           || pPager->journalMode==PAGER_JOURNALMODE_WAL 
       );
       sqlite3OsClose(pPager->jfd);
       if( !pPager->tempFile ){
         rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
       }
     }
+  }
 
 #ifdef SQLITE_CHECK_PAGES
-    sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);
+  sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);
+  if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){
+    PgHdr *p = pager_lookup(pPager, 1);
+    if( p ){
+      p->pageHash = 0;
+      sqlite3PagerUnref(p);
+    }
+  }
 #endif
 
-    sqlite3PcacheCleanAll(pPager->pPCache);
-    sqlite3BitvecDestroy(pPager->pInJournal);
-    pPager->pInJournal = 0;
-    pPager->nRec = 0;
-  }
+  sqlite3BitvecDestroy(pPager->pInJournal);
+  pPager->pInJournal = 0;
+  pPager->nRec = 0;
+  sqlite3PcacheCleanAll(pPager->pPCache);
+  sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);
 
-  if( !pPager->exclusiveMode ){
-    rc2 = osUnlock(pPager->fd, SHARED_LOCK);
-    pPager->state = PAGER_SHARED;
+  if( pagerUseWal(pPager) ){
+    /* Drop the WAL write-lock, if any. Also, if the connection was in 
+    ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE 
+    ** lock held on the database file.
+    */
+    rc2 = sqlite3WalEndWriteTransaction(pPager->pWal);
+    assert( rc2==SQLITE_OK );
+  }
+  if( !pPager->exclusiveMode 
+   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))
+  ){
+    rc2 = pagerUnlockDb(pPager, SHARED_LOCK);
     pPager->changeCountDone = 0;
-  }else if( pPager->state==PAGER_SYNCED ){
-    pPager->state = PAGER_EXCLUSIVE;
   }
+  pPager->eState = PAGER_READER;
   pPager->setMaster = 0;
-  pPager->needSync = 0;
-  pPager->dbModified = 0;
-
-  /* TODO: Is this optimal? Why is the db size invalidated here 
-  ** when the database file is not unlocked? */
-  pPager->dbOrigSize = 0;
-  sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);
-  if( !MEMDB ){
-    pPager->dbSizeValid = 0;
-  }
 
   return (rc==SQLITE_OK?rc2:rc);
 }
 
 /*
+** Execute a rollback if a transaction is active and unlock the 
+** database file. 
+**
+** If the pager has already entered the ERROR state, do not attempt 
+** the rollback at this time. Instead, pager_unlock() is called. The
+** call to pager_unlock() will discard all in-memory pages, unlock
+** the database file and move the pager back to OPEN state. If this 
+** means that there is a hot-journal left in the file-system, the next 
+** connection to obtain a shared lock on the pager (which may be this one) 
+** will roll it back.
+**
+** If the pager has not already entered the ERROR state, but an IO or
+** malloc error occurs during a rollback, then this will itself cause 
+** the pager to enter the ERROR state. Which will be cleared by the
+** call to pager_unlock(), as described above.
+*/
+static void pagerUnlockAndRollback(Pager *pPager){
+  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){
+    assert( assert_pager_state(pPager) );
+    if( pPager->eState>=PAGER_WRITER_LOCKED ){
+      sqlite3BeginBenignMalloc();
+      sqlite3PagerRollback(pPager);
+      sqlite3EndBenignMalloc();
+    }else if( !pPager->exclusiveMode ){
+      assert( pPager->eState==PAGER_READER );
+      pager_end_transaction(pPager, 0);
+    }
+  }
+  pager_unlock(pPager);
+}
+
+/*
 ** Parameter aData must point to a buffer of pPager->pageSize bytes
 ** of data. Compute and return a checksum based ont the contents of the 
 ** page of data and the current value of pPager->cksumInit.
@@ -33569,14 +36615,28 @@ static u32 pager_cksum(Pager *pPager, const u8 *aData){
 }
 
 /*
+** Report the current page size and number of reserved bytes back
+** to the codec.
+*/
+#ifdef SQLITE_HAS_CODEC
+static void pagerReportSize(Pager *pPager){
+  if( pPager->xCodecSizeChng ){
+    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,
+                           (int)pPager->nReserve);
+  }
+}
+#else
+# define pagerReportSize(X)     /* No-op if we do not support a codec */
+#endif
+
+/*
 ** Read a single page from either the journal file (if isMainJrnl==1) or
 ** from the sub-journal (if isMainJrnl==0) and playback that page.
 ** The page begins at offset *pOffset into the file. The *pOffset
 ** value is increased to the start of the next page in the journal.
 **
-** The isMainJrnl flag is true if this is the main rollback journal and
-** false for the statement journal.  The main rollback journal uses
-** checksums - the statement journal does not.
+** The main rollback journal uses checksums - the statement journal does 
+** not.
 **
 ** If the page number of the page record read from the (sub-)journal file
 ** is greater than the current value of Pager.dbSize, then playback is
@@ -33608,11 +36668,10 @@ static u32 pager_cksum(Pager *pPager, const u8 *aData){
 */
 static int pager_playback_one_page(
   Pager *pPager,                /* The pager being played back */
-  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */
-  int isUnsync,                 /* True if reading from unsynced main journal */
   i64 *pOffset,                 /* Offset of record to playback */
-  int isSavepnt,                /* True for a savepoint rollback */
-  Bitvec *pDone                 /* Bitvec of pages already played back */
+  Bitvec *pDone,                /* Bitvec of pages already played back */
+  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */
+  int isSavepnt                 /* True for a savepoint rollback */
 ){
   int rc;
   PgHdr *pPg;                   /* An existing page in the cache */
@@ -33620,6 +36679,7 @@ static int pager_playback_one_page(
   u32 cksum;                    /* Checksum used for sanity checking */
   char *aData;                  /* Temporary storage for the page */
   sqlite3_file *jfd;            /* The file descriptor for the journal file */
+  int isSynced;                 /* True if journal page is synced */
 
   assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */
   assert( (isSavepnt&~1)==0 );       /* isSavepnt is 0 or 1 */
@@ -33628,6 +36688,18 @@ static int pager_playback_one_page(
 
   aData = pPager->pTmpSpace;
   assert( aData );         /* Temp storage must have already been allocated */
+  assert( pagerUseWal(pPager)==0 || (!isMainJrnl && isSavepnt) );
+
+  /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction 
+  ** or savepoint rollback done at the request of the caller) or this is
+  ** a hot-journal rollback. If it is a hot-journal rollback, the pager
+  ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
+  ** only reads from the main journal, not the sub-journal.
+  */
+  assert( pPager->eState>=PAGER_WRITER_CACHEMOD
+       || (pPager->eState==PAGER_OPEN && pPager->eLock==EXCLUSIVE_LOCK)
+  );
+  assert( pPager->eState>=PAGER_WRITER_CACHEMOD || isMainJrnl );
 
   /* Read the page number and page data from the journal or sub-journal
   ** file. Return an error code to the caller if an IO error occurs.
@@ -33659,13 +36731,21 @@ static int pager_playback_one_page(
     }
   }
 
+  /* If this page has already been played by before during the current
+  ** rollback, then don't bother to play it back again.
+  */
   if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){
     return rc;
   }
 
-  assert( pPager->state==PAGER_RESERVED || pPager->state>=PAGER_EXCLUSIVE );
+  /* When playing back page 1, restore the nReserve setting
+  */
+  if( pgno==1 && pPager->nReserve!=((u8*)aData)[20] ){
+    pPager->nReserve = ((u8*)aData)[20];
+    pagerReportSize(pPager);
+  }
 
-  /* If the pager is in RESERVED state, then there must be a copy of this
+  /* If the pager is in CACHEMOD state, then there must be a copy of this
   ** page in the pager cache. In this case just update the pager cache,
   ** not the database file. The page is left marked dirty in this case.
   **
@@ -33676,8 +36756,11 @@ static int pager_playback_one_page(
   ** either. So the condition described in the above paragraph is not
   ** assert()able.
   **
-  ** If in EXCLUSIVE state, then we update the pager cache if it exists
-  ** and the main file. The page is then marked not dirty.
+  ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the
+  ** pager cache if it exists and the main file. The page is then marked 
+  ** not dirty. Since this code is only executed in PAGER_OPEN state for
+  ** a hot-journal rollback, it is guaranteed that the page-cache is empty
+  ** if the pager is in OPEN state.
   **
   ** Ticket #1171:  The statement journal might contain page content that is
   ** different from the page content at the start of the transaction.
@@ -33697,18 +36780,29 @@ static int pager_playback_one_page(
   ** is possible to fail a statement on a database that does not yet exist.
   ** Do not attempt to write if database file has never been opened.
   */
-  pPg = pager_lookup(pPager, pgno);
+  if( pagerUseWal(pPager) ){
+    pPg = 0;
+  }else{
+    pPg = pager_lookup(pPager, pgno);
+  }
   assert( pPg || !MEMDB );
+  assert( pPager->eState!=PAGER_OPEN || pPg==0 );
   PAGERTRACE(("PLAYBACK %d page %d hash(%08x) %s\n",
            PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),
            (isMainJrnl?"main-journal":"sub-journal")
   ));
-  if( (pPager->state>=PAGER_EXCLUSIVE)
-   && (pPg==0 || 0==(pPg->flags&PGHDR_NEED_SYNC))
-   && isOpen(pPager->fd)
-   && !isUnsync
+  if( isMainJrnl ){
+    isSynced = pPager->noSync || (*pOffset <= pPager->journalHdr);
+  }else{
+    isSynced = (pPg==0 || 0==(pPg->flags & PGHDR_NEED_SYNC));
+  }
+  if( isOpen(pPager->fd)
+   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
+   && isSynced
   ){
     i64 ofst = (pgno-1)*(i64)pPager->pageSize;
+    testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 );
+    assert( !pagerUseWal(pPager) );
     rc = sqlite3OsWrite(pPager->fd, (u8*)aData, pPager->pageSize, ofst);
     if( pgno>pPager->dbFileSize ){
       pPager->dbFileSize = pgno;
@@ -33736,9 +36830,12 @@ static int pager_playback_one_page(
     ** requiring a journal-sync before it is written.
     */
     assert( isSavepnt );
-    if( (rc = sqlite3PagerAcquire(pPager, pgno, &pPg, 1))!=SQLITE_OK ){
-      return rc;
-    }
+    assert( pPager->doNotSpill==0 );
+    pPager->doNotSpill++;
+    rc = sqlite3PagerAcquire(pPager, pgno, &pPg, 1);
+    assert( pPager->doNotSpill==1 );
+    pPager->doNotSpill--;
+    if( rc!=SQLITE_OK ) return rc;
     pPg->flags &= ~PGHDR_NEED_READ;
     sqlite3PcacheMakeDirty(pPg);
   }
@@ -33757,7 +36854,8 @@ static int pager_playback_one_page(
       /* If the contents of this page were just restored from the main 
       ** journal file, then its content must be as they were when the 
       ** transaction was first opened. In this case we can mark the page
-      ** as clean, since there will be no need to write it out to the.
+      ** as clean, since there will be no need to write it out to the
+      ** database.
       **
       ** There is one exception to this rule. If the page is being rolled
       ** back as part of a savepoint (or statement) rollback from an 
@@ -33772,11 +36870,11 @@ static int pager_playback_one_page(
       ** segment is synced. If a crash occurs during or following this,
       ** database corruption may ensue.
       */
+      assert( !pagerUseWal(pPager) );
       sqlite3PcacheMakeClean(pPg);
     }
-#ifdef SQLITE_CHECK_PAGES
-    pPg->pageHash = pager_pagehash(pPg);
-#endif
+    pager_set_pagehash(pPg);
+
     /* If this was page 1, then restore the value of Pager.dbFileVers.
     ** Do this before any decoding. */
     if( pgno==1 ){
@@ -33840,6 +36938,9 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){
   sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */
   char *zMasterJournal = 0; /* Contents of master journal file */
   i64 nMasterJournal;       /* Size of master journal file */
+  char *zJournal;           /* Pointer to one journal within MJ file */
+  char *zMasterPtr;         /* Space to hold MJ filename from a journal file */
+  int nMasterPtr;           /* Amount of space allocated to zMasterPtr[] */
 
   /* Allocate space for both the pJournal and pMaster file descriptors.
   ** If successful, open the master journal file for reading.
@@ -33854,73 +36955,68 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){
   }
   if( rc!=SQLITE_OK ) goto delmaster_out;
 
+  /* Load the entire master journal file into space obtained from
+  ** sqlite3_malloc() and pointed to by zMasterJournal.   Also obtain
+  ** sufficient space (in zMasterPtr) to hold the names of master
+  ** journal files extracted from regular rollback-journals.
+  */
   rc = sqlite3OsFileSize(pMaster, &nMasterJournal);
   if( rc!=SQLITE_OK ) goto delmaster_out;
+  nMasterPtr = pVfs->mxPathname+1;
+  zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1);
+  if( !zMasterJournal ){
+    rc = SQLITE_NOMEM;
+    goto delmaster_out;
+  }
+  zMasterPtr = &zMasterJournal[nMasterJournal+1];
+  rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
+  if( rc!=SQLITE_OK ) goto delmaster_out;
+  zMasterJournal[nMasterJournal] = 0;
 
-  if( nMasterJournal>0 ){
-    char *zJournal;
-    char *zMasterPtr = 0;
-    int nMasterPtr = pVfs->mxPathname+1;
-
-    /* Load the entire master journal file into space obtained from
-    ** sqlite3_malloc() and pointed to by zMasterJournal. 
-    */
-    zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1);
-    if( !zMasterJournal ){
-      rc = SQLITE_NOMEM;
+  zJournal = zMasterJournal;
+  while( (zJournal-zMasterJournal)<nMasterJournal ){
+    int exists;
+    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
+    if( rc!=SQLITE_OK ){
       goto delmaster_out;
     }
-    zMasterPtr = &zMasterJournal[nMasterJournal+1];
-    rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);
-    if( rc!=SQLITE_OK ) goto delmaster_out;
-    zMasterJournal[nMasterJournal] = 0;
-
-    zJournal = zMasterJournal;
-    while( (zJournal-zMasterJournal)<nMasterJournal ){
-      int exists;
-      rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
+    if( exists ){
+      /* One of the journals pointed to by the master journal exists.
+      ** Open it and check if it points at the master journal. If
+      ** so, return without deleting the master journal file.
+      */
+      int c;
+      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);
+      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);
       if( rc!=SQLITE_OK ){
         goto delmaster_out;
       }
-      if( exists ){
-        /* One of the journals pointed to by the master journal exists.
-        ** Open it and check if it points at the master journal. If
-        ** so, return without deleting the master journal file.
-        */
-        int c;
-        int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);
-        rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);
-        if( rc!=SQLITE_OK ){
-          goto delmaster_out;
-        }
 
-        rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);
-        sqlite3OsClose(pJournal);
-        if( rc!=SQLITE_OK ){
-          goto delmaster_out;
-        }
+      rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);
+      sqlite3OsClose(pJournal);
+      if( rc!=SQLITE_OK ){
+        goto delmaster_out;
+      }
 
-        c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;
-        if( c ){
-          /* We have a match. Do not delete the master journal file. */
-          goto delmaster_out;
-        }
+      c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;
+      if( c ){
+        /* We have a match. Do not delete the master journal file. */
+        goto delmaster_out;
       }
-      zJournal += (sqlite3Strlen30(zJournal)+1);
     }
+    zJournal += (sqlite3Strlen30(zJournal)+1);
   }
-  
+ 
+  sqlite3OsClose(pMaster);
   rc = sqlite3OsDelete(pVfs, zMaster, 0);
 
 delmaster_out:
-  if( zMasterJournal ){
-    sqlite3_free(zMasterJournal);
-  }  
+  sqlite3_free(zMasterJournal);
   if( pMaster ){
     sqlite3OsClose(pMaster);
     assert( !isOpen(pJournal) );
+    sqlite3_free(pMaster);
   }
-  sqlite3_free(pMaster);
   return rc;
 }
 
@@ -33930,10 +37026,10 @@ delmaster_out:
 ** file in the file-system. This only happens when committing a transaction,
 ** or rolling back a transaction (including rolling back a hot-journal).
 **
-** If the main database file is not open, or an exclusive lock is not
-** held, this function is a no-op. Otherwise, the size of the file is
-** changed to nPage pages (nPage*pPager->pageSize bytes). If the file
-** on disk is currently larger than nPage pages, then use the VFS
+** If the main database file is not open, or the pager is not in either
+** DBMOD or OPEN state, this function is a no-op. Otherwise, the size 
+** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). 
+** If the file on disk is currently larger than nPage pages, then use the VFS
 ** xTruncate() method to truncate it.
 **
 ** Or, it might might be the case that the file on disk is smaller than 
@@ -33947,8 +37043,14 @@ delmaster_out:
 */
 static int pager_truncate(Pager *pPager, Pgno nPage){
   int rc = SQLITE_OK;
-  if( pPager->state>=PAGER_EXCLUSIVE && isOpen(pPager->fd) ){
+  assert( pPager->eState!=PAGER_ERROR );
+  assert( pPager->eState!=PAGER_READER );
+  
+  if( isOpen(pPager->fd) 
+   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) 
+  ){
     i64 currentSize, newSize;
+    assert( pPager->eLock==EXCLUSIVE_LOCK );
     /* TODO: Is it safe to use Pager.dbFileSize here? */
     rc = sqlite3OsFileSize(pPager->fd, &currentSize);
     newSize = pPager->pageSize*(i64)nPage;
@@ -34072,7 +37174,7 @@ static int pager_playback(Pager *pPager, int isHot){
   */
   assert( isOpen(pPager->jfd) );
   rc = sqlite3OsFileSize(pPager->jfd, &szJ);
-  if( rc!=SQLITE_OK || szJ==0 ){
+  if( rc!=SQLITE_OK ){
     goto end_playback;
   }
 
@@ -34104,11 +37206,9 @@ static int pager_playback(Pager *pPager, int isHot){
   ** occurs. 
   */
   while( 1 ){
-    int isUnsync = 0;
-
     /* Read the next journal header from the journal file.  If there are
     ** not enough bytes left in the journal file for a complete header, or
-    ** it is corrupted, then a process must of failed while writing it.
+    ** it is corrupted, then a process must have failed while writing it.
     ** This indicates nothing more needs to be rolled back.
     */
     rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);
@@ -34146,7 +37246,6 @@ static int pager_playback(Pager *pPager, int isHot){
     if( nRec==0 && !isHot &&
         pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){
       nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));
-      isUnsync = 1;
     }
 
     /* If this is the first header read from the journal, truncate the
@@ -34168,12 +37267,20 @@ static int pager_playback(Pager *pPager, int isHot){
         pager_reset(pPager);
         needPagerReset = 0;
       }
-      rc = pager_playback_one_page(pPager,1,isUnsync,&pPager->journalOff,0,0);
+      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);
       if( rc!=SQLITE_OK ){
         if( rc==SQLITE_DONE ){
           rc = SQLITE_OK;
           pPager->journalOff = szJ;
           break;
+        }else if( rc==SQLITE_IOERR_SHORT_READ ){
+          /* If the journal has been truncated, simply stop reading and
+          ** processing the journal. This might happen if the journal was
+          ** not completely written and synced prior to a crash.  In that
+          ** case, the database should have never been written in the
+          ** first place so it is OK to simply abandon the rollback. */
+          rc = SQLITE_OK;
+          goto end_playback;
         }else{
           /* If we are unable to rollback, quit and return the error
           ** code.  This will cause the pager to enter the error state
@@ -34215,7 +37322,9 @@ end_playback:
     rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
     testcase( rc!=SQLITE_OK );
   }
-  if( rc==SQLITE_OK && pPager->noSync==0 && pPager->state>=PAGER_EXCLUSIVE ){
+  if( rc==SQLITE_OK && !pPager->noSync 
+   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
+  ){
     rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
   }
   if( rc==SQLITE_OK ){
@@ -34238,6 +37347,320 @@ end_playback:
   return rc;
 }
 
+
+/*
+** Read the content for page pPg out of the database file and into 
+** pPg->pData. A shared lock or greater must be held on the database
+** file before this function is called.
+**
+** If page 1 is read, then the value of Pager.dbFileVers[] is set to
+** the value read from the database file.
+**
+** If an IO error occurs, then the IO error is returned to the caller.
+** Otherwise, SQLITE_OK is returned.
+*/
+static int readDbPage(PgHdr *pPg){
+  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */
+  Pgno pgno = pPg->pgno;       /* Page number to read */
+  int rc = SQLITE_OK;          /* Return code */
+  int isInWal = 0;             /* True if page is in log file */
+  int pgsz = pPager->pageSize; /* Number of bytes to read */
+
+  assert( pPager->eState>=PAGER_READER && !MEMDB );
+  assert( isOpen(pPager->fd) );
+
+  if( NEVER(!isOpen(pPager->fd)) ){
+    assert( pPager->tempFile );
+    memset(pPg->pData, 0, pPager->pageSize);
+    return SQLITE_OK;
+  }
+
+  if( pagerUseWal(pPager) ){
+    /* Try to pull the page from the write-ahead log. */
+    rc = sqlite3WalRead(pPager->pWal, pgno, &isInWal, pgsz, pPg->pData);
+  }
+  if( rc==SQLITE_OK && !isInWal ){
+    i64 iOffset = (pgno-1)*(i64)pPager->pageSize;
+    rc = sqlite3OsRead(pPager->fd, pPg->pData, pgsz, iOffset);
+    if( rc==SQLITE_IOERR_SHORT_READ ){
+      rc = SQLITE_OK;
+    }
+  }
+
+  if( pgno==1 ){
+    if( rc ){
+      /* If the read is unsuccessful, set the dbFileVers[] to something
+      ** that will never be a valid file version.  dbFileVers[] is a copy
+      ** of bytes 24..39 of the database.  Bytes 28..31 should always be
+      ** zero or the size of the database in page. Bytes 32..35 and 35..39
+      ** should be page numbers which are never 0xffffffff.  So filling
+      ** pPager->dbFileVers[] with all 0xff bytes should suffice.
+      **
+      ** For an encrypted database, the situation is more complex:  bytes
+      ** 24..39 of the database are white noise.  But the probability of
+      ** white noising equaling 16 bytes of 0xff is vanishingly small so
+      ** we should still be ok.
+      */
+      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
+    }else{
+      u8 *dbFileVers = &((u8*)pPg->pData)[24];
+      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
+    }
+  }
+  CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);
+
+  PAGER_INCR(sqlite3_pager_readdb_count);
+  PAGER_INCR(pPager->nRead);
+  IOTRACE(("PGIN %p %d\n", pPager, pgno));
+  PAGERTRACE(("FETCH %d page %d hash(%08x)\n",
+               PAGERID(pPager), pgno, pager_pagehash(pPg)));
+
+  return rc;
+}
+
+#ifndef SQLITE_OMIT_WAL
+/*
+** This function is invoked once for each page that has already been 
+** written into the log file when a WAL transaction is rolled back.
+** Parameter iPg is the page number of said page. The pCtx argument 
+** is actually a pointer to the Pager structure.
+**
+** If page iPg is present in the cache, and has no outstanding references,
+** it is discarded. Otherwise, if there are one or more outstanding
+** references, the page content is reloaded from the database. If the
+** attempt to reload content from the database is required and fails, 
+** return an SQLite error code. Otherwise, SQLITE_OK.
+*/
+static int pagerUndoCallback(void *pCtx, Pgno iPg){
+  int rc = SQLITE_OK;
+  Pager *pPager = (Pager *)pCtx;
+  PgHdr *pPg;
+
+  pPg = sqlite3PagerLookup(pPager, iPg);
+  if( pPg ){
+    if( sqlite3PcachePageRefcount(pPg)==1 ){
+      sqlite3PcacheDrop(pPg);
+    }else{
+      rc = readDbPage(pPg);
+      if( rc==SQLITE_OK ){
+        pPager->xReiniter(pPg);
+      }
+      sqlite3PagerUnref(pPg);
+    }
+  }
+
+  /* Normally, if a transaction is rolled back, any backup processes are
+  ** updated as data is copied out of the rollback journal and into the
+  ** database. This is not generally possible with a WAL database, as
+  ** rollback involves simply truncating the log file. Therefore, if one
+  ** or more frames have already been written to the log (and therefore 
+  ** also copied into the backup databases) as part of this transaction,
+  ** the backups must be restarted.
+  */
+  sqlite3BackupRestart(pPager->pBackup);
+
+  return rc;
+}
+
+/*
+** This function is called to rollback a transaction on a WAL database.
+*/
+static int pagerRollbackWal(Pager *pPager){
+  int rc;                         /* Return Code */
+  PgHdr *pList;                   /* List of dirty pages to revert */
+
+  /* For all pages in the cache that are currently dirty or have already
+  ** been written (but not committed) to the log file, do one of the 
+  ** following:
+  **
+  **   + Discard the cached page (if refcount==0), or
+  **   + Reload page content from the database (if refcount>0).
+  */
+  pPager->dbSize = pPager->dbOrigSize;
+  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);
+  pList = sqlite3PcacheDirtyList(pPager->pPCache);
+  while( pList && rc==SQLITE_OK ){
+    PgHdr *pNext = pList->pDirty;
+    rc = pagerUndoCallback((void *)pPager, pList->pgno);
+    pList = pNext;
+  }
+
+  return rc;
+}
+
+/*
+** This function is a wrapper around sqlite3WalFrames(). As well as logging
+** the contents of the list of pages headed by pList (connected by pDirty),
+** this function notifies any active backup processes that the pages have
+** changed. 
+*/ 
+static int pagerWalFrames(
+  Pager *pPager,                  /* Pager object */
+  PgHdr *pList,                   /* List of frames to log */
+  Pgno nTruncate,                 /* Database size after this commit */
+  int isCommit,                   /* True if this is a commit */
+  int sync_flags                  /* Flags to pass to OsSync() (or 0) */
+){
+  int rc;                         /* Return code */
+
+  assert( pPager->pWal );
+  rc = sqlite3WalFrames(pPager->pWal, 
+      pPager->pageSize, pList, nTruncate, isCommit, sync_flags
+  );
+  if( rc==SQLITE_OK && pPager->pBackup ){
+    PgHdr *p;
+    for(p=pList; p; p=p->pDirty){
+      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
+    }
+  }
+
+#ifdef SQLITE_CHECK_PAGES
+  {
+    PgHdr *p;
+    for(p=pList; p; p=p->pDirty) pager_set_pagehash(p);
+  }
+#endif
+
+  return rc;
+}
+
+/*
+** Begin a read transaction on the WAL.
+**
+** This routine used to be called "pagerOpenSnapshot()" because it essentially
+** makes a snapshot of the database at the current point in time and preserves
+** that snapshot for use by the reader in spite of concurrently changes by
+** other writers or checkpointers.
+*/
+static int pagerBeginReadTransaction(Pager *pPager){
+  int rc;                         /* Return code */
+  int changed = 0;                /* True if cache must be reset */
+
+  assert( pagerUseWal(pPager) );
+  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );
+
+  /* sqlite3WalEndReadTransaction() was not called for the previous
+  ** transaction in locking_mode=EXCLUSIVE.  So call it now.  If we
+  ** are in locking_mode=NORMAL and EndRead() was previously called,
+  ** the duplicate call is harmless.
+  */
+  sqlite3WalEndReadTransaction(pPager->pWal);
+
+  rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);
+  if( rc!=SQLITE_OK || changed ){
+    pager_reset(pPager);
+  }
+
+  return rc;
+}
+#endif
+
+/*
+** This function is called as part of the transition from PAGER_OPEN
+** to PAGER_READER state to determine the size of the database file
+** in pages (assuming the page size currently stored in Pager.pageSize).
+**
+** If no error occurs, SQLITE_OK is returned and the size of the database
+** in pages is stored in *pnPage. Otherwise, an error code (perhaps
+** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified.
+*/
+static int pagerPagecount(Pager *pPager, Pgno *pnPage){
+  Pgno nPage;                     /* Value to return via *pnPage */
+
+  /* Query the WAL sub-system for the database size. The WalDbsize()
+  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or
+  ** if the database size is not available. The database size is not
+  ** available from the WAL sub-system if the log file is empty or
+  ** contains no valid committed transactions.
+  */
+  assert( pPager->eState==PAGER_OPEN );
+  assert( pPager->eLock>=SHARED_LOCK || pPager->noReadlock );
+  nPage = sqlite3WalDbsize(pPager->pWal);
+
+  /* If the database size was not available from the WAL sub-system,
+  ** determine it based on the size of the database file. If the size
+  ** of the database file is not an integer multiple of the page-size,
+  ** round down to the nearest page. Except, any file larger than 0
+  ** bytes in size is considered to contain at least one page.
+  */
+  if( nPage==0 ){
+    i64 n = 0;                    /* Size of db file in bytes */
+    assert( isOpen(pPager->fd) || pPager->tempFile );
+    if( isOpen(pPager->fd) ){
+      int rc = sqlite3OsFileSize(pPager->fd, &n);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+    }
+    nPage = (Pgno)(n / pPager->pageSize);
+    if( nPage==0 && n>0 ){
+      nPage = 1;
+    }
+  }
+
+  /* If the current number of pages in the file is greater than the
+  ** configured maximum pager number, increase the allowed limit so
+  ** that the file can be read.
+  */
+  if( nPage>pPager->mxPgno ){
+    pPager->mxPgno = (Pgno)nPage;
+  }
+
+  *pnPage = nPage;
+  return SQLITE_OK;
+}
+
+#ifndef SQLITE_OMIT_WAL
+/*
+** Check if the *-wal file that corresponds to the database opened by pPager
+** exists if the database is not empy, or verify that the *-wal file does
+** not exist (by deleting it) if the database file is empty.
+**
+** If the database is not empty and the *-wal file exists, open the pager
+** in WAL mode.  If the database is empty or if no *-wal file exists and
+** if no error occurs, make sure Pager.journalMode is not set to
+** PAGER_JOURNALMODE_WAL.
+**
+** Return SQLITE_OK or an error code.
+**
+** The caller must hold a SHARED lock on the database file to call this
+** function. Because an EXCLUSIVE lock on the db file is required to delete 
+** a WAL on a none-empty database, this ensures there is no race condition 
+** between the xAccess() below and an xDelete() being executed by some 
+** other connection.
+*/
+static int pagerOpenWalIfPresent(Pager *pPager){
+  int rc = SQLITE_OK;
+  assert( pPager->eState==PAGER_OPEN );
+  assert( pPager->eLock>=SHARED_LOCK || pPager->noReadlock );
+
+  if( !pPager->tempFile ){
+    int isWal;                    /* True if WAL file exists */
+    Pgno nPage;                   /* Size of the database file */
+
+    rc = pagerPagecount(pPager, &nPage);
+    if( rc ) return rc;
+    if( nPage==0 ){
+      rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);
+      isWal = 0;
+    }else{
+      rc = sqlite3OsAccess(
+          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal
+      );
+    }
+    if( rc==SQLITE_OK ){
+      if( isWal ){
+        testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );
+        rc = sqlite3PagerOpenWal(pPager, 0);
+      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){
+        pPager->journalMode = PAGER_JOURNALMODE_DELETE;
+      }
+    }
+  }
+  return rc;
+}
+#endif
+
 /*
 ** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback
 ** the entire master journal file. The case pSavepoint==NULL occurs when 
@@ -34280,7 +37703,8 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   int rc = SQLITE_OK;      /* Return code */
   Bitvec *pDone = 0;       /* Bitvec to ensure pages played back only once */
 
-  assert( pPager->state>=PAGER_SHARED );
+  assert( pPager->eState!=PAGER_ERROR );
+  assert( pPager->eState>=PAGER_WRITER_LOCKED );
 
   /* Allocate a bitvec to use to store the set of pages rolled back */
   if( pSavepoint ){
@@ -34294,6 +37718,11 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   ** being reverted was opened.
   */
   pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;
+  pPager->changeCountDone = pPager->tempFile;
+
+  if( !pSavepoint && pagerUseWal(pPager) ){
+    return pagerRollbackWal(pPager);
+  }
 
   /* Use pPager->journalOff as the effective size of the main rollback
   ** journal.  The actual file might be larger than this in
@@ -34301,6 +37730,7 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   ** past pPager->journalOff is off-limits to us.
   */
   szJ = pPager->journalOff;
+  assert( pagerUseWal(pPager)==0 || szJ==0 );
 
   /* Begin by rolling back records from the main journal starting at
   ** PagerSavepoint.iOffset and continuing to the next journal header.
@@ -34309,11 +37739,11 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   ** will be skipped automatically.  Pages are added to pDone as they
   ** are played back.
   */
-  if( pSavepoint ){
+  if( pSavepoint && !pagerUseWal(pPager) ){
     iHdrOff = pSavepoint->iHdrOffset ? pSavepoint->iHdrOffset : szJ;
     pPager->journalOff = pSavepoint->iOffset;
     while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){
-      rc = pager_playback_one_page(pPager, 1, 0, &pPager->journalOff, 1, pDone);
+      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);
     }
     assert( rc!=SQLITE_DONE );
   }else{
@@ -34343,11 +37773,11 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
       nJRec = (u32)((szJ - pPager->journalOff)/JOURNAL_PG_SZ(pPager));
     }
     for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){
-      rc = pager_playback_one_page(pPager, 1, 0, &pPager->journalOff, 1, pDone);
+      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);
     }
     assert( rc!=SQLITE_DONE );
   }
-  assert( rc!=SQLITE_OK || pPager->journalOff==szJ );
+  assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );
 
   /* Finally,  rollback pages from the sub-journal.  Page that were
   ** previously rolled back out of the main journal (and are hence in pDone)
@@ -34356,9 +37786,13 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   if( pSavepoint ){
     u32 ii;            /* Loop counter */
     i64 offset = pSavepoint->iSubRec*(4+pPager->pageSize);
+
+    if( pagerUseWal(pPager) ){
+      rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);
+    }
     for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){
       assert( offset==ii*(4+pPager->pageSize) );
-      rc = pager_playback_one_page(pPager, 0, 0, &offset, 1, pDone);
+      rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);
     }
     assert( rc!=SQLITE_DONE );
   }
@@ -34367,6 +37801,7 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
   if( rc==SQLITE_OK ){
     pPager->journalOff = szJ;
   }
+
   return rc;
 }
 
@@ -34408,7 +37843,6 @@ SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager *pPager, int level, int bFu
   pPager->noSync =  (level==1 || pPager->tempFile) ?1:0;
   pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0;
   pPager->sync_flags = (bFullFsync?SQLITE_SYNC_FULL:SQLITE_SYNC_NORMAL);
-  if( pPager->noSync ) pPager->needSync = 0;
 }
 #endif
 
@@ -34485,27 +37919,12 @@ SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(
 }
 
 /*
-** Report the current page size and number of reserved bytes back
-** to the codec.
-*/
-#ifdef SQLITE_HAS_CODEC
-static void pagerReportSize(Pager *pPager){
-  if( pPager->xCodecSizeChng ){
-    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,
-                           (int)pPager->nReserve);
-  }
-}
-#else
-# define pagerReportSize(X)     /* No-op if we do not support a codec */
-#endif
-
-/*
 ** Change the page size used by the Pager object. The new page size 
 ** is passed in *pPageSize.
 **
 ** If the pager is in the error state when this function is called, it
 ** is a no-op. The value returned is the error state error code (i.e. 
-** one of SQLITE_IOERR, SQLITE_CORRUPT or SQLITE_FULL).
+** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).
 **
 ** Otherwise, if all of the following are true:
 **
@@ -34529,28 +37948,48 @@ static void pagerReportSize(Pager *pPager){
 ** function was called, or because the memory allocation attempt failed, 
 ** then *pPageSize is set to the old, retained page size before returning.
 */
-SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u16 *pPageSize, int nReserve){
-  int rc = pPager->errCode;
+SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){
+  int rc = SQLITE_OK;
 
-  if( rc==SQLITE_OK ){
-    u16 pageSize = *pPageSize;
-    assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );
-    if( (pPager->memDb==0 || pPager->dbSize==0)
-     && sqlite3PcacheRefCount(pPager->pPCache)==0 
-     && pageSize && pageSize!=pPager->pageSize 
-    ){
-      char *pNew = (char *)sqlite3PageMalloc(pageSize);
-      if( !pNew ){
-        rc = SQLITE_NOMEM;
-      }else{
-        pager_reset(pPager);
-        pPager->pageSize = pageSize;
-        sqlite3PageFree(pPager->pTmpSpace);
-        pPager->pTmpSpace = pNew;
-        sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
-      }
+  /* It is not possible to do a full assert_pager_state() here, as this
+  ** function may be called from within PagerOpen(), before the state
+  ** of the Pager object is internally consistent.
+  **
+  ** At one point this function returned an error if the pager was in 
+  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that
+  ** there is at least one outstanding page reference, this function
+  ** is a no-op for that case anyhow.
+  */
+
+  u32 pageSize = *pPageSize;
+  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );
+  if( (pPager->memDb==0 || pPager->dbSize==0)
+   && sqlite3PcacheRefCount(pPager->pPCache)==0 
+   && pageSize && pageSize!=(u32)pPager->pageSize 
+  ){
+    char *pNew = NULL;             /* New temp space */
+    i64 nByte = 0;
+
+    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){
+      rc = sqlite3OsFileSize(pPager->fd, &nByte);
+    }
+    if( rc==SQLITE_OK ){
+      pNew = (char *)sqlite3PageMalloc(pageSize);
+      if( !pNew ) rc = SQLITE_NOMEM;
     }
-    *pPageSize = (u16)pPager->pageSize;
+
+    if( rc==SQLITE_OK ){
+      pager_reset(pPager);
+      pPager->dbSize = (Pgno)(nByte/pageSize);
+      pPager->pageSize = pageSize;
+      sqlite3PageFree(pPager->pTmpSpace);
+      pPager->pTmpSpace = pNew;
+      sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
+    }
+  }
+
+  *pPageSize = pPager->pageSize;
+  if( rc==SQLITE_OK ){
     if( nReserve<0 ) nReserve = pPager->nReserve;
     assert( nReserve>=0 && nReserve<1000 );
     pPager->nReserve = (i16)nReserve;
@@ -34582,7 +38021,9 @@ SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
   if( mxPage>0 ){
     pPager->mxPgno = mxPage;
   }
-  sqlite3PagerPagecount(pPager, 0);
+  if( pPager->eState!=PAGER_OPEN && pPager->mxPgno<pPager->dbSize ){
+    pPager->mxPgno = pPager->dbSize;
+  }
   return pPager->mxPgno;
 }
 
@@ -34628,6 +38069,13 @@ SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned cha
   int rc = SQLITE_OK;
   memset(pDest, 0, N);
   assert( isOpen(pPager->fd) || pPager->tempFile );
+
+  /* This routine is only called by btree immediately after creating
+  ** the Pager object.  There has not been an opportunity to transition
+  ** to WAL mode yet.
+  */
+  assert( !pagerUseWal(pPager) );
+
   if( isOpen(pPager->fd) ){
     IOTRACE(("DBHDR %p 0 %d\n", pPager, N))
     rc = sqlite3OsRead(pPager->fd, pDest, N, 0);
@@ -34639,65 +38087,16 @@ SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned cha
 }
 
 /*
-** Return the total number of pages in the database file associated 
-** with pPager. Normally, this is calculated as (<db file size>/<page-size>).
+** This function may only be called when a read-transaction is open on
+** the pager. It returns the total number of pages in the database.
+**
 ** However, if the file is between 1 and <page-size> bytes in size, then 
 ** this is considered a 1 page file.
-**
-** If the pager is in error state when this function is called, then the
-** error state error code is returned and *pnPage left unchanged. Or,
-** if the file system has to be queried for the size of the file and
-** the query attempt returns an IO error, the IO error code is returned
-** and *pnPage is left unchanged.
-**
-** Otherwise, if everything is successful, then SQLITE_OK is returned
-** and *pnPage is set to the number of pages in the database.
 */
-SQLITE_PRIVATE int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
-  Pgno nPage;               /* Value to return via *pnPage */
-
-  /* If the pager is already in the error state, return the error code. */
-  if( pPager->errCode ){
-    return pPager->errCode;
-  }
-
-  /* Determine the number of pages in the file. Store this in nPage. */
-  if( pPager->dbSizeValid ){
-    nPage = pPager->dbSize;
-  }else{
-    int rc;                 /* Error returned by OsFileSize() */
-    i64 n = 0;              /* File size in bytes returned by OsFileSize() */
-
-    assert( isOpen(pPager->fd) || pPager->tempFile );
-    if( isOpen(pPager->fd) && (0 != (rc = sqlite3OsFileSize(pPager->fd, &n))) ){
-      pager_error(pPager, rc);
-      return rc;
-    }
-    if( n>0 && n<pPager->pageSize ){
-      nPage = 1;
-    }else{
-      nPage = (Pgno)(n / pPager->pageSize);
-    }
-    if( pPager->state!=PAGER_UNLOCK ){
-      pPager->dbSize = nPage;
-      pPager->dbFileSize = nPage;
-      pPager->dbSizeValid = 1;
-    }
-  }
-
-  /* If the current number of pages in the file is greater than the 
-  ** configured maximum pager number, increase the allowed limit so
-  ** that the file can be read.
-  */
-  if( nPage>pPager->mxPgno ){
-    pPager->mxPgno = (Pgno)nPage;
-  }
-
-  /* Set the output variable and return SQLITE_OK */
-  if( pnPage ){
-    *pnPage = nPage;
-  }
-  return SQLITE_OK;
+SQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){
+  assert( pPager->eState>=PAGER_READER );
+  assert( pPager->eState!=PAGER_WRITER_FINISHED );
+  *pnPage = (int)pPager->dbSize;
 }
 
 
@@ -34718,38 +38117,19 @@ SQLITE_PRIVATE int sqlite3PagerPagecount(Pager *pPager, int *pnPage){
 static int pager_wait_on_lock(Pager *pPager, int locktype){
   int rc;                              /* Return code */
 
-  /* The OS lock values must be the same as the Pager lock values */
-  assert( PAGER_SHARED==SHARED_LOCK );
-  assert( PAGER_RESERVED==RESERVED_LOCK );
-  assert( PAGER_EXCLUSIVE==EXCLUSIVE_LOCK );
-
-  /* If the file is currently unlocked then the size must be unknown. It
-  ** must not have been modified at this point.
-  */
-  assert( pPager->state>=PAGER_SHARED || pPager->dbSizeValid==0 );
-  assert( pPager->state>=PAGER_SHARED || pPager->dbModified==0 );
-
   /* Check that this is either a no-op (because the requested lock is 
   ** already held, or one of the transistions that the busy-handler
   ** may be invoked during, according to the comment above
   ** sqlite3PagerSetBusyhandler().
   */
-  assert( (pPager->state>=locktype)
-       || (pPager->state==PAGER_UNLOCK && locktype==PAGER_SHARED)
-       || (pPager->state==PAGER_RESERVED && locktype==PAGER_EXCLUSIVE)
+  assert( (pPager->eLock>=locktype)
+       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)
+       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)
   );
 
-  if( pPager->state>=locktype ){
-    rc = SQLITE_OK;
-  }else{
-    do {
-      rc = sqlite3OsLock(pPager->fd, locktype);
-    }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );
-    if( rc==SQLITE_OK ){
-      pPager->state = (u8)locktype;
-      IOTRACE(("LOCK %p %d\n", pPager, locktype))
-    }
-  }
+  do {
+    rc = pagerLockDb(pPager, locktype);
+  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );
   return rc;
 }
 
@@ -34794,13 +38174,38 @@ static void assertTruncateConstraint(Pager *pPager){
 ** truncation will be done when the current transaction is committed.
 */
 SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
-  assert( pPager->dbSizeValid );
   assert( pPager->dbSize>=nPage );
-  assert( pPager->state>=PAGER_RESERVED );
+  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
   pPager->dbSize = nPage;
   assertTruncateConstraint(pPager);
 }
 
+
+/*
+** This function is called before attempting a hot-journal rollback. It
+** syncs the journal file to disk, then sets pPager->journalHdr to the
+** size of the journal file so that the pager_playback() routine knows
+** that the entire journal file has been synced.
+**
+** Syncing a hot-journal to disk before attempting to roll it back ensures 
+** that if a power-failure occurs during the rollback, the process that
+** attempts rollback following system recovery sees the same journal
+** content as this process.
+**
+** If everything goes as planned, SQLITE_OK is returned. Otherwise, 
+** an SQLite error code.
+*/
+static int pagerSyncHotJournal(Pager *pPager){
+  int rc = SQLITE_OK;
+  if( !pPager->noSync ){
+    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);
+  }
+  if( rc==SQLITE_OK ){
+    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);
+  }
+  return rc;
+}
+
 /*
 ** Shutdown the page cache.  Free all memory and close all files.
 **
@@ -34816,29 +38221,46 @@ SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
 ** to the caller.
 */
 SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
+  u8 *pTmp = (u8 *)pPager->pTmpSpace;
+
   disable_simulated_io_errors();
   sqlite3BeginBenignMalloc();
-  pPager->errCode = 0;
+  /* pPager->errCode = 0; */
   pPager->exclusiveMode = 0;
+#ifndef SQLITE_OMIT_WAL
+  sqlite3WalClose(pPager->pWal,
+    (pPager->noSync ? 0 : pPager->sync_flags), 
+    pPager->pageSize, pTmp
+  );
+  pPager->pWal = 0;
+#endif
   pager_reset(pPager);
   if( MEMDB ){
     pager_unlock(pPager);
   }else{
-    /* Set Pager.journalHdr to -1 for the benefit of the pager_playback() 
-    ** call which may be made from within pagerUnlockAndRollback(). If it
-    ** is not -1, then the unsynced portion of an open journal file may
-    ** be played back into the database. If a power failure occurs while
-    ** this is happening, the database may become corrupt.
+    /* If it is open, sync the journal file before calling UnlockAndRollback.
+    ** If this is not done, then an unsynced portion of the open journal 
+    ** file may be played back into the database. If a power failure occurs 
+    ** while this is happening, the database could become corrupt.
+    **
+    ** If an error occurs while trying to sync the journal, shift the pager
+    ** into the ERROR state. This causes UnlockAndRollback to unlock the
+    ** database and close the journal file without attempting to roll it
+    ** back or finalize it. The next database user will have to do hot-journal
+    ** rollback before accessing the database file.
     */
-    pPager->journalHdr = -1;
+    if( isOpen(pPager->jfd) ){
+      pager_error(pPager, pagerSyncHotJournal(pPager));
+    }
     pagerUnlockAndRollback(pPager);
   }
   sqlite3EndBenignMalloc();
   enable_simulated_io_errors();
   PAGERTRACE(("CLOSE %d\n", PAGERID(pPager)));
   IOTRACE(("CLOSE %p\n", pPager))
+  sqlite3OsClose(pPager->jfd);
   sqlite3OsClose(pPager->fd);
-  sqlite3PageFree(pPager->pTmpSpace);
+  sqlite3PageFree(pTmp);
   sqlite3PcacheClose(pPager->pPCache);
 
 #ifdef SQLITE_HAS_CODEC
@@ -34873,9 +38295,9 @@ SQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){
 ** been written to the journal have actually reached the surface of the
 ** disk and can be restored in the event of a hot-journal rollback.
 **
-** If the Pager.needSync flag is not set, then this function is a
-** no-op. Otherwise, the actions required depend on the journal-mode
-** and the device characteristics of the the file-system, as follows:
+** If the Pager.noSync flag is set, then this function is a no-op.
+** Otherwise, the actions required depend on the journal-mode and the 
+** device characteristics of the the file-system, as follows:
 **
 **   * If the journal file is an in-memory journal file, no action need
 **     be taken.
@@ -34899,18 +38321,25 @@ SQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){
 **     if( NOT SEQUENTIAL ) xSync(<journal file>);
 **   }
 **
-** The Pager.needSync flag is never be set for temporary files, or any
-** file operating in no-sync mode (Pager.noSync set to non-zero).
-**
 ** If successful, this routine clears the PGHDR_NEED_SYNC flag of every 
 ** page currently held in memory before returning SQLITE_OK. If an IO
 ** error is encountered, then the IO error code is returned to the caller.
 */
-static int syncJournal(Pager *pPager){
-  if( pPager->needSync ){
+static int syncJournal(Pager *pPager, int newHdr){
+  int rc;                         /* Return code */
+
+  assert( pPager->eState==PAGER_WRITER_CACHEMOD
+       || pPager->eState==PAGER_WRITER_DBMOD
+  );
+  assert( assert_pager_state(pPager) );
+  assert( !pagerUseWal(pPager) );
+
+  rc = sqlite3PagerExclusiveLock(pPager);
+  if( rc!=SQLITE_OK ) return rc;
+
+  if( !pPager->noSync ){
     assert( !pPager->tempFile );
-    if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){
-      int rc;                              /* Return code */
+    if( isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){
       const int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);
       assert( isOpen(pPager->jfd) );
 
@@ -34920,7 +38349,7 @@ static int syncJournal(Pager *pPager){
         ** mode, then the journal file may at this point actually be larger
         ** than Pager.journalOff bytes. If the next thing in the journal
         ** file happens to be a journal-header (written as part of the
-        ** previous connections transaction), and a crash or power-failure 
+        ** previous connection's transaction), and a crash or power-failure 
         ** occurs after nRec is updated but before this connection writes 
         ** anything else to the journal file (or commits/rolls back its 
         ** transaction), then SQLite may become confused when doing the 
@@ -34939,10 +38368,10 @@ static int syncJournal(Pager *pPager){
         */
         i64 iNextHdrOffset;
         u8 aMagic[8];
-	u8 zHeader[sizeof(aJournalMagic)+4];
+        u8 zHeader[sizeof(aJournalMagic)+4];
 
-	memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));
-	put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);
+        memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));
+        put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);
 
         iNextHdrOffset = journalHdrOffset(pPager);
         rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);
@@ -34974,7 +38403,7 @@ static int syncJournal(Pager *pPager){
         IOTRACE(("JHDR %p %lld\n", pPager, pPager->journalHdr));
         rc = sqlite3OsWrite(
             pPager->jfd, zHeader, sizeof(zHeader), pPager->journalHdr
-	);
+        );
         if( rc!=SQLITE_OK ) return rc;
       }
       if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){
@@ -34985,16 +38414,25 @@ static int syncJournal(Pager *pPager){
         );
         if( rc!=SQLITE_OK ) return rc;
       }
-    }
 
-    /* The journal file was just successfully synced. Set Pager.needSync 
-    ** to zero and clear the PGHDR_NEED_SYNC flag on all pagess.
-    */
-    pPager->needSync = 0;
-    pPager->journalStarted = 1;
-    sqlite3PcacheClearSyncFlags(pPager->pPCache);
+      pPager->journalHdr = pPager->journalOff;
+      if( newHdr && 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){
+        pPager->nRec = 0;
+        rc = writeJournalHdr(pPager);
+        if( rc!=SQLITE_OK ) return rc;
+      }
+    }else{
+      pPager->journalHdr = pPager->journalOff;
+    }
   }
 
+  /* Unless the pager is in noSync mode, the journal file was just 
+  ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on 
+  ** all pages.
+  */
+  sqlite3PcacheClearSyncFlags(pPager->pPCache);
+  pPager->eState = PAGER_WRITER_DBMOD;
+  assert( assert_pager_state(pPager) );
   return SQLITE_OK;
 }
 
@@ -35030,31 +38468,13 @@ static int syncJournal(Pager *pPager){
 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
 ** be obtained, SQLITE_BUSY is returned.
 */
-static int pager_write_pagelist(PgHdr *pList){
-  Pager *pPager;                       /* Pager object */
-  int rc;                              /* Return code */
+static int pager_write_pagelist(Pager *pPager, PgHdr *pList){
+  int rc = SQLITE_OK;                  /* Return code */
 
-  if( NEVER(pList==0) ) return SQLITE_OK;
-  pPager = pList->pPager;
-
-  /* At this point there may be either a RESERVED or EXCLUSIVE lock on the
-  ** database file. If there is already an EXCLUSIVE lock, the following
-  ** call is a no-op.
-  **
-  ** Moving the lock from RESERVED to EXCLUSIVE actually involves going
-  ** through an intermediate state PENDING.   A PENDING lock prevents new
-  ** readers from attaching to the database but is unsufficient for us to
-  ** write.  The idea of a PENDING lock is to prevent new readers from
-  ** coming in while we wait for existing readers to clear.
-  **
-  ** While the pager is in the RESERVED state, the original database file
-  ** is unchanged and we can rollback without having to playback the
-  ** journal into the original database file.  Once we transition to
-  ** EXCLUSIVE, it means the database file has been changed and any rollback
-  ** will require a journal playback.
-  */
-  assert( pPager->state>=PAGER_RESERVED );
-  rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
+  /* This function is only called for rollback pagers in WRITER_DBMOD state. */
+  assert( !pagerUseWal(pPager) );
+  assert( pPager->eState==PAGER_WRITER_DBMOD );
+  assert( pPager->eLock==EXCLUSIVE_LOCK );
 
   /* If the file is a temp-file has not yet been opened, open it now. It
   ** is not possible for rc to be other than SQLITE_OK if this branch
@@ -35065,6 +38485,16 @@ static int pager_write_pagelist(PgHdr *pList){
     rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);
   }
 
+  /* Before the first write, give the VFS a hint of what the final
+  ** file size will be.
+  */
+  assert( rc!=SQLITE_OK || isOpen(pPager->fd) );
+  if( rc==SQLITE_OK && pPager->dbSize>pPager->dbHintSize ){
+    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;
+    sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);
+    pPager->dbHintSize = pPager->dbSize;
+  }
+
   while( rc==SQLITE_OK && pList ){
     Pgno pgno = pList->pgno;
 
@@ -35080,6 +38510,8 @@ static int pager_write_pagelist(PgHdr *pList){
       i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */
       char *pData;                                   /* Data to write */    
 
+      assert( (pList->flags&PGHDR_NEED_SYNC)==0 );
+
       /* Encode the database */
       CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM, pData);
 
@@ -35108,9 +38540,7 @@ static int pager_write_pagelist(PgHdr *pList){
     }else{
       PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
     }
-#ifdef SQLITE_CHECK_PAGES
-    pList->pageHash = pager_pagehash(pList);
-#endif
+    pager_set_pagehash(pList);
     pList = pList->pDirty;
   }
 
@@ -35118,6 +38548,26 @@ static int pager_write_pagelist(PgHdr *pList){
 }
 
 /*
+** Ensure that the sub-journal file is open. If it is already open, this 
+** function is a no-op.
+**
+** SQLITE_OK is returned if everything goes according to plan. An 
+** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() 
+** fails.
+*/
+static int openSubJournal(Pager *pPager){
+  int rc = SQLITE_OK;
+  if( !isOpen(pPager->sjfd) ){
+    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){
+      sqlite3MemJournalOpen(pPager->sjfd);
+    }else{
+      rc = pagerOpentemp(pPager, pPager->sjfd, SQLITE_OPEN_SUBJOURNAL);
+    }
+  }
+  return rc;
+}
+
+/*
 ** Append a record of the current state of page pPg to the sub-journal. 
 ** It is the callers responsibility to use subjRequiresPage() to check 
 ** that it is really required before calling this function.
@@ -35133,18 +38583,31 @@ static int pager_write_pagelist(PgHdr *pList){
 static int subjournalPage(PgHdr *pPg){
   int rc = SQLITE_OK;
   Pager *pPager = pPg->pPager;
-  if( isOpen(pPager->sjfd) ){
-    void *pData = pPg->pData;
-    i64 offset = pPager->nSubRec*(4+pPager->pageSize);
-    char *pData2;
+  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
+
+    /* Open the sub-journal, if it has not already been opened */
+    assert( pPager->useJournal );
+    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );
+    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );
+    assert( pagerUseWal(pPager) 
+         || pageInJournal(pPg) 
+         || pPg->pgno>pPager->dbOrigSize 
+    );
+    rc = openSubJournal(pPager);
 
-    CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);
-    PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno));
-  
-    assert( pageInJournal(pPg) || pPg->pgno>pPager->dbOrigSize );
-    rc = write32bits(pPager->sjfd, offset, pPg->pgno);
+    /* If the sub-journal was opened successfully (or was already open),
+    ** write the journal record into the file.  */
     if( rc==SQLITE_OK ){
-      rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);
+      void *pData = pPg->pData;
+      i64 offset = pPager->nSubRec*(4+pPager->pageSize);
+      char *pData2;
+  
+      CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);
+      PAGERTRACE(("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno));
+      rc = write32bits(pPager->sjfd, offset, pPg->pgno);
+      if( rc==SQLITE_OK ){
+        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);
+      }
     }
   }
   if( rc==SQLITE_OK ){
@@ -35155,7 +38618,6 @@ static int subjournalPage(PgHdr *pPg){
   return rc;
 }
 
-
 /*
 ** This function is called by the pcache layer when it has reached some
 ** soft memory limit. The first argument is a pointer to a Pager object
@@ -35182,74 +38644,83 @@ static int pagerStress(void *p, PgHdr *pPg){
   assert( pPg->pPager==pPager );
   assert( pPg->flags&PGHDR_DIRTY );
 
-  /* The doNotSync flag is set by the sqlite3PagerWrite() function while it
-  ** is journalling a set of two or more database pages that are stored
-  ** on the same disk sector. Syncing the journal is not allowed while
-  ** this is happening as it is important that all members of such a
-  ** set of pages are synced to disk together. So, if the page this function
-  ** is trying to make clean will require a journal sync and the doNotSync
-  ** flag is set, return without doing anything. The pcache layer will
-  ** just have to go ahead and allocate a new page buffer instead of
-  ** reusing pPg.
+  /* The doNotSyncSpill flag is set during times when doing a sync of
+  ** journal (and adding a new header) is not allowed.  This occurs
+  ** during calls to sqlite3PagerWrite() while trying to journal multiple
+  ** pages belonging to the same sector.
   **
-  ** Similarly, if the pager has already entered the error state, do not
-  ** try to write the contents of pPg to disk.
-  */
-  if( NEVER(pPager->errCode)
-   || (pPager->doNotSync && pPg->flags&PGHDR_NEED_SYNC)
-  ){
+  ** The doNotSpill flag inhibits all cache spilling regardless of whether
+  ** or not a sync is required.  This is set during a rollback.
+  **
+  ** Spilling is also prohibited when in an error state since that could
+  ** lead to database corruption.   In the current implementaton it 
+  ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1
+  ** while in the error state, hence it is impossible for this routine to
+  ** be called in the error state.  Nevertheless, we include a NEVER()
+  ** test for the error state as a safeguard against future changes.
+  */
+  if( NEVER(pPager->errCode) ) return SQLITE_OK;
+  if( pPager->doNotSpill ) return SQLITE_OK;
+  if( pPager->doNotSyncSpill && (pPg->flags & PGHDR_NEED_SYNC)!=0 ){
     return SQLITE_OK;
   }
 
-  /* Sync the journal file if required. */
-  if( pPg->flags&PGHDR_NEED_SYNC ){
-    rc = syncJournal(pPager);
-    if( rc==SQLITE_OK && pPager->fullSync && 
-      !(pPager->journalMode==PAGER_JOURNALMODE_MEMORY) &&
-      !(sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND)
+  pPg->pDirty = 0;
+  if( pagerUseWal(pPager) ){
+    /* Write a single frame for this page to the log. */
+    if( subjRequiresPage(pPg) ){ 
+      rc = subjournalPage(pPg); 
+    }
+    if( rc==SQLITE_OK ){
+      rc = pagerWalFrames(pPager, pPg, 0, 0, 0);
+    }
+  }else{
+  
+    /* Sync the journal file if required. */
+    if( pPg->flags&PGHDR_NEED_SYNC 
+     || pPager->eState==PAGER_WRITER_CACHEMOD
     ){
-      pPager->nRec = 0;
-      rc = writeJournalHdr(pPager);
+      rc = syncJournal(pPager, 1);
+    }
+  
+    /* If the page number of this page is larger than the current size of
+    ** the database image, it may need to be written to the sub-journal.
+    ** This is because the call to pager_write_pagelist() below will not
+    ** actually write data to the file in this case.
+    **
+    ** Consider the following sequence of events:
+    **
+    **   BEGIN;
+    **     <journal page X>
+    **     <modify page X>
+    **     SAVEPOINT sp;
+    **       <shrink database file to Y pages>
+    **       pagerStress(page X)
+    **     ROLLBACK TO sp;
+    **
+    ** If (X>Y), then when pagerStress is called page X will not be written
+    ** out to the database file, but will be dropped from the cache. Then,
+    ** following the "ROLLBACK TO sp" statement, reading page X will read
+    ** data from the database file. This will be the copy of page X as it
+    ** was when the transaction started, not as it was when "SAVEPOINT sp"
+    ** was executed.
+    **
+    ** The solution is to write the current data for page X into the 
+    ** sub-journal file now (if it is not already there), so that it will
+    ** be restored to its current value when the "ROLLBACK TO sp" is 
+    ** executed.
+    */
+    if( NEVER(
+        rc==SQLITE_OK && pPg->pgno>pPager->dbSize && subjRequiresPage(pPg)
+    ) ){
+      rc = subjournalPage(pPg);
+    }
+  
+    /* Write the contents of the page out to the database file. */
+    if( rc==SQLITE_OK ){
+      assert( (pPg->flags&PGHDR_NEED_SYNC)==0 );
+      rc = pager_write_pagelist(pPager, pPg);
     }
-  }
-
-  /* If the page number of this page is larger than the current size of
-  ** the database image, it may need to be written to the sub-journal.
-  ** This is because the call to pager_write_pagelist() below will not
-  ** actually write data to the file in this case.
-  **
-  ** Consider the following sequence of events:
-  **
-  **   BEGIN;
-  **     <journal page X>
-  **     <modify page X>
-  **     SAVEPOINT sp;
-  **       <shrink database file to Y pages>
-  **       pagerStress(page X)
-  **     ROLLBACK TO sp;
-  **
-  ** If (X>Y), then when pagerStress is called page X will not be written
-  ** out to the database file, but will be dropped from the cache. Then,
-  ** following the "ROLLBACK TO sp" statement, reading page X will read
-  ** data from the database file. This will be the copy of page X as it
-  ** was when the transaction started, not as it was when "SAVEPOINT sp"
-  ** was executed.
-  **
-  ** The solution is to write the current data for page X into the 
-  ** sub-journal file now (if it is not already there), so that it will
-  ** be restored to its current value when the "ROLLBACK TO sp" is 
-  ** executed.
-  */
-  if( NEVER(
-      rc==SQLITE_OK && pPg->pgno>pPager->dbSize && subjRequiresPage(pPg)
-  ) ){
-    rc = subjournalPage(pPg);
-  }
-
-  /* Write the contents of the page out to the database file. */
-  if( rc==SQLITE_OK ){
-    pPg->pDirty = 0;
-    rc = pager_write_pagelist(pPg);
   }
 
   /* Mark the page as clean. */
@@ -35258,7 +38729,7 @@ static int pagerStress(void *p, PgHdr *pPg){
     sqlite3PcacheMakeClean(pPg);
   }
 
-  return pager_error(pPager, rc);
+  return pager_error(pPager, rc); 
 }
 
 
@@ -35313,7 +38784,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
   int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
   int noReadlock = (flags & PAGER_NO_READLOCK)!=0;  /* True to omit read-lock */
   int pcacheSize = sqlite3PcacheSize();       /* Bytes to allocate for PCache */
-  u16 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */
+  u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */
 
   /* Figure out how much space is required for each journal file-handle
   ** (there are two of them, the main journal and the sub-journal). This
@@ -35332,6 +38803,13 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
   /* Set the output variable to NULL in case an error occurs. */
   *ppPager = 0;
 
+#ifndef SQLITE_OMIT_MEMORYDB
+  if( flags & PAGER_MEMORY ){
+    memDb = 1;
+    zFilename = 0;
+  }
+#endif
+
   /* Compute and store the full pathname in an allocated buffer pointed
   ** to by zPathname, length nPathname. Or, if this is a temporary file,
   ** leave both nPathname and zPathname set to 0.
@@ -35342,17 +38820,8 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
     if( zPathname==0 ){
       return SQLITE_NOMEM;
     }
-#ifndef SQLITE_OMIT_MEMORYDB
-    if( strcmp(zFilename,":memory:")==0 ){
-      memDb = 1;
-      zPathname[0] = 0;
-    }else
-#endif
-    {
-      zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
-      rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
-    }
-
+    zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
+    rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
     nPathname = sqlite3Strlen30(zPathname);
     if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
       /* This branch is taken when the journal path required by
@@ -35388,6 +38857,9 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
     journalFileSize * 2 +          /* The two journal files */ 
     nPathname + 1 +                /* zFilename */
     nPathname + 8 + 1              /* zJournal */
+#ifndef SQLITE_OMIT_WAL
+    + nPathname + 4 + 1              /* zWal */
+#endif
   );
   assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
   if( !pPtr ){
@@ -35404,11 +38876,16 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
 
   /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
   if( zPathname ){
+    assert( nPathname>0 );
     pPager->zJournal =   (char*)(pPtr += nPathname + 1);
     memcpy(pPager->zFilename, zPathname, nPathname);
     memcpy(pPager->zJournal, zPathname, nPathname);
     memcpy(&pPager->zJournal[nPathname], "-journal", 8);
-    if( pPager->zFilename[0]==0 ) pPager->zJournal[0] = 0;
+#ifndef SQLITE_OMIT_WAL
+    pPager->zWal = &pPager->zJournal[nPathname+8+1];
+    memcpy(pPager->zWal, zPathname, nPathname);
+    memcpy(&pPager->zWal[nPathname], "-wal", 4);
+#endif
     sqlite3_free(zPathname);
   }
   pPager->pVfs = pVfs;
@@ -35416,9 +38893,10 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
 
   /* Open the pager file.
   */
-  if( zFilename && zFilename[0] && !memDb ){
+  if( zFilename && zFilename[0] ){
     int fout = 0;                    /* VFS flags returned by xOpen() */
     rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);
+    assert( !memDb );
     readOnly = (fout&SQLITE_OPEN_READONLY);
 
     /* If the file was successfully opened for read/write access,
@@ -35436,7 +38914,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
         if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){
           szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;
         }else{
-          szPageDflt = (u16)pPager->sectorSize;
+          szPageDflt = (u32)pPager->sectorSize;
         }
       }
 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
@@ -35464,7 +38942,8 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
     ** disk and uses an in-memory rollback journal.
     */ 
     tempFile = 1;
-    pPager->state = PAGER_EXCLUSIVE;
+    pPager->eState = PAGER_READER;
+    pPager->eLock = EXCLUSIVE_LOCK;
     readOnly = (vfsFlags&SQLITE_OPEN_READONLY);
   }
 
@@ -35501,13 +38980,14 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
   /* pPager->stmtOpen = 0; */
   /* pPager->stmtInUse = 0; */
   /* pPager->nRef = 0; */
-  pPager->dbSizeValid = (u8)memDb;
   /* pPager->stmtSize = 0; */
   /* pPager->stmtJSize = 0; */
   /* pPager->nPage = 0; */
   pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;
   /* pPager->state = PAGER_UNLOCK; */
+#if 0
   assert( pPager->state == (tempFile ? PAGER_EXCLUSIVE : PAGER_UNLOCK) );
+#endif
   /* pPager->errMask = 0; */
   pPager->tempFile = (u8)tempFile;
   assert( tempFile==PAGER_LOCKINGMODE_NORMAL 
@@ -35517,7 +38997,6 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
   pPager->changeCountDone = pPager->tempFile;
   pPager->memDb = (u8)memDb;
   pPager->readOnly = (u8)readOnly;
-  /* pPager->needSync = 0; */
   assert( useJournal || pPager->tempFile );
   pPager->noSync = pPager->tempFile;
   pPager->fullSync = pPager->noSync ?0:1;
@@ -35578,19 +39057,24 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
 */
 static int hasHotJournal(Pager *pPager, int *pExists){
   sqlite3_vfs * const pVfs = pPager->pVfs;
-  int rc;                       /* Return code */
-  int exists;                   /* True if a journal file is present */
+  int rc = SQLITE_OK;           /* Return code */
+  int exists = 1;               /* True if a journal file is present */
+  int jrnlOpen = !!isOpen(pPager->jfd);
 
-  assert( pPager!=0 );
   assert( pPager->useJournal );
   assert( isOpen(pPager->fd) );
-  assert( !isOpen(pPager->jfd) );
-  assert( pPager->state <= PAGER_SHARED );
+  assert( pPager->eState==PAGER_OPEN );
+
+  assert( jrnlOpen==0 || ( sqlite3OsDeviceCharacteristics(pPager->jfd) &
+    SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
+  ));
 
   *pExists = 0;
-  rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);
+  if( !jrnlOpen ){
+    rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);
+  }
   if( rc==SQLITE_OK && exists ){
-    int locked;                 /* True if some process holds a RESERVED lock */
+    int locked = 0;             /* True if some process holds a RESERVED lock */
 
     /* Race condition here:  Another process might have been holding the
     ** the RESERVED lock and have a journal open at the sqlite3OsAccess() 
@@ -35602,7 +39086,7 @@ static int hasHotJournal(Pager *pPager, int *pExists){
     */
     rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);
     if( rc==SQLITE_OK && !locked ){
-      int nPage;
+      Pgno nPage;                 /* Number of pages in database file */
 
       /* Check the size of the database file. If it consists of 0 pages,
       ** then delete the journal file. See the header comment above for 
@@ -35610,13 +39094,13 @@ static int hasHotJournal(Pager *pPager, int *pExists){
       ** a RESERVED lock to avoid race conditions and to avoid violating
       ** [H33020].
       */
-      rc = sqlite3PagerPagecount(pPager, &nPage);
+      rc = pagerPagecount(pPager, &nPage);
       if( rc==SQLITE_OK ){
         if( nPage==0 ){
           sqlite3BeginBenignMalloc();
-          if( sqlite3OsLock(pPager->fd, RESERVED_LOCK)==SQLITE_OK ){
+          if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){
             sqlite3OsDelete(pVfs, pPager->zJournal, 0);
-            sqlite3OsUnlock(pPager->fd, SHARED_LOCK);
+            pagerUnlockDb(pPager, SHARED_LOCK);
           }
           sqlite3EndBenignMalloc();
         }else{
@@ -35626,15 +39110,19 @@ static int hasHotJournal(Pager *pPager, int *pExists){
           ** If there is, then we consider this journal to be hot. If not, 
           ** it can be ignored.
           */
-          int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;
-          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);
+          if( !jrnlOpen ){
+            int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;
+            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);
+          }
           if( rc==SQLITE_OK ){
             u8 first = 0;
             rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);
             if( rc==SQLITE_IOERR_SHORT_READ ){
               rc = SQLITE_OK;
             }
-            sqlite3OsClose(pPager->jfd);
+            if( !jrnlOpen ){
+              sqlite3OsClose(pPager->jfd);
+            }
             *pExists = (first!=0);
           }else if( rc==SQLITE_CANTOPEN ){
             /* If we cannot open the rollback journal file in order to see if
@@ -35658,67 +39146,6 @@ static int hasHotJournal(Pager *pPager, int *pExists){
 }
 
 /*
-** Read the content for page pPg out of the database file and into 
-** pPg->pData. A shared lock or greater must be held on the database
-** file before this function is called.
-**
-** If page 1 is read, then the value of Pager.dbFileVers[] is set to
-** the value read from the database file.
-**
-** If an IO error occurs, then the IO error is returned to the caller.
-** Otherwise, SQLITE_OK is returned.
-*/
-static int readDbPage(PgHdr *pPg){
-  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */
-  Pgno pgno = pPg->pgno;       /* Page number to read */
-  int rc;                      /* Return code */
-  i64 iOffset;                 /* Byte offset of file to read from */
-
-  assert( pPager->state>=PAGER_SHARED && !MEMDB );
-  assert( isOpen(pPager->fd) );
-
-  if( NEVER(!isOpen(pPager->fd)) ){
-    assert( pPager->tempFile );
-    memset(pPg->pData, 0, pPager->pageSize);
-    return SQLITE_OK;
-  }
-  iOffset = (pgno-1)*(i64)pPager->pageSize;
-  rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
-  if( rc==SQLITE_IOERR_SHORT_READ ){
-    rc = SQLITE_OK;
-  }
-  if( pgno==1 ){
-    if( rc ){
-      /* If the read is unsuccessful, set the dbFileVers[] to something
-      ** that will never be a valid file version.  dbFileVers[] is a copy
-      ** of bytes 24..39 of the database.  Bytes 28..31 should always be
-      ** zero.  Bytes 32..35 and 35..39 should be page numbers which are
-      ** never 0xffffffff.  So filling pPager->dbFileVers[] with all 0xff
-      ** bytes should suffice.
-      **
-      ** For an encrypted database, the situation is more complex:  bytes
-      ** 24..39 of the database are white noise.  But the probability of
-      ** white noising equaling 16 bytes of 0xff is vanishingly small so
-      ** we should still be ok.
-      */
-      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
-    }else{
-      u8 *dbFileVers = &((u8*)pPg->pData)[24];
-      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
-    }
-  }
-  CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);
-
-  PAGER_INCR(sqlite3_pager_readdb_count);
-  PAGER_INCR(pPager->nRead);
-  IOTRACE(("PGIN %p %d\n", pPager, pgno));
-  PAGERTRACE(("FETCH %d page %d hash(%08x)\n",
-               PAGERID(pPager), pgno, pager_pagehash(pPg)));
-
-  return rc;
-}
-
-/*
 ** This function is called to obtain a shared lock on the database file.
 ** It is illegal to call sqlite3PagerAcquire() until after this function
 ** has been successfully called. If a shared-lock is already held when
@@ -35726,7 +39153,7 @@ static int readDbPage(PgHdr *pPg){
 **
 ** The following operations are also performed by this function.
 **
-**   1) If the pager is currently in PAGER_UNLOCK state (no lock held
+**   1) If the pager is currently in PAGER_OPEN state (no lock held
 **      on the database file), then an attempt is made to obtain a
 **      SHARED lock on the database file. Immediately after obtaining
 **      the SHARED lock, the file-system is checked for a hot-journal,
@@ -35741,64 +39168,47 @@ static int readDbPage(PgHdr *pPg){
 **      the contents of the page cache and rolling back any open journal
 **      file.
 **
-** If the operation described by (2) above is not attempted, and if the
-** pager is in an error state other than SQLITE_FULL when this is called,
-** the error state error code is returned. It is permitted to read the
-** database when in SQLITE_FULL error state.
-**
-** Otherwise, if everything is successful, SQLITE_OK is returned. If an
-** IO error occurs while locking the database, checking for a hot-journal
-** file or rolling back a journal file, the IO error code is returned.
+** If everything is successful, SQLITE_OK is returned. If an IO error 
+** occurs while locking the database, checking for a hot-journal file or 
+** rolling back a journal file, the IO error code is returned.
 */
 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
   int rc = SQLITE_OK;                /* Return code */
-  int isErrorReset = 0;              /* True if recovering from error state */
 
   /* This routine is only called from b-tree and only when there are no
-  ** outstanding pages */
+  ** outstanding pages. This implies that the pager state should either
+  ** be OPEN or READER. READER is only possible if the pager is or was in 
+  ** exclusive access mode.
+  */
   assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );
+  assert( assert_pager_state(pPager) );
+  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );
   if( NEVER(MEMDB && pPager->errCode) ){ return pPager->errCode; }
 
-  /* If this database is in an error-state, now is a chance to clear
-  ** the error. Discard the contents of the pager-cache and rollback
-  ** any hot journal in the file-system.
-  */
-  if( pPager->errCode ){
-    if( isOpen(pPager->jfd) || pPager->zJournal ){
-      isErrorReset = 1;
-    }
-    pPager->errCode = SQLITE_OK;
-    pager_reset(pPager);
-  }
+  if( !pagerUseWal(pPager) && pPager->eState==PAGER_OPEN ){
+    int bHotJournal = 1;          /* True if there exists a hot journal-file */
 
-  if( pPager->state==PAGER_UNLOCK || isErrorReset ){
-    sqlite3_vfs * const pVfs = pPager->pVfs;
-    int isHotJournal = 0;
     assert( !MEMDB );
-    assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );
-    if( pPager->noReadlock ){
-      assert( pPager->readOnly );
-      pPager->state = PAGER_SHARED;
-    }else{
+    assert( pPager->noReadlock==0 || pPager->readOnly );
+
+    if( pPager->noReadlock==0 ){
       rc = pager_wait_on_lock(pPager, SHARED_LOCK);
       if( rc!=SQLITE_OK ){
-        assert( pPager->state==PAGER_UNLOCK );
-        return pager_error(pPager, rc);
+        assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK );
+        goto failed;
       }
     }
-    assert( pPager->state>=SHARED_LOCK );
 
     /* If a journal file exists, and there is no RESERVED lock on the
     ** database file, then it either needs to be played back or deleted.
     */
-    if( !isErrorReset ){
-      assert( pPager->state <= PAGER_SHARED );
-      rc = hasHotJournal(pPager, &isHotJournal);
-      if( rc!=SQLITE_OK ){
-        goto failed;
-      }
+    if( pPager->eLock<=SHARED_LOCK ){
+      rc = hasHotJournal(pPager, &bHotJournal);
     }
-    if( isErrorReset || isHotJournal ){
+    if( rc!=SQLITE_OK ){
+      goto failed;
+    }
+    if( bHotJournal ){
       /* Get an EXCLUSIVE lock on the database file. At this point it is
       ** important that a RESERVED lock is not obtained on the way to the
       ** EXCLUSIVE lock. If it were, another process might open the
@@ -35810,74 +39220,95 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
       ** other process attempting to access the database file will get to 
       ** this point in the code and fail to obtain its own EXCLUSIVE lock 
       ** on the database file.
+      **
+      ** Unless the pager is in locking_mode=exclusive mode, the lock is
+      ** downgraded to SHARED_LOCK before this function returns.
       */
-      if( pPager->state<EXCLUSIVE_LOCK ){
-        rc = sqlite3OsLock(pPager->fd, EXCLUSIVE_LOCK);
-        if( rc!=SQLITE_OK ){
-          rc = pager_error(pPager, rc);
-          goto failed;
-        }
-        pPager->state = PAGER_EXCLUSIVE;
+      rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
+      if( rc!=SQLITE_OK ){
+        goto failed;
       }
  
-      /* Open the journal for read/write access. This is because in 
-      ** exclusive-access mode the file descriptor will be kept open and
-      ** possibly used for a transaction later on. On some systems, the
-      ** OsTruncate() call used in exclusive-access mode also requires
-      ** a read/write file handle.
+      /* If it is not already open and the file exists on disk, open the 
+      ** journal for read/write access. Write access is required because 
+      ** in exclusive-access mode the file descriptor will be kept open 
+      ** and possibly used for a transaction later on. Also, write-access 
+      ** is usually required to finalize the journal in journal_mode=persist 
+      ** mode (and also for journal_mode=truncate on some systems).
+      **
+      ** If the journal does not exist, it usually means that some 
+      ** other connection managed to get in and roll it back before 
+      ** this connection obtained the exclusive lock above. Or, it 
+      ** may mean that the pager was in the error-state when this
+      ** function was called and the journal file does not exist.
       */
       if( !isOpen(pPager->jfd) ){
-        int res;
-        rc = sqlite3OsAccess(pVfs,pPager->zJournal,SQLITE_ACCESS_EXISTS,&res);
-        if( rc==SQLITE_OK ){
-          if( res ){
-            int fout = 0;
-            int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;
-            assert( !pPager->tempFile );
-            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
-            assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
-            if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){
-              rc = SQLITE_CANTOPEN_BKPT;
-              sqlite3OsClose(pPager->jfd);
-            }
-          }else{
-            /* If the journal does not exist, it usually means that some 
-            ** other connection managed to get in and roll it back before 
-            ** this connection obtained the exclusive lock above. Or, it 
-            ** may mean that the pager was in the error-state when this
-            ** function was called and the journal file does not exist.  */
-            rc = pager_end_transaction(pPager, 0);
+        sqlite3_vfs * const pVfs = pPager->pVfs;
+        int bExists;              /* True if journal file exists */
+        rc = sqlite3OsAccess(
+            pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);
+        if( rc==SQLITE_OK && bExists ){
+          int fout = 0;
+          int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;
+          assert( !pPager->tempFile );
+          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);
+          assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
+          if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){
+            rc = SQLITE_CANTOPEN_BKPT;
+            sqlite3OsClose(pPager->jfd);
           }
         }
       }
-      if( rc!=SQLITE_OK ){
-        goto failed;
-      }
-
-      /* TODO: Why are these cleared here? Is it necessary? */
-      pPager->journalStarted = 0;
-      pPager->journalOff = 0;
-      pPager->setMaster = 0;
-      pPager->journalHdr = 0;
  
       /* Playback and delete the journal.  Drop the database write
       ** lock and reacquire the read lock. Purge the cache before
       ** playing back the hot-journal so that we don't end up with
-      ** an inconsistent cache.
+      ** an inconsistent cache.  Sync the hot journal before playing
+      ** it back since the process that crashed and left the hot journal
+      ** probably did not sync it and we are required to always sync
+      ** the journal before playing it back.
       */
       if( isOpen(pPager->jfd) ){
-        rc = pager_playback(pPager, 1);
-        if( rc!=SQLITE_OK ){
-          rc = pager_error(pPager, rc);
-          goto failed;
+        assert( rc==SQLITE_OK );
+        rc = pagerSyncHotJournal(pPager);
+        if( rc==SQLITE_OK ){
+          rc = pager_playback(pPager, 1);
+          pPager->eState = PAGER_OPEN;
         }
+      }else if( !pPager->exclusiveMode ){
+        pagerUnlockDb(pPager, SHARED_LOCK);
       }
-      assert( (pPager->state==PAGER_SHARED)
-           || (pPager->exclusiveMode && pPager->state>PAGER_SHARED)
+
+      if( rc!=SQLITE_OK ){
+        /* This branch is taken if an error occurs while trying to open
+        ** or roll back a hot-journal while holding an EXCLUSIVE lock. The
+        ** pager_unlock() routine will be called before returning to unlock
+        ** the file. If the unlock attempt fails, then Pager.eLock must be
+        ** set to UNKNOWN_LOCK (see the comment above the #define for 
+        ** UNKNOWN_LOCK above for an explanation). 
+        **
+        ** In order to get pager_unlock() to do this, set Pager.eState to
+        ** PAGER_ERROR now. This is not actually counted as a transition
+        ** to ERROR state in the state diagram at the top of this file,
+        ** since we know that the same call to pager_unlock() will very
+        ** shortly transition the pager object to the OPEN state. Calling
+        ** assert_pager_state() would fail now, as it should not be possible
+        ** to be in ERROR state when there are zero outstanding page 
+        ** references.
+        */
+        pager_error(pPager, rc);
+        goto failed;
+      }
+
+      assert( pPager->eState==PAGER_OPEN );
+      assert( (pPager->eLock==SHARED_LOCK)
+           || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK)
       );
     }
 
-    if( pPager->pBackup || sqlite3PcachePagecount(pPager->pPCache)>0 ){
+    if( !pPager->tempFile 
+     && (pPager->pBackup || sqlite3PcachePagecount(pPager->pPCache)>0) 
+    ){
       /* The shared-lock has just been acquired on the database file
       ** and there are already pages in the cache (from a previous
       ** read or write transaction).  Check to see if the database
@@ -35894,16 +39325,13 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
       ** detected.  The chance of an undetected change is so small that
       ** it can be neglected.
       */
+      Pgno nPage = 0;
       char dbFileVers[sizeof(pPager->dbFileVers)];
-      sqlite3PagerPagecount(pPager, 0);
 
-      if( pPager->errCode ){
-        rc = pPager->errCode;
-        goto failed;
-      }
+      rc = pagerPagecount(pPager, &nPage);
+      if( rc ) goto failed;
 
-      assert( pPager->dbSizeValid );
-      if( pPager->dbSize>0 ){
+      if( nPage>0 ){
         IOTRACE(("CKVERS %p %d\n", pPager, sizeof(dbFileVers)));
         rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);
         if( rc!=SQLITE_OK ){
@@ -35917,13 +39345,32 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
         pager_reset(pPager);
       }
     }
-    assert( pPager->exclusiveMode || pPager->state==PAGER_SHARED );
+
+    /* If there is a WAL file in the file-system, open this database in WAL
+    ** mode. Otherwise, the following function call is a no-op.
+    */
+    rc = pagerOpenWalIfPresent(pPager);
+#ifndef SQLITE_OMIT_WAL
+    assert( pPager->pWal==0 || rc==SQLITE_OK );
+#endif
+  }
+
+  if( pagerUseWal(pPager) ){
+    assert( rc==SQLITE_OK );
+    rc = pagerBeginReadTransaction(pPager);
+  }
+
+  if( pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){
+    rc = pagerPagecount(pPager, &pPager->dbSize);
   }
 
  failed:
   if( rc!=SQLITE_OK ){
-    /* pager_unlock() is a no-op for exclusive mode and in-memory databases. */
+    assert( !MEMDB );
     pager_unlock(pPager);
+    assert( pPager->eState==PAGER_OPEN );
+  }else{
+    pPager->eState = PAGER_READER;
   }
   return rc;
 }
@@ -35937,9 +39384,7 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
 ** nothing to rollback, so this routine is a no-op.
 */ 
 static void pagerUnlockIfUnused(Pager *pPager){
-  if( (sqlite3PcacheRefCount(pPager->pPCache)==0)
-   && (!pPager->exclusiveMode || pPager->journalOff>0) 
-  ){
+  if( (sqlite3PcacheRefCount(pPager->pPCache)==0) ){
     pagerUnlockAndRollback(pPager);
   }
 }
@@ -35972,7 +39417,7 @@ static void pagerUnlockIfUnused(Pager *pPager){
 **   a) When reading a free-list leaf page from the database, and
 **
 **   b) When a savepoint is being rolled back and we need to load
-**      a new page into the cache to populate with the data read
+**      a new page into the cache to be filled with the data read
 **      from the savepoint journal.
 **
 ** If noContent is true, then the data returned is zeroed instead of
@@ -36003,8 +39448,8 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
   int rc;
   PgHdr *pPg;
 
+  assert( pPager->eState>=PAGER_READER );
   assert( assert_pager_state(pPager) );
-  assert( pPager->state>PAGER_UNLOCK );
 
   if( pgno==0 ){
     return SQLITE_CORRUPT_BKPT;
@@ -36012,7 +39457,7 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
 
   /* If the pager is in the error state, return an error immediately. 
   ** Otherwise, request the page from the PCache layer. */
-  if( pPager->errCode!=SQLITE_OK && pPager->errCode!=SQLITE_FULL ){
+  if( pPager->errCode!=SQLITE_OK ){
     rc = pPager->errCode;
   }else{
     rc = sqlite3PcacheFetch(pPager->pPCache, pgno, 1, ppPage);
@@ -36028,7 +39473,7 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
   assert( (*ppPage)->pgno==pgno );
   assert( (*ppPage)->pPager==pPager || (*ppPage)->pPager==0 );
 
-  if( (*ppPage)->pPager ){
+  if( (*ppPage)->pPager && !noContent ){
     /* In this case the pcache already contains an initialized copy of
     ** the page. Return without further ado.  */
     assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
@@ -36038,7 +39483,6 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
   }else{
     /* The pager cache has created a new page. Its content needs to 
     ** be initialized.  */
-    int nMax;
 
     PAGER_INCR(pPager->nMiss);
     pPg = *ppPage;
@@ -36051,15 +39495,10 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
       goto pager_acquire_err;
     }
 
-    rc = sqlite3PagerPagecount(pPager, &nMax);
-    if( rc!=SQLITE_OK ){
-      goto pager_acquire_err;
-    }
-
-    if( MEMDB || nMax<(int)pgno || noContent || !isOpen(pPager->fd) ){
+    if( MEMDB || pPager->dbSize<pgno || noContent || !isOpen(pPager->fd) ){
       if( pgno>pPager->mxPgno ){
-	rc = SQLITE_FULL;
-	goto pager_acquire_err;
+        rc = SQLITE_FULL;
+        goto pager_acquire_err;
       }
       if( noContent ){
         /* Failure to set the bits in the InJournal bit-vectors is benign.
@@ -36086,9 +39525,7 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
         goto pager_acquire_err;
       }
     }
-#ifdef SQLITE_CHECK_PAGES
-    pPg->pageHash = pager_pagehash(pPg);
-#endif
+    pager_set_pagehash(pPg);
   }
 
   return SQLITE_OK;
@@ -36107,9 +39544,7 @@ pager_acquire_err:
 /*
 ** Acquire a page if it is already in the in-memory cache.  Do
 ** not read the page from disk.  Return a pointer to the page,
-** or 0 if the page is not in cache. Also, return 0 if the 
-** pager is in PAGER_UNLOCK state when this function is called,
-** or if the pager is in an error state other than SQLITE_FULL.
+** or 0 if the page is not in cache. 
 **
 ** See also sqlite3PagerGet().  The difference between this routine
 ** and sqlite3PagerGet() is that _get() will go to the disk and read
@@ -36122,7 +39557,7 @@ SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
   assert( pPager!=0 );
   assert( pgno!=0 );
   assert( pPager->pPCache!=0 );
-  assert( pPager->state > PAGER_UNLOCK );
+  assert( pPager->eState>=PAGER_READER && pPager->eState!=PAGER_ERROR );
   sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
   return pPg;
 }
@@ -36144,27 +39579,6 @@ SQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){
 }
 
 /*
-** If the main journal file has already been opened, ensure that the
-** sub-journal file is open too. If the main journal is not open,
-** this function is a no-op.
-**
-** SQLITE_OK is returned if everything goes according to plan. 
-** An SQLITE_IOERR_XXX error code is returned if a call to 
-** sqlite3OsOpen() fails.
-*/
-static int openSubJournal(Pager *pPager){
-  int rc = SQLITE_OK;
-  if( isOpen(pPager->jfd) && !isOpen(pPager->sjfd) ){
-    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){
-      sqlite3MemJournalOpen(pPager->sjfd);
-    }else{
-      rc = pagerOpentemp(pPager, pPager->sjfd, SQLITE_OPEN_SUBJOURNAL);
-    }
-  }
-  return rc;
-}
-
-/*
 ** This function is called at the start of every write transaction.
 ** There must already be a RESERVED or EXCLUSIVE lock on the database 
 ** file when this routine is called.
@@ -36190,9 +39604,8 @@ static int pager_open_journal(Pager *pPager){
   int rc = SQLITE_OK;                        /* Return code */
   sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */
 
-  assert( pPager->state>=PAGER_RESERVED );
-  assert( pPager->useJournal );
-  assert( pPager->journalMode!=PAGER_JOURNALMODE_OFF );
+  assert( pPager->eState==PAGER_WRITER_LOCKED );
+  assert( assert_pager_state(pPager) );
   assert( pPager->pInJournal==0 );
   
   /* If already in the error state, this function is a no-op.  But on
@@ -36200,62 +39613,56 @@ static int pager_open_journal(Pager *pPager){
   ** an error state. */
   if( NEVER(pPager->errCode) ) return pPager->errCode;
 
-  /* TODO: Is it really possible to get here with dbSizeValid==0? If not,
-  ** the call to PagerPagecount() can be removed.
-  */
-  testcase( pPager->dbSizeValid==0 );
-  sqlite3PagerPagecount(pPager, 0);
-
-  pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);
-  if( pPager->pInJournal==0 ){
-    return SQLITE_NOMEM;
-  }
-
-  /* Open the journal file if it is not already open. */
-  if( !isOpen(pPager->jfd) ){
-    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
-      sqlite3MemJournalOpen(pPager->jfd);
-    }else{
-      const int flags =                   /* VFS flags to open journal file */
-        SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|
-        (pPager->tempFile ? 
-          (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
-          (SQLITE_OPEN_MAIN_JOURNAL)
+  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
+    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);
+    if( pPager->pInJournal==0 ){
+      return SQLITE_NOMEM;
+    }
+  
+    /* Open the journal file if it is not already open. */
+    if( !isOpen(pPager->jfd) ){
+      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
+        sqlite3MemJournalOpen(pPager->jfd);
+      }else{
+        const int flags =                   /* VFS flags to open journal file */
+          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|
+          (pPager->tempFile ? 
+            (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
+            (SQLITE_OPEN_MAIN_JOURNAL)
+          );
+  #ifdef SQLITE_ENABLE_ATOMIC_WRITE
+        rc = sqlite3JournalOpen(
+            pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)
         );
-#ifdef SQLITE_ENABLE_ATOMIC_WRITE
-      rc = sqlite3JournalOpen(
-          pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)
-      );
-#else
-      rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
-#endif
+  #else
+        rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
+  #endif
+      }
+      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
+    }
+  
+  
+    /* Write the first journal header to the journal file and open 
+    ** the sub-journal if necessary.
+    */
+    if( rc==SQLITE_OK ){
+      /* TODO: Check if all of these are really required. */
+      pPager->nRec = 0;
+      pPager->journalOff = 0;
+      pPager->setMaster = 0;
+      pPager->journalHdr = 0;
+      rc = writeJournalHdr(pPager);
     }
-    assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
-  }
-
-
-  /* Write the first journal header to the journal file and open 
-  ** the sub-journal if necessary.
-  */
-  if( rc==SQLITE_OK ){
-    /* TODO: Check if all of these are really required. */
-    pPager->dbOrigSize = pPager->dbSize;
-    pPager->journalStarted = 0;
-    pPager->needSync = 0;
-    pPager->nRec = 0;
-    pPager->journalOff = 0;
-    pPager->setMaster = 0;
-    pPager->journalHdr = 0;
-    rc = writeJournalHdr(pPager);
-  }
-  if( rc==SQLITE_OK && pPager->nSavepoint ){
-    rc = openSubJournal(pPager);
   }
 
   if( rc!=SQLITE_OK ){
     sqlite3BitvecDestroy(pPager->pInJournal);
     pPager->pInJournal = 0;
+  }else{
+    assert( pPager->eState==PAGER_WRITER_LOCKED );
+    pPager->eState = PAGER_WRITER_CACHEMOD;
   }
+
   return rc;
 }
 
@@ -36268,14 +39675,6 @@ static int pager_open_journal(Pager *pPager){
 ** an EXCLUSIVE lock. If such a lock is already held, no locking 
 ** functions need be called.
 **
-** If this is not a temporary or in-memory file and, the journal file is 
-** opened if it has not been already. For a temporary file, the opening 
-** of the journal file is deferred until there is an actual need to 
-** write to the journal. TODO: Why handle temporary files differently?
-**
-** If the journal file is opened (or if it is already open), then a
-** journal-header is written to the start of it.
-**
 ** If the subjInMemory argument is non-zero, then any sub-journal opened
 ** within this transaction will be opened as an in-memory file. This
 ** has no effect if the sub-journal is already opened (as it may be when
@@ -36286,55 +39685,67 @@ static int pager_open_journal(Pager *pPager){
 */
 SQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
   int rc = SQLITE_OK;
-  assert( pPager->state!=PAGER_UNLOCK );
+
+  if( pPager->errCode ) return pPager->errCode;
+  assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );
   pPager->subjInMemory = (u8)subjInMemory;
-  if( pPager->state==PAGER_SHARED ){
+
+  if( ALWAYS(pPager->eState==PAGER_READER) ){
     assert( pPager->pInJournal==0 );
-    assert( !MEMDB && !pPager->tempFile );
 
-    /* Obtain a RESERVED lock on the database file. If the exFlag parameter
-    ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
-    ** busy-handler callback can be used when upgrading to the EXCLUSIVE
-    ** lock, but not when obtaining the RESERVED lock.
-    */
-    rc = sqlite3OsLock(pPager->fd, RESERVED_LOCK);
-    if( rc==SQLITE_OK ){
-      pPager->state = PAGER_RESERVED;
-      if( exFlag ){
+    if( pagerUseWal(pPager) ){
+      /* If the pager is configured to use locking_mode=exclusive, and an
+      ** exclusive lock on the database is not already held, obtain it now.
+      */
+      if( pPager->exclusiveMode && sqlite3WalExclusiveMode(pPager->pWal, -1) ){
+        rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
+        if( rc!=SQLITE_OK ){
+          return rc;
+        }
+        sqlite3WalExclusiveMode(pPager->pWal, 1);
+      }
+
+      /* Grab the write lock on the log file. If successful, upgrade to
+      ** PAGER_RESERVED state. Otherwise, return an error code to the caller.
+      ** The busy-handler is not invoked if another connection already
+      ** holds the write-lock. If possible, the upper layer will call it.
+      */
+      rc = sqlite3WalBeginWriteTransaction(pPager->pWal);
+    }else{
+      /* Obtain a RESERVED lock on the database file. If the exFlag parameter
+      ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
+      ** busy-handler callback can be used when upgrading to the EXCLUSIVE
+      ** lock, but not when obtaining the RESERVED lock.
+      */
+      rc = pagerLockDb(pPager, RESERVED_LOCK);
+      if( rc==SQLITE_OK && exFlag ){
         rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
       }
     }
 
-    /* If the required locks were successfully obtained, open the journal
-    ** file and write the first journal-header to it.
-    */
-    if( rc==SQLITE_OK && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
-      rc = pager_open_journal(pPager);
-    }
-  }else if( isOpen(pPager->jfd) && pPager->journalOff==0 ){
-    /* This happens when the pager was in exclusive-access mode the last
-    ** time a (read or write) transaction was successfully concluded
-    ** by this connection. Instead of deleting the journal file it was 
-    ** kept open and either was truncated to 0 bytes or its header was
-    ** overwritten with zeros.
-    */
-    assert( pPager->nRec==0 );
-    assert( pPager->dbOrigSize==0 );
-    assert( pPager->pInJournal==0 );
-    rc = pager_open_journal(pPager);
+    if( rc==SQLITE_OK ){
+      /* Change to WRITER_LOCKED state.
+      **
+      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD
+      ** when it has an open transaction, but never to DBMOD or FINISHED.
+      ** This is because in those states the code to roll back savepoint 
+      ** transactions may copy data from the sub-journal into the database 
+      ** file as well as into the page cache. Which would be incorrect in 
+      ** WAL mode.
+      */
+      pPager->eState = PAGER_WRITER_LOCKED;
+      pPager->dbHintSize = pPager->dbSize;
+      pPager->dbFileSize = pPager->dbSize;
+      pPager->dbOrigSize = pPager->dbSize;
+      pPager->journalOff = 0;
+    }
+
+    assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );
+    assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );
+    assert( assert_pager_state(pPager) );
   }
 
   PAGERTRACE(("TRANSACTION %d\n", PAGERID(pPager)));
-  assert( !isOpen(pPager->jfd) || pPager->journalOff>0 || rc!=SQLITE_OK );
-  if( rc!=SQLITE_OK ){
-    assert( !pPager->dbModified );
-    /* Ignore any IO error that occurs within pager_end_transaction(). The
-    ** purpose of this call is to reset the internal state of the pager
-    ** sub-system. It doesn't matter if the journal-file is not properly
-    ** finalized at this point (since it is not a valid journal file anyway).
-    */
-    pager_end_transaction(pPager, 0);
-  }
   return rc;
 }
 
@@ -36350,102 +39761,94 @@ static int pager_write(PgHdr *pPg){
   Pager *pPager = pPg->pPager;
   int rc = SQLITE_OK;
 
-  /* This routine is not called unless a transaction has already been
-  ** started.
+  /* This routine is not called unless a write-transaction has already 
+  ** been started. The journal file may or may not be open at this point.
+  ** It is never called in the ERROR state.
   */
-  assert( pPager->state>=PAGER_RESERVED );
+  assert( pPager->eState==PAGER_WRITER_LOCKED
+       || pPager->eState==PAGER_WRITER_CACHEMOD
+       || pPager->eState==PAGER_WRITER_DBMOD
+  );
+  assert( assert_pager_state(pPager) );
 
-  /* If an error has been previously detected, we should not be
-  ** calling this routine.  Repeat the error for robustness.
-  */
+  /* If an error has been previously detected, report the same error
+  ** again. This should not happen, but the check provides robustness. */
   if( NEVER(pPager->errCode) )  return pPager->errCode;
 
   /* Higher-level routines never call this function if database is not
   ** writable.  But check anyway, just for robustness. */
   if( NEVER(pPager->readOnly) ) return SQLITE_PERM;
 
-  assert( !pPager->setMaster );
-
   CHECK_PAGE(pPg);
 
+  /* The journal file needs to be opened. Higher level routines have already
+  ** obtained the necessary locks to begin the write-transaction, but the
+  ** rollback journal might not yet be open. Open it now if this is the case.
+  **
+  ** This is done before calling sqlite3PcacheMakeDirty() on the page. 
+  ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then
+  ** an error might occur and the pager would end up in WRITER_LOCKED state
+  ** with pages marked as dirty in the cache.
+  */
+  if( pPager->eState==PAGER_WRITER_LOCKED ){
+    rc = pager_open_journal(pPager);
+    if( rc!=SQLITE_OK ) return rc;
+  }
+  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
+  assert( assert_pager_state(pPager) );
+
   /* Mark the page as dirty.  If the page has already been written
   ** to the journal then we can return right away.
   */
   sqlite3PcacheMakeDirty(pPg);
   if( pageInJournal(pPg) && !subjRequiresPage(pPg) ){
-    pPager->dbModified = 1;
+    assert( !pagerUseWal(pPager) );
   }else{
-
-    /* If we get this far, it means that the page needs to be
-    ** written to the transaction journal or the ckeckpoint journal
-    ** or both.
-    **
-    ** Higher level routines should have already started a transaction,
-    ** which means they have acquired the necessary locks and opened
-    ** a rollback journal.  Double-check to makes sure this is the case.
-    */
-    rc = sqlite3PagerBegin(pPager, 0, pPager->subjInMemory);
-    if( NEVER(rc!=SQLITE_OK) ){
-      return rc;
-    }
-    if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
-      assert( pPager->useJournal );
-      rc = pager_open_journal(pPager);
-      if( rc!=SQLITE_OK ) return rc;
-    }
-    pPager->dbModified = 1;
   
     /* The transaction journal now exists and we have a RESERVED or an
     ** EXCLUSIVE lock on the main database file.  Write the current page to
     ** the transaction journal if it is not there already.
     */
-    if( !pageInJournal(pPg) && isOpen(pPager->jfd) ){
-      if( pPg->pgno<=pPager->dbOrigSize ){
+    if( !pageInJournal(pPg) && !pagerUseWal(pPager) ){
+      assert( pagerUseWal(pPager)==0 );
+      if( pPg->pgno<=pPager->dbOrigSize && isOpen(pPager->jfd) ){
         u32 cksum;
         char *pData2;
+        i64 iOff = pPager->journalOff;
 
         /* We should never write to the journal file the page that
         ** contains the database locks.  The following assert verifies
         ** that we do not. */
         assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );
+
+        assert( pPager->journalHdr<=pPager->journalOff );
         CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);
         cksum = pager_cksum(pPager, (u8*)pData2);
-        rc = write32bits(pPager->jfd, pPager->journalOff, pPg->pgno);
-        if( rc==SQLITE_OK ){
-          rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize,
-                              pPager->journalOff + 4);
-          pPager->journalOff += pPager->pageSize+4;
-        }
-        if( rc==SQLITE_OK ){
-          rc = write32bits(pPager->jfd, pPager->journalOff, cksum);
-          pPager->journalOff += 4;
-        }
-        IOTRACE(("JOUT %p %d %lld %d\n", pPager, pPg->pgno, 
-                 pPager->journalOff, pPager->pageSize));
-        PAGER_INCR(sqlite3_pager_writej_count);
-        PAGERTRACE(("JOURNAL %d page %d needSync=%d hash(%08x)\n",
-             PAGERID(pPager), pPg->pgno, 
-             ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));
 
-        /* Even if an IO or diskfull error occurred while journalling the
+        /* Even if an IO or diskfull error occurs while journalling the
         ** page in the block above, set the need-sync flag for the page.
         ** Otherwise, when the transaction is rolled back, the logic in
         ** playback_one_page() will think that the page needs to be restored
         ** in the database file. And if an IO error occurs while doing so,
         ** then corruption may follow.
         */
-        if( !pPager->noSync ){
-          pPg->flags |= PGHDR_NEED_SYNC;
-          pPager->needSync = 1;
-        }
+        pPg->flags |= PGHDR_NEED_SYNC;
 
-        /* An error has occurred writing to the journal file. The 
-        ** transaction will be rolled back by the layer above.
-        */
-        if( rc!=SQLITE_OK ){
-          return rc;
-        }
+        rc = write32bits(pPager->jfd, iOff, pPg->pgno);
+        if( rc!=SQLITE_OK ) return rc;
+        rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);
+        if( rc!=SQLITE_OK ) return rc;
+        rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);
+        if( rc!=SQLITE_OK ) return rc;
 
+        IOTRACE(("JOUT %p %d %lld %d\n", pPager, pPg->pgno, 
+                 pPager->journalOff, pPager->pageSize));
+        PAGER_INCR(sqlite3_pager_writej_count);
+        PAGERTRACE(("JOURNAL %d page %d needSync=%d hash(%08x)\n",
+             PAGERID(pPager), pPg->pgno, 
+             ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));
+
+        pPager->journalOff += 8 + pPager->pageSize;
         pPager->nRec++;
         assert( pPager->pInJournal!=0 );
         rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);
@@ -36457,9 +39860,8 @@ static int pager_write(PgHdr *pPg){
           return rc;
         }
       }else{
-        if( !pPager->journalStarted && !pPager->noSync ){
+        if( pPager->eState!=PAGER_WRITER_DBMOD ){
           pPg->flags |= PGHDR_NEED_SYNC;
-          pPager->needSync = 1;
         }
         PAGERTRACE(("APPEND %d page %d needSync=%d\n",
                 PAGERID(pPager), pPg->pgno,
@@ -36479,7 +39881,6 @@ static int pager_write(PgHdr *pPg){
 
   /* Update the database size and return.
   */
-  assert( pPager->state>=PAGER_SHARED );
   if( pPager->dbSize<pPg->pgno ){
     pPager->dbSize = pPg->pgno;
   }
@@ -36507,19 +39908,24 @@ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){
   Pager *pPager = pPg->pPager;
   Pgno nPagePerSector = (pPager->sectorSize/pPager->pageSize);
 
+  assert( pPager->eState>=PAGER_WRITER_LOCKED );
+  assert( pPager->eState!=PAGER_ERROR );
+  assert( assert_pager_state(pPager) );
+
   if( nPagePerSector>1 ){
     Pgno nPageCount;          /* Total number of pages in database file */
     Pgno pg1;                 /* First page of the sector pPg is located on. */
-    int nPage;                /* Number of pages starting at pg1 to journal */
+    int nPage = 0;            /* Number of pages starting at pg1 to journal */
     int ii;                   /* Loop counter */
     int needSync = 0;         /* True if any page has PGHDR_NEED_SYNC */
 
-    /* Set the doNotSync flag to 1. This is because we cannot allow a journal
-    ** header to be written between the pages journaled by this function.
+    /* Set the doNotSyncSpill flag to 1. This is because we cannot allow
+    ** a journal header to be written between the pages journaled by
+    ** this function.
     */
     assert( !MEMDB );
-    assert( pPager->doNotSync==0 );
-    pPager->doNotSync = 1;
+    assert( pPager->doNotSyncSpill==0 );
+    pPager->doNotSyncSpill++;
 
     /* This trick assumes that both the page-size and sector-size are
     ** an integer power of 2. It sets variable pg1 to the identifier
@@ -36527,7 +39933,7 @@ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){
     */
     pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;
 
-    sqlite3PagerPagecount(pPager, (int *)&nPageCount);
+    nPageCount = pPager->dbSize;
     if( pPg->pgno>nPageCount ){
       nPage = (pPg->pgno - pg1)+1;
     }else if( (pg1+nPagePerSector-1)>nPageCount ){
@@ -36549,7 +39955,6 @@ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){
             rc = pager_write(pPage);
             if( pPage->flags&PGHDR_NEED_SYNC ){
               needSync = 1;
-              assert(pPager->needSync);
             }
             sqlite3PagerUnref(pPage);
           }
@@ -36569,7 +39974,7 @@ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){
     ** before any of them can be written out to the database file.
     */
     if( rc==SQLITE_OK && needSync ){
-      assert( !MEMDB && pPager->noSync==0 );
+      assert( !MEMDB );
       for(ii=0; ii<nPage; ii++){
         PgHdr *pPage = pager_lookup(pPager, pg1+ii);
         if( pPage ){
@@ -36577,11 +39982,10 @@ SQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){
           sqlite3PagerUnref(pPage);
         }
       }
-      assert(pPager->needSync);
     }
 
-    assert( pPager->doNotSync==1 );
-    pPager->doNotSync = 0;
+    assert( pPager->doNotSyncSpill==1 );
+    pPager->doNotSyncSpill--;
   }else{
     rc = pager_write(pDbPage);
   }
@@ -36619,9 +40023,7 @@ SQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){
     PAGERTRACE(("DONT_WRITE page %d of %d\n", pPg->pgno, PAGERID(pPager)));
     IOTRACE(("CLEAN %p %d\n", pPager, pPg->pgno))
     pPg->flags |= PGHDR_DONT_WRITE;
-#ifdef SQLITE_CHECK_PAGES
-    pPg->pageHash = pager_pagehash(pPg);
-#endif
+    pager_set_pagehash(pPg);
   }
 }
 
@@ -36644,6 +40046,11 @@ SQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){
 static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
   int rc = SQLITE_OK;
 
+  assert( pPager->eState==PAGER_WRITER_CACHEMOD
+       || pPager->eState==PAGER_WRITER_DBMOD
+  );
+  assert( assert_pager_state(pPager) );
+
   /* Declare and initialize constant integer 'isDirect'. If the
   ** atomic-write optimization is enabled in this build, then isDirect
   ** is initialized to the value passed as the isDirectMode parameter
@@ -36662,7 +40069,6 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
 # define DIRECT_MODE isDirectMode
 #endif
 
-  assert( pPager->state>=PAGER_RESERVED );
   if( !pPager->changeCountDone && pPager->dbSize>0 ){
     PgHdr *pPgHdr;                /* Reference to page 1 */
     u32 change_counter;           /* Initial value of change-counter field */
@@ -36688,11 +40094,20 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
       change_counter++;
       put32bits(((char*)pPgHdr->pData)+24, change_counter);
 
+      /* Also store the SQLite version number in bytes 96..99 and in
+      ** bytes 92..95 store the change counter for which the version number
+      ** is valid. */
+      put32bits(((char*)pPgHdr->pData)+92, change_counter);
+      put32bits(((char*)pPgHdr->pData)+96, SQLITE_VERSION_NUMBER);
+
       /* If running in direct mode, write the contents of page 1 to the file. */
       if( DIRECT_MODE ){
-        const void *zBuf = pPgHdr->pData;
+        const void *zBuf;
         assert( pPager->dbFileSize>0 );
-        rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
+        CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
+        if( rc==SQLITE_OK ){
+          rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
+        }
         if( rc==SQLITE_OK ){
           pPager->changeCountDone = 1;
         }
@@ -36726,6 +40141,30 @@ SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager){
 }
 
 /*
+** This function may only be called while a write-transaction is active in
+** rollback. If the connection is in WAL mode, this call is a no-op. 
+** Otherwise, if the connection does not already have an EXCLUSIVE lock on 
+** the database file, an attempt is made to obtain one.
+**
+** If the EXCLUSIVE lock is already held or the attempt to obtain it is
+** successful, or the connection is in WAL mode, SQLITE_OK is returned.
+** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is 
+** returned.
+*/
+SQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){
+  int rc = SQLITE_OK;
+  assert( pPager->eState==PAGER_WRITER_CACHEMOD 
+       || pPager->eState==PAGER_WRITER_DBMOD 
+       || pPager->eState==PAGER_WRITER_LOCKED 
+  );
+  assert( assert_pager_state(pPager) );
+  if( 0==pagerUseWal(pPager) ){
+    rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
+  }
+  return rc;
+}
+
+/*
 ** Sync the database file for the pager pPager. zMaster points to the name
 ** of a master journal file that should be written into the individual
 ** journal file. zMaster may be NULL, which is interpreted as no master
@@ -36758,151 +40197,174 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(
 ){
   int rc = SQLITE_OK;             /* Return code */
 
-  /* The dbOrigSize is never set if journal_mode=OFF */
-  assert( pPager->journalMode!=PAGER_JOURNALMODE_OFF || pPager->dbOrigSize==0 );
+  assert( pPager->eState==PAGER_WRITER_LOCKED
+       || pPager->eState==PAGER_WRITER_CACHEMOD
+       || pPager->eState==PAGER_WRITER_DBMOD
+       || pPager->eState==PAGER_ERROR
+  );
+  assert( assert_pager_state(pPager) );
 
-  /* If a prior error occurred, this routine should not be called.  ROLLBACK
-  ** is the appropriate response to an error, not COMMIT.  Guard against
-  ** coding errors by repeating the prior error. */
+  /* If a prior error occurred, report that error again. */
   if( NEVER(pPager->errCode) ) return pPager->errCode;
 
   PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n", 
       pPager->zFilename, zMaster, pPager->dbSize));
 
-  if( MEMDB && pPager->dbModified ){
+  /* If no database changes have been made, return early. */
+  if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;
+
+  if( MEMDB ){
     /* If this is an in-memory db, or no pages have been written to, or this
     ** function has already been called, it is mostly a no-op.  However, any
     ** backup in progress needs to be restarted.
     */
     sqlite3BackupRestart(pPager->pBackup);
-  }else if( pPager->state!=PAGER_SYNCED && pPager->dbModified ){
-
-    /* The following block updates the change-counter. Exactly how it
-    ** does this depends on whether or not the atomic-update optimization
-    ** was enabled at compile time, and if this transaction meets the 
-    ** runtime criteria to use the operation: 
-    **
-    **    * The file-system supports the atomic-write property for
-    **      blocks of size page-size, and 
-    **    * This commit is not part of a multi-file transaction, and
-    **    * Exactly one page has been modified and store in the journal file.
-    **
-    ** If the optimization was not enabled at compile time, then the
-    ** pager_incr_changecounter() function is called to update the change
-    ** counter in 'indirect-mode'. If the optimization is compiled in but
-    ** is not applicable to this transaction, call sqlite3JournalCreate()
-    ** to make sure the journal file has actually been created, then call
-    ** pager_incr_changecounter() to update the change-counter in indirect
-    ** mode. 
-    **
-    ** Otherwise, if the optimization is both enabled and applicable,
-    ** then call pager_incr_changecounter() to update the change-counter
-    ** in 'direct' mode. In this case the journal file will never be
-    ** created for this transaction.
-    */
-#ifdef SQLITE_ENABLE_ATOMIC_WRITE
-    PgHdr *pPg;
-    assert( isOpen(pPager->jfd) || pPager->journalMode==PAGER_JOURNALMODE_OFF );
-    if( !zMaster && isOpen(pPager->jfd) 
-     && pPager->journalOff==jrnlBufferSize(pPager) 
-     && pPager->dbSize>=pPager->dbFileSize
-     && (0==(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)
-    ){
-      /* Update the db file change counter via the direct-write method. The 
-      ** following call will modify the in-memory representation of page 1 
-      ** to include the updated change counter and then write page 1 
-      ** directly to the database file. Because of the atomic-write 
-      ** property of the host file-system, this is safe.
-      */
-      rc = pager_incr_changecounter(pPager, 1);
-    }else{
-      rc = sqlite3JournalCreate(pPager->jfd);
+  }else{
+    if( pagerUseWal(pPager) ){
+      PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);
+      if( pList ){
+        rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1, 
+            (pPager->fullSync ? pPager->sync_flags : 0)
+        );
+      }
       if( rc==SQLITE_OK ){
-        rc = pager_incr_changecounter(pPager, 0);
+        sqlite3PcacheCleanAll(pPager->pPCache);
       }
-    }
-#else
-    rc = pager_incr_changecounter(pPager, 0);
-#endif
-    if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
-
-    /* If this transaction has made the database smaller, then all pages
-    ** being discarded by the truncation must be written to the journal
-    ** file. This can only happen in auto-vacuum mode.
-    **
-    ** Before reading the pages with page numbers larger than the 
-    ** current value of Pager.dbSize, set dbSize back to the value
-    ** that it took at the start of the transaction. Otherwise, the
-    ** calls to sqlite3PagerGet() return zeroed pages instead of 
-    ** reading data from the database file.
-    **
-    ** When journal_mode==OFF the dbOrigSize is always zero, so this
-    ** block never runs if journal_mode=OFF.
-    */
-#ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pPager->dbSize<pPager->dbOrigSize 
-     && ALWAYS(pPager->journalMode!=PAGER_JOURNALMODE_OFF)
-    ){
-      Pgno i;                                   /* Iterator variable */
-      const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */
-      const Pgno dbSize = pPager->dbSize;       /* Database image size */ 
-      pPager->dbSize = pPager->dbOrigSize;
-      for( i=dbSize+1; i<=pPager->dbOrigSize; i++ ){
-        if( !sqlite3BitvecTest(pPager->pInJournal, i) && i!=iSkip ){
-          PgHdr *pPage;             /* Page to journal */
-          rc = sqlite3PagerGet(pPager, i, &pPage);
-          if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
-          rc = sqlite3PagerWrite(pPage);
-          sqlite3PagerUnref(pPage);
-          if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+    }else{
+      /* The following block updates the change-counter. Exactly how it
+      ** does this depends on whether or not the atomic-update optimization
+      ** was enabled at compile time, and if this transaction meets the 
+      ** runtime criteria to use the operation: 
+      **
+      **    * The file-system supports the atomic-write property for
+      **      blocks of size page-size, and 
+      **    * This commit is not part of a multi-file transaction, and
+      **    * Exactly one page has been modified and store in the journal file.
+      **
+      ** If the optimization was not enabled at compile time, then the
+      ** pager_incr_changecounter() function is called to update the change
+      ** counter in 'indirect-mode'. If the optimization is compiled in but
+      ** is not applicable to this transaction, call sqlite3JournalCreate()
+      ** to make sure the journal file has actually been created, then call
+      ** pager_incr_changecounter() to update the change-counter in indirect
+      ** mode. 
+      **
+      ** Otherwise, if the optimization is both enabled and applicable,
+      ** then call pager_incr_changecounter() to update the change-counter
+      ** in 'direct' mode. In this case the journal file will never be
+      ** created for this transaction.
+      */
+  #ifdef SQLITE_ENABLE_ATOMIC_WRITE
+      PgHdr *pPg;
+      assert( isOpen(pPager->jfd) 
+           || pPager->journalMode==PAGER_JOURNALMODE_OFF 
+           || pPager->journalMode==PAGER_JOURNALMODE_WAL 
+      );
+      if( !zMaster && isOpen(pPager->jfd) 
+       && pPager->journalOff==jrnlBufferSize(pPager) 
+       && pPager->dbSize>=pPager->dbOrigSize
+       && (0==(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)
+      ){
+        /* Update the db file change counter via the direct-write method. The 
+        ** following call will modify the in-memory representation of page 1 
+        ** to include the updated change counter and then write page 1 
+        ** directly to the database file. Because of the atomic-write 
+        ** property of the host file-system, this is safe.
+        */
+        rc = pager_incr_changecounter(pPager, 1);
+      }else{
+        rc = sqlite3JournalCreate(pPager->jfd);
+        if( rc==SQLITE_OK ){
+          rc = pager_incr_changecounter(pPager, 0);
         }
+      }
+  #else
+      rc = pager_incr_changecounter(pPager, 0);
+  #endif
+      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+  
+      /* If this transaction has made the database smaller, then all pages
+      ** being discarded by the truncation must be written to the journal
+      ** file. This can only happen in auto-vacuum mode.
+      **
+      ** Before reading the pages with page numbers larger than the 
+      ** current value of Pager.dbSize, set dbSize back to the value
+      ** that it took at the start of the transaction. Otherwise, the
+      ** calls to sqlite3PagerGet() return zeroed pages instead of 
+      ** reading data from the database file.
+      */
+  #ifndef SQLITE_OMIT_AUTOVACUUM
+      if( pPager->dbSize<pPager->dbOrigSize 
+       && pPager->journalMode!=PAGER_JOURNALMODE_OFF
+      ){
+        Pgno i;                                   /* Iterator variable */
+        const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */
+        const Pgno dbSize = pPager->dbSize;       /* Database image size */ 
+        pPager->dbSize = pPager->dbOrigSize;
+        for( i=dbSize+1; i<=pPager->dbOrigSize; i++ ){
+          if( !sqlite3BitvecTest(pPager->pInJournal, i) && i!=iSkip ){
+            PgHdr *pPage;             /* Page to journal */
+            rc = sqlite3PagerGet(pPager, i, &pPage);
+            if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+            rc = sqlite3PagerWrite(pPage);
+            sqlite3PagerUnref(pPage);
+            if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+          }
+        }
+        pPager->dbSize = dbSize;
       } 
-      pPager->dbSize = dbSize;
-    }
-#endif
-
-    /* Write the master journal name into the journal file. If a master 
-    ** journal file name has already been written to the journal file, 
-    ** or if zMaster is NULL (no master journal), then this call is a no-op.
-    */
-    rc = writeMasterJournal(pPager, zMaster);
-    if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
-
-    /* Sync the journal file. If the atomic-update optimization is being
-    ** used, this call will not create the journal file or perform any
-    ** real IO.
-    */
-    rc = syncJournal(pPager);
-    if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
-
-    /* Write all dirty pages to the database file. */
-    rc = pager_write_pagelist(sqlite3PcacheDirtyList(pPager->pPCache));
-    if( rc!=SQLITE_OK ){
-      assert( rc!=SQLITE_IOERR_BLOCKED );
-      goto commit_phase_one_exit;
-    }
-    sqlite3PcacheCleanAll(pPager->pPCache);
-
-    /* If the file on disk is not the same size as the database image,
-    ** then use pager_truncate to grow or shrink the file here.
-    */
-    if( pPager->dbSize!=pPager->dbFileSize ){
-      Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));
-      assert( pPager->state>=PAGER_EXCLUSIVE );
-      rc = pager_truncate(pPager, nNew);
+  #endif
+  
+      /* Write the master journal name into the journal file. If a master 
+      ** journal file name has already been written to the journal file, 
+      ** or if zMaster is NULL (no master journal), then this call is a no-op.
+      */
+      rc = writeMasterJournal(pPager, zMaster);
       if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+  
+      /* Sync the journal file and write all dirty pages to the database.
+      ** If the atomic-update optimization is being used, this sync will not 
+      ** create the journal file or perform any real IO.
+      **
+      ** Because the change-counter page was just modified, unless the
+      ** atomic-update optimization is used it is almost certain that the
+      ** journal requires a sync here. However, in locking_mode=exclusive
+      ** on a system under memory pressure it is just possible that this is 
+      ** not the case. In this case it is likely enough that the redundant
+      ** xSync() call will be changed to a no-op by the OS anyhow. 
+      */
+      rc = syncJournal(pPager, 0);
+      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+  
+      rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));
+      if( rc!=SQLITE_OK ){
+        assert( rc!=SQLITE_IOERR_BLOCKED );
+        goto commit_phase_one_exit;
+      }
+      sqlite3PcacheCleanAll(pPager->pPCache);
+  
+      /* If the file on disk is not the same size as the database image,
+      ** then use pager_truncate to grow or shrink the file here.
+      */
+      if( pPager->dbSize!=pPager->dbFileSize ){
+        Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));
+        assert( pPager->eState==PAGER_WRITER_DBMOD );
+        rc = pager_truncate(pPager, nNew);
+        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
+      }
+  
+      /* Finally, sync the database file. */
+      if( !pPager->noSync && !noSync ){
+        rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
+      }
+      IOTRACE(("DBSYNC %p\n", pPager))
     }
-
-    /* Finally, sync the database file. */
-    if( !pPager->noSync && !noSync ){
-      rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
-    }
-    IOTRACE(("DBSYNC %p\n", pPager))
-
-    pPager->state = PAGER_SYNCED;
   }
 
 commit_phase_one_exit:
+  if( rc==SQLITE_OK && !pagerUseWal(pPager) ){
+    pPager->eState = PAGER_WRITER_FINISHED;
+  }
   return rc;
 }
 
@@ -36930,11 +40392,11 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){
   ** called, just return the same error code without doing anything. */
   if( NEVER(pPager->errCode) ) return pPager->errCode;
 
-  /* This function should not be called if the pager is not in at least
-  ** PAGER_RESERVED state. And indeed SQLite never does this. But it is
-  ** nice to have this defensive test here anyway.
-  */
-  if( NEVER(pPager->state<PAGER_RESERVED) ) return SQLITE_ERROR;
+  assert( pPager->eState==PAGER_WRITER_LOCKED
+       || pPager->eState==PAGER_WRITER_FINISHED
+       || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)
+  );
+  assert( assert_pager_state(pPager) );
 
   /* An optimization. If the database was not actually modified during
   ** this transaction, the pager is running in exclusive-mode and is
@@ -36947,95 +40409,76 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){
   ** header. Since the pager is in exclusive mode, there is no need
   ** to drop any locks either.
   */
-  if( pPager->dbModified==0 && pPager->exclusiveMode 
+  if( pPager->eState==PAGER_WRITER_LOCKED 
+   && pPager->exclusiveMode 
    && pPager->journalMode==PAGER_JOURNALMODE_PERSIST
   ){
-    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );
+    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );
+    pPager->eState = PAGER_READER;
     return SQLITE_OK;
   }
 
   PAGERTRACE(("COMMIT %d\n", PAGERID(pPager)));
-  assert( pPager->state==PAGER_SYNCED || MEMDB || !pPager->dbModified );
   rc = pager_end_transaction(pPager, pPager->setMaster);
   return pager_error(pPager, rc);
 }
 
 /*
-** Rollback all changes. The database falls back to PAGER_SHARED mode.
+** If a write transaction is open, then all changes made within the 
+** transaction are reverted and the current write-transaction is closed.
+** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR
+** state if an error occurs.
 **
-** This function performs two tasks:
+** If the pager is already in PAGER_ERROR state when this function is called,
+** it returns Pager.errCode immediately. No work is performed in this case.
+**
+** Otherwise, in rollback mode, this function performs two functions:
 **
 **   1) It rolls back the journal file, restoring all database file and 
 **      in-memory cache pages to the state they were in when the transaction
 **      was opened, and
+**
 **   2) It finalizes the journal file, so that it is not used for hot
 **      rollback at any point in the future.
 **
-** subject to the following qualifications:
-**
-** * If the journal file is not yet open when this function is called,
-**   then only (2) is performed. In this case there is no journal file
-**   to roll back.
-**
-** * If in an error state other than SQLITE_FULL, then task (1) is 
-**   performed. If successful, task (2). Regardless of the outcome
-**   of either, the error state error code is returned to the caller
-**   (i.e. either SQLITE_IOERR or SQLITE_CORRUPT).
-**
-** * If the pager is in PAGER_RESERVED state, then attempt (1). Whether
-**   or not (1) is succussful, also attempt (2). If successful, return
-**   SQLITE_OK. Otherwise, enter the error state and return the first 
-**   error code encountered. 
-**
-**   In this case there is no chance that the database was written to. 
-**   So is safe to finalize the journal file even if the playback 
-**   (operation 1) failed. However the pager must enter the error state
-**   as the contents of the in-memory cache are now suspect.
+** Finalization of the journal file (task 2) is only performed if the 
+** rollback is successful.
 **
-** * Finally, if in PAGER_EXCLUSIVE state, then attempt (1). Only
-**   attempt (2) if (1) is successful. Return SQLITE_OK if successful,
-**   otherwise enter the error state and return the error code from the 
-**   failing operation.
-**
-**   In this case the database file may have been written to. So if the
-**   playback operation did not succeed it would not be safe to finalize
-**   the journal file. It needs to be left in the file-system so that
-**   some other process can use it to restore the database state (by
-**   hot-journal rollback).
+** In WAL mode, all cache-entries containing data modified within the
+** current transaction are either expelled from the cache or reverted to
+** their pre-transaction state by re-reading data from the database or
+** WAL files. The WAL transaction is then closed.
 */
 SQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){
   int rc = SQLITE_OK;                  /* Return code */
   PAGERTRACE(("ROLLBACK %d\n", PAGERID(pPager)));
-  if( !pPager->dbModified || !isOpen(pPager->jfd) ){
-    rc = pager_end_transaction(pPager, pPager->setMaster);
-  }else if( pPager->errCode && pPager->errCode!=SQLITE_FULL ){
-    if( pPager->state>=PAGER_EXCLUSIVE ){
-      pager_playback(pPager, 0);
-    }
-    rc = pPager->errCode;
-  }else{
-    if( pPager->state==PAGER_RESERVED ){
-      int rc2;
-      rc = pager_playback(pPager, 0);
-      rc2 = pager_end_transaction(pPager, pPager->setMaster);
-      if( rc==SQLITE_OK ){
-        rc = rc2;
-      }
-    }else{
-      rc = pager_playback(pPager, 0);
-    }
 
-    if( !MEMDB ){
-      pPager->dbSizeValid = 0;
-    }
+  /* PagerRollback() is a no-op if called in READER or OPEN state. If
+  ** the pager is already in the ERROR state, the rollback is not 
+  ** attempted here. Instead, the error code is returned to the caller.
+  */
+  assert( assert_pager_state(pPager) );
+  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;
+  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;
 
-    /* If an error occurs during a ROLLBACK, we can no longer trust the pager
-    ** cache. So call pager_error() on the way out to make any error 
-    ** persistent.
-    */
-    rc = pager_error(pPager, rc);
+  if( pagerUseWal(pPager) ){
+    int rc2;
+    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);
+    rc2 = pager_end_transaction(pPager, pPager->setMaster);
+    if( rc==SQLITE_OK ) rc = rc2;
+  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){
+    rc = pager_end_transaction(pPager, 0);
+  }else{
+    rc = pager_playback(pPager, 0);
   }
-  return rc;
+
+  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );
+  assert( rc==SQLITE_OK || rc==SQLITE_FULL || (rc&0xFF)==SQLITE_IOERR );
+
+  /* If an error occurs during a ROLLBACK, we can no longer trust the pager
+  ** cache. So call pager_error() on the way out to make any error persistent.
+  */
+  return pager_error(pPager, rc);
 }
 
 /*
@@ -37054,6 +40497,18 @@ SQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){
 }
 
 /*
+** Return the approximate number of bytes of memory currently
+** used by the pager and its associated cache.
+*/
+SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){
+  int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)
+                                     + 5*sizeof(void*);
+  return perPageSize*sqlite3PcachePagecount(pPager->pPCache)
+           + sqlite3MallocSize(pPager)
+           + pPager->pageSize;
+}
+
+/*
 ** Return the number of references to the specified page.
 */
 SQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage *pPage){
@@ -37069,8 +40524,8 @@ SQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){
   a[0] = sqlite3PcacheRefCount(pPager->pPCache);
   a[1] = sqlite3PcachePagecount(pPager->pPCache);
   a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
-  a[3] = pPager->dbSizeValid ? (int) pPager->dbSize : -1;
-  a[4] = pPager->state;
+  a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
+  a[4] = pPager->eState;
   a[5] = pPager->errCode;
   a[6] = pPager->nHit;
   a[7] = pPager->nMiss;
@@ -37102,15 +40557,13 @@ SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
   int rc = SQLITE_OK;                       /* Return code */
   int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */
 
+  assert( pPager->eState>=PAGER_WRITER_LOCKED );
+  assert( assert_pager_state(pPager) );
+
   if( nSavepoint>nCurrent && pPager->useJournal ){
     int ii;                                 /* Iterator variable */
     PagerSavepoint *aNew;                   /* New Pager.aSavepoint array */
 
-    /* Either there is no active journal or the sub-journal is open or 
-    ** the journal is always stored in memory */
-    assert( pPager->nSavepoint==0 || isOpen(pPager->sjfd) ||
-            pPager->journalMode==PAGER_JOURNALMODE_MEMORY );
-
     /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
     ** if the allocation fails. Otherwise, zero the new portion in case a 
     ** malloc failure occurs while populating it in the for(...) loop below.
@@ -37123,13 +40576,11 @@ SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
     }
     memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));
     pPager->aSavepoint = aNew;
-    pPager->nSavepoint = nSavepoint;
 
     /* Populate the PagerSavepoint structures just allocated. */
     for(ii=nCurrent; ii<nSavepoint; ii++){
-      assert( pPager->dbSizeValid );
       aNew[ii].nOrig = pPager->dbSize;
-      if( isOpen(pPager->jfd) && ALWAYS(pPager->journalOff>0) ){
+      if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
         aNew[ii].iOffset = pPager->journalOff;
       }else{
         aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
@@ -37139,10 +40590,12 @@ SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
       if( !aNew[ii].pInSavepoint ){
         return SQLITE_NOMEM;
       }
+      if( pagerUseWal(pPager) ){
+        sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);
+      }
+      pPager->nSavepoint = ii+1;
     }
-
-    /* Open the sub-journal, if it is not already opened. */
-    rc = openSubJournal(pPager);
+    assert( pPager->nSavepoint==nSavepoint );
     assertTruncateConstraint(pPager);
   }
 
@@ -37180,12 +40633,12 @@ SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
 ** savepoint. If no errors occur, SQLITE_OK is returned.
 */ 
 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
-  int rc = SQLITE_OK;
+  int rc = pPager->errCode;       /* Return code */
 
   assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
   assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );
 
-  if( iSavepoint<pPager->nSavepoint ){
+  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
     int ii;            /* Iterator variable */
     int nNew;          /* Number of remaining savepoints after this op. */
 
@@ -37216,13 +40669,13 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
     ** not yet been opened. In this case there have been no changes to
     ** the database file, so the playback operation can be skipped.
     */
-    else if( isOpen(pPager->jfd) ){
+    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){
       PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];
       rc = pagerPlaybackSavepoint(pPager, pSavepoint);
       assert(rc!=SQLITE_DONE);
     }
-  
   }
+
   return rc;
 }
 
@@ -37268,7 +40721,7 @@ SQLITE_PRIVATE int sqlite3PagerNosync(Pager *pPager){
 /*
 ** Set or retrieve the codec for this pager
 */
-static void sqlite3PagerSetCodec(
+SQLITE_PRIVATE void sqlite3PagerSetCodec(
   Pager *pPager,
   void *(*xCodec)(void*,void*,Pgno,int),
   void (*xCodecSizeChng)(void*,int,int),
@@ -37282,7 +40735,7 @@ static void sqlite3PagerSetCodec(
   pPager->pCodec = pCodec;
   pagerReportSize(pPager);
 }
-static void *sqlite3PagerGetCodec(Pager *pPager){
+SQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){
   return pPager->pCodec;
 }
 #endif
@@ -37320,6 +40773,10 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
   Pgno origPgno;               /* The original page number */
 
   assert( pPg->nRef>0 );
+  assert( pPager->eState==PAGER_WRITER_CACHEMOD
+       || pPager->eState==PAGER_WRITER_DBMOD
+  );
+  assert( assert_pager_state(pPager) );
 
   /* In order to be able to rollback, an in-memory database must journal
   ** the page we are moving from.
@@ -37369,11 +40826,10 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
     needSyncPgno = pPg->pgno;
     assert( pageInJournal(pPg) || pPg->pgno>pPager->dbOrigSize );
     assert( pPg->flags&PGHDR_DIRTY );
-    assert( pPager->needSync );
   }
 
   /* If the cache contains a page with page-number pgno, remove it
-  ** from its hash chain. Also, if the PgHdr.needSync was set for 
+  ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for 
   ** page pgno before the 'move' operation, it needs to be retained 
   ** for the page moved there.
   */
@@ -37385,7 +40841,6 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
     if( MEMDB ){
       /* Do not discard pages from an in-memory database since we might
       ** need to rollback later.  Just move the page out of the way. */
-      assert( pPager->dbSizeValid );
       sqlite3PcacheMove(pPgOld, pPager->dbSize+1);
     }else{
       sqlite3PcacheDrop(pPgOld);
@@ -37395,14 +40850,23 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
   origPgno = pPg->pgno;
   sqlite3PcacheMove(pPg, pgno);
   sqlite3PcacheMakeDirty(pPg);
-  pPager->dbModified = 1;
+
+  /* For an in-memory database, make sure the original page continues
+  ** to exist, in case the transaction needs to roll back.  Use pPgOld
+  ** as the original page since it has already been allocated.
+  */
+  if( MEMDB ){
+    assert( pPgOld );
+    sqlite3PcacheMove(pPgOld, origPgno);
+    sqlite3PagerUnref(pPgOld);
+  }
 
   if( needSyncPgno ){
     /* If needSyncPgno is non-zero, then the journal file needs to be 
     ** sync()ed before any data is written to database file page needSyncPgno.
     ** Currently, no such page exists in the page-cache and the 
     ** "is journaled" bitvec flag has been set. This needs to be remedied by
-    ** loading the page into the pager-cache and setting the PgHdr.needSync 
+    ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC
     ** flag.
     **
     ** If the attempt to load the page into the page-cache fails, (due
@@ -37411,12 +40875,8 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
     ** this transaction, it may be written to the database file before
     ** it is synced into the journal file. This way, it may end up in
     ** the journal file twice, but that is not a problem.
-    **
-    ** The sqlite3PagerGet() call may cause the journal to sync. So make
-    ** sure the Pager.needSync flag is set too.
     */
     PgHdr *pPgHdr;
-    assert( pPager->needSync );
     rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr);
     if( rc!=SQLITE_OK ){
       if( needSyncPgno<=pPager->dbOrigSize ){
@@ -37425,23 +40885,11 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
       }
       return rc;
     }
-    pPager->needSync = 1;
-    assert( pPager->noSync==0 && !MEMDB );
     pPgHdr->flags |= PGHDR_NEED_SYNC;
     sqlite3PcacheMakeDirty(pPgHdr);
     sqlite3PagerUnref(pPgHdr);
   }
 
-  /*
-  ** For an in-memory database, make sure the original page continues
-  ** to exist, in case the transaction needs to roll back.  Use pPgOld
-  ** as the original page since it has already been allocated.
-  */
-  if( MEMDB ){
-    sqlite3PcacheMove(pPgOld, origPgno);
-    sqlite3PagerUnref(pPgOld);
-  }
-
   return SQLITE_OK;
 }
 #endif
@@ -37485,49 +40933,138 @@ SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){
 }
 
 /*
-** Get/set the journal-mode for this pager. Parameter eMode must be one of:
+** Set the journal-mode for this pager. Parameter eMode must be one of:
 **
-**    PAGER_JOURNALMODE_QUERY
 **    PAGER_JOURNALMODE_DELETE
 **    PAGER_JOURNALMODE_TRUNCATE
 **    PAGER_JOURNALMODE_PERSIST
 **    PAGER_JOURNALMODE_OFF
 **    PAGER_JOURNALMODE_MEMORY
+**    PAGER_JOURNALMODE_WAL
 **
-** If the parameter is not _QUERY, then the journal_mode is set to the
-** value specified if the change is allowed.  The change is disallowed
-** for the following reasons:
+** The journalmode is set to the value specified if the change is allowed.
+** The change may be disallowed for the following reasons:
 **
 **   *  An in-memory database can only have its journal_mode set to _OFF
 **      or _MEMORY.
 **
-**   *  The journal mode may not be changed while a transaction is active.
+**   *  Temporary databases cannot have _WAL journalmode.
 **
 ** The returned indicate the current (possibly updated) journal-mode.
 */
-SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *pPager, int eMode){
-  assert( eMode==PAGER_JOURNALMODE_QUERY
-            || eMode==PAGER_JOURNALMODE_DELETE
+SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
+  u8 eOld = pPager->journalMode;    /* Prior journalmode */
+
+#ifdef SQLITE_DEBUG
+  /* The print_pager_state() routine is intended to be used by the debugger
+  ** only.  We invoke it once here to suppress a compiler warning. */
+  print_pager_state(pPager);
+#endif
+
+
+  /* The eMode parameter is always valid */
+  assert(      eMode==PAGER_JOURNALMODE_DELETE
             || eMode==PAGER_JOURNALMODE_TRUNCATE
             || eMode==PAGER_JOURNALMODE_PERSIST
             || eMode==PAGER_JOURNALMODE_OFF 
+            || eMode==PAGER_JOURNALMODE_WAL 
             || eMode==PAGER_JOURNALMODE_MEMORY );
-  assert( PAGER_JOURNALMODE_QUERY<0 );
-  if( eMode>=0
-   && (!MEMDB || eMode==PAGER_JOURNALMODE_MEMORY 
-              || eMode==PAGER_JOURNALMODE_OFF)
-   && !pPager->dbModified
-   && (!isOpen(pPager->jfd) || 0==pPager->journalOff)
-  ){
-    if( isOpen(pPager->jfd) ){
-      sqlite3OsClose(pPager->jfd);
+
+  /* This routine is only called from the OP_JournalMode opcode, and
+  ** the logic there will never allow a temporary file to be changed
+  ** to WAL mode.
+  */
+  assert( pPager->tempFile==0 || eMode!=PAGER_JOURNALMODE_WAL );
+
+  /* Do allow the journalmode of an in-memory database to be set to
+  ** anything other than MEMORY or OFF
+  */
+  if( MEMDB ){
+    assert( eOld==PAGER_JOURNALMODE_MEMORY || eOld==PAGER_JOURNALMODE_OFF );
+    if( eMode!=PAGER_JOURNALMODE_MEMORY && eMode!=PAGER_JOURNALMODE_OFF ){
+      eMode = eOld;
     }
+  }
+
+  if( eMode!=eOld ){
+
+    /* Change the journal mode. */
+    assert( pPager->eState!=PAGER_ERROR );
     pPager->journalMode = (u8)eMode;
+
+    /* When transistioning from TRUNCATE or PERSIST to any other journal
+    ** mode except WAL, unless the pager is in locking_mode=exclusive mode,
+    ** delete the journal file.
+    */
+    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );
+    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );
+    assert( (PAGER_JOURNALMODE_DELETE & 5)==0 );
+    assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );
+    assert( (PAGER_JOURNALMODE_OFF & 5)==0 );
+    assert( (PAGER_JOURNALMODE_WAL & 5)==5 );
+
+    assert( isOpen(pPager->fd) || pPager->exclusiveMode );
+    if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){
+
+      /* In this case we would like to delete the journal file. If it is
+      ** not possible, then that is not a problem. Deleting the journal file
+      ** here is an optimization only.
+      **
+      ** Before deleting the journal file, obtain a RESERVED lock on the
+      ** database file. This ensures that the journal file is not deleted
+      ** while it is in use by some other client.
+      */
+      sqlite3OsClose(pPager->jfd);
+      if( pPager->eLock>=RESERVED_LOCK ){
+        sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
+      }else{
+        int rc = SQLITE_OK;
+        int state = pPager->eState;
+        assert( state==PAGER_OPEN || state==PAGER_READER );
+        if( state==PAGER_OPEN ){
+          rc = sqlite3PagerSharedLock(pPager);
+        }
+        if( pPager->eState==PAGER_READER ){
+          assert( rc==SQLITE_OK );
+          rc = pagerLockDb(pPager, RESERVED_LOCK);
+        }
+        if( rc==SQLITE_OK ){
+          sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
+        }
+        if( rc==SQLITE_OK && state==PAGER_READER ){
+          pagerUnlockDb(pPager, SHARED_LOCK);
+        }else if( state==PAGER_OPEN ){
+          pager_unlock(pPager);
+        }
+        assert( state==pPager->eState );
+      }
+    }
   }
+
+  /* Return the new journal mode */
+  return (int)pPager->journalMode;
+}
+
+/*
+** Return the current journal mode.
+*/
+SQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){
   return (int)pPager->journalMode;
 }
 
 /*
+** Return TRUE if the pager is in a state where it is OK to change the
+** journalmode.  Journalmode changes can only happen when the database
+** is unmodified.
+*/
+SQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){
+  assert( assert_pager_state(pPager) );
+  if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;
+  if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;
+  return 1;
+}
+
+/*
 ** Get/set the size-limit used for persistent journal files.
 **
 ** Setting the size limit to -1 means no limit is enforced.
@@ -37550,9 +41087,2868 @@ SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
   return &pPager->pBackup;
 }
 
+#ifndef SQLITE_OMIT_WAL
+/*
+** This function is called when the user invokes "PRAGMA checkpoint".
+*/
+SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager){
+  int rc = SQLITE_OK;
+  if( pPager->pWal ){
+    u8 *zBuf = (u8 *)pPager->pTmpSpace;
+    rc = sqlite3WalCheckpoint(pPager->pWal,
+        (pPager->noSync ? 0 : pPager->sync_flags),
+        pPager->pageSize, zBuf
+    );
+  }
+  return rc;
+}
+
+SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){
+  return sqlite3WalCallback(pPager->pWal);
+}
+
+/*
+** Return true if the underlying VFS for the given pager supports the
+** primitives necessary for write-ahead logging.
+*/
+SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){
+  const sqlite3_io_methods *pMethods = pPager->fd->pMethods;
+  return pMethods->iVersion>=2 && pMethods->xShmMap!=0;
+}
+
+/*
+** The caller must be holding a SHARED lock on the database file to call
+** this function.
+**
+** If the pager passed as the first argument is open on a real database
+** file (not a temp file or an in-memory database), and the WAL file
+** is not already open, make an attempt to open it now. If successful,
+** return SQLITE_OK. If an error occurs or the VFS used by the pager does 
+** not support the xShmXXX() methods, return an error code. *pbOpen is
+** not modified in either case.
+**
+** If the pager is open on a temp-file (or in-memory database), or if
+** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK
+** without doing anything.
+*/
+SQLITE_PRIVATE int sqlite3PagerOpenWal(
+  Pager *pPager,                  /* Pager object */
+  int *pbOpen                     /* OUT: Set to true if call is a no-op */
+){
+  int rc = SQLITE_OK;             /* Return code */
+
+  assert( assert_pager_state(pPager) );
+  assert( pPager->eState==PAGER_OPEN   || pbOpen );
+  assert( pPager->eState==PAGER_READER || !pbOpen );
+  assert( pbOpen==0 || *pbOpen==0 );
+  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );
+
+  if( !pPager->tempFile && !pPager->pWal ){
+    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;
+
+    /* Close any rollback journal previously open */
+    sqlite3OsClose(pPager->jfd);
+
+    /* Open the connection to the log file. If this operation fails, 
+    ** (e.g. due to malloc() failure), unlock the database file and 
+    ** return an error code.
+    */
+    rc = sqlite3WalOpen(pPager->pVfs, pPager->fd, pPager->zWal, &pPager->pWal);
+    if( rc==SQLITE_OK ){
+      pPager->journalMode = PAGER_JOURNALMODE_WAL;
+      pPager->eState = PAGER_OPEN;
+    }
+  }else{
+    *pbOpen = 1;
+  }
+
+  return rc;
+}
+
+/*
+** This function is called to close the connection to the log file prior
+** to switching from WAL to rollback mode.
+**
+** Before closing the log file, this function attempts to take an 
+** EXCLUSIVE lock on the database file. If this cannot be obtained, an
+** error (SQLITE_BUSY) is returned and the log connection is not closed.
+** If successful, the EXCLUSIVE lock is not released before returning.
+*/
+SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){
+  int rc = SQLITE_OK;
+
+  assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );
+
+  /* If the log file is not already open, but does exist in the file-system,
+  ** it may need to be checkpointed before the connection can switch to
+  ** rollback mode. Open it now so this can happen.
+  */
+  if( !pPager->pWal ){
+    int logexists = 0;
+    rc = pagerLockDb(pPager, SHARED_LOCK);
+    if( rc==SQLITE_OK ){
+      rc = sqlite3OsAccess(
+          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists
+      );
+    }
+    if( rc==SQLITE_OK && logexists ){
+      rc = sqlite3WalOpen(pPager->pVfs, pPager->fd,
+                          pPager->zWal, &pPager->pWal);
+    }
+  }
+    
+  /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on
+  ** the database file, the log and log-summary files will be deleted.
+  */
+  if( rc==SQLITE_OK && pPager->pWal ){
+    rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);
+    if( rc==SQLITE_OK ){
+      rc = sqlite3WalClose(pPager->pWal,
+                           (pPager->noSync ? 0 : pPager->sync_flags), 
+        pPager->pageSize, (u8*)pPager->pTmpSpace
+      );
+      pPager->pWal = 0;
+    }else{
+      /* If we cannot get an EXCLUSIVE lock, downgrade the PENDING lock
+      ** that we did get back to SHARED. */
+      pagerUnlockDb(pPager, SQLITE_LOCK_SHARED);
+    }
+  }
+  return rc;
+}
+
+#ifdef SQLITE_HAS_CODEC
+/*
+** This function is called by the wal module when writing page content
+** into the log file.
+**
+** This function returns a pointer to a buffer containing the encrypted
+** page content. If a malloc fails, this function may return NULL.
+*/
+SQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){
+  void *aData = 0;
+  CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);
+  return aData;
+}
+#endif /* SQLITE_HAS_CODEC */
+
+#endif /* !SQLITE_OMIT_WAL */
+
 #endif /* SQLITE_OMIT_DISKIO */
 
 /************** End of pager.c ***********************************************/
+/************** Begin file wal.c *********************************************/
+/*
+** 2010 February 1
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file contains the implementation of a write-ahead log (WAL) used in 
+** "journal_mode=WAL" mode.
+**
+** WRITE-AHEAD LOG (WAL) FILE FORMAT
+**
+** A WAL file consists of a header followed by zero or more "frames".
+** Each frame records the revised content of a single page from the
+** database file.  All changes to the database are recorded by writing
+** frames into the WAL.  Transactions commit when a frame is written that
+** contains a commit marker.  A single WAL can and usually does record 
+** multiple transactions.  Periodically, the content of the WAL is
+** transferred back into the database file in an operation called a
+** "checkpoint".
+**
+** A single WAL file can be used multiple times.  In other words, the
+** WAL can fill up with frames and then be checkpointed and then new
+** frames can overwrite the old ones.  A WAL always grows from beginning
+** toward the end.  Checksums and counters attached to each frame are
+** used to determine which frames within the WAL are valid and which
+** are leftovers from prior checkpoints.
+**
+** The WAL header is 32 bytes in size and consists of the following eight
+** big-endian 32-bit unsigned integer values:
+**
+**     0: Magic number.  0x377f0682 or 0x377f0683
+**     4: File format version.  Currently 3007000
+**     8: Database page size.  Example: 1024
+**    12: Checkpoint sequence number
+**    16: Salt-1, random integer incremented with each checkpoint
+**    20: Salt-2, a different random integer changing with each ckpt
+**    24: Checksum-1 (first part of checksum for first 24 bytes of header).
+**    28: Checksum-2 (second part of checksum for first 24 bytes of header).
+**
+** Immediately following the wal-header are zero or more frames. Each
+** frame consists of a 24-byte frame-header followed by a <page-size> bytes
+** of page data. The frame-header is six big-endian 32-bit unsigned 
+** integer values, as follows:
+**
+**     0: Page number.
+**     4: For commit records, the size of the database image in pages 
+**        after the commit. For all other records, zero.
+**     8: Salt-1 (copied from the header)
+**    12: Salt-2 (copied from the header)
+**    16: Checksum-1.
+**    20: Checksum-2.
+**
+** A frame is considered valid if and only if the following conditions are
+** true:
+**
+**    (1) The salt-1 and salt-2 values in the frame-header match
+**        salt values in the wal-header
+**
+**    (2) The checksum values in the final 8 bytes of the frame-header
+**        exactly match the checksum computed consecutively on the
+**        WAL header and the first 8 bytes and the content of all frames
+**        up to and including the current frame.
+**
+** The checksum is computed using 32-bit big-endian integers if the
+** magic number in the first 4 bytes of the WAL is 0x377f0683 and it
+** is computed using little-endian if the magic number is 0x377f0682.
+** The checksum values are always stored in the frame header in a
+** big-endian format regardless of which byte order is used to compute
+** the checksum.  The checksum is computed by interpreting the input as
+** an even number of unsigned 32-bit integers: x[0] through x[N].  The
+** algorithm used for the checksum is as follows:
+** 
+**   for i from 0 to n-1 step 2:
+**     s0 += x[i] + s1;
+**     s1 += x[i+1] + s0;
+**   endfor
+**
+** Note that s0 and s1 are both weighted checksums using fibonacci weights
+** in reverse order (the largest fibonacci weight occurs on the first element
+** of the sequence being summed.)  The s1 value spans all 32-bit 
+** terms of the sequence whereas s0 omits the final term.
+**
+** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the
+** WAL is transferred into the database, then the database is VFS.xSync-ed.
+** The VFS.xSync operations serve as write barriers - all writes launched
+** before the xSync must complete before any write that launches after the
+** xSync begins.
+**
+** After each checkpoint, the salt-1 value is incremented and the salt-2
+** value is randomized.  This prevents old and new frames in the WAL from
+** being considered valid at the same time and being checkpointing together
+** following a crash.
+**
+** READER ALGORITHM
+**
+** To read a page from the database (call it page number P), a reader
+** first checks the WAL to see if it contains page P.  If so, then the
+** last valid instance of page P that is a followed by a commit frame
+** or is a commit frame itself becomes the value read.  If the WAL
+** contains no copies of page P that are valid and which are a commit
+** frame or are followed by a commit frame, then page P is read from
+** the database file.
+**
+** To start a read transaction, the reader records the index of the last
+** valid frame in the WAL.  The reader uses this recorded "mxFrame" value
+** for all subsequent read operations.  New transactions can be appended
+** to the WAL, but as long as the reader uses its original mxFrame value
+** and ignores the newly appended content, it will see a consistent snapshot
+** of the database from a single point in time.  This technique allows
+** multiple concurrent readers to view different versions of the database
+** content simultaneously.
+**
+** The reader algorithm in the previous paragraphs works correctly, but 
+** because frames for page P can appear anywhere within the WAL, the
+** reader has to scan the entire WAL looking for page P frames.  If the
+** WAL is large (multiple megabytes is typical) that scan can be slow,
+** and read performance suffers.  To overcome this problem, a separate
+** data structure called the wal-index is maintained to expedite the
+** search for frames of a particular page.
+** 
+** WAL-INDEX FORMAT
+**
+** Conceptually, the wal-index is shared memory, though VFS implementations
+** might choose to implement the wal-index using a mmapped file.  Because
+** the wal-index is shared memory, SQLite does not support journal_mode=WAL 
+** on a network filesystem.  All users of the database must be able to
+** share memory.
+**
+** The wal-index is transient.  After a crash, the wal-index can (and should
+** be) reconstructed from the original WAL file.  In fact, the VFS is required
+** to either truncate or zero the header of the wal-index when the last
+** connection to it closes.  Because the wal-index is transient, it can
+** use an architecture-specific format; it does not have to be cross-platform.
+** Hence, unlike the database and WAL file formats which store all values
+** as big endian, the wal-index can store multi-byte values in the native
+** byte order of the host computer.
+**
+** The purpose of the wal-index is to answer this question quickly:  Given
+** a page number P, return the index of the last frame for page P in the WAL,
+** or return NULL if there are no frames for page P in the WAL.
+**
+** The wal-index consists of a header region, followed by an one or
+** more index blocks.  
+**
+** The wal-index header contains the total number of frames within the WAL
+** in the the mxFrame field.  
+**
+** Each index block except for the first contains information on 
+** HASHTABLE_NPAGE frames. The first index block contains information on
+** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and 
+** HASHTABLE_NPAGE are selected so that together the wal-index header and
+** first index block are the same size as all other index blocks in the
+** wal-index.
+**
+** Each index block contains two sections, a page-mapping that contains the
+** database page number associated with each wal frame, and a hash-table 
+** that allows readers to query an index block for a specific page number.
+** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
+** for the first index block) 32-bit page numbers. The first entry in the 
+** first index-block contains the database page number corresponding to the
+** first frame in the WAL file. The first entry in the second index block
+** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in
+** the log, and so on.
+**
+** The last index block in a wal-index usually contains less than the full
+** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,
+** depending on the contents of the WAL file. This does not change the
+** allocated size of the page-mapping array - the page-mapping array merely
+** contains unused entries.
+**
+** Even without using the hash table, the last frame for page P
+** can be found by scanning the page-mapping sections of each index block
+** starting with the last index block and moving toward the first, and
+** within each index block, starting at the end and moving toward the
+** beginning.  The first entry that equals P corresponds to the frame
+** holding the content for that page.
+**
+** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
+** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the
+** hash table for each page number in the mapping section, so the hash 
+** table is never more than half full.  The expected number of collisions 
+** prior to finding a match is 1.  Each entry of the hash table is an
+** 1-based index of an entry in the mapping section of the same
+** index block.   Let K be the 1-based index of the largest entry in
+** the mapping section.  (For index blocks other than the last, K will
+** always be exactly HASHTABLE_NPAGE (4096) and for the last index block
+** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table
+** contain a value of 0.
+**
+** To look for page P in the hash table, first compute a hash iKey on
+** P as follows:
+**
+**      iKey = (P * 383) % HASHTABLE_NSLOT
+**
+** Then start scanning entries of the hash table, starting with iKey
+** (wrapping around to the beginning when the end of the hash table is
+** reached) until an unused hash slot is found. Let the first unused slot
+** be at index iUnused.  (iUnused might be less than iKey if there was
+** wrap-around.) Because the hash table is never more than half full,
+** the search is guaranteed to eventually hit an unused entry.  Let 
+** iMax be the value between iKey and iUnused, closest to iUnused,
+** where aHash[iMax]==P.  If there is no iMax entry (if there exists
+** no hash slot such that aHash[i]==p) then page P is not in the
+** current index block.  Otherwise the iMax-th mapping entry of the
+** current index block corresponds to the last entry that references 
+** page P.
+**
+** A hash search begins with the last index block and moves toward the
+** first index block, looking for entries corresponding to page P.  On
+** average, only two or three slots in each index block need to be
+** examined in order to either find the last entry for page P, or to
+** establish that no such entry exists in the block.  Each index block
+** holds over 4000 entries.  So two or three index blocks are sufficient
+** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10
+** comparisons (on average) suffice to either locate a frame in the
+** WAL or to establish that the frame does not exist in the WAL.  This
+** is much faster than scanning the entire 10MB WAL.
+**
+** Note that entries are added in order of increasing K.  Hence, one
+** reader might be using some value K0 and a second reader that started
+** at a later time (after additional transactions were added to the WAL
+** and to the wal-index) might be using a different value K1, where K1>K0.
+** Both readers can use the same hash table and mapping section to get
+** the correct result.  There may be entries in the hash table with
+** K>K0 but to the first reader, those entries will appear to be unused
+** slots in the hash table and so the first reader will get an answer as
+** if no values greater than K0 had ever been inserted into the hash table
+** in the first place - which is what reader one wants.  Meanwhile, the
+** second reader using K1 will see additional values that were inserted
+** later, which is exactly what reader two wants.  
+**
+** When a rollback occurs, the value of K is decreased. Hash table entries
+** that correspond to frames greater than the new K value are removed
+** from the hash table at this point.
+*/
+#ifndef SQLITE_OMIT_WAL
+
+
+/*
+** Trace output macros
+*/
+#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
+SQLITE_PRIVATE int sqlite3WalTrace = 0;
+# define WALTRACE(X)  if(sqlite3WalTrace) sqlite3DebugPrintf X
+#else
+# define WALTRACE(X)
+#endif
+
+/*
+** The maximum (and only) versions of the wal and wal-index formats
+** that may be interpreted by this version of SQLite.
+**
+** If a client begins recovering a WAL file and finds that (a) the checksum
+** values in the wal-header are correct and (b) the version field is not
+** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.
+**
+** Similarly, if a client successfully reads a wal-index header (i.e. the 
+** checksum test is successful) and finds that the version field is not
+** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite
+** returns SQLITE_CANTOPEN.
+*/
+#define WAL_MAX_VERSION      3007000
+#define WALINDEX_MAX_VERSION 3007000
+
+/*
+** Indices of various locking bytes.   WAL_NREADER is the number
+** of available reader locks and should be at least 3.
+*/
+#define WAL_WRITE_LOCK         0
+#define WAL_ALL_BUT_WRITE      1
+#define WAL_CKPT_LOCK          1
+#define WAL_RECOVER_LOCK       2
+#define WAL_READ_LOCK(I)       (3+(I))
+#define WAL_NREADER            (SQLITE_SHM_NLOCK-3)
+
+
+/* Object declarations */
+typedef struct WalIndexHdr WalIndexHdr;
+typedef struct WalIterator WalIterator;
+typedef struct WalCkptInfo WalCkptInfo;
+
+
+/*
+** The following object holds a copy of the wal-index header content.
+**
+** The actual header in the wal-index consists of two copies of this
+** object.
+**
+** The szPage value can be any power of 2 between 512 and 32768, inclusive.
+** Or it can be 1 to represent a 65536-byte page.  The latter case was
+** added in 3.7.1 when support for 64K pages was added.  
+*/
+struct WalIndexHdr {
+  u32 iVersion;                   /* Wal-index version */
+  u32 unused;                     /* Unused (padding) field */
+  u32 iChange;                    /* Counter incremented each transaction */
+  u8 isInit;                      /* 1 when initialized */
+  u8 bigEndCksum;                 /* True if checksums in WAL are big-endian */
+  u16 szPage;                     /* Database page size in bytes. 1==64K */
+  u32 mxFrame;                    /* Index of last valid frame in the WAL */
+  u32 nPage;                      /* Size of database in pages */
+  u32 aFrameCksum[2];             /* Checksum of last frame in log */
+  u32 aSalt[2];                   /* Two salt values copied from WAL header */
+  u32 aCksum[2];                  /* Checksum over all prior fields */
+};
+
+/*
+** A copy of the following object occurs in the wal-index immediately
+** following the second copy of the WalIndexHdr.  This object stores
+** information used by checkpoint.
+**
+** nBackfill is the number of frames in the WAL that have been written
+** back into the database. (We call the act of moving content from WAL to
+** database "backfilling".)  The nBackfill number is never greater than
+** WalIndexHdr.mxFrame.  nBackfill can only be increased by threads
+** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).
+** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from
+** mxFrame back to zero when the WAL is reset.
+**
+** There is one entry in aReadMark[] for each reader lock.  If a reader
+** holds read-lock K, then the value in aReadMark[K] is no greater than
+** the mxFrame for that reader.  The value READMARK_NOT_USED (0xffffffff)
+** for any aReadMark[] means that entry is unused.  aReadMark[0] is 
+** a special case; its value is never used and it exists as a place-holder
+** to avoid having to offset aReadMark[] indexs by one.  Readers holding
+** WAL_READ_LOCK(0) always ignore the entire WAL and read all content
+** directly from the database.
+**
+** The value of aReadMark[K] may only be changed by a thread that
+** is holding an exclusive lock on WAL_READ_LOCK(K).  Thus, the value of
+** aReadMark[K] cannot changed while there is a reader is using that mark
+** since the reader will be holding a shared lock on WAL_READ_LOCK(K).
+**
+** The checkpointer may only transfer frames from WAL to database where
+** the frame numbers are less than or equal to every aReadMark[] that is
+** in use (that is, every aReadMark[j] for which there is a corresponding
+** WAL_READ_LOCK(j)).  New readers (usually) pick the aReadMark[] with the
+** largest value and will increase an unused aReadMark[] to mxFrame if there
+** is not already an aReadMark[] equal to mxFrame.  The exception to the
+** previous sentence is when nBackfill equals mxFrame (meaning that everything
+** in the WAL has been backfilled into the database) then new readers
+** will choose aReadMark[0] which has value 0 and hence such reader will
+** get all their all content directly from the database file and ignore 
+** the WAL.
+**
+** Writers normally append new frames to the end of the WAL.  However,
+** if nBackfill equals mxFrame (meaning that all WAL content has been
+** written back into the database) and if no readers are using the WAL
+** (in other words, if there are no WAL_READ_LOCK(i) where i>0) then
+** the writer will first "reset" the WAL back to the beginning and start
+** writing new content beginning at frame 1.
+**
+** We assume that 32-bit loads are atomic and so no locks are needed in
+** order to read from any aReadMark[] entries.
+*/
+struct WalCkptInfo {
+  u32 nBackfill;                  /* Number of WAL frames backfilled into DB */
+  u32 aReadMark[WAL_NREADER];     /* Reader marks */
+};
+#define READMARK_NOT_USED  0xffffffff
+
+
+/* A block of WALINDEX_LOCK_RESERVED bytes beginning at
+** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems
+** only support mandatory file-locks, we do not read or write data
+** from the region of the file on which locks are applied.
+*/
+#define WALINDEX_LOCK_OFFSET   (sizeof(WalIndexHdr)*2 + sizeof(WalCkptInfo))
+#define WALINDEX_LOCK_RESERVED 16
+#define WALINDEX_HDR_SIZE      (WALINDEX_LOCK_OFFSET+WALINDEX_LOCK_RESERVED)
+
+/* Size of header before each frame in wal */
+#define WAL_FRAME_HDRSIZE 24
+
+/* Size of write ahead log header, including checksum. */
+/* #define WAL_HDRSIZE 24 */
+#define WAL_HDRSIZE 32
+
+/* WAL magic value. Either this value, or the same value with the least
+** significant bit also set (WAL_MAGIC | 0x00000001) is stored in 32-bit
+** big-endian format in the first 4 bytes of a WAL file.
+**
+** If the LSB is set, then the checksums for each frame within the WAL
+** file are calculated by treating all data as an array of 32-bit 
+** big-endian words. Otherwise, they are calculated by interpreting 
+** all data as 32-bit little-endian words.
+*/
+#define WAL_MAGIC 0x377f0682
+
+/*
+** Return the offset of frame iFrame in the write-ahead log file, 
+** assuming a database page size of szPage bytes. The offset returned
+** is to the start of the write-ahead log frame-header.
+*/
+#define walFrameOffset(iFrame, szPage) (                               \
+  WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE)         \
+)
+
+/*
+** An open write-ahead log file is represented by an instance of the
+** following object.
+*/
+struct Wal {
+  sqlite3_vfs *pVfs;         /* The VFS used to create pDbFd */
+  sqlite3_file *pDbFd;       /* File handle for the database file */
+  sqlite3_file *pWalFd;      /* File handle for WAL file */
+  u32 iCallback;             /* Value to pass to log callback (or 0) */
+  int nWiData;               /* Size of array apWiData */
+  volatile u32 **apWiData;   /* Pointer to wal-index content in memory */
+  u32 szPage;                /* Database page size */
+  i16 readLock;              /* Which read lock is being held.  -1 for none */
+  u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */
+  u8 writeLock;              /* True if in a write transaction */
+  u8 ckptLock;               /* True if holding a checkpoint lock */
+  u8 readOnly;               /* True if the WAL file is open read-only */
+  WalIndexHdr hdr;           /* Wal-index header for current transaction */
+  const char *zWalName;      /* Name of WAL file */
+  u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */
+#ifdef SQLITE_DEBUG
+  u8 lockError;              /* True if a locking error has occurred */
+#endif
+};
+
+/*
+** Each page of the wal-index mapping contains a hash-table made up of
+** an array of HASHTABLE_NSLOT elements of the following type.
+*/
+typedef u16 ht_slot;
+
+/*
+** This structure is used to implement an iterator that loops through
+** all frames in the WAL in database page order. Where two or more frames
+** correspond to the same database page, the iterator visits only the 
+** frame most recently written to the WAL (in other words, the frame with
+** the largest index).
+**
+** The internals of this structure are only accessed by:
+**
+**   walIteratorInit() - Create a new iterator,
+**   walIteratorNext() - Step an iterator,
+**   walIteratorFree() - Free an iterator.
+**
+** This functionality is used by the checkpoint code (see walCheckpoint()).
+*/
+struct WalIterator {
+  int iPrior;                     /* Last result returned from the iterator */
+  int nSegment;                   /* Size of the aSegment[] array */
+  struct WalSegment {
+    int iNext;                    /* Next slot in aIndex[] not yet returned */
+    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */
+    u32 *aPgno;                   /* Array of page numbers. */
+    int nEntry;                   /* Max size of aPgno[] and aIndex[] arrays */
+    int iZero;                    /* Frame number associated with aPgno[0] */
+  } aSegment[1];                  /* One for every 32KB page in the WAL */
+};
+
+/*
+** Define the parameters of the hash tables in the wal-index file. There
+** is a hash-table following every HASHTABLE_NPAGE page numbers in the
+** wal-index.
+**
+** Changing any of these constants will alter the wal-index format and
+** create incompatibilities.
+*/
+#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */
+#define HASHTABLE_HASH_1     383                  /* Should be prime */
+#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */
+
+/* 
+** The block of page numbers associated with the first hash-table in a
+** wal-index is smaller than usual. This is so that there is a complete
+** hash-table on each aligned 32KB page of the wal-index.
+*/
+#define HASHTABLE_NPAGE_ONE  (HASHTABLE_NPAGE - (WALINDEX_HDR_SIZE/sizeof(u32)))
+
+/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */
+#define WALINDEX_PGSZ   (                                         \
+    sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \
+)
+
+/*
+** Obtain a pointer to the iPage'th page of the wal-index. The wal-index
+** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are
+** numbered from zero.
+**
+** If this call is successful, *ppPage is set to point to the wal-index
+** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,
+** then an SQLite error code is returned and *ppPage is set to 0.
+*/
+static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){
+  int rc = SQLITE_OK;
+
+  /* Enlarge the pWal->apWiData[] array if required */
+  if( pWal->nWiData<=iPage ){
+    int nByte = sizeof(u32*)*(iPage+1);
+    volatile u32 **apNew;
+    apNew = (volatile u32 **)sqlite3_realloc((void *)pWal->apWiData, nByte);
+    if( !apNew ){
+      *ppPage = 0;
+      return SQLITE_NOMEM;
+    }
+    memset((void*)&apNew[pWal->nWiData], 0,
+           sizeof(u32*)*(iPage+1-pWal->nWiData));
+    pWal->apWiData = apNew;
+    pWal->nWiData = iPage+1;
+  }
+
+  /* Request a pointer to the required page from the VFS */
+  if( pWal->apWiData[iPage]==0 ){
+    rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, 
+        pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]
+    );
+  }
+
+  *ppPage = pWal->apWiData[iPage];
+  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );
+  return rc;
+}
+
+/*
+** Return a pointer to the WalCkptInfo structure in the wal-index.
+*/
+static volatile WalCkptInfo *walCkptInfo(Wal *pWal){
+  assert( pWal->nWiData>0 && pWal->apWiData[0] );
+  return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]);
+}
+
+/*
+** Return a pointer to the WalIndexHdr structure in the wal-index.
+*/
+static volatile WalIndexHdr *walIndexHdr(Wal *pWal){
+  assert( pWal->nWiData>0 && pWal->apWiData[0] );
+  return (volatile WalIndexHdr*)pWal->apWiData[0];
+}
+
+/*
+** The argument to this macro must be of type u32. On a little-endian
+** architecture, it returns the u32 value that results from interpreting
+** the 4 bytes as a big-endian value. On a big-endian architecture, it
+** returns the value that would be produced by intepreting the 4 bytes
+** of the input value as a little-endian integer.
+*/
+#define BYTESWAP32(x) ( \
+    (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \
+  + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \
+)
+
+/*
+** Generate or extend an 8 byte checksum based on the data in 
+** array aByte[] and the initial values of aIn[0] and aIn[1] (or
+** initial values of 0 and 0 if aIn==NULL).
+**
+** The checksum is written back into aOut[] before returning.
+**
+** nByte must be a positive multiple of 8.
+*/
+static void walChecksumBytes(
+  int nativeCksum, /* True for native byte-order, false for non-native */
+  u8 *a,           /* Content to be checksummed */
+  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */
+  const u32 *aIn,  /* Initial checksum value input */
+  u32 *aOut        /* OUT: Final checksum value output */
+){
+  u32 s1, s2;
+  u32 *aData = (u32 *)a;
+  u32 *aEnd = (u32 *)&a[nByte];
+
+  if( aIn ){
+    s1 = aIn[0];
+    s2 = aIn[1];
+  }else{
+    s1 = s2 = 0;
+  }
+
+  assert( nByte>=8 );
+  assert( (nByte&0x00000007)==0 );
+
+  if( nativeCksum ){
+    do {
+      s1 += *aData++ + s2;
+      s2 += *aData++ + s1;
+    }while( aData<aEnd );
+  }else{
+    do {
+      s1 += BYTESWAP32(aData[0]) + s2;
+      s2 += BYTESWAP32(aData[1]) + s1;
+      aData += 2;
+    }while( aData<aEnd );
+  }
+
+  aOut[0] = s1;
+  aOut[1] = s2;
+}
+
+/*
+** Write the header information in pWal->hdr into the wal-index.
+**
+** The checksum on pWal->hdr is updated before it is written.
+*/
+static void walIndexWriteHdr(Wal *pWal){
+  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
+  const int nCksum = offsetof(WalIndexHdr, aCksum);
+
+  assert( pWal->writeLock );
+  pWal->hdr.isInit = 1;
+  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
+  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
+  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+  sqlite3OsShmBarrier(pWal->pDbFd);
+  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
+}
+
+/*
+** This function encodes a single frame header and writes it to a buffer
+** supplied by the caller. A frame-header is made up of a series of 
+** 4-byte big-endian integers, as follows:
+**
+**     0: Page number.
+**     4: For commit records, the size of the database image in pages 
+**        after the commit. For all other records, zero.
+**     8: Salt-1 (copied from the wal-header)
+**    12: Salt-2 (copied from the wal-header)
+**    16: Checksum-1.
+**    20: Checksum-2.
+*/
+static void walEncodeFrame(
+  Wal *pWal,                      /* The write-ahead log */
+  u32 iPage,                      /* Database page number for frame */
+  u32 nTruncate,                  /* New db size (or 0 for non-commit frames) */
+  u8 *aData,                      /* Pointer to page data */
+  u8 *aFrame                      /* OUT: Write encoded frame here */
+){
+  int nativeCksum;                /* True for native byte-order checksums */
+  u32 *aCksum = pWal->hdr.aFrameCksum;
+  assert( WAL_FRAME_HDRSIZE==24 );
+  sqlite3Put4byte(&aFrame[0], iPage);
+  sqlite3Put4byte(&aFrame[4], nTruncate);
+  memcpy(&aFrame[8], pWal->hdr.aSalt, 8);
+
+  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
+  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
+  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
+
+  sqlite3Put4byte(&aFrame[16], aCksum[0]);
+  sqlite3Put4byte(&aFrame[20], aCksum[1]);
+}
+
+/*
+** Check to see if the frame with header in aFrame[] and content
+** in aData[] is valid.  If it is a valid frame, fill *piPage and
+** *pnTruncate and return true.  Return if the frame is not valid.
+*/
+static int walDecodeFrame(
+  Wal *pWal,                      /* The write-ahead log */
+  u32 *piPage,                    /* OUT: Database page number for frame */
+  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */
+  u8 *aData,                      /* Pointer to page data (for checksum) */
+  u8 *aFrame                      /* Frame data */
+){
+  int nativeCksum;                /* True for native byte-order checksums */
+  u32 *aCksum = pWal->hdr.aFrameCksum;
+  u32 pgno;                       /* Page number of the frame */
+  assert( WAL_FRAME_HDRSIZE==24 );
+
+  /* A frame is only valid if the salt values in the frame-header
+  ** match the salt values in the wal-header. 
+  */
+  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){
+    return 0;
+  }
+
+  /* A frame is only valid if the page number is creater than zero.
+  */
+  pgno = sqlite3Get4byte(&aFrame[0]);
+  if( pgno==0 ){
+    return 0;
+  }
+
+  /* A frame is only valid if a checksum of the WAL header,
+  ** all prior frams, the first 16 bytes of this frame-header, 
+  ** and the frame-data matches the checksum in the last 8 
+  ** bytes of this frame-header.
+  */
+  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);
+  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);
+  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);
+  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) 
+   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) 
+  ){
+    /* Checksum failed. */
+    return 0;
+  }
+
+  /* If we reach this point, the frame is valid.  Return the page number
+  ** and the new database size.
+  */
+  *piPage = pgno;
+  *pnTruncate = sqlite3Get4byte(&aFrame[4]);
+  return 1;
+}
+
+
+#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
+/*
+** Names of locks.  This routine is used to provide debugging output and is not
+** a part of an ordinary build.
+*/
+static const char *walLockName(int lockIdx){
+  if( lockIdx==WAL_WRITE_LOCK ){
+    return "WRITE-LOCK";
+  }else if( lockIdx==WAL_CKPT_LOCK ){
+    return "CKPT-LOCK";
+  }else if( lockIdx==WAL_RECOVER_LOCK ){
+    return "RECOVER-LOCK";
+  }else{
+    static char zName[15];
+    sqlite3_snprintf(sizeof(zName), zName, "READ-LOCK[%d]",
+                     lockIdx-WAL_READ_LOCK(0));
+    return zName;
+  }
+}
+#endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */
+    
+
+/*
+** Set or release locks on the WAL.  Locks are either shared or exclusive.
+** A lock cannot be moved directly between shared and exclusive - it must go
+** through the unlocked state first.
+**
+** In locking_mode=EXCLUSIVE, all of these routines become no-ops.
+*/
+static int walLockShared(Wal *pWal, int lockIdx){
+  int rc;
+  if( pWal->exclusiveMode ) return SQLITE_OK;
+  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
+                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);
+  WALTRACE(("WAL%p: acquire SHARED-%s %s\n", pWal,
+            walLockName(lockIdx), rc ? "failed" : "ok"));
+  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
+  return rc;
+}
+static void walUnlockShared(Wal *pWal, int lockIdx){
+  if( pWal->exclusiveMode ) return;
+  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,
+                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
+  WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
+}
+static int walLockExclusive(Wal *pWal, int lockIdx, int n){
+  int rc;
+  if( pWal->exclusiveMode ) return SQLITE_OK;
+  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
+                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
+  WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
+            walLockName(lockIdx), n, rc ? "failed" : "ok"));
+  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )
+  return rc;
+}
+static void walUnlockExclusive(Wal *pWal, int lockIdx, int n){
+  if( pWal->exclusiveMode ) return;
+  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
+                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);
+  WALTRACE(("WAL%p: release EXCLUSIVE-%s cnt=%d\n", pWal,
+             walLockName(lockIdx), n));
+}
+
+/*
+** Compute a hash on a page number.  The resulting hash value must land
+** between 0 and (HASHTABLE_NSLOT-1).  The walHashNext() function advances
+** the hash to the next value in the event of a collision.
+*/
+static int walHash(u32 iPage){
+  assert( iPage>0 );
+  assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );
+  return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);
+}
+static int walNextHash(int iPriorHash){
+  return (iPriorHash+1)&(HASHTABLE_NSLOT-1);
+}
+
+/* 
+** Return pointers to the hash table and page number array stored on
+** page iHash of the wal-index. The wal-index is broken into 32KB pages
+** numbered starting from 0.
+**
+** Set output variable *paHash to point to the start of the hash table
+** in the wal-index file. Set *piZero to one less than the frame 
+** number of the first frame indexed by this hash table. If a
+** slot in the hash table is set to N, it refers to frame number 
+** (*piZero+N) in the log.
+**
+** Finally, set *paPgno so that *paPgno[1] is the page number of the
+** first frame indexed by the hash table, frame (*piZero+1).
+*/
+static int walHashGet(
+  Wal *pWal,                      /* WAL handle */
+  int iHash,                      /* Find the iHash'th table */
+  volatile ht_slot **paHash,      /* OUT: Pointer to hash index */
+  volatile u32 **paPgno,          /* OUT: Pointer to page number array */
+  u32 *piZero                     /* OUT: Frame associated with *paPgno[0] */
+){
+  int rc;                         /* Return code */
+  volatile u32 *aPgno;
+
+  rc = walIndexPage(pWal, iHash, &aPgno);
+  assert( rc==SQLITE_OK || iHash>0 );
+
+  if( rc==SQLITE_OK ){
+    u32 iZero;
+    volatile ht_slot *aHash;
+
+    aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
+    if( iHash==0 ){
+      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
+      iZero = 0;
+    }else{
+      iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
+    }
+  
+    *paPgno = &aPgno[-1];
+    *paHash = aHash;
+    *piZero = iZero;
+  }
+  return rc;
+}
+
+/*
+** Return the number of the wal-index page that contains the hash-table
+** and page-number array that contain entries corresponding to WAL frame
+** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages 
+** are numbered starting from 0.
+*/
+static int walFramePage(u32 iFrame){
+  int iHash = (iFrame+HASHTABLE_NPAGE-HASHTABLE_NPAGE_ONE-1) / HASHTABLE_NPAGE;
+  assert( (iHash==0 || iFrame>HASHTABLE_NPAGE_ONE)
+       && (iHash>=1 || iFrame<=HASHTABLE_NPAGE_ONE)
+       && (iHash<=1 || iFrame>(HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE))
+       && (iHash>=2 || iFrame<=HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE)
+       && (iHash<=2 || iFrame>(HASHTABLE_NPAGE_ONE+2*HASHTABLE_NPAGE))
+  );
+  return iHash;
+}
+
+/*
+** Return the page number associated with frame iFrame in this WAL.
+*/
+static u32 walFramePgno(Wal *pWal, u32 iFrame){
+  int iHash = walFramePage(iFrame);
+  if( iHash==0 ){
+    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];
+  }
+  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];
+}
+
+/*
+** Remove entries from the hash table that point to WAL slots greater
+** than pWal->hdr.mxFrame.
+**
+** This function is called whenever pWal->hdr.mxFrame is decreased due
+** to a rollback or savepoint.
+**
+** At most only the hash table containing pWal->hdr.mxFrame needs to be
+** updated.  Any later hash tables will be automatically cleared when
+** pWal->hdr.mxFrame advances to the point where those hash tables are
+** actually needed.
+*/
+static void walCleanupHash(Wal *pWal){
+  volatile ht_slot *aHash = 0;    /* Pointer to hash table to clear */
+  volatile u32 *aPgno = 0;        /* Page number array for hash table */
+  u32 iZero = 0;                  /* frame == (aHash[x]+iZero) */
+  int iLimit = 0;                 /* Zero values greater than this */
+  int nByte;                      /* Number of bytes to zero in aPgno[] */
+  int i;                          /* Used to iterate through aHash[] */
+
+  assert( pWal->writeLock );
+  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
+  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
+  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
+
+  if( pWal->hdr.mxFrame==0 ) return;
+
+  /* Obtain pointers to the hash-table and page-number array containing 
+  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
+  ** that the page said hash-table and array reside on is already mapped.
+  */
+  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
+  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
+  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);
+
+  /* Zero all hash-table entries that correspond to frame numbers greater
+  ** than pWal->hdr.mxFrame.
+  */
+  iLimit = pWal->hdr.mxFrame - iZero;
+  assert( iLimit>0 );
+  for(i=0; i<HASHTABLE_NSLOT; i++){
+    if( aHash[i]>iLimit ){
+      aHash[i] = 0;
+    }
+  }
+  
+  /* Zero the entries in the aPgno array that correspond to frames with
+  ** frame numbers greater than pWal->hdr.mxFrame. 
+  */
+  nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);
+  memset((void *)&aPgno[iLimit+1], 0, nByte);
+
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
+  /* Verify that the every entry in the mapping region is still reachable
+  ** via the hash table even after the cleanup.
+  */
+  if( iLimit ){
+    int i;           /* Loop counter */
+    int iKey;        /* Hash key */
+    for(i=1; i<=iLimit; i++){
+      for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
+        if( aHash[iKey]==i ) break;
+      }
+      assert( aHash[iKey]==i );
+    }
+  }
+#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
+}
+
+
+/*
+** Set an entry in the wal-index that will map database page number
+** pPage into WAL frame iFrame.
+*/
+static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
+  int rc;                         /* Return code */
+  u32 iZero = 0;                  /* One less than frame number of aPgno[1] */
+  volatile u32 *aPgno = 0;        /* Page number array */
+  volatile ht_slot *aHash = 0;    /* Hash table */
+
+  rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);
+
+  /* Assuming the wal-index file was successfully mapped, populate the
+  ** page number array and hash table entry.
+  */
+  if( rc==SQLITE_OK ){
+    int iKey;                     /* Hash table key */
+    int idx;                      /* Value to write to hash-table slot */
+    int nCollide;                 /* Number of hash collisions */
+
+    idx = iFrame - iZero;
+    assert( idx <= HASHTABLE_NSLOT/2 + 1 );
+    
+    /* If this is the first entry to be added to this hash-table, zero the
+    ** entire hash table and aPgno[] array before proceding. 
+    */
+    if( idx==1 ){
+      int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);
+      memset((void*)&aPgno[1], 0, nByte);
+    }
+
+    /* If the entry in aPgno[] is already set, then the previous writer
+    ** must have exited unexpectedly in the middle of a transaction (after
+    ** writing one or more dirty pages to the WAL to free up memory). 
+    ** Remove the remnants of that writers uncommitted transaction from 
+    ** the hash-table before writing any new entries.
+    */
+    if( aPgno[idx] ){
+      walCleanupHash(pWal);
+      assert( !aPgno[idx] );
+    }
+
+    /* Write the aPgno[] array entry and the hash-table slot. */
+    nCollide = idx;
+    for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
+      if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;
+    }
+    aPgno[idx] = iPage;
+    aHash[iKey] = (ht_slot)idx;
+
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
+    /* Verify that the number of entries in the hash table exactly equals
+    ** the number of entries in the mapping region.
+    */
+    {
+      int i;           /* Loop counter */
+      int nEntry = 0;  /* Number of entries in the hash table */
+      for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }
+      assert( nEntry==idx );
+    }
+
+    /* Verify that the every entry in the mapping region is reachable
+    ** via the hash table.  This turns out to be a really, really expensive
+    ** thing to check, so only do this occasionally - not on every
+    ** iteration.
+    */
+    if( (idx&0x3ff)==0 ){
+      int i;           /* Loop counter */
+      for(i=1; i<=idx; i++){
+        for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
+          if( aHash[iKey]==i ) break;
+        }
+        assert( aHash[iKey]==i );
+      }
+    }
+#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */
+  }
+
+
+  return rc;
+}
+
+
+/*
+** Recover the wal-index by reading the write-ahead log file. 
+**
+** This routine first tries to establish an exclusive lock on the
+** wal-index to prevent other threads/processes from doing anything
+** with the WAL or wal-index while recovery is running.  The
+** WAL_RECOVER_LOCK is also held so that other threads will know
+** that this thread is running recovery.  If unable to establish
+** the necessary locks, this routine returns SQLITE_BUSY.
+*/
+static int walIndexRecover(Wal *pWal){
+  int rc;                         /* Return Code */
+  i64 nSize;                      /* Size of log file */
+  u32 aFrameCksum[2] = {0, 0};
+  int iLock;                      /* Lock offset to lock for checkpoint */
+  int nLock;                      /* Number of locks to hold */
+
+  /* Obtain an exclusive lock on all byte in the locking range not already
+  ** locked by the caller. The caller is guaranteed to have locked the
+  ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.
+  ** If successful, the same bytes that are locked here are unlocked before
+  ** this function returns.
+  */
+  assert( pWal->ckptLock==1 || pWal->ckptLock==0 );
+  assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );
+  assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );
+  assert( pWal->writeLock );
+  iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
+  nLock = SQLITE_SHM_NLOCK - iLock;
+  rc = walLockExclusive(pWal, iLock, nLock);
+  if( rc ){
+    return rc;
+  }
+  WALTRACE(("WAL%p: recovery begin...\n", pWal));
+
+  memset(&pWal->hdr, 0, sizeof(WalIndexHdr));
+
+  rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);
+  if( rc!=SQLITE_OK ){
+    goto recovery_error;
+  }
+
+  if( nSize>WAL_HDRSIZE ){
+    u8 aBuf[WAL_HDRSIZE];         /* Buffer to load WAL header into */
+    u8 *aFrame = 0;               /* Malloc'd buffer to load entire frame */
+    int szFrame;                  /* Number of bytes in buffer aFrame[] */
+    u8 *aData;                    /* Pointer to data part of aFrame buffer */
+    int iFrame;                   /* Index of last frame read */
+    i64 iOffset;                  /* Next offset to read from log file */
+    int szPage;                   /* Page size according to the log */
+    u32 magic;                    /* Magic value read from WAL header */
+    u32 version;                  /* Magic value read from WAL header */
+
+    /* Read in the WAL header. */
+    rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);
+    if( rc!=SQLITE_OK ){
+      goto recovery_error;
+    }
+
+    /* If the database page size is not a power of two, or is greater than
+    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid 
+    ** data. Similarly, if the 'magic' value is invalid, ignore the whole
+    ** WAL file.
+    */
+    magic = sqlite3Get4byte(&aBuf[0]);
+    szPage = sqlite3Get4byte(&aBuf[8]);
+    if( (magic&0xFFFFFFFE)!=WAL_MAGIC 
+     || szPage&(szPage-1) 
+     || szPage>SQLITE_MAX_PAGE_SIZE 
+     || szPage<512 
+    ){
+      goto finished;
+    }
+    pWal->hdr.bigEndCksum = (u8)(magic&0x00000001);
+    pWal->szPage = szPage;
+    pWal->nCkpt = sqlite3Get4byte(&aBuf[12]);
+    memcpy(&pWal->hdr.aSalt, &aBuf[16], 8);
+
+    /* Verify that the WAL header checksum is correct */
+    walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, 
+        aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum
+    );
+    if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24])
+     || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28])
+    ){
+      goto finished;
+    }
+
+    /* Verify that the version number on the WAL format is one that
+    ** are able to understand */
+    version = sqlite3Get4byte(&aBuf[4]);
+    if( version!=WAL_MAX_VERSION ){
+      rc = SQLITE_CANTOPEN_BKPT;
+      goto finished;
+    }
+
+    /* Malloc a buffer to read frames into. */
+    szFrame = szPage + WAL_FRAME_HDRSIZE;
+    aFrame = (u8 *)sqlite3_malloc(szFrame);
+    if( !aFrame ){
+      rc = SQLITE_NOMEM;
+      goto recovery_error;
+    }
+    aData = &aFrame[WAL_FRAME_HDRSIZE];
+
+    /* Read all frames from the log file. */
+    iFrame = 0;
+    for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){
+      u32 pgno;                   /* Database page number for frame */
+      u32 nTruncate;              /* dbsize field from frame header */
+      int isValid;                /* True if this frame is valid */
+
+      /* Read and decode the next log frame. */
+      rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);
+      if( rc!=SQLITE_OK ) break;
+      isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);
+      if( !isValid ) break;
+      rc = walIndexAppend(pWal, ++iFrame, pgno);
+      if( rc!=SQLITE_OK ) break;
+
+      /* If nTruncate is non-zero, this is a commit record. */
+      if( nTruncate ){
+        pWal->hdr.mxFrame = iFrame;
+        pWal->hdr.nPage = nTruncate;
+        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));
+        testcase( szPage<=32768 );
+        testcase( szPage>=65536 );
+        aFrameCksum[0] = pWal->hdr.aFrameCksum[0];
+        aFrameCksum[1] = pWal->hdr.aFrameCksum[1];
+      }
+    }
+
+    sqlite3_free(aFrame);
+  }
+
+finished:
+  if( rc==SQLITE_OK ){
+    volatile WalCkptInfo *pInfo;
+    int i;
+    pWal->hdr.aFrameCksum[0] = aFrameCksum[0];
+    pWal->hdr.aFrameCksum[1] = aFrameCksum[1];
+    walIndexWriteHdr(pWal);
+
+    /* Reset the checkpoint-header. This is safe because this thread is 
+    ** currently holding locks that exclude all other readers, writers and
+    ** checkpointers.
+    */
+    pInfo = walCkptInfo(pWal);
+    pInfo->nBackfill = 0;
+    pInfo->aReadMark[0] = 0;
+    for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
+
+    /* If more than one frame was recovered from the log file, report an
+    ** event via sqlite3_log(). This is to help with identifying performance
+    ** problems caused by applications routinely shutting down without
+    ** checkpointing the log file.
+    */
+    if( pWal->hdr.nPage ){
+      sqlite3_log(SQLITE_OK, "Recovered %d frames from WAL file %s",
+          pWal->hdr.nPage, pWal->zWalName
+      );
+    }
+  }
+
+recovery_error:
+  WALTRACE(("WAL%p: recovery %s\n", pWal, rc ? "failed" : "ok"));
+  walUnlockExclusive(pWal, iLock, nLock);
+  return rc;
+}
+
+/*
+** Close an open wal-index.
+*/
+static void walIndexClose(Wal *pWal, int isDelete){
+  sqlite3OsShmUnmap(pWal->pDbFd, isDelete);
+}
+
+/* 
+** Open a connection to the WAL file zWalName. The database file must 
+** already be opened on connection pDbFd. The buffer that zWalName points
+** to must remain valid for the lifetime of the returned Wal* handle.
+**
+** A SHARED lock should be held on the database file when this function
+** is called. The purpose of this SHARED lock is to prevent any other
+** client from unlinking the WAL or wal-index file. If another process
+** were to do this just after this client opened one of these files, the
+** system would be badly broken.
+**
+** If the log file is successfully opened, SQLITE_OK is returned and 
+** *ppWal is set to point to a new WAL handle. If an error occurs,
+** an SQLite error code is returned and *ppWal is left unmodified.
+*/
+SQLITE_PRIVATE int sqlite3WalOpen(
+  sqlite3_vfs *pVfs,              /* vfs module to open wal and wal-index */
+  sqlite3_file *pDbFd,            /* The open database file */
+  const char *zWalName,           /* Name of the WAL file */
+  Wal **ppWal                     /* OUT: Allocated Wal handle */
+){
+  int rc;                         /* Return Code */
+  Wal *pRet;                      /* Object to allocate and return */
+  int flags;                      /* Flags passed to OsOpen() */
+
+  assert( zWalName && zWalName[0] );
+  assert( pDbFd );
+
+  /* In the amalgamation, the os_unix.c and os_win.c source files come before
+  ** this source file.  Verify that the #defines of the locking byte offsets
+  ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.
+  */
+#ifdef WIN_SHM_BASE
+  assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );
+#endif
+#ifdef UNIX_SHM_BASE
+  assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );
+#endif
+
+
+  /* Allocate an instance of struct Wal to return. */
+  *ppWal = 0;
+  pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile);
+  if( !pRet ){
+    return SQLITE_NOMEM;
+  }
+
+  pRet->pVfs = pVfs;
+  pRet->pWalFd = (sqlite3_file *)&pRet[1];
+  pRet->pDbFd = pDbFd;
+  pRet->readLock = -1;
+  pRet->zWalName = zWalName;
+
+  /* Open file handle on the write-ahead log file. */
+  flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);
+  rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);
+  if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){
+    pRet->readOnly = 1;
+  }
+
+  if( rc!=SQLITE_OK ){
+    walIndexClose(pRet, 0);
+    sqlite3OsClose(pRet->pWalFd);
+    sqlite3_free(pRet);
+  }else{
+    *ppWal = pRet;
+    WALTRACE(("WAL%d: opened\n", pRet));
+  }
+  return rc;
+}
+
+/*
+** Find the smallest page number out of all pages held in the WAL that
+** has not been returned by any prior invocation of this method on the
+** same WalIterator object.   Write into *piFrame the frame index where
+** that page was last written into the WAL.  Write into *piPage the page
+** number.
+**
+** Return 0 on success.  If there are no pages in the WAL with a page
+** number larger than *piPage, then return 1.
+*/
+static int walIteratorNext(
+  WalIterator *p,               /* Iterator */
+  u32 *piPage,                  /* OUT: The page number of the next page */
+  u32 *piFrame                  /* OUT: Wal frame index of next page */
+){
+  u32 iMin;                     /* Result pgno must be greater than iMin */
+  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */
+  int i;                        /* For looping through segments */
+
+  iMin = p->iPrior;
+  assert( iMin<0xffffffff );
+  for(i=p->nSegment-1; i>=0; i--){
+    struct WalSegment *pSegment = &p->aSegment[i];
+    while( pSegment->iNext<pSegment->nEntry ){
+      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];
+      if( iPg>iMin ){
+        if( iPg<iRet ){
+          iRet = iPg;
+          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];
+        }
+        break;
+      }
+      pSegment->iNext++;
+    }
+  }
+
+  *piPage = p->iPrior = iRet;
+  return (iRet==0xFFFFFFFF);
+}
+
+/*
+** This function merges two sorted lists into a single sorted list.
+*/
+static void walMerge(
+  u32 *aContent,                  /* Pages in wal */
+  ht_slot *aLeft,                 /* IN: Left hand input list */
+  int nLeft,                      /* IN: Elements in array *paLeft */
+  ht_slot **paRight,              /* IN/OUT: Right hand input list */
+  int *pnRight,                   /* IN/OUT: Elements in *paRight */
+  ht_slot *aTmp                   /* Temporary buffer */
+){
+  int iLeft = 0;                  /* Current index in aLeft */
+  int iRight = 0;                 /* Current index in aRight */
+  int iOut = 0;                   /* Current index in output buffer */
+  int nRight = *pnRight;
+  ht_slot *aRight = *paRight;
+
+  assert( nLeft>0 && nRight>0 );
+  while( iRight<nRight || iLeft<nLeft ){
+    ht_slot logpage;
+    Pgno dbpage;
+
+    if( (iLeft<nLeft) 
+     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])
+    ){
+      logpage = aLeft[iLeft++];
+    }else{
+      logpage = aRight[iRight++];
+    }
+    dbpage = aContent[logpage];
+
+    aTmp[iOut++] = logpage;
+    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;
+
+    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );
+    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );
+  }
+
+  *paRight = aLeft;
+  *pnRight = iOut;
+  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);
+}
+
+/*
+** Sort the elements in list aList, removing any duplicates.
+*/
+static void walMergesort(
+  u32 *aContent,                  /* Pages in wal */
+  ht_slot *aBuffer,               /* Buffer of at least *pnList items to use */
+  ht_slot *aList,                 /* IN/OUT: List to sort */
+  int *pnList                     /* IN/OUT: Number of elements in aList[] */
+){
+  struct Sublist {
+    int nList;                    /* Number of elements in aList */
+    ht_slot *aList;               /* Pointer to sub-list content */
+  };
+
+  const int nList = *pnList;      /* Size of input list */
+  int nMerge = 0;                 /* Number of elements in list aMerge */
+  ht_slot *aMerge = 0;            /* List to be merged */
+  int iList;                      /* Index into input list */
+  int iSub = 0;                   /* Index into aSub array */
+  struct Sublist aSub[13];        /* Array of sub-lists */
+
+  memset(aSub, 0, sizeof(aSub));
+  assert( nList<=HASHTABLE_NPAGE && nList>0 );
+  assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );
+
+  for(iList=0; iList<nList; iList++){
+    nMerge = 1;
+    aMerge = &aList[iList];
+    for(iSub=0; iList & (1<<iSub); iSub++){
+      struct Sublist *p = &aSub[iSub];
+      assert( p->aList && p->nList<=(1<<iSub) );
+      assert( p->aList==&aList[iList&~((2<<iSub)-1)] );
+      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
+    }
+    aSub[iSub].aList = aMerge;
+    aSub[iSub].nList = nMerge;
+  }
+
+  for(iSub++; iSub<ArraySize(aSub); iSub++){
+    if( nList & (1<<iSub) ){
+      struct Sublist *p = &aSub[iSub];
+      assert( p->nList<=(1<<iSub) );
+      assert( p->aList==&aList[nList&~((2<<iSub)-1)] );
+      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);
+    }
+  }
+  assert( aMerge==aList );
+  *pnList = nMerge;
+
+#ifdef SQLITE_DEBUG
+  {
+    int i;
+    for(i=1; i<*pnList; i++){
+      assert( aContent[aList[i]] > aContent[aList[i-1]] );
+    }
+  }
+#endif
+}
+
+/* 
+** Free an iterator allocated by walIteratorInit().
+*/
+static void walIteratorFree(WalIterator *p){
+  sqlite3ScratchFree(p);
+}
+
+/*
+** Construct a WalInterator object that can be used to loop over all 
+** pages in the WAL in ascending order. The caller must hold the checkpoint
+**
+** On success, make *pp point to the newly allocated WalInterator object
+** return SQLITE_OK. Otherwise, return an error code. If this routine
+** returns an error, the value of *pp is undefined.
+**
+** The calling routine should invoke walIteratorFree() to destroy the
+** WalIterator object when it has finished with it.
+*/
+static int walIteratorInit(Wal *pWal, WalIterator **pp){
+  WalIterator *p;                 /* Return value */
+  int nSegment;                   /* Number of segments to merge */
+  u32 iLast;                      /* Last frame in log */
+  int nByte;                      /* Number of bytes to allocate */
+  int i;                          /* Iterator variable */
+  ht_slot *aTmp;                  /* Temp space used by merge-sort */
+  int rc = SQLITE_OK;             /* Return Code */
+
+  /* This routine only runs while holding the checkpoint lock. And
+  ** it only runs if there is actually content in the log (mxFrame>0).
+  */
+  assert( pWal->ckptLock && pWal->hdr.mxFrame>0 );
+  iLast = pWal->hdr.mxFrame;
+
+  /* Allocate space for the WalIterator object. */
+  nSegment = walFramePage(iLast) + 1;
+  nByte = sizeof(WalIterator) 
+        + (nSegment-1)*sizeof(struct WalSegment)
+        + iLast*sizeof(ht_slot);
+  p = (WalIterator *)sqlite3ScratchMalloc(nByte);
+  if( !p ){
+    return SQLITE_NOMEM;
+  }
+  memset(p, 0, nByte);
+  p->nSegment = nSegment;
+
+  /* Allocate temporary space used by the merge-sort routine. This block
+  ** of memory will be freed before this function returns.
+  */
+  aTmp = (ht_slot *)sqlite3ScratchMalloc(
+      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
+  );
+  if( !aTmp ){
+    rc = SQLITE_NOMEM;
+  }
+
+  for(i=0; rc==SQLITE_OK && i<nSegment; i++){
+    volatile ht_slot *aHash;
+    u32 iZero;
+    volatile u32 *aPgno;
+
+    rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);
+    if( rc==SQLITE_OK ){
+      int j;                      /* Counter variable */
+      int nEntry;                 /* Number of entries in this segment */
+      ht_slot *aIndex;            /* Sorted index for this segment */
+
+      aPgno++;
+      if( (i+1)==nSegment ){
+        nEntry = (int)(iLast - iZero);
+      }else{
+        nEntry = (int)((u32*)aHash - (u32*)aPgno);
+      }
+      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];
+      iZero++;
+  
+      for(j=0; j<nEntry; j++){
+        aIndex[j] = (ht_slot)j;
+      }
+      walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);
+      p->aSegment[i].iZero = iZero;
+      p->aSegment[i].nEntry = nEntry;
+      p->aSegment[i].aIndex = aIndex;
+      p->aSegment[i].aPgno = (u32 *)aPgno;
+    }
+  }
+  sqlite3ScratchFree(aTmp);
+
+  if( rc!=SQLITE_OK ){
+    walIteratorFree(p);
+  }
+  *pp = p;
+  return rc;
+}
+
+/*
+** Copy as much content as we can from the WAL back into the database file
+** in response to an sqlite3_wal_checkpoint() request or the equivalent.
+**
+** The amount of information copies from WAL to database might be limited
+** by active readers.  This routine will never overwrite a database page
+** that a concurrent reader might be using.
+**
+** All I/O barrier operations (a.k.a fsyncs) occur in this routine when
+** SQLite is in WAL-mode in synchronous=NORMAL.  That means that if 
+** checkpoints are always run by a background thread or background 
+** process, foreground threads will never block on a lengthy fsync call.
+**
+** Fsync is called on the WAL before writing content out of the WAL and
+** into the database.  This ensures that if the new content is persistent
+** in the WAL and can be recovered following a power-loss or hard reset.
+**
+** Fsync is also called on the database file if (and only if) the entire
+** WAL content is copied into the database file.  This second fsync makes
+** it safe to delete the WAL since the new content will persist in the
+** database file.
+**
+** This routine uses and updates the nBackfill field of the wal-index header.
+** This is the only routine tha will increase the value of nBackfill.  
+** (A WAL reset or recovery will revert nBackfill to zero, but not increase
+** its value.)
+**
+** The caller must be holding sufficient locks to ensure that no other
+** checkpoint is running (in any other thread or process) at the same
+** time.
+*/
+static int walCheckpoint(
+  Wal *pWal,                      /* Wal connection */
+  int sync_flags,                 /* Flags for OsSync() (or 0) */
+  int nBuf,                       /* Size of zBuf in bytes */
+  u8 *zBuf                        /* Temporary buffer to use */
+){
+  int rc;                         /* Return code */
+  int szPage;                     /* Database page-size */
+  WalIterator *pIter = 0;         /* Wal iterator context */
+  u32 iDbpage = 0;                /* Next database page to write */
+  u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */
+  u32 mxSafeFrame;                /* Max frame that can be backfilled */
+  u32 mxPage;                     /* Max database page to write */
+  int i;                          /* Loop counter */
+  volatile WalCkptInfo *pInfo;    /* The checkpoint status information */
+
+  szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);
+  testcase( szPage<=32768 );
+  testcase( szPage>=65536 );
+  if( pWal->hdr.mxFrame==0 ) return SQLITE_OK;
+
+  /* Allocate the iterator */
+  rc = walIteratorInit(pWal, &pIter);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+  assert( pIter );
+
+  /*** TODO:  Move this test out to the caller.  Make it an assert() here ***/
+  if( szPage!=nBuf ){
+    rc = SQLITE_CORRUPT_BKPT;
+    goto walcheckpoint_out;
+  }
+
+  /* Compute in mxSafeFrame the index of the last frame of the WAL that is
+  ** safe to write into the database.  Frames beyond mxSafeFrame might
+  ** overwrite database pages that are in use by active readers and thus
+  ** cannot be backfilled from the WAL.
+  */
+  mxSafeFrame = pWal->hdr.mxFrame;
+  mxPage = pWal->hdr.nPage;
+  pInfo = walCkptInfo(pWal);
+  for(i=1; i<WAL_NREADER; i++){
+    u32 y = pInfo->aReadMark[i];
+    if( mxSafeFrame>=y ){
+      assert( y<=pWal->hdr.mxFrame );
+      rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
+      if( rc==SQLITE_OK ){
+        pInfo->aReadMark[i] = READMARK_NOT_USED;
+        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
+      }else if( rc==SQLITE_BUSY ){
+        mxSafeFrame = y;
+      }else{
+        goto walcheckpoint_out;
+      }
+    }
+  }
+
+  if( pInfo->nBackfill<mxSafeFrame
+   && (rc = walLockExclusive(pWal, WAL_READ_LOCK(0), 1))==SQLITE_OK
+  ){
+    i64 nSize;                    /* Current size of database file */
+    u32 nBackfill = pInfo->nBackfill;
+
+    /* Sync the WAL to disk */
+    if( sync_flags ){
+      rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
+    }
+
+    /* If the database file may grow as a result of this checkpoint, hint
+    ** about the eventual size of the db file to the VFS layer. 
+    */
+    if( rc==SQLITE_OK ){
+      i64 nReq = ((i64)mxPage * szPage);
+      rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
+      if( rc==SQLITE_OK && nSize<nReq ){
+        sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
+      }
+    }
+
+    /* Iterate through the contents of the WAL, copying data to the db file. */
+    while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
+      i64 iOffset;
+      assert( walFramePgno(pWal, iFrame)==iDbpage );
+      if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue;
+      iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
+      /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
+      rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
+      if( rc!=SQLITE_OK ) break;
+      iOffset = (iDbpage-1)*(i64)szPage;
+      testcase( IS_BIG_INT(iOffset) );
+      rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
+      if( rc!=SQLITE_OK ) break;
+    }
+
+    /* If work was actually accomplished... */
+    if( rc==SQLITE_OK ){
+      if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
+        i64 szDb = pWal->hdr.nPage*(i64)szPage;
+        testcase( IS_BIG_INT(szDb) );
+        rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
+        if( rc==SQLITE_OK && sync_flags ){
+          rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
+        }
+      }
+      if( rc==SQLITE_OK ){
+        pInfo->nBackfill = mxSafeFrame;
+      }
+    }
+
+    /* Release the reader lock held while backfilling */
+    walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
+  }else if( rc==SQLITE_BUSY ){
+    /* Reset the return code so as not to report a checkpoint failure
+    ** just because active readers prevent any backfill.
+    */
+    rc = SQLITE_OK;
+  }
+
+ walcheckpoint_out:
+  walIteratorFree(pIter);
+  return rc;
+}
+
+/*
+** Close a connection to a log file.
+*/
+SQLITE_PRIVATE int sqlite3WalClose(
+  Wal *pWal,                      /* Wal to close */
+  int sync_flags,                 /* Flags to pass to OsSync() (or 0) */
+  int nBuf,
+  u8 *zBuf                        /* Buffer of at least nBuf bytes */
+){
+  int rc = SQLITE_OK;
+  if( pWal ){
+    int isDelete = 0;             /* True to unlink wal and wal-index files */
+
+    /* If an EXCLUSIVE lock can be obtained on the database file (using the
+    ** ordinary, rollback-mode locking methods, this guarantees that the
+    ** connection associated with this log file is the only connection to
+    ** the database. In this case checkpoint the database and unlink both
+    ** the wal and wal-index files.
+    **
+    ** The EXCLUSIVE lock is not released before returning.
+    */
+    rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);
+    if( rc==SQLITE_OK ){
+      pWal->exclusiveMode = 1;
+      rc = sqlite3WalCheckpoint(pWal, sync_flags, nBuf, zBuf);
+      if( rc==SQLITE_OK ){
+        isDelete = 1;
+      }
+    }
+
+    walIndexClose(pWal, isDelete);
+    sqlite3OsClose(pWal->pWalFd);
+    if( isDelete ){
+      sqlite3OsDelete(pWal->pVfs, pWal->zWalName, 0);
+    }
+    WALTRACE(("WAL%p: closed\n", pWal));
+    sqlite3_free((void *)pWal->apWiData);
+    sqlite3_free(pWal);
+  }
+  return rc;
+}
+
+/*
+** Try to read the wal-index header.  Return 0 on success and 1 if
+** there is a problem.
+**
+** The wal-index is in shared memory.  Another thread or process might
+** be writing the header at the same time this procedure is trying to
+** read it, which might result in inconsistency.  A dirty read is detected
+** by verifying that both copies of the header are the same and also by
+** a checksum on the header.
+**
+** If and only if the read is consistent and the header is different from
+** pWal->hdr, then pWal->hdr is updated to the content of the new header
+** and *pChanged is set to 1.
+**
+** If the checksum cannot be verified return non-zero. If the header
+** is read successfully and the checksum verified, return zero.
+*/
+static int walIndexTryHdr(Wal *pWal, int *pChanged){
+  u32 aCksum[2];                  /* Checksum on the header content */
+  WalIndexHdr h1, h2;             /* Two copies of the header content */
+  WalIndexHdr volatile *aHdr;     /* Header in shared memory */
+
+  /* The first page of the wal-index must be mapped at this point. */
+  assert( pWal->nWiData>0 && pWal->apWiData[0] );
+
+  /* Read the header. This might happen concurrently with a write to the
+  ** same area of shared memory on a different CPU in a SMP,
+  ** meaning it is possible that an inconsistent snapshot is read
+  ** from the file. If this happens, return non-zero.
+  **
+  ** There are two copies of the header at the beginning of the wal-index.
+  ** When reading, read [0] first then [1].  Writes are in the reverse order.
+  ** Memory barriers are used to prevent the compiler or the hardware from
+  ** reordering the reads and writes.
+  */
+  aHdr = walIndexHdr(pWal);
+  memcpy(&h1, (void *)&aHdr[0], sizeof(h1));
+  sqlite3OsShmBarrier(pWal->pDbFd);
+  memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
+
+  if( memcmp(&h1, &h2, sizeof(h1))!=0 ){
+    return 1;   /* Dirty read */
+  }  
+  if( h1.isInit==0 ){
+    return 1;   /* Malformed header - probably all zeros */
+  }
+  walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);
+  if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){
+    return 1;   /* Checksum does not match */
+  }
+
+  if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){
+    *pChanged = 1;
+    memcpy(&pWal->hdr, &h1, sizeof(WalIndexHdr));
+    pWal->szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);
+    testcase( pWal->szPage<=32768 );
+    testcase( pWal->szPage>=65536 );
+  }
+
+  /* The header was successfully read. Return zero. */
+  return 0;
+}
+
+/*
+** Read the wal-index header from the wal-index and into pWal->hdr.
+** If the wal-header appears to be corrupt, try to reconstruct the
+** wal-index from the WAL before returning.
+**
+** Set *pChanged to 1 if the wal-index header value in pWal->hdr is
+** changed by this opertion.  If pWal->hdr is unchanged, set *pChanged
+** to 0.
+**
+** If the wal-index header is successfully read, return SQLITE_OK. 
+** Otherwise an SQLite error code.
+*/
+static int walIndexReadHdr(Wal *pWal, int *pChanged){
+  int rc;                         /* Return code */
+  int badHdr;                     /* True if a header read failed */
+  volatile u32 *page0;            /* Chunk of wal-index containing header */
+
+  /* Ensure that page 0 of the wal-index (the page that contains the 
+  ** wal-index header) is mapped. Return early if an error occurs here.
+  */
+  assert( pChanged );
+  rc = walIndexPage(pWal, 0, &page0);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  };
+  assert( page0 || pWal->writeLock==0 );
+
+  /* If the first page of the wal-index has been mapped, try to read the
+  ** wal-index header immediately, without holding any lock. This usually
+  ** works, but may fail if the wal-index header is corrupt or currently 
+  ** being modified by another thread or process.
+  */
+  badHdr = (page0 ? walIndexTryHdr(pWal, pChanged) : 1);
+
+  /* If the first attempt failed, it might have been due to a race
+  ** with a writer.  So get a WRITE lock and try again.
+  */
+  assert( badHdr==0 || pWal->writeLock==0 );
+  if( badHdr && SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
+    pWal->writeLock = 1;
+    if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
+      badHdr = walIndexTryHdr(pWal, pChanged);
+      if( badHdr ){
+        /* If the wal-index header is still malformed even while holding
+        ** a WRITE lock, it can only mean that the header is corrupted and
+        ** needs to be reconstructed.  So run recovery to do exactly that.
+        */
+        rc = walIndexRecover(pWal);
+        *pChanged = 1;
+      }
+    }
+    pWal->writeLock = 0;
+    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
+  }
+
+  /* If the header is read successfully, check the version number to make
+  ** sure the wal-index was not constructed with some future format that
+  ** this version of SQLite cannot understand.
+  */
+  if( badHdr==0 && pWal->hdr.iVersion!=WALINDEX_MAX_VERSION ){
+    rc = SQLITE_CANTOPEN_BKPT;
+  }
+
+  return rc;
+}
+
+/*
+** This is the value that walTryBeginRead returns when it needs to
+** be retried.
+*/
+#define WAL_RETRY  (-1)
+
+/*
+** Attempt to start a read transaction.  This might fail due to a race or
+** other transient condition.  When that happens, it returns WAL_RETRY to
+** indicate to the caller that it is safe to retry immediately.
+**
+** On success return SQLITE_OK.  On a permanent failure (such an
+** I/O error or an SQLITE_BUSY because another process is running
+** recovery) return a positive error code.
+**
+** The useWal parameter is true to force the use of the WAL and disable
+** the case where the WAL is bypassed because it has been completely
+** checkpointed.  If useWal==0 then this routine calls walIndexReadHdr() 
+** to make a copy of the wal-index header into pWal->hdr.  If the 
+** wal-index header has changed, *pChanged is set to 1 (as an indication 
+** to the caller that the local paget cache is obsolete and needs to be 
+** flushed.)  When useWal==1, the wal-index header is assumed to already
+** be loaded and the pChanged parameter is unused.
+**
+** The caller must set the cnt parameter to the number of prior calls to
+** this routine during the current read attempt that returned WAL_RETRY.
+** This routine will start taking more aggressive measures to clear the
+** race conditions after multiple WAL_RETRY returns, and after an excessive
+** number of errors will ultimately return SQLITE_PROTOCOL.  The
+** SQLITE_PROTOCOL return indicates that some other process has gone rogue
+** and is not honoring the locking protocol.  There is a vanishingly small
+** chance that SQLITE_PROTOCOL could be returned because of a run of really
+** bad luck when there is lots of contention for the wal-index, but that
+** possibility is so small that it can be safely neglected, we believe.
+**
+** On success, this routine obtains a read lock on 
+** WAL_READ_LOCK(pWal->readLock).  The pWal->readLock integer is
+** in the range 0 <= pWal->readLock < WAL_NREADER.  If pWal->readLock==(-1)
+** that means the Wal does not hold any read lock.  The reader must not
+** access any database page that is modified by a WAL frame up to and
+** including frame number aReadMark[pWal->readLock].  The reader will
+** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0
+** Or if pWal->readLock==0, then the reader will ignore the WAL
+** completely and get all content directly from the database file.
+** If the useWal parameter is 1 then the WAL will never be ignored and
+** this routine will always set pWal->readLock>0 on success.
+** When the read transaction is completed, the caller must release the
+** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.
+**
+** This routine uses the nBackfill and aReadMark[] fields of the header
+** to select a particular WAL_READ_LOCK() that strives to let the
+** checkpoint process do as much work as possible.  This routine might
+** update values of the aReadMark[] array in the header, but if it does
+** so it takes care to hold an exclusive lock on the corresponding
+** WAL_READ_LOCK() while changing values.
+*/
+static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
+  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */
+  u32 mxReadMark;                 /* Largest aReadMark[] value */
+  int mxI;                        /* Index of largest aReadMark[] value */
+  int i;                          /* Loop counter */
+  int rc = SQLITE_OK;             /* Return code  */
+
+  assert( pWal->readLock<0 );     /* Not currently locked */
+
+  /* Take steps to avoid spinning forever if there is a protocol error. */
+  if( cnt>5 ){
+    if( cnt>100 ) return SQLITE_PROTOCOL;
+    sqlite3OsSleep(pWal->pVfs, 1);
+  }
+
+  if( !useWal ){
+    rc = walIndexReadHdr(pWal, pChanged);
+    if( rc==SQLITE_BUSY ){
+      /* If there is not a recovery running in another thread or process
+      ** then convert BUSY errors to WAL_RETRY.  If recovery is known to
+      ** be running, convert BUSY to BUSY_RECOVERY.  There is a race here
+      ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY
+      ** would be technically correct.  But the race is benign since with
+      ** WAL_RETRY this routine will be called again and will probably be
+      ** right on the second iteration.
+      */
+      if( pWal->apWiData[0]==0 ){
+        /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.
+        ** We assume this is a transient condition, so return WAL_RETRY. The
+        ** xShmMap() implementation used by the default unix and win32 VFS 
+        ** modules may return SQLITE_BUSY due to a race condition in the 
+        ** code that determines whether or not the shared-memory region 
+        ** must be zeroed before the requested page is returned.
+        */
+        rc = WAL_RETRY;
+      }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){
+        walUnlockShared(pWal, WAL_RECOVER_LOCK);
+        rc = WAL_RETRY;
+      }else if( rc==SQLITE_BUSY ){
+        rc = SQLITE_BUSY_RECOVERY;
+      }
+    }
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+  }
+
+  pInfo = walCkptInfo(pWal);
+  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame ){
+    /* The WAL has been completely backfilled (or it is empty).
+    ** and can be safely ignored.
+    */
+    rc = walLockShared(pWal, WAL_READ_LOCK(0));
+    sqlite3OsShmBarrier(pWal->pDbFd);
+    if( rc==SQLITE_OK ){
+      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
+        /* It is not safe to allow the reader to continue here if frames
+        ** may have been appended to the log before READ_LOCK(0) was obtained.
+        ** When holding READ_LOCK(0), the reader ignores the entire log file,
+        ** which implies that the database file contains a trustworthy
+        ** snapshoT. Since holding READ_LOCK(0) prevents a checkpoint from
+        ** happening, this is usually correct.
+        **
+        ** However, if frames have been appended to the log (or if the log 
+        ** is wrapped and written for that matter) before the READ_LOCK(0)
+        ** is obtained, that is not necessarily true. A checkpointer may
+        ** have started to backfill the appended frames but crashed before
+        ** it finished. Leaving a corrupt image in the database file.
+        */
+        walUnlockShared(pWal, WAL_READ_LOCK(0));
+        return WAL_RETRY;
+      }
+      pWal->readLock = 0;
+      return SQLITE_OK;
+    }else if( rc!=SQLITE_BUSY ){
+      return rc;
+    }
+  }
+
+  /* If we get this far, it means that the reader will want to use
+  ** the WAL to get at content from recent commits.  The job now is
+  ** to select one of the aReadMark[] entries that is closest to
+  ** but not exceeding pWal->hdr.mxFrame and lock that entry.
+  */
+  mxReadMark = 0;
+  mxI = 0;
+  for(i=1; i<WAL_NREADER; i++){
+    u32 thisMark = pInfo->aReadMark[i];
+    if( mxReadMark<=thisMark && thisMark<=pWal->hdr.mxFrame ){
+      assert( thisMark!=READMARK_NOT_USED );
+      mxReadMark = thisMark;
+      mxI = i;
+    }
+  }
+  if( mxI==0 ){
+    /* If we get here, it means that all of the aReadMark[] entries between
+    ** 1 and WAL_NREADER-1 are zero.  Try to initialize aReadMark[1] to
+    ** be mxFrame, then retry.
+    */
+    rc = walLockExclusive(pWal, WAL_READ_LOCK(1), 1);
+    if( rc==SQLITE_OK ){
+      pInfo->aReadMark[1] = pWal->hdr.mxFrame;
+      walUnlockExclusive(pWal, WAL_READ_LOCK(1), 1);
+      rc = WAL_RETRY;
+    }else if( rc==SQLITE_BUSY ){
+      rc = WAL_RETRY;
+    }
+    return rc;
+  }else{
+    if( mxReadMark < pWal->hdr.mxFrame ){
+      for(i=1; i<WAL_NREADER; i++){
+        rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
+        if( rc==SQLITE_OK ){
+          mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
+          mxI = i;
+          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
+          break;
+        }else if( rc!=SQLITE_BUSY ){
+          return rc;
+        }
+      }
+    }
+
+    rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
+    if( rc ){
+      return rc==SQLITE_BUSY ? WAL_RETRY : rc;
+    }
+    /* Now that the read-lock has been obtained, check that neither the
+    ** value in the aReadMark[] array or the contents of the wal-index
+    ** header have changed.
+    **
+    ** It is necessary to check that the wal-index header did not change
+    ** between the time it was read and when the shared-lock was obtained
+    ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
+    ** that the log file may have been wrapped by a writer, or that frames
+    ** that occur later in the log than pWal->hdr.mxFrame may have been
+    ** copied into the database by a checkpointer. If either of these things
+    ** happened, then reading the database with the current value of
+    ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
+    ** instead.
+    **
+    ** This does not guarantee that the copy of the wal-index header is up to
+    ** date before proceeding. That would not be possible without somehow
+    ** blocking writers. It only guarantees that a dangerous checkpoint or 
+    ** log-wrap (either of which would require an exclusive lock on
+    ** WAL_READ_LOCK(mxI)) has not occurred since the snapshot was valid.
+    */
+    sqlite3OsShmBarrier(pWal->pDbFd);
+    if( pInfo->aReadMark[mxI]!=mxReadMark
+     || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
+    ){
+      walUnlockShared(pWal, WAL_READ_LOCK(mxI));
+      return WAL_RETRY;
+    }else{
+      assert( mxReadMark<=pWal->hdr.mxFrame );
+      pWal->readLock = (i16)mxI;
+    }
+  }
+  return rc;
+}
+
+/*
+** Begin a read transaction on the database.
+**
+** This routine used to be called sqlite3OpenSnapshot() and with good reason:
+** it takes a snapshot of the state of the WAL and wal-index for the current
+** instant in time.  The current thread will continue to use this snapshot.
+** Other threads might append new content to the WAL and wal-index but
+** that extra content is ignored by the current thread.
+**
+** If the database contents have changes since the previous read
+** transaction, then *pChanged is set to 1 before returning.  The
+** Pager layer will use this to know that is cache is stale and
+** needs to be flushed.
+*/
+SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
+  int rc;                         /* Return code */
+  int cnt = 0;                    /* Number of TryBeginRead attempts */
+
+  do{
+    rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);
+  }while( rc==WAL_RETRY );
+  return rc;
+}
+
+/*
+** Finish with a read transaction.  All this does is release the
+** read-lock.
+*/
+SQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){
+  sqlite3WalEndWriteTransaction(pWal);
+  if( pWal->readLock>=0 ){
+    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));
+    pWal->readLock = -1;
+  }
+}
+
+/*
+** Read a page from the WAL, if it is present in the WAL and if the 
+** current read transaction is configured to use the WAL.  
+**
+** The *pInWal is set to 1 if the requested page is in the WAL and
+** has been loaded.  Or *pInWal is set to 0 if the page was not in 
+** the WAL and needs to be read out of the database.
+*/
+SQLITE_PRIVATE int sqlite3WalRead(
+  Wal *pWal,                      /* WAL handle */
+  Pgno pgno,                      /* Database page number to read data for */
+  int *pInWal,                    /* OUT: True if data is read from WAL */
+  int nOut,                       /* Size of buffer pOut in bytes */
+  u8 *pOut                        /* Buffer to write page data to */
+){
+  u32 iRead = 0;                  /* If !=0, WAL frame to return data from */
+  u32 iLast = pWal->hdr.mxFrame;  /* Last page in WAL for this reader */
+  int iHash;                      /* Used to loop through N hash tables */
+
+  /* This routine is only be called from within a read transaction. */
+  assert( pWal->readLock>=0 || pWal->lockError );
+
+  /* If the "last page" field of the wal-index header snapshot is 0, then
+  ** no data will be read from the wal under any circumstances. Return early
+  ** in this case as an optimization.  Likewise, if pWal->readLock==0, 
+  ** then the WAL is ignored by the reader so return early, as if the 
+  ** WAL were empty.
+  */
+  if( iLast==0 || pWal->readLock==0 ){
+    *pInWal = 0;
+    return SQLITE_OK;
+  }
+
+  /* Search the hash table or tables for an entry matching page number
+  ** pgno. Each iteration of the following for() loop searches one
+  ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
+  **
+  ** This code might run concurrently to the code in walIndexAppend()
+  ** that adds entries to the wal-index (and possibly to this hash 
+  ** table). This means the value just read from the hash 
+  ** slot (aHash[iKey]) may have been added before or after the 
+  ** current read transaction was opened. Values added after the
+  ** read transaction was opened may have been written incorrectly -
+  ** i.e. these slots may contain garbage data. However, we assume
+  ** that any slots written before the current read transaction was
+  ** opened remain unmodified.
+  **
+  ** For the reasons above, the if(...) condition featured in the inner
+  ** loop of the following block is more stringent that would be required 
+  ** if we had exclusive access to the hash-table:
+  **
+  **   (aPgno[iFrame]==pgno): 
+  **     This condition filters out normal hash-table collisions.
+  **
+  **   (iFrame<=iLast): 
+  **     This condition filters out entries that were added to the hash
+  **     table after the current read-transaction had started.
+  */
+  for(iHash=walFramePage(iLast); iHash>=0 && iRead==0; iHash--){
+    volatile ht_slot *aHash;      /* Pointer to hash table */
+    volatile u32 *aPgno;          /* Pointer to array of page numbers */
+    u32 iZero;                    /* Frame number corresponding to aPgno[0] */
+    int iKey;                     /* Hash slot index */
+    int nCollide;                 /* Number of hash collisions remaining */
+    int rc;                       /* Error code */
+
+    rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+    nCollide = HASHTABLE_NSLOT;
+    for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
+      u32 iFrame = aHash[iKey] + iZero;
+      if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){
+        assert( iFrame>iRead );
+        iRead = iFrame;
+      }
+      if( (nCollide--)==0 ){
+        return SQLITE_CORRUPT_BKPT;
+      }
+    }
+  }
+
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
+  /* If expensive assert() statements are available, do a linear search
+  ** of the wal-index file content. Make sure the results agree with the
+  ** result obtained using the hash indexes above.  */
+  {
+    u32 iRead2 = 0;
+    u32 iTest;
+    for(iTest=iLast; iTest>0; iTest--){
+      if( walFramePgno(pWal, iTest)==pgno ){
+        iRead2 = iTest;
+        break;
+      }
+    }
+    assert( iRead==iRead2 );
+  }
+#endif
+
+  /* If iRead is non-zero, then it is the log frame number that contains the
+  ** required page. Read and return data from the log file.
+  */
+  if( iRead ){
+    int sz;
+    i64 iOffset;
+    sz = pWal->hdr.szPage;
+    sz = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);
+    testcase( sz<=32768 );
+    testcase( sz>=65536 );
+    iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;
+    *pInWal = 1;
+    /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
+    return sqlite3OsRead(pWal->pWalFd, pOut, nOut, iOffset);
+  }
+
+  *pInWal = 0;
+  return SQLITE_OK;
+}
+
+
+/* 
+** Return the size of the database in pages (or zero, if unknown).
+*/
+SQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal){
+  if( pWal && ALWAYS(pWal->readLock>=0) ){
+    return pWal->hdr.nPage;
+  }
+  return 0;
+}
+
+
+/* 
+** This function starts a write transaction on the WAL.
+**
+** A read transaction must have already been started by a prior call
+** to sqlite3WalBeginReadTransaction().
+**
+** If another thread or process has written into the database since
+** the read transaction was started, then it is not possible for this
+** thread to write as doing so would cause a fork.  So this routine
+** returns SQLITE_BUSY in that case and no write transaction is started.
+**
+** There can only be a single writer active at a time.
+*/
+SQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){
+  int rc;
+
+  /* Cannot start a write transaction without first holding a read
+  ** transaction. */
+  assert( pWal->readLock>=0 );
+
+  if( pWal->readOnly ){
+    return SQLITE_READONLY;
+  }
+
+  /* Only one writer allowed at a time.  Get the write lock.  Return
+  ** SQLITE_BUSY if unable.
+  */
+  rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
+  if( rc ){
+    return rc;
+  }
+  pWal->writeLock = 1;
+
+  /* If another connection has written to the database file since the
+  ** time the read transaction on this connection was started, then
+  ** the write is disallowed.
+  */
+  if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
+    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
+    pWal->writeLock = 0;
+    rc = SQLITE_BUSY;
+  }
+
+  return rc;
+}
+
+/*
+** End a write transaction.  The commit has already been done.  This
+** routine merely releases the lock.
+*/
+SQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){
+  if( pWal->writeLock ){
+    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
+    pWal->writeLock = 0;
+  }
+  return SQLITE_OK;
+}
+
+/*
+** If any data has been written (but not committed) to the log file, this
+** function moves the write-pointer back to the start of the transaction.
+**
+** Additionally, the callback function is invoked for each frame written
+** to the WAL since the start of the transaction. If the callback returns
+** other than SQLITE_OK, it is not invoked again and the error code is
+** returned to the caller.
+**
+** Otherwise, if the callback function does not return an error, this
+** function returns SQLITE_OK.
+*/
+SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
+  int rc = SQLITE_OK;
+  if( ALWAYS(pWal->writeLock) ){
+    Pgno iMax = pWal->hdr.mxFrame;
+    Pgno iFrame;
+  
+    /* Restore the clients cache of the wal-index header to the state it
+    ** was in before the client began writing to the database. 
+    */
+    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));
+
+    for(iFrame=pWal->hdr.mxFrame+1; 
+        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; 
+        iFrame++
+    ){
+      /* This call cannot fail. Unless the page for which the page number
+      ** is passed as the second argument is (a) in the cache and 
+      ** (b) has an outstanding reference, then xUndo is either a no-op
+      ** (if (a) is false) or simply expels the page from the cache (if (b)
+      ** is false).
+      **
+      ** If the upper layer is doing a rollback, it is guaranteed that there
+      ** are no outstanding references to any page other than page 1. And
+      ** page 1 is never written to the log until the transaction is
+      ** committed. As a result, the call to xUndo may not fail.
+      */
+      assert( walFramePgno(pWal, iFrame)!=1 );
+      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
+    }
+    walCleanupHash(pWal);
+  }
+  assert( rc==SQLITE_OK );
+  return rc;
+}
+
+/* 
+** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 
+** values. This function populates the array with values required to 
+** "rollback" the write position of the WAL handle back to the current 
+** point in the event of a savepoint rollback (via WalSavepointUndo()).
+*/
+SQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
+  assert( pWal->writeLock );
+  aWalData[0] = pWal->hdr.mxFrame;
+  aWalData[1] = pWal->hdr.aFrameCksum[0];
+  aWalData[2] = pWal->hdr.aFrameCksum[1];
+  aWalData[3] = pWal->nCkpt;
+}
+
+/* 
+** Move the write position of the WAL back to the point identified by
+** the values in the aWalData[] array. aWalData must point to an array
+** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated
+** by a call to WalSavepoint().
+*/
+SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
+  int rc = SQLITE_OK;
+
+  assert( pWal->writeLock );
+  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );
+
+  if( aWalData[3]!=pWal->nCkpt ){
+    /* This savepoint was opened immediately after the write-transaction
+    ** was started. Right after that, the writer decided to wrap around
+    ** to the start of the log. Update the savepoint values to match.
+    */
+    aWalData[0] = 0;
+    aWalData[3] = pWal->nCkpt;
+  }
+
+  if( aWalData[0]<pWal->hdr.mxFrame ){
+    pWal->hdr.mxFrame = aWalData[0];
+    pWal->hdr.aFrameCksum[0] = aWalData[1];
+    pWal->hdr.aFrameCksum[1] = aWalData[2];
+    walCleanupHash(pWal);
+  }
+
+  return rc;
+}
+
+/*
+** This function is called just before writing a set of frames to the log
+** file (see sqlite3WalFrames()). It checks to see if, instead of appending
+** to the current log file, it is possible to overwrite the start of the
+** existing log file with the new frames (i.e. "reset" the log). If so,
+** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left
+** unchanged.
+**
+** SQLITE_OK is returned if no error is encountered (regardless of whether
+** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned
+** if an error occurs.
+*/
+static int walRestartLog(Wal *pWal){
+  int rc = SQLITE_OK;
+  int cnt;
+
+  if( pWal->readLock==0 ){
+    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
+    assert( pInfo->nBackfill==pWal->hdr.mxFrame );
+    if( pInfo->nBackfill>0 ){
+      rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
+      if( rc==SQLITE_OK ){
+        /* If all readers are using WAL_READ_LOCK(0) (in other words if no
+        ** readers are currently using the WAL), then the transactions
+        ** frames will overwrite the start of the existing log. Update the
+        ** wal-index header to reflect this.
+        **
+        ** In theory it would be Ok to update the cache of the header only
+        ** at this point. But updating the actual wal-index header is also
+        ** safe and means there is no special case for sqlite3WalUndo()
+        ** to handle if this transaction is rolled back.
+        */
+        int i;                    /* Loop counter */
+        u32 *aSalt = pWal->hdr.aSalt;       /* Big-endian salt values */
+        pWal->nCkpt++;
+        pWal->hdr.mxFrame = 0;
+        sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
+        sqlite3_randomness(4, &aSalt[1]);
+        walIndexWriteHdr(pWal);
+        pInfo->nBackfill = 0;
+        for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
+        assert( pInfo->aReadMark[0]==0 );
+        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
+      }else if( rc!=SQLITE_BUSY ){
+        return rc;
+      }
+    }
+    walUnlockShared(pWal, WAL_READ_LOCK(0));
+    pWal->readLock = -1;
+    cnt = 0;
+    do{
+      int notUsed;
+      rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);
+    }while( rc==WAL_RETRY );
+  }
+  return rc;
+}
+
+/* 
+** Write a set of frames to the log. The caller must hold the write-lock
+** on the log file (obtained using sqlite3WalBeginWriteTransaction()).
+*/
+SQLITE_PRIVATE int sqlite3WalFrames(
+  Wal *pWal,                      /* Wal handle to write to */
+  int szPage,                     /* Database page-size in bytes */
+  PgHdr *pList,                   /* List of dirty pages to write */
+  Pgno nTruncate,                 /* Database size after this commit */
+  int isCommit,                   /* True if this is a commit */
+  int sync_flags                  /* Flags to pass to OsSync() (or 0) */
+){
+  int rc;                         /* Used to catch return codes */
+  u32 iFrame;                     /* Next frame address */
+  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */
+  PgHdr *p;                       /* Iterator to run through pList with. */
+  PgHdr *pLast = 0;               /* Last frame in list */
+  int nLast = 0;                  /* Number of extra copies of last page */
+
+  assert( pList );
+  assert( pWal->writeLock );
+
+#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
+  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}
+    WALTRACE(("WAL%p: frame write begin. %d frames. mxFrame=%d. %s\n",
+              pWal, cnt, pWal->hdr.mxFrame, isCommit ? "Commit" : "Spill"));
+  }
+#endif
+
+  /* See if it is possible to write these frames into the start of the
+  ** log file, instead of appending to it at pWal->hdr.mxFrame.
+  */
+  if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){
+    return rc;
+  }
+
+  /* If this is the first frame written into the log, write the WAL
+  ** header to the start of the WAL file. See comments at the top of
+  ** this source file for a description of the WAL header format.
+  */
+  iFrame = pWal->hdr.mxFrame;
+  if( iFrame==0 ){
+    u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */
+    u32 aCksum[2];                /* Checksum for wal-header */
+
+    sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));
+    sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
+    sqlite3Put4byte(&aWalHdr[8], szPage);
+    sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
+    sqlite3_randomness(8, pWal->hdr.aSalt);
+    memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
+    walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
+    sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
+    sqlite3Put4byte(&aWalHdr[28], aCksum[1]);
+    
+    pWal->szPage = szPage;
+    pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;
+    pWal->hdr.aFrameCksum[0] = aCksum[0];
+    pWal->hdr.aFrameCksum[1] = aCksum[1];
+
+    rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);
+    WALTRACE(("WAL%p: wal-header write %s\n", pWal, rc ? "failed" : "ok"));
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+  }
+  assert( (int)pWal->szPage==szPage );
+
+  /* Write the log file. */
+  for(p=pList; p; p=p->pDirty){
+    u32 nDbsize;                  /* Db-size field for frame header */
+    i64 iOffset;                  /* Write offset in log file */
+    void *pData;
+   
+    iOffset = walFrameOffset(++iFrame, szPage);
+    /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
+    
+    /* Populate and write the frame header */
+    nDbsize = (isCommit && p->pDirty==0) ? nTruncate : 0;
+#if defined(SQLITE_HAS_CODEC)
+    if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;
+#else
+    pData = p->pData;
+#endif
+    walEncodeFrame(pWal, p->pgno, nDbsize, pData, aFrame);
+    rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+
+    /* Write the page data */
+    rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset+sizeof(aFrame));
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+    pLast = p;
+  }
+
+  /* Sync the log file if the 'isSync' flag was specified. */
+  if( sync_flags ){
+    i64 iSegment = sqlite3OsSectorSize(pWal->pWalFd);
+    i64 iOffset = walFrameOffset(iFrame+1, szPage);
+
+    assert( isCommit );
+    assert( iSegment>0 );
+
+    iSegment = (((iOffset+iSegment-1)/iSegment) * iSegment);
+    while( iOffset<iSegment ){
+      void *pData;
+#if defined(SQLITE_HAS_CODEC)
+      if( (pData = sqlite3PagerCodec(pLast))==0 ) return SQLITE_NOMEM;
+#else
+      pData = pLast->pData;
+#endif
+      walEncodeFrame(pWal, pLast->pgno, nTruncate, pData, aFrame);
+      /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */
+      rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOffset);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+      iOffset += WAL_FRAME_HDRSIZE;
+      rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOffset); 
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+      nLast++;
+      iOffset += szPage;
+    }
+
+    rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
+  }
+
+  /* Append data to the wal-index. It is not necessary to lock the 
+  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index
+  ** guarantees that there are no other writers, and no data that may
+  ** be in use by existing readers is being overwritten.
+  */
+  iFrame = pWal->hdr.mxFrame;
+  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){
+    iFrame++;
+    rc = walIndexAppend(pWal, iFrame, p->pgno);
+  }
+  while( nLast>0 && rc==SQLITE_OK ){
+    iFrame++;
+    nLast--;
+    rc = walIndexAppend(pWal, iFrame, pLast->pgno);
+  }
+
+  if( rc==SQLITE_OK ){
+    /* Update the private copy of the header. */
+    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));
+    testcase( szPage<=32768 );
+    testcase( szPage>=65536 );
+    pWal->hdr.mxFrame = iFrame;
+    if( isCommit ){
+      pWal->hdr.iChange++;
+      pWal->hdr.nPage = nTruncate;
+    }
+    /* If this is a commit, update the wal-index header too. */
+    if( isCommit ){
+      walIndexWriteHdr(pWal);
+      pWal->iCallback = iFrame;
+    }
+  }
+
+  WALTRACE(("WAL%p: frame write %s\n", pWal, rc ? "failed" : "ok"));
+  return rc;
+}
+
+/* 
+** This routine is called to implement sqlite3_wal_checkpoint() and
+** related interfaces.
+**
+** Obtain a CHECKPOINT lock and then backfill as much information as
+** we can from WAL into the database.
+*/
+SQLITE_PRIVATE int sqlite3WalCheckpoint(
+  Wal *pWal,                      /* Wal connection */
+  int sync_flags,                 /* Flags to sync db file with (or 0) */
+  int nBuf,                       /* Size of temporary buffer */
+  u8 *zBuf                        /* Temporary buffer to use */
+){
+  int rc;                         /* Return code */
+  int isChanged = 0;              /* True if a new wal-index header is loaded */
+
+  assert( pWal->ckptLock==0 );
+
+  WALTRACE(("WAL%p: checkpoint begins\n", pWal));
+  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
+  if( rc ){
+    /* Usually this is SQLITE_BUSY meaning that another thread or process
+    ** is already running a checkpoint, or maybe a recovery.  But it might
+    ** also be SQLITE_IOERR. */
+    return rc;
+  }
+  pWal->ckptLock = 1;
+
+  /* Copy data from the log to the database file. */
+  rc = walIndexReadHdr(pWal, &isChanged);
+  if( rc==SQLITE_OK ){
+    rc = walCheckpoint(pWal, sync_flags, nBuf, zBuf);
+  }
+  if( isChanged ){
+    /* If a new wal-index header was loaded before the checkpoint was 
+    ** performed, then the pager-cache associated with pWal is now
+    ** out of date. So zero the cached wal-index header to ensure that
+    ** next time the pager opens a snapshot on this database it knows that
+    ** the cache needs to be reset.
+    */
+    memset(&pWal->hdr, 0, sizeof(WalIndexHdr));
+  }
+
+  /* Release the locks. */
+  walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);
+  pWal->ckptLock = 0;
+  WALTRACE(("WAL%p: checkpoint %s\n", pWal, rc ? "failed" : "ok"));
+  return rc;
+}
+
+/* Return the value to pass to a sqlite3_wal_hook callback, the
+** number of frames in the WAL at the point of the last commit since
+** sqlite3WalCallback() was called.  If no commits have occurred since
+** the last call, then return 0.
+*/
+SQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal){
+  u32 ret = 0;
+  if( pWal ){
+    ret = pWal->iCallback;
+    pWal->iCallback = 0;
+  }
+  return (int)ret;
+}
+
+/*
+** This function is called to change the WAL subsystem into or out
+** of locking_mode=EXCLUSIVE.
+**
+** If op is zero, then attempt to change from locking_mode=EXCLUSIVE
+** into locking_mode=NORMAL.  This means that we must acquire a lock
+** on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL
+** or if the acquisition of the lock fails, then return 0.  If the
+** transition out of exclusive-mode is successful, return 1.  This
+** operation must occur while the pager is still holding the exclusive
+** lock on the main database file.
+**
+** If op is one, then change from locking_mode=NORMAL into 
+** locking_mode=EXCLUSIVE.  This means that the pWal->readLock must
+** be released.  Return 1 if the transition is made and 0 if the
+** WAL is already in exclusive-locking mode - meaning that this
+** routine is a no-op.  The pager must already hold the exclusive lock
+** on the main database file before invoking this operation.
+**
+** If op is negative, then do a dry-run of the op==1 case but do
+** not actually change anything.  The pager uses this to see if it
+** should acquire the database exclusive lock prior to invoking
+** the op==1 case.
+*/
+SQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){
+  int rc;
+  assert( pWal->writeLock==0 );
+
+  /* pWal->readLock is usually set, but might be -1 if there was a 
+  ** prior error while attempting to acquire are read-lock. This cannot 
+  ** happen if the connection is actually in exclusive mode (as no xShmLock
+  ** locks are taken in this case). Nor should the pager attempt to
+  ** upgrade to exclusive-mode following such an error.
+  */
+  assert( pWal->readLock>=0 || pWal->lockError );
+  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );
+
+  if( op==0 ){
+    if( pWal->exclusiveMode ){
+      pWal->exclusiveMode = 0;
+      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){
+        pWal->exclusiveMode = 1;
+      }
+      rc = pWal->exclusiveMode==0;
+    }else{
+      /* Already in locking_mode=NORMAL */
+      rc = 0;
+    }
+  }else if( op>0 ){
+    assert( pWal->exclusiveMode==0 );
+    assert( pWal->readLock>=0 );
+    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));
+    pWal->exclusiveMode = 1;
+    rc = 1;
+  }else{
+    rc = pWal->exclusiveMode==0;
+  }
+  return rc;
+}
+
+#endif /* #ifndef SQLITE_OMIT_WAL */
+
+/************** End of wal.c *************************************************/
 /************** Begin file btmutex.c *****************************************/
 /*
 ** 2007 August 27
@@ -37621,7 +44017,7 @@ SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){
 **
 ** The file is divided into pages.  The first page is called page 1,
 ** the second is page 2, and so forth.  A page number of zero indicates
-** "no such page".  The page size can be any power of 2 between 512 and 32768.
+** "no such page".  The page size can be any power of 2 between 512 and 65536.
 ** Each page can be either a btree page, a freelist page, an overflow
 ** page, or a pointer-map page.
 **
@@ -37982,18 +44378,22 @@ struct BtShared {
   u8 readOnly;          /* True if the underlying file is readonly */
   u8 pageSizeFixed;     /* True if the page size can no longer be changed */
   u8 secureDelete;      /* True if secure_delete is enabled */
+  u8 initiallyEmpty;    /* Database is empty at start of transaction */
+  u8 openFlags;         /* Flags to sqlite3BtreeOpen() */
 #ifndef SQLITE_OMIT_AUTOVACUUM
   u8 autoVacuum;        /* True if auto-vacuum is enabled */
   u8 incrVacuum;        /* True if incr-vacuum is enabled */
 #endif
-  u16 pageSize;         /* Total number of bytes on a page */
-  u16 usableSize;       /* Number of usable bytes on each page */
   u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */
   u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */
   u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */
   u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */
   u8 inTransaction;     /* Transaction state */
+  u8 doNotUseWAL;       /* If true, do not open write-ahead-log file */
+  u32 pageSize;         /* Total number of bytes on a page */
+  u32 usableSize;       /* Number of usable bytes on each page */
   int nTransaction;     /* Number of open transactions (read + write) */
+  u32 nPage;            /* Number of pages in the database */
   void *pSchema;        /* Pointer to space allocated by sqlite3BtreeSchema() */
   void (*xFreeSchema)(void*);  /* Destructor for BtShared.pSchema */
   sqlite3_mutex *mutex; /* Non-recursive mutex required to access this struct */
@@ -38590,7 +44990,16 @@ int sqlite3BtreeTrace=1;  /* True to enable tracing */
 # define TRACE(X)
 #endif
 
-
+/*
+** Extract a 2-byte big-endian integer from an array of unsigned bytes.
+** But if the value is zero, make it 65536.
+**
+** This routine is used to extract the "offset to cell content area" value
+** from the header of a btree page.  If the page size is 65536 and the page
+** is empty, the offset should be 65536, but the 2-byte value stores zero.
+** This routine makes the necessary adjustment to 65536.
+*/
+#define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)
 
 #ifndef SQLITE_OMIT_SHARED_CACHE
 /*
@@ -39074,11 +45483,8 @@ static void invalidateIncrblobCursors(
 static int btreeSetHasContent(BtShared *pBt, Pgno pgno){
   int rc = SQLITE_OK;
   if( !pBt->pHasContent ){
-    int nPage = 100;
-    sqlite3PagerPagecount(pBt->pPager, &nPage);
-    /* If sqlite3PagerPagecount() fails there is no harm because the
-    ** nPage variable is unchanged from its default value of 100 */
-    pBt->pHasContent = sqlite3BitvecCreate((u32)nPage);
+    assert( pgno<=pBt->nPage );
+    pBt->pHasContent = sqlite3BitvecCreate(pBt->nPage);
     if( !pBt->pHasContent ){
       rc = SQLITE_NOMEM;
     }
@@ -39282,11 +45688,16 @@ SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){
 ** Given a page number of a regular database page, return the page
 ** number for the pointer-map page that contains the entry for the
 ** input page number.
+**
+** Return 0 (not a valid page) for pgno==1 since there is
+** no pointer map associated with page 1.  The integrity_check logic
+** requires that ptrmapPageno(*,1)!=1.
 */
 static Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){
   int nPagesPerMapPage;
   Pgno iPtrMap, ret;
   assert( sqlite3_mutex_held(pBt->mutex) );
+  if( pgno<2 ) return 0;
   nPagesPerMapPage = (pBt->usableSize/5)+1;
   iPtrMap = (pgno-2)/nPagesPerMapPage;
   ret = (iPtrMap*nPagesPerMapPage) + 2; 
@@ -39715,7 +46126,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   nFrag = data[hdr+7];
   assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );
   gap = pPage->cellOffset + 2*pPage->nCell;
-  top = get2byte(&data[hdr+5]);
+  top = get2byteNotZero(&data[hdr+5]);
   if( gap>top ) return SQLITE_CORRUPT_BKPT;
   testcase( gap+2==top );
   testcase( gap+1==top );
@@ -39725,7 +46136,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
     /* Always defragment highly fragmented pages */
     rc = defragmentPage(pPage);
     if( rc ) return rc;
-    top = get2byte(&data[hdr+5]);
+    top = get2byteNotZero(&data[hdr+5]);
   }else if( gap+2<=top ){
     /* Search the freelist looking for a free slot big enough to satisfy 
     ** the request. The allocation is made from the first free slot in 
@@ -39767,7 +46178,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
   if( gap+2+nByte>top ){
     rc = defragmentPage(pPage);
     if( rc ) return rc;
-    top = get2byte(&data[hdr+5]);
+    top = get2byteNotZero(&data[hdr+5]);
     assert( gap+nByte<=top );
   }
 
@@ -39933,10 +46344,10 @@ static int btreeInitPage(MemPage *pPage){
     u8 hdr;            /* Offset to beginning of page header */
     u8 *data;          /* Equal to pPage->aData */
     BtShared *pBt;        /* The main btree structure */
-    u16 usableSize;    /* Amount of usable space on each page */
+    int usableSize;    /* Amount of usable space on each page */
     u16 cellOffset;    /* Offset from start of page to first cell pointer */
-    u16 nFree;         /* Number of unused bytes on the page */
-    u16 top;           /* First byte of the cell content area */
+    int nFree;         /* Number of unused bytes on the page */
+    int top;           /* First byte of the cell content area */
     int iCellFirst;    /* First allowable cell or freeblock offset */
     int iCellLast;     /* Last possible cell or freeblock offset */
 
@@ -39945,12 +46356,12 @@ static int btreeInitPage(MemPage *pPage){
     hdr = pPage->hdrOffset;
     data = pPage->aData;
     if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;
-    assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
-    pPage->maskPage = pBt->pageSize - 1;
+    assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
+    pPage->maskPage = (u16)(pBt->pageSize - 1);
     pPage->nOverflow = 0;
     usableSize = pBt->usableSize;
     pPage->cellOffset = cellOffset = hdr + 12 - 4*pPage->leaf;
-    top = get2byte(&data[hdr+5]);
+    top = get2byteNotZero(&data[hdr+5]);
     pPage->nCell = get2byte(&data[hdr+3]);
     if( pPage->nCell>MX_CELL(pBt) ){
       /* To many cells for a single page.  The page must be corrupt */
@@ -40049,13 +46460,13 @@ static void zeroPage(MemPage *pPage, int flags){
   memset(&data[hdr+1], 0, 4);
   data[hdr+7] = 0;
   put2byte(&data[hdr+5], pBt->usableSize);
-  pPage->nFree = pBt->usableSize - first;
+  pPage->nFree = (u16)(pBt->usableSize - first);
   decodeFlags(pPage, flags);
   pPage->hdrOffset = hdr;
   pPage->cellOffset = first;
   pPage->nOverflow = 0;
-  assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
-  pPage->maskPage = pBt->pageSize - 1;
+  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
+  pPage->maskPage = (u16)(pBt->pageSize - 1);
   pPage->nCell = 0;
   pPage->isInit = 1;
 }
@@ -40121,13 +46532,13 @@ static MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){
 ** Return the size of the database file in pages. If there is any kind of
 ** error, return ((unsigned int)-1).
 */
-static Pgno pagerPagecount(BtShared *pBt){
-  int nPage = -1;
-  int rc;
-  assert( pBt->pPage1 );
-  rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
-  assert( rc==SQLITE_OK || nPage==-1 );
-  return (Pgno)nPage;
+static Pgno btreePagecount(BtShared *pBt){
+  return pBt->nPage;
+}
+SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){
+  assert( sqlite3BtreeHoldsMutex(p) );
+  assert( ((p->pBt->nPage)&0x8000000)==0 );
+  return (int)btreePagecount(p->pBt);
 }
 
 /*
@@ -40144,25 +46555,22 @@ static int getAndInitPage(
   MemPage **ppPage     /* Write the page pointer here */
 ){
   int rc;
-  TESTONLY( Pgno iLastPg = pagerPagecount(pBt); )
   assert( sqlite3_mutex_held(pBt->mutex) );
 
-  rc = btreeGetPage(pBt, pgno, ppPage, 0);
-  if( rc==SQLITE_OK ){
-    rc = btreeInitPage(*ppPage);
-    if( rc!=SQLITE_OK ){
-      releasePage(*ppPage);
+  if( pgno>btreePagecount(pBt) ){
+    rc = SQLITE_CORRUPT_BKPT;
+  }else{
+    rc = btreeGetPage(pBt, pgno, ppPage, 0);
+    if( rc==SQLITE_OK ){
+      rc = btreeInitPage(*ppPage);
+      if( rc!=SQLITE_OK ){
+        releasePage(*ppPage);
+      }
     }
   }
 
-  /* If the requested page number was either 0 or greater than the page
-  ** number of the last page in the database, this function should return
-  ** SQLITE_CORRUPT or some other error (i.e. SQLITE_FULL). Check that this
-  ** is the case.  */
-  assert( (pgno>0 && pgno<=iLastPg) || rc!=SQLITE_OK );
   testcase( pgno==0 );
-  testcase( pgno==iLastPg );
-
+  assert( pgno!=0 || rc==SQLITE_CORRUPT );
   return rc;
 }
 
@@ -40222,11 +46630,20 @@ static int btreeInvokeBusyHandler(void *pArg){
 ** Open a database file.
 ** 
 ** zFilename is the name of the database file.  If zFilename is NULL
-** a new database with a random name is created.  This randomly named
-** database file will be deleted when sqlite3BtreeClose() is called.
+** then an ephemeral database is created.  The ephemeral database might
+** be exclusively in memory, or it might use a disk-based memory cache.
+** Either way, the ephemeral database will be automatically deleted 
+** when sqlite3BtreeClose() is called.
+**
 ** If zFilename is ":memory:" then an in-memory database is created
 ** that is automatically destroyed when it is closed.
 **
+** The "flags" parameter is a bitmask that might contain bits
+** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK.  The BTREE_NO_READLOCK
+** bit is also set if the SQLITE_NoReadlock flags is set in db->flags.
+** These flags are passed through into sqlite3PagerOpen() and must
+** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK.
+**
 ** If the database is already opened in the same database connection
 ** and we are in shared cache mode, then the open will fail with an
 ** SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared
@@ -40248,6 +46665,9 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
   u8 nReserve;                   /* Byte of unused space on each page */
   unsigned char zDbHeader[100];  /* Database header content */
 
+  /* True if opening an ephemeral, temporary database */
+  const int isTempDb = zFilename==0 || zFilename[0]==0;
+
   /* Set the variable isMemdb to true for an in-memory database, or 
   ** false for a file-based database. This symbol is only required if
   ** either of the shared-data or autovacuum features are compiled 
@@ -40257,13 +46677,30 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
   #ifdef SQLITE_OMIT_MEMORYDB
     const int isMemdb = 0;
   #else
-    const int isMemdb = zFilename && !strcmp(zFilename, ":memory:");
+    const int isMemdb = (zFilename && strcmp(zFilename, ":memory:")==0)
+                         || (isTempDb && sqlite3TempInMemory(db));
   #endif
 #endif
 
   assert( db!=0 );
   assert( sqlite3_mutex_held(db->mutex) );
+  assert( (flags&0xff)==flags );   /* flags fit in 8 bits */
 
+  /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */
+  assert( (flags & BTREE_UNORDERED)==0 || (flags & BTREE_SINGLE)!=0 );
+
+  /* A BTREE_SINGLE database is always a temporary and/or ephemeral */
+  assert( (flags & BTREE_SINGLE)==0 || isTempDb );
+
+  if( db->flags & SQLITE_NoReadlock ){
+    flags |= BTREE_NO_READLOCK;
+  }
+  if( isMemdb ){
+    flags |= BTREE_MEMORY;
+  }
+  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){
+    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;
+  }
   pVfs = db->pVfs;
   p = sqlite3MallocZero(sizeof(Btree));
   if( !p ){
@@ -40281,7 +46718,7 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
   ** If this Btree is a candidate for shared cache, try to find an
   ** existing BtShared object that we can share with
   */
-  if( isMemdb==0 && zFilename && zFilename[0] ){
+  if( isMemdb==0 && isTempDb==0 ){
     if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
       int nFullPathname = pVfs->mxPathname+1;
       char *zFullPathname = sqlite3Malloc(nFullPathname);
@@ -40356,6 +46793,7 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
     if( rc!=SQLITE_OK ){
       goto btree_open_out;
     }
+    pBt->openFlags = (u8)flags;
     pBt->db = db;
     sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);
     p->pBt = pBt;
@@ -40366,7 +46804,7 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
 #ifdef SQLITE_SECURE_DELETE
     pBt->secureDelete = 1;
 #endif
-    pBt->pageSize = get2byte(&zDbHeader[16]);
+    pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);
     if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE
          || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){
       pBt->pageSize = 0;
@@ -40460,6 +46898,14 @@ btree_open_out:
     sqlite3_free(pBt);
     sqlite3_free(p);
     *ppBtree = 0;
+  }else{
+    /* If the B-Tree was successfully opened, set the pager-cache size to the
+    ** default value. Except, when opening on an existing shared pager-cache,
+    ** do not change the pager-cache size.
+    */
+    if( sqlite3BtreeSchema(p, 0, 0)==0 ){
+      sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);
+    }
   }
   if( mutexOpen ){
     assert( sqlite3_mutex_held(mutexOpen) );
@@ -40568,7 +47014,7 @@ SQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){
     if( pBt->xFreeSchema && pBt->pSchema ){
       pBt->xFreeSchema(pBt->pSchema);
     }
-    sqlite3_free(pBt->pSchema);
+    sqlite3DbFree(0, pBt->pSchema);
     freeTempSpace(pBt);
     sqlite3_free(pBt);
   }
@@ -40680,7 +47126,7 @@ SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve,
         ((pageSize-1)&pageSize)==0 ){
     assert( (pageSize & 7)==0 );
     assert( !pBt->pPage1 && !pBt->pCursor );
-    pBt->pageSize = (u16)pageSize;
+    pBt->pageSize = (u32)pageSize;
     freeTempSpace(pBt);
   }
   rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
@@ -40798,9 +47244,11 @@ SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){
 ** is returned if we run out of memory. 
 */
 static int lockBtree(BtShared *pBt){
-  int rc;
-  MemPage *pPage1;
-  int nPage;
+  int rc;              /* Result code from subfunctions */
+  MemPage *pPage1;     /* Page 1 of the database file */
+  int nPage;           /* Number of pages in the database */
+  int nPageFile = 0;   /* Number of pages in the database file */
+  int nPageHeader;     /* Number of pages in the database according to hdr */
 
   assert( sqlite3_mutex_held(pBt->mutex) );
   assert( pBt->pPage1==0 );
@@ -40812,23 +47260,55 @@ static int lockBtree(BtShared *pBt){
   /* Do some checking to help insure the file we opened really is
   ** a valid database file. 
   */
-  rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
-  if( rc!=SQLITE_OK ){
-    goto page1_init_failed;
-  }else if( nPage>0 ){
-    int pageSize;
-    int usableSize;
+  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
+  sqlite3PagerPagecount(pBt->pPager, &nPageFile);
+  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
+    nPage = nPageFile;
+  }
+  if( nPage>0 ){
+    u32 pageSize;
+    u32 usableSize;
     u8 *page1 = pPage1->aData;
     rc = SQLITE_NOTADB;
     if( memcmp(page1, zMagicHeader, 16)!=0 ){
       goto page1_init_failed;
     }
+
+#ifdef SQLITE_OMIT_WAL
     if( page1[18]>1 ){
       pBt->readOnly = 1;
     }
     if( page1[19]>1 ){
       goto page1_init_failed;
     }
+#else
+    if( page1[18]>2 ){
+      pBt->readOnly = 1;
+    }
+    if( page1[19]>2 ){
+      goto page1_init_failed;
+    }
+
+    /* If the write version is set to 2, this database should be accessed
+    ** in WAL mode. If the log is not already open, open it now. Then 
+    ** return SQLITE_OK and return without populating BtShared.pPage1.
+    ** The caller detects this and calls this function again. This is
+    ** required as the version of page 1 currently in the page1 buffer
+    ** may not be the latest version - there may be a newer one in the log
+    ** file.
+    */
+    if( page1[19]==2 && pBt->doNotUseWAL==0 ){
+      int isOpen = 0;
+      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
+      if( rc!=SQLITE_OK ){
+        goto page1_init_failed;
+      }else if( isOpen==0 ){
+        releasePage(pPage1);
+        return SQLITE_OK;
+      }
+      rc = SQLITE_NOTADB;
+    }
+#endif
 
     /* The maximum embedded fraction must be exactly 25%.  And the minimum
     ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data.
@@ -40838,15 +47318,16 @@ static int lockBtree(BtShared *pBt){
     if( memcmp(&page1[21], "\100\040\040",3)!=0 ){
       goto page1_init_failed;
     }
-    pageSize = get2byte(&page1[16]);
-    if( ((pageSize-1)&pageSize)!=0 || pageSize<512 ||
-        (SQLITE_MAX_PAGE_SIZE<32768 && pageSize>SQLITE_MAX_PAGE_SIZE)
+    pageSize = (page1[16]<<8) | (page1[17]<<16);
+    if( ((pageSize-1)&pageSize)!=0
+     || pageSize>SQLITE_MAX_PAGE_SIZE 
+     || pageSize<=256 
     ){
       goto page1_init_failed;
     }
     assert( (pageSize & 7)==0 );
     usableSize = pageSize - page1[20];
-    if( pageSize!=pBt->pageSize ){
+    if( (u32)pageSize!=pBt->pageSize ){
       /* After reading the first page of the database assuming a page size
       ** of BtShared.pageSize, we have discovered that the page-size is
       ** actually pageSize. Unlock the database, leave pBt->pPage1 at
@@ -40854,18 +47335,22 @@ static int lockBtree(BtShared *pBt){
       ** again with the correct page-size.
       */
       releasePage(pPage1);
-      pBt->usableSize = (u16)usableSize;
-      pBt->pageSize = (u16)pageSize;
+      pBt->usableSize = usableSize;
+      pBt->pageSize = pageSize;
       freeTempSpace(pBt);
       rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,
                                    pageSize-usableSize);
       return rc;
     }
+    if( nPageHeader>nPageFile ){
+      rc = SQLITE_CORRUPT_BKPT;
+      goto page1_init_failed;
+    }
     if( usableSize<480 ){
       goto page1_init_failed;
     }
-    pBt->pageSize = (u16)pageSize;
-    pBt->usableSize = (u16)usableSize;
+    pBt->pageSize = pageSize;
+    pBt->usableSize = usableSize;
 #ifndef SQLITE_OMIT_AUTOVACUUM
     pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);
     pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);
@@ -40881,16 +47366,17 @@ static int lockBtree(BtShared *pBt){
   **     9-byte nKey value
   **     4-byte nData value
   **     4-byte overflow page pointer
-  ** So a cell consists of a 2-byte poiner, a header which is as much as
+  ** So a cell consists of a 2-byte pointer, a header which is as much as
   ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow
   ** page pointer.
   */
-  pBt->maxLocal = (pBt->usableSize-12)*64/255 - 23;
-  pBt->minLocal = (pBt->usableSize-12)*32/255 - 23;
-  pBt->maxLeaf = pBt->usableSize - 35;
-  pBt->minLeaf = (pBt->usableSize-12)*32/255 - 23;
+  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);
+  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);
+  pBt->maxLeaf = (u16)(pBt->usableSize - 35);
+  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);
   assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );
   pBt->pPage1 = pPage1;
+  pBt->nPage = nPage;
   return SQLITE_OK;
 
 page1_init_failed:
@@ -40928,12 +47414,10 @@ static int newDatabase(BtShared *pBt){
   MemPage *pP1;
   unsigned char *data;
   int rc;
-  int nPage;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
-  rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
-  if( rc!=SQLITE_OK || nPage>0 ){
-    return rc;
+  if( pBt->nPage>0 ){
+    return SQLITE_OK;
   }
   pP1 = pBt->pPage1;
   assert( pP1!=0 );
@@ -40942,7 +47426,8 @@ static int newDatabase(BtShared *pBt){
   if( rc ) return rc;
   memcpy(data, zMagicHeader, sizeof(zMagicHeader));
   assert( sizeof(zMagicHeader)==16 );
-  put2byte(&data[16], pBt->pageSize);
+  data[16] = (u8)((pBt->pageSize>>8)&0xff);
+  data[17] = (u8)((pBt->pageSize>>16)&0xff);
   data[18] = 1;
   data[19] = 1;
   assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);
@@ -40959,6 +47444,8 @@ static int newDatabase(BtShared *pBt){
   put4byte(&data[36 + 4*4], pBt->autoVacuum);
   put4byte(&data[36 + 7*4], pBt->incrVacuum);
 #endif
+  pBt->nPage = 1;
+  data[31] = 1;
   return SQLITE_OK;
 }
 
@@ -41048,6 +47535,7 @@ SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
   rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);
   if( SQLITE_OK!=rc ) goto trans_begun;
 
+  pBt->initiallyEmpty = (u8)(pBt->nPage==0);
   do {
     /* Call lockBtree() until either pBt->pPage1 is populated or
     ** lockBtree() returns something other than SQLITE_OK. lockBtree()
@@ -41072,7 +47560,7 @@ SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
     if( rc!=SQLITE_OK ){
       unlockBtreeIfUnused(pBt);
     }
-  }while( rc==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
+  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&
           btreeInvokeBusyHandler(pBt) );
 
   if( rc==SQLITE_OK ){
@@ -41091,13 +47579,27 @@ SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
     if( p->inTrans>pBt->inTransaction ){
       pBt->inTransaction = p->inTrans;
     }
-#ifndef SQLITE_OMIT_SHARED_CACHE
     if( wrflag ){
+      MemPage *pPage1 = pBt->pPage1;
+#ifndef SQLITE_OMIT_SHARED_CACHE
       assert( !pBt->pWriter );
       pBt->pWriter = p;
       pBt->isExclusive = (u8)(wrflag>1);
-    }
 #endif
+
+      /* If the db-size header field is incorrect (as it may be if an old
+      ** client has been writing the database file), update it now. Doing
+      ** this sooner rather than later means the database size can safely 
+      ** re-read the database size from page 1 if a savepoint or transaction
+      ** rollback occurs within the transaction.
+      */
+      if( pBt->nPage!=get4byte(&pPage1->aData[28]) ){
+        rc = sqlite3PagerWrite(pPage1->pDbPage);
+        if( rc==SQLITE_OK ){
+          put4byte(&pPage1->aData[28], pBt->nPage);
+        }
+      }
+    }
   }
 
 
@@ -41327,12 +47829,12 @@ static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
 */
 static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
   Pgno nFreeList;           /* Number of pages still on the free-list */
+  int rc;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
   assert( iLastPg>nFin );
 
   if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){
-    int rc;
     u8 eType;
     Pgno iPtrPage;
 
@@ -41408,7 +47910,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
     while( iLastPg==PENDING_BYTE_PAGE(pBt)||PTRMAP_ISPAGE(pBt, iLastPg) ){
       if( PTRMAP_ISPAGE(pBt, iLastPg) ){
         MemPage *pPg;
-        int rc = btreeGetPage(pBt, iLastPg, &pPg, 0);
+        rc = btreeGetPage(pBt, iLastPg, &pPg, 0);
         if( rc!=SQLITE_OK ){
           return rc;
         }
@@ -41421,6 +47923,7 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg){
       iLastPg--;
     }
     sqlite3PagerTruncateImage(pBt->pPager, iLastPg);
+    pBt->nPage = iLastPg;
   }
   return SQLITE_OK;
 }
@@ -41443,7 +47946,11 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
     rc = SQLITE_DONE;
   }else{
     invalidateAllOverflowCache(pBt);
-    rc = incrVacuumStep(pBt, 0, pagerPagecount(pBt));
+    rc = incrVacuumStep(pBt, 0, btreePagecount(pBt));
+    if( rc==SQLITE_OK ){
+      rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
+      put4byte(&pBt->pPage1->aData[28], pBt->nPage);
+    }
   }
   sqlite3BtreeLeave(p);
   return rc;
@@ -41474,7 +47981,7 @@ static int autoVacuumCommit(BtShared *pBt){
     int nEntry;        /* Number of entries on one ptrmap page */
     Pgno nOrig;        /* Database size before freeing */
 
-    nOrig = pagerPagecount(pBt);
+    nOrig = btreePagecount(pBt);
     if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){
       /* It is not possible to create a database for which the final page
       ** is either a pointer-map page or the pending-byte page. If one
@@ -41499,11 +48006,12 @@ static int autoVacuumCommit(BtShared *pBt){
       rc = incrVacuumStep(pBt, nFin, iFree);
     }
     if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){
-      rc = SQLITE_OK;
       rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
       put4byte(&pBt->pPage1->aData[32], 0);
       put4byte(&pBt->pPage1->aData[36], 0);
+      put4byte(&pBt->pPage1->aData[28], nFin);
       sqlite3PagerTruncateImage(pBt->pPager, nFin);
+      pBt->nPage = nFin;
     }
     if( rc!=SQLITE_OK ){
       sqlite3PagerRollback(pPager);
@@ -41753,6 +48261,11 @@ SQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p){
     ** call btreeGetPage() on page 1 again to make
     ** sure pPage1->aData is set correctly. */
     if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){
+      int nPage = get4byte(28+(u8*)pPage1->aData);
+      testcase( nPage==0 );
+      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
+      testcase( pBt->nPage!=nPage );
+      pBt->nPage = nPage;
       releasePage(pPage1);
     }
     assert( countWriteCursors(pBt)==0 );
@@ -41790,17 +48303,13 @@ SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
   assert( pBt->readOnly==0 );
   assert( iStatement>0 );
   assert( iStatement>p->db->nSavepoint );
-  if( NEVER(p->inTrans!=TRANS_WRITE || pBt->readOnly) ){
-    rc = SQLITE_INTERNAL;
-  }else{
-    assert( pBt->inTransaction==TRANS_WRITE );
-    /* At the pager level, a statement transaction is a savepoint with
-    ** an index greater than all savepoints created explicitly using
-    ** SQL statements. It is illegal to open, release or rollback any
-    ** such savepoints while the statement transaction savepoint is active.
-    */
-    rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);
-  }
+  assert( pBt->inTransaction==TRANS_WRITE );
+  /* At the pager level, a statement transaction is a savepoint with
+  ** an index greater than all savepoints created explicitly using
+  ** SQL statements. It is illegal to open, release or rollback any
+  ** such savepoints while the statement transaction savepoint is active.
+  */
+  rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);
   sqlite3BtreeLeave(p);
   return rc;
 }
@@ -41826,7 +48335,14 @@ SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
     sqlite3BtreeEnter(p);
     rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
     if( rc==SQLITE_OK ){
+      if( iSavepoint<0 && pBt->initiallyEmpty ) pBt->nPage = 0;
       rc = newDatabase(pBt);
+      pBt->nPage = get4byte(28 + pBt->pPage1->aData);
+
+      /* The database size was written into the offset 28 of the header
+      ** when the transaction started, so we know that the value at offset
+      ** 28 is nonzero. */
+      assert( pBt->nPage>0 );
     }
     sqlite3BtreeLeave(p);
   }
@@ -41892,7 +48408,7 @@ static int btreeCursor(
   if( NEVER(wrFlag && pBt->readOnly) ){
     return SQLITE_READONLY;
   }
-  if( iTable==1 && pagerPagecount(pBt)==0 ){
+  if( iTable==1 && btreePagecount(pBt)==0 ){
     return SQLITE_EMPTY;
   }
 
@@ -42163,7 +48679,7 @@ static int getOverflowPage(
       iGuess++;
     }
 
-    if( iGuess<=pagerPagecount(pBt) ){
+    if( iGuess<=btreePagecount(pBt) ){
       rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
       if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
         next = iGuess;
@@ -42758,7 +49274,6 @@ SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
     if( pCur->eState==CURSOR_INVALID ){
       assert( pCur->apPage[pCur->iPage]->nCell==0 );
       *pRes = 1;
-      rc = SQLITE_OK;
     }else{
       assert( pCur->apPage[pCur->iPage]->nCell>0 );
       *pRes = 0;
@@ -42923,9 +49438,9 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
         pCur->validNKey = 1;
         pCur->info.nKey = nCellKey;
       }else{
-        /* The maximum supported page-size is 32768 bytes. This means that
+        /* The maximum supported page-size is 65536 bytes. This means that
         ** the maximum number of record bytes stored on an index B-Tree
-        ** page is at most 8198 bytes, which may be stored as a 2-byte
+        ** page is less than 16384 bytes and may be stored as a 2-byte
         ** varint. This information is used to attempt to avoid parsing 
         ** the entire cell by checking for the cases where the record is 
         ** stored entirely within the b-tree page by inspecting the first 
@@ -43195,7 +49710,7 @@ static int allocateBtreePage(
 
   assert( sqlite3_mutex_held(pBt->mutex) );
   pPage1 = pBt->pPage1;
-  mxPage = pagerPagecount(pBt);
+  mxPage = btreePagecount(pBt);
   n = get4byte(&pPage1->aData[36]);
   testcase( n==mxPage-1 );
   if( n>=mxPage ){
@@ -43288,6 +49803,10 @@ static int allocateBtreePage(
           if( !pPrevTrunk ){
             memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);
           }else{
+            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);
+            if( rc!=SQLITE_OK ){
+              goto end_allocate_page;
+            }
             memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);
           }
         }else{
@@ -43391,35 +49910,35 @@ static int allocateBtreePage(
   }else{
     /* There are no pages on the freelist, so create a new page at the
     ** end of the file */
-    int nPage = pagerPagecount(pBt);
-    *pPgno = nPage + 1;
-
-    if( *pPgno==PENDING_BYTE_PAGE(pBt) ){
-      (*pPgno)++;
-    }
+    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
+    if( rc ) return rc;
+    pBt->nPage++;
+    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;
 
 #ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
+    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){
       /* If *pPgno refers to a pointer-map page, allocate two new pages
       ** at the end of the file instead of one. The first allocated page
       ** becomes a new pointer-map page, the second is used by the caller.
       */
       MemPage *pPg = 0;
-      TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", *pPgno));
-      assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
-      rc = btreeGetPage(pBt, *pPgno, &pPg, 0);
+      TRACE(("ALLOCATE: %d from end of file (pointer-map page)\n", pBt->nPage));
+      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );
+      rc = btreeGetPage(pBt, pBt->nPage, &pPg, 1);
       if( rc==SQLITE_OK ){
         rc = sqlite3PagerWrite(pPg->pDbPage);
         releasePage(pPg);
       }
       if( rc ) return rc;
-      (*pPgno)++;
-      if( *pPgno==PENDING_BYTE_PAGE(pBt) ){ (*pPgno)++; }
+      pBt->nPage++;
+      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }
     }
 #endif
+    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);
+    *pPgno = pBt->nPage;
 
     assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
-    rc = btreeGetPage(pBt, *pPgno, ppPage, 0);
+    rc = btreeGetPage(pBt, *pPgno, ppPage, 1);
     if( rc ) return rc;
     rc = sqlite3PagerWrite((*ppPage)->pDbPage);
     if( rc!=SQLITE_OK ){
@@ -43594,7 +50113,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
   Pgno ovflPgno;
   int rc;
   int nOvfl;
-  u16 ovflPageSize;
+  u32 ovflPageSize;
 
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
   btreeParseCellPtr(pPage, pCell, &info);
@@ -43609,7 +50128,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
   while( nOvfl-- ){
     Pgno iNext = 0;
     MemPage *pOvfl = 0;
-    if( ovflPgno<2 || ovflPgno>pagerPagecount(pBt) ){
+    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){
       /* 0 is not a legal page number and page 1 cannot be an 
       ** overflow page. Therefore if ovflPgno<2 or past the end of the 
       ** file the database must be corrupt. */
@@ -43819,7 +50338,7 @@ static int fillInCell(
 */
 static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
   int i;          /* Loop counter */
-  int pc;         /* Offset to cell content of cell being deleted */
+  u32 pc;         /* Offset to cell content of cell being deleted */
   u8 *data;       /* pPage->aData */
   u8 *ptr;        /* Used to move bytes around within data[] */
   int rc;         /* The return code */
@@ -43837,7 +50356,7 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
   hdr = pPage->hdrOffset;
   testcase( pc==get2byte(&data[hdr+5]) );
   testcase( pc+sz==pPage->pBt->usableSize );
-  if( pc < get2byte(&data[hdr+5]) || pc+sz > pPage->pBt->usableSize ){
+  if( pc < (u32)get2byte(&data[hdr+5]) || pc+sz > pPage->pBt->usableSize ){
     *pRC = SQLITE_CORRUPT_BKPT;
     return;
   }
@@ -43894,7 +50413,7 @@ static void insertCell(
   if( *pRC ) return;
 
   assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
-  assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
+  assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=10921 );
   assert( pPage->nOverflow<=ArraySize(pPage->aOvfl) );
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
   /* The cell should normally be sized correctly.  However, when moving a
@@ -43974,12 +50493,12 @@ static void assemblePage(
 
   assert( pPage->nOverflow==0 );
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
-  assert( nCell>=0 && nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
+  assert( nCell>=0 && nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=10921);
   assert( sqlite3PagerIswriteable(pPage->pDbPage) );
 
   /* Check that the page has just been zeroed by zeroPage() */
   assert( pPage->nCell==0 );
-  assert( get2byte(&data[hdr+5])==nUsable );
+  assert( get2byteNotZero(&data[hdr+5])==nUsable );
 
   pCellptr = &data[pPage->cellOffset + nCell*2];
   cellbody = nUsable;
@@ -44045,6 +50564,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
   assert( sqlite3PagerIswriteable(pParent->pDbPage) );
   assert( pPage->nOverflow==1 );
 
+  /* This error condition is now caught prior to reaching this function */
   if( pPage->nCell<=0 ) return SQLITE_CORRUPT_BKPT;
 
   /* Allocate a new page. This page will become the right-sibling of 
@@ -44374,7 +50894,7 @@ static int balance_nonroot(
       ** is allocated.  */
       if( pBt->secureDelete ){
         int iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
-        if( (iOff+szNew[i])>pBt->usableSize ){
+        if( (iOff+szNew[i])>(int)pBt->usableSize ){
           rc = SQLITE_CORRUPT_BKPT;
           memset(apOld, 0, (i+1)*sizeof(MemPage*));
           goto balance_cleanup;
@@ -44453,7 +50973,7 @@ static int balance_nonroot(
       szCell[nCell] = sz;
       pTemp = &aSpace1[iSpace1];
       iSpace1 += sz;
-      assert( sz<=pBt->pageSize/4 );
+      assert( sz<=pBt->maxLocal+23 );
       assert( iSpace1<=pBt->pageSize );
       memcpy(pTemp, apDiv[i], sz);
       apCell[nCell] = pTemp+leafCorrection;
@@ -44699,7 +51219,7 @@ static int balance_nonroot(
         }
       }
       iOvflSpace += sz;
-      assert( sz<=pBt->pageSize/4 );
+      assert( sz<=pBt->maxLocal+23 );
       assert( iOvflSpace<=pBt->pageSize );
       insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew->pgno, &rc);
       if( rc!=SQLITE_OK ) goto balance_cleanup;
@@ -45336,11 +51856,12 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur){
 **     BTREE_INTKEY|BTREE_LEAFDATA     Used for SQL tables with rowid keys
 **     BTREE_ZERODATA                  Used for SQL indices
 */
-static int btreeCreateTable(Btree *p, int *piTable, int flags){
+static int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){
   BtShared *pBt = p->pBt;
   MemPage *pRoot;
   Pgno pgnoRoot;
   int rc;
+  int ptfFlags;          /* Page-type flage for the root page of new table */
 
   assert( sqlite3BtreeHoldsMutex(p) );
   assert( pBt->inTransaction==TRANS_WRITE );
@@ -45441,8 +51962,14 @@ static int btreeCreateTable(Btree *p, int *piTable, int flags){
       releasePage(pRoot);
       return rc;
     }
+
+    /* When the new root page was allocated, page 1 was made writable in
+    ** order either to increase the database filesize, or to decrement the
+    ** freelist count.  Hence, the sqlite3BtreeUpdateMeta() call cannot fail.
+    */
+    assert( sqlite3PagerIswriteable(pBt->pPage1->pDbPage) );
     rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);
-    if( rc ){
+    if( NEVER(rc) ){
       releasePage(pRoot);
       return rc;
     }
@@ -45453,8 +51980,14 @@ static int btreeCreateTable(Btree *p, int *piTable, int flags){
   }
 #endif
   assert( sqlite3PagerIswriteable(pRoot->pDbPage) );
-  zeroPage(pRoot, flags | PTF_LEAF);
+  if( createTabFlags & BTREE_INTKEY ){
+    ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF;
+  }else{
+    ptfFlags = PTF_ZERODATA | PTF_LEAF;
+  }
+  zeroPage(pRoot, ptfFlags);
   sqlite3PagerUnref(pRoot->pDbPage);
+  assert( (pBt->openFlags & BTREE_SINGLE)==0 || pgnoRoot==2 );
   *piTable = (int)pgnoRoot;
   return SQLITE_OK;
 }
@@ -45482,7 +52015,7 @@ static int clearDatabasePage(
   int i;
 
   assert( sqlite3_mutex_held(pBt->mutex) );
-  if( pgno>pagerPagecount(pBt) ){
+  if( pgno>btreePagecount(pBt) ){
     return SQLITE_CORRUPT_BKPT;
   }
 
@@ -45937,7 +52470,7 @@ static void checkList(
         checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0, zContext);
       }
 #endif
-      if( n>pCheck->pBt->usableSize/4-2 ){
+      if( n>(int)pCheck->pBt->usableSize/4-2 ){
         checkAppendMsg(pCheck, zContext,
            "freelist leaf count too big on page %d", iPage);
         N--;
@@ -46148,7 +52681,7 @@ static int checkTreePage(
   if( hit==0 ){
     pCheck->mallocFailed = 1;
   }else{
-    u16 contentOffset = get2byte(&data[hdr+5]);
+    int contentOffset = get2byteNotZero(&data[hdr+5]);
     assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */
     memset(hit+contentOffset, 0, usableSize-contentOffset);
     memset(hit, 1, contentOffset);
@@ -46156,12 +52689,12 @@ static int checkTreePage(
     cellStart = hdr + 12 - 4*pPage->leaf;
     for(i=0; i<nCell; i++){
       int pc = get2byte(&data[cellStart+i*2]);
-      u16 size = 1024;
+      u32 size = 65536;
       int j;
       if( pc<=usableSize-4 ){
         size = cellSizePtr(pPage, &data[pc]);
       }
-      if( (pc+size-1)>=usableSize ){
+      if( (int)(pc+size-1)>=usableSize ){
         checkAppendMsg(pCheck, 0, 
             "Corruption detected in cell %d on page %d",i,iPage);
       }else{
@@ -46233,7 +52766,7 @@ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
   nRef = sqlite3PagerRefcount(pBt->pPager);
   sCheck.pBt = pBt;
   sCheck.pPager = pBt->pPager;
-  sCheck.nPage = pagerPagecount(sCheck.pBt);
+  sCheck.nPage = btreePagecount(sCheck.pBt);
   sCheck.mxErr = mxErr;
   sCheck.nErr = 0;
   sCheck.mallocFailed = 0;
@@ -46254,6 +52787,7 @@ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
     sCheck.anRef[i] = 1;
   }
   sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), 20000);
+  sCheck.errMsg.useMalloc = 2;
 
   /* Check the integrity of the freelist
   */
@@ -46352,6 +52886,29 @@ SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree *p){
   return (p && (p->inTrans==TRANS_WRITE));
 }
 
+#ifndef SQLITE_OMIT_WAL
+/*
+** Run a checkpoint on the Btree passed as the first argument.
+**
+** Return SQLITE_LOCKED if this or any other connection has an open 
+** transaction on the shared-cache the argument Btree is connected to.
+*/
+SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p){
+  int rc = SQLITE_OK;
+  if( p ){
+    BtShared *pBt = p->pBt;
+    sqlite3BtreeEnter(p);
+    if( pBt->inTransaction!=TRANS_NONE ){
+      rc = SQLITE_LOCKED;
+    }else{
+      rc = sqlite3PagerCheckpoint(pBt->pPager);
+    }
+    sqlite3BtreeLeave(p);
+  }
+  return rc;
+}
+#endif
+
 /*
 ** Return non-zero if a read (or write) transaction is active.
 */
@@ -46391,7 +52948,7 @@ SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void
   BtShared *pBt = p->pBt;
   sqlite3BtreeEnter(p);
   if( !pBt->pSchema && nBytes ){
-    pBt->pSchema = sqlite3MallocZero(nBytes);
+    pBt->pSchema = sqlite3DbMallocZero(0, nBytes);
     pBt->xFreeSchema = xFree;
   }
   sqlite3BtreeLeave(p);
@@ -46502,6 +53059,42 @@ SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *pCur){
 }
 #endif
 
+/*
+** Set both the "read version" (single byte at byte offset 18) and 
+** "write version" (single byte at byte offset 19) fields in the database
+** header to iVersion.
+*/
+SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
+  BtShared *pBt = pBtree->pBt;
+  int rc;                         /* Return code */
+ 
+  assert( pBtree->inTrans==TRANS_NONE );
+  assert( iVersion==1 || iVersion==2 );
+
+  /* If setting the version fields to 1, do not automatically open the
+  ** WAL connection, even if the version fields are currently set to 2.
+  */
+  pBt->doNotUseWAL = (u8)(iVersion==1);
+
+  rc = sqlite3BtreeBeginTrans(pBtree, 0);
+  if( rc==SQLITE_OK ){
+    u8 *aData = pBt->pPage1->aData;
+    if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){
+      rc = sqlite3BtreeBeginTrans(pBtree, 2);
+      if( rc==SQLITE_OK ){
+        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);
+        if( rc==SQLITE_OK ){
+          aData[18] = (u8)iVersion;
+          aData[19] = (u8)iVersion;
+        }
+      }
+    }
+  }
+
+  pBt->doNotUseWAL = 0;
+  return rc;
+}
+
 /************** End of btree.c ***********************************************/
 /************** Begin file backup.c ******************************************/
 /*
@@ -46654,7 +53247,10 @@ SQLITE_API sqlite3_backup *sqlite3_backup_init(
     );
     p = 0;
   }else {
-    /* Allocate space for a new sqlite3_backup object */
+    /* Allocate space for a new sqlite3_backup object...
+    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a
+    ** call to sqlite3_backup_init() and is destroyed by a call to
+    ** sqlite3_backup_finish(). */
     p = (sqlite3_backup *)sqlite3_malloc(sizeof(sqlite3_backup));
     if( !p ){
       sqlite3Error(pDestDb, SQLITE_NOMEM, 0);
@@ -46721,10 +53317,19 @@ static int backupOnePage(sqlite3_backup *p, Pgno iSrcPg, const u8 *zSrcData){
   /* Catch the case where the destination is an in-memory database and the
   ** page sizes of the source and destination differ. 
   */
-  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(sqlite3BtreePager(p->pDest)) ){
+  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){
     rc = SQLITE_READONLY;
   }
 
+#ifdef SQLITE_HAS_CODEC
+  /* Backup is not possible if the page size of the destination is changing
+  ** a a codec is in use.
+  */
+  if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){
+    rc = SQLITE_READONLY;
+  }
+#endif
+
   /* This loop runs once for each destination page spanned by the source 
   ** page. For each iteration, variable iOff is set to the byte offset
   ** of the destination page.
@@ -46791,6 +53396,9 @@ static void attachBackupObject(sqlite3_backup *p){
 */
 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
   int rc;
+  int destMode;       /* Destination journal mode */
+  int pgszSrc = 0;    /* Source page size */
+  int pgszDest = 0;   /* Destination page size */
 
   sqlite3_mutex_enter(p->pSrcDb->mutex);
   sqlite3BtreeEnter(p->pSrc);
@@ -46831,13 +53439,21 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
       rc = sqlite3BtreeBeginTrans(p->pSrc, 0);
       bCloseTrans = 1;
     }
+
+    /* Do not allow backup if the destination database is in WAL mode
+    ** and the page sizes are different between source and destination */
+    pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);
+    pgszDest = sqlite3BtreeGetPageSize(p->pDest);
+    destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));
+    if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){
+      rc = SQLITE_READONLY;
+    }
   
     /* Now that there is a read-lock on the source database, query the
     ** source pager for the number of pages in the database.
     */
-    if( rc==SQLITE_OK ){
-      rc = sqlite3PagerPagecount(pSrcPager, &nSrcPage);
-    }
+    nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);
+    assert( nSrcPage>=0 );
     for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){
       const Pgno iSrcPg = p->iNext;                 /* Source page number */
       if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){
@@ -46868,8 +53484,6 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
     if( rc==SQLITE_DONE 
      && (rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1))==SQLITE_OK
     ){
-      const int nSrcPagesize = sqlite3BtreeGetPageSize(p->pSrc);
-      const int nDestPagesize = sqlite3BtreeGetPageSize(p->pDest);
       int nDestTruncate;
   
       if( p->pDestDb ){
@@ -46888,18 +53502,20 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
       ** journalled by PagerCommitPhaseOne() before they are destroyed
       ** by the file truncation.
       */
-      if( nSrcPagesize<nDestPagesize ){
-        int ratio = nDestPagesize/nSrcPagesize;
+      assert( pgszSrc==sqlite3BtreeGetPageSize(p->pSrc) );
+      assert( pgszDest==sqlite3BtreeGetPageSize(p->pDest) );
+      if( pgszSrc<pgszDest ){
+        int ratio = pgszDest/pgszSrc;
         nDestTruncate = (nSrcPage+ratio-1)/ratio;
         if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){
           nDestTruncate--;
         }
       }else{
-        nDestTruncate = nSrcPage * (nSrcPagesize/nDestPagesize);
+        nDestTruncate = nSrcPage * (pgszSrc/pgszDest);
       }
       sqlite3PagerTruncateImage(pDestPager, nDestTruncate);
 
-      if( nSrcPagesize<nDestPagesize ){
+      if( pgszSrc<pgszDest ){
         /* If the source page-size is smaller than the destination page-size,
         ** two extra things may need to happen:
         **
@@ -46909,31 +53525,31 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
         **     pending-byte page in the source database may need to be
         **     copied into the destination database.
         */
-        const i64 iSize = (i64)nSrcPagesize * (i64)nSrcPage;
+        const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;
         sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
 
         assert( pFile );
-        assert( (i64)nDestTruncate*(i64)nDestPagesize >= iSize || (
+        assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || (
               nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
-           && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+nDestPagesize
+           && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
         ));
         if( SQLITE_OK==(rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1))
          && SQLITE_OK==(rc = backupTruncateFile(pFile, iSize))
          && SQLITE_OK==(rc = sqlite3PagerSync(pDestPager))
         ){
           i64 iOff;
-          i64 iEnd = MIN(PENDING_BYTE + nDestPagesize, iSize);
+          i64 iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
           for(
-            iOff=PENDING_BYTE+nSrcPagesize; 
+            iOff=PENDING_BYTE+pgszSrc; 
             rc==SQLITE_OK && iOff<iEnd; 
-            iOff+=nSrcPagesize
+            iOff+=pgszSrc
           ){
             PgHdr *pSrcPg = 0;
-            const Pgno iSrcPg = (Pgno)((iOff/nSrcPagesize)+1);
+            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);
             rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
             if( rc==SQLITE_OK ){
               u8 *zData = sqlite3PagerGetData(pSrcPg);
-              rc = sqlite3OsWrite(pFile, zData, nSrcPagesize, iOff);
+              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
             }
             sqlite3PagerUnref(pSrcPg);
           }
@@ -46962,6 +53578,9 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
       assert( rc2==SQLITE_OK );
     }
   
+    if( rc==SQLITE_IOERR_NOMEM ){
+      rc = SQLITE_NOMEM;
+    }
     p->rc = rc;
   }
   if( p->pDestDb ){
@@ -47014,6 +53633,9 @@ SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
   }
   sqlite3BtreeLeave(p->pSrc);
   if( p->pDestDb ){
+    /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a
+    ** call to sqlite3_backup_init() and is destroyed by a call to
+    ** sqlite3_backup_finish(). */
     sqlite3_free(p);
   }
   sqlite3_mutex_leave(mutex);
@@ -47265,6 +53887,9 @@ SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){
     pMem->z[pMem->n] = 0;
     pMem->z[pMem->n+1] = 0;
     pMem->flags |= MEM_Term;
+#ifdef SQLITE_DEBUG
+    pMem->pScopyFrom = 0;
+#endif
   }
 
   return SQLITE_OK;
@@ -47385,7 +54010,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
     ctx.s.db = pMem->db;
     ctx.pMem = pMem;
     ctx.pFunc = pFunc;
-    pFunc->xFinalize(&ctx);
+    pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */
     assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel );
     sqlite3DbFree(pMem->db, pMem->zMalloc);
     memcpy(pMem, &ctx.s, sizeof(ctx.s));
@@ -47498,13 +54123,9 @@ SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
     return doubleToInt64(pMem->r);
   }else if( flags & (MEM_Str|MEM_Blob) ){
     i64 value;
-    pMem->flags |= MEM_Str;
-    if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
-       || sqlite3VdbeMemNulTerminate(pMem) ){
-      return 0;
-    }
-    assert( pMem->z );
-    sqlite3Atoi64(pMem->z, &value);
+    assert( pMem->z || pMem->n==0 );
+    testcase( pMem->z==0 );
+    sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
     return value;
   }else{
     return 0;
@@ -47527,14 +54148,7 @@ SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){
   }else if( pMem->flags & (MEM_Str|MEM_Blob) ){
     /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
     double val = (double)0;
-    pMem->flags |= MEM_Str;
-    if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
-       || sqlite3VdbeMemNulTerminate(pMem) ){
-      /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
-      return (double)0;
-    }
-    assert( pMem->z );
-    sqlite3AtoF(pMem->z, &val);
+    sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
     return val;
   }else{
     /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
@@ -47607,21 +54221,19 @@ SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){
 ** as much of the string as we can and ignore the rest.
 */
 SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){
-  int rc;
-  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 );
-  assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
-  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
-  rc = sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8);
-  if( rc ) return rc;
-  rc = sqlite3VdbeMemNulTerminate(pMem);
-  if( rc ) return rc;
-  if( sqlite3Atoi64(pMem->z, &pMem->u.i) ){
-    MemSetTypeFlag(pMem, MEM_Int);
-  }else{
-    pMem->r = sqlite3VdbeRealValue(pMem);
-    MemSetTypeFlag(pMem, MEM_Real);
-    sqlite3VdbeIntegerAffinity(pMem);
+  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){
+    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );
+    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
+    if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){
+      MemSetTypeFlag(pMem, MEM_Int);
+    }else{
+      pMem->r = sqlite3VdbeRealValue(pMem);
+      MemSetTypeFlag(pMem, MEM_Real);
+      sqlite3VdbeIntegerAffinity(pMem);
+    }
   }
+  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );
+  pMem->flags &= ~(MEM_Str|MEM_Blob);
   return SQLITE_OK;
 }
 
@@ -47726,6 +54338,28 @@ SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){
   return 0; 
 }
 
+#ifdef SQLITE_DEBUG
+/*
+** This routine prepares a memory cell for modication by breaking
+** its link to a shallow copy and by marking any current shallow
+** copies of this cell as invalid.
+**
+** This is used for testing and debugging only - to make sure shallow
+** copies are not misused.
+*/
+SQLITE_PRIVATE void sqlite3VdbeMemPrepareToChange(Vdbe *pVdbe, Mem *pMem){
+  int i;
+  Mem *pX;
+  for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){
+    if( pX->pScopyFrom==pMem ){
+      pX->flags |= MEM_Invalid;
+      pX->pScopyFrom = 0;
+    }
+  }
+  pMem->pScopyFrom = 0;
+}
+#endif /* SQLITE_DEBUG */
+
 /*
 ** Size of struct Mem not including the Mem.zMalloc member.
 */
@@ -48094,7 +54728,7 @@ SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
         return 0;
       }
     }
-    sqlite3VdbeMemNulTerminate(pVal);
+    sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */
   }else{
     assert( (pVal->flags&MEM_Blob)==0 );
     sqlite3VdbeMemStringify(pVal, enc);
@@ -48142,23 +54776,43 @@ SQLITE_PRIVATE int sqlite3ValueFromExpr(
   int op;
   char *zVal = 0;
   sqlite3_value *pVal = 0;
+  int negInt = 1;
+  const char *zNeg = "";
 
   if( !pExpr ){
     *ppVal = 0;
     return SQLITE_OK;
   }
   op = pExpr->op;
-  if( op==TK_REGISTER ){
-    op = pExpr->op2;  /* This only happens with SQLITE_ENABLE_STAT2 */
+
+  /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2.
+  ** The ifdef here is to enable us to achieve 100% branch test coverage even
+  ** when SQLITE_ENABLE_STAT2 is omitted.
+  */
+#ifdef SQLITE_ENABLE_STAT2
+  if( op==TK_REGISTER ) op = pExpr->op2;
+#else
+  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
+#endif
+
+  /* Handle negative integers in a single step.  This is needed in the
+  ** case when the value is -9223372036854775808.
+  */
+  if( op==TK_UMINUS
+   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){
+    pExpr = pExpr->pLeft;
+    op = pExpr->op;
+    negInt = -1;
+    zNeg = "-";
   }
 
   if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){
     pVal = sqlite3ValueNew(db);
     if( pVal==0 ) goto no_mem;
     if( ExprHasProperty(pExpr, EP_IntValue) ){
-      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue);
+      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);
     }else{
-      zVal = sqlite3DbStrDup(db, pExpr->u.zToken);
+      zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken);
       if( zVal==0 ) goto no_mem;
       sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);
       if( op==TK_FLOAT ) pVal->type = SQLITE_FLOAT;
@@ -48168,14 +54822,18 @@ SQLITE_PRIVATE int sqlite3ValueFromExpr(
     }else{
       sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);
     }
+    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;
     if( enc!=SQLITE_UTF8 ){
       sqlite3VdbeChangeEncoding(pVal, enc);
     }
   }else if( op==TK_UMINUS ) {
+    /* This branch happens for multiple negative signs.  Ex: -(-5) */
     if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
+      sqlite3VdbeMemNumerify(pVal);
       pVal->u.i = -1 * pVal->u.i;
       /* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */
       pVal->r = (double)-1 * pVal->r;
+      sqlite3ValueApplyAffinity(pVal, affinity, enc);
     }
   }
 #ifndef SQLITE_OMIT_BLOB_LITERAL
@@ -48820,15 +55478,17 @@ static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){
   }
 }
 
+static void vdbeFreeOpArray(sqlite3 *, Op *, int);
+
 /*
 ** Delete a P4 value if necessary.
 */
 static void freeP4(sqlite3 *db, int p4type, void *p4){
   if( p4 ){
+    assert( db );
     switch( p4type ){
       case P4_REAL:
       case P4_INT64:
-      case P4_MPRINTF:
       case P4_DYNAMIC:
       case P4_KEYINFO:
       case P4_INTARRAY:
@@ -48836,10 +55496,14 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){
         sqlite3DbFree(db, p4);
         break;
       }
+      case P4_MPRINTF: {
+        if( db->pnBytesFreed==0 ) sqlite3_free(p4);
+        break;
+      }
       case P4_VDBEFUNC: {
         VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;
         freeEphemeralFunction(db, pVdbeFunc->pFunc);
-        sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
+        if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);
         sqlite3DbFree(db, pVdbeFunc);
         break;
       }
@@ -48848,15 +55512,17 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){
         break;
       }
       case P4_MEM: {
-        sqlite3ValueFree((sqlite3_value*)p4);
+        if( db->pnBytesFreed==0 ){
+          sqlite3ValueFree((sqlite3_value*)p4);
+        }else{
+          Mem *p = (Mem*)p4;
+          sqlite3DbFree(db, p->zMalloc);
+          sqlite3DbFree(db, p);
+        }
         break;
       }
       case P4_VTAB : {
-        sqlite3VtabUnlock((VTable *)p4);
-        break;
-      }
-      case P4_SUBPROGRAM : {
-        sqlite3VdbeProgramDelete(db, (SubProgram *)p4, 1);
+        if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);
         break;
       }
     }
@@ -48882,35 +55548,15 @@ static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){
 }
 
 /*
-** Decrement the ref-count on the SubProgram structure passed as the
-** second argument. If the ref-count reaches zero, free the structure.
-**
-** The array of VDBE opcodes stored as SubProgram.aOp is freed if
-** either the ref-count reaches zero or parameter freeop is non-zero.
-**
-** Since the array of opcodes pointed to by SubProgram.aOp may directly
-** or indirectly contain a reference to the SubProgram structure itself.
-** By passing a non-zero freeop parameter, the caller may ensure that all
-** SubProgram structures and their aOp arrays are freed, even when there
-** are such circular references.
+** Link the SubProgram object passed as the second argument into the linked
+** list at Vdbe.pSubProgram. This list is used to delete all sub-program
+** objects when the VM is no longer required.
 */
-SQLITE_PRIVATE void sqlite3VdbeProgramDelete(sqlite3 *db, SubProgram *p, int freeop){
-  if( p ){
-    assert( p->nRef>0 );
-    if( freeop || p->nRef==1 ){
-      Op *aOp = p->aOp;
-      p->aOp = 0;
-      vdbeFreeOpArray(db, aOp, p->nOp);
-      p->nOp = 0;
-    }
-    p->nRef--;
-    if( p->nRef==0 ){
-      sqlite3DbFree(db, p);
-    }
-  }
+SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){
+  p->pNext = pVdbe->pProgram;
+  pVdbe->pProgram = p;
 }
 
-
 /*
 ** Change N opcodes starting at addr to No-ops.
 */
@@ -48986,11 +55632,11 @@ SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int
 
     nField = ((KeyInfo*)zP4)->nField;
     nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;
-    pKeyInfo = sqlite3Malloc( nByte );
+    pKeyInfo = sqlite3DbMallocRaw(0, nByte);
     pOp->p4.pKeyInfo = pKeyInfo;
     if( pKeyInfo ){
       u8 *aSortOrder;
-      memcpy(pKeyInfo, zP4, nByte);
+      memcpy((char*)pKeyInfo, zP4, nByte - nField);
       aSortOrder = pKeyInfo->aSortOrder;
       if( aSortOrder ){
         pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];
@@ -49061,9 +55707,12 @@ SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){
 **
 ** If a memory allocation error has occurred prior to the calling of this
 ** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode
-** is readable and writable, but it has no effect.  The return of a dummy
-** opcode allows the call to continue functioning after a OOM fault without
-** having to check to see if the return from this routine is a valid pointer.
+** is readable but not writable, though it is cast to a writable value.
+** The return of a dummy opcode allows the call to continue functioning
+** after a OOM fault without having to check to see if the return from 
+** this routine is a valid pointer.  But because the dummy.opcode is 0,
+** dummy will never be written to.  This is verified by code inspection and
+** by running with Valgrind.
 **
 ** About the #ifdef SQLITE_OMIT_TRACE:  Normally, this routine is never called
 ** unless p->nOp>0.  This is because in the absense of SQLITE_OMIT_TRACE,
@@ -49074,17 +55723,19 @@ SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){
 ** check the value of p->nOp-1 before continuing.
 */
 SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
-  static VdbeOp dummy;
+  /* C89 specifies that the constant "dummy" will be initialized to all
+  ** zeros, which is correct.  MSVC generates a warning, nevertheless. */
+  static const VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */
   assert( p->magic==VDBE_MAGIC_INIT );
   if( addr<0 ){
 #ifdef SQLITE_OMIT_TRACE
-    if( p->nOp==0 ) return &dummy;
+    if( p->nOp==0 ) return (VdbeOp*)&dummy;
 #endif
     addr = p->nOp - 1;
   }
   assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );
   if( p->db->mallocFailed ){
-    return &dummy;
+    return (VdbeOp*)&dummy;
   }else{
     return &p->aOp[addr];
   }
@@ -49197,6 +55848,11 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
 
 /*
 ** Declare to the Vdbe that the BTree object at db->aDb[i] is used.
+**
+** The prepared statement has to know in advance which Btree objects
+** will be used so that it can acquire mutexes on them all in sorted
+** order (via sqlite3VdbeMutexArrayEnter().  Mutexes are acquired
+** in order (and released in reverse order) to avoid deadlocks.
 */
 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){
   int mask;
@@ -49240,6 +55896,12 @@ static void releaseMemArray(Mem *p, int N){
     Mem *pEnd;
     sqlite3 *db = p->db;
     u8 malloc_failed = db->mallocFailed;
+    if( db->pnBytesFreed ){
+      for(pEnd=&p[N]; p<pEnd; p++){
+        sqlite3DbFree(db, p->zMalloc);
+      }
+      return;
+    }
     for(pEnd=&p[N]; p<pEnd; p++){
       assert( (&p[1])==pEnd || p[0].db==p[1].db );
 
@@ -49696,6 +56358,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
   p->cacheCtr = 1;
   p->minWriteFileFormat = 255;
   p->iStatement = 0;
+  p->nFkConstraint = 0;
 #ifdef VDBE_PROFILE
   {
     int i;
@@ -49888,9 +56551,6 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
   ** to the transaction.
   */
   rc = sqlite3VtabSync(db, &p->zErrMsg);
-  if( rc!=SQLITE_OK ){
-    return rc;
-  }
 
   /* This loop determines (a) if the commit hook should be invoked and
   ** (b) how many database files have open write transactions, not 
@@ -49898,13 +56558,17 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
   ** one database file has an open write transaction, a master journal
   ** file is required for an atomic commit.
   */ 
-  for(i=0; i<db->nDb; i++){ 
+  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ 
     Btree *pBt = db->aDb[i].pBt;
     if( sqlite3BtreeIsInTrans(pBt) ){
       needXcommit = 1;
       if( i!=1 ) nTrans++;
+      rc = sqlite3PagerExclusiveLock(sqlite3BtreePager(pBt));
     }
   }
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
 
   /* If there are any write-transactions at all, invoke the commit hook */
   if( needXcommit && db->xCommitCallback ){
@@ -49996,9 +56660,10 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
       Btree *pBt = db->aDb[i].pBt;
       if( sqlite3BtreeIsInTrans(pBt) ){
         char const *zFile = sqlite3BtreeGetJournalname(pBt);
-        if( zFile==0 || zFile[0]==0 ){
+        if( zFile==0 ){
           continue;  /* Ignore TEMP and :memory: databases */
         }
+        assert( zFile[0]!=0 );
         if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
           needSync = 1;
         }
@@ -50043,6 +56708,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
       }
     }
     sqlite3OsCloseFree(pMaster);
+    assert( rc!=SQLITE_BUSY );
     if( rc!=SQLITE_OK ){
       sqlite3DbFree(db, zMaster);
       return rc;
@@ -50301,8 +56967,17 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
     isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR
                      || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;
     if( isSpecialError ){
-      /* If the query was read-only, we need do no rollback at all. Otherwise,
-      ** proceed with the special handling.
+      /* If the query was read-only and the error code is SQLITE_INTERRUPT, 
+      ** no rollback is necessary. Otherwise, at least a savepoint 
+      ** transaction must be rolled back to restore the database to a 
+      ** consistent state.
+      **
+      ** Even if the statement is read-only, it is important to perform
+      ** a statement or transaction rollback operation. If the error 
+      ** occured while writing to the journal, sub-journal or database
+      ** file as part of an effort to free up cache space (see function
+      ** pagerStress() in pager.c), the rollback is required to restore 
+      ** the pager to a consistent state.
       */
       if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){
         if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){
@@ -50384,10 +57059,17 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
     */
     if( eStatementOp ){
       rc = sqlite3VdbeCloseStatement(p, eStatementOp);
-      if( rc && (NEVER(p->rc==SQLITE_OK) || p->rc==SQLITE_CONSTRAINT) ){
-        p->rc = rc;
-        sqlite3DbFree(db, p->zErrMsg);
-        p->zErrMsg = 0;
+      if( rc ){
+        assert( eStatementOp==SAVEPOINT_ROLLBACK );
+        if( NEVER(p->rc==SQLITE_OK) || p->rc==SQLITE_CONSTRAINT ){
+          p->rc = rc;
+          sqlite3DbFree(db, p->zErrMsg);
+          p->zErrMsg = 0;
+        }
+        invalidateCursorsOnModifiedBtrees(db);
+        sqlite3RollbackAll(db);
+        sqlite3CloseSavepoints(db);
+        db->autoCommit = 1;
       }
     }
   
@@ -50565,6 +57247,30 @@ SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){
 }
 
 /*
+** Free all memory associated with the Vdbe passed as the second argument.
+** The difference between this function and sqlite3VdbeDelete() is that
+** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with
+** the database connection.
+*/
+SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3 *db, Vdbe *p){
+  SubProgram *pSub, *pNext;
+  assert( p->db==0 || p->db==db );
+  releaseMemArray(p->aVar, p->nVar);
+  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
+  for(pSub=p->pProgram; pSub; pSub=pNext){
+    pNext = pSub->pNext;
+    vdbeFreeOpArray(db, pSub->aOp, pSub->nOp);
+    sqlite3DbFree(db, pSub);
+  }
+  vdbeFreeOpArray(db, p->aOp, p->nOp);
+  sqlite3DbFree(db, p->aLabel);
+  sqlite3DbFree(db, p->aColName);
+  sqlite3DbFree(db, p->zSql);
+  sqlite3DbFree(db, p->pFree);
+  sqlite3DbFree(db, p);
+}
+
+/*
 ** Delete an entire VDBE.
 */
 SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){
@@ -50581,16 +57287,9 @@ SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){
   if( p->pNext ){
     p->pNext->pPrev = p->pPrev;
   }
-  releaseMemArray(p->aVar, p->nVar);
-  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
-  vdbeFreeOpArray(db, p->aOp, p->nOp);
-  sqlite3DbFree(db, p->aLabel);
-  sqlite3DbFree(db, p->aColName);
-  sqlite3DbFree(db, p->zSql);
   p->magic = VDBE_MAGIC_DEAD;
-  sqlite3DbFree(db, p->pFree);
   p->db = 0;
-  sqlite3DbFree(db, p);
+  sqlite3VdbeDeleteObject(db, p);
 }
 
 /*
@@ -50616,11 +57315,8 @@ SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor *p){
     rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);
     if( rc ) return rc;
     p->lastRowid = p->movetoTarget;
-    p->rowidIsValid = ALWAYS(res==0) ?1:0;
-    if( NEVER(res<0) ){
-      rc = sqlite3BtreeNext(p->pCursor, &res);
-      if( rc ) return rc;
-    }
+    if( res!=0 ) return SQLITE_CORRUPT_BKPT;
+    p->rowidIsValid = 1;
 #ifdef SQLITE_TEST
     sqlite3_search_count++;
 #endif
@@ -51431,6 +58127,8 @@ static int vdbeSafetyNotNull(Vdbe *p){
 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
   int rc;
   if( pStmt==0 ){
+    /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
+    ** pointer is a harmless no-op. */
     rc = SQLITE_OK;
   }else{
     Vdbe *v = (Vdbe*)pStmt;
@@ -51507,7 +58205,7 @@ SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
     sqlite3VdbeMemExpandBlob(p);
     p->flags &= ~MEM_Str;
     p->flags |= MEM_Blob;
-    return p->z;
+    return p->n ? p->z : 0;
   }else{
     return sqlite3_value_text(pVal);
   }
@@ -51673,6 +58371,27 @@ SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
 }
 
 /*
+** This function is called after a transaction has been committed. It 
+** invokes callbacks registered with sqlite3_wal_hook() as required.
+*/
+static int doWalCallbacks(sqlite3 *db){
+  int rc = SQLITE_OK;
+#ifndef SQLITE_OMIT_WAL
+  int i;
+  for(i=0; i<db->nDb; i++){
+    Btree *pBt = db->aDb[i].pBt;
+    if( pBt ){
+      int nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));
+      if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK ){
+        rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry);
+      }
+    }
+  }
+#endif
+  return rc;
+}
+
+/*
 ** Execute the statement pStmt, either until a row of data is ready, the
 ** statement is completely executed or an error occurs.
 **
@@ -51687,9 +58406,12 @@ static int sqlite3Step(Vdbe *p){
 
   assert(p);
   if( p->magic!=VDBE_MAGIC_RUN ){
-    sqlite3_log(SQLITE_MISUSE, 
-          "attempt to step a halted statement: [%s]", p->zSql);
-    return SQLITE_MISUSE_BKPT;
+    /* We used to require that sqlite3_reset() be called before retrying
+    ** sqlite3_step() after any error.  But after 3.6.23, we changed this
+    ** so that sqlite3_reset() would be called automatically instead of
+    ** throwing the error.
+    */
+    sqlite3_reset((sqlite3_stmt*)p);
   }
 
   /* Check that malloc() has not failed. If it has, return early. */
@@ -51717,9 +58439,7 @@ static int sqlite3Step(Vdbe *p){
 
 #ifndef SQLITE_OMIT_TRACE
     if( db->xProfile && !db->init.busy ){
-      double rNow;
-      sqlite3OsCurrentTime(db->pVfs, &rNow);
-      p->startTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
+      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
     }
 #endif
 
@@ -51740,16 +58460,20 @@ static int sqlite3Step(Vdbe *p){
   /* Invoke the profile callback if there is one
   */
   if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){
-    double rNow;
-    u64 elapseTime;
-
-    sqlite3OsCurrentTime(db->pVfs, &rNow);
-    elapseTime = (u64)((rNow - (int)rNow)*3600.0*24.0*1000000000.0);
-    elapseTime -= p->startTime;
-    db->xProfile(db->pProfileArg, p->zSql, elapseTime);
+    sqlite3_int64 iNow;
+    sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
+    db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
   }
 #endif
 
+  if( rc==SQLITE_DONE ){
+    assert( p->rc==SQLITE_OK );
+    p->rc = doWalCallbacks(db);
+    if( p->rc!=SQLITE_OK ){
+      rc = SQLITE_ERROR;
+    }
+  }
+
   db->errCode = rc;
   if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){
     p->rc = SQLITE_NOMEM;
@@ -51835,6 +58559,12 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
 /*
 ** Extract the user data from a sqlite3_context structure and return a
 ** pointer to it.
+**
+** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface
+** returns a copy of the pointer to the database connection (the 1st
+** parameter) of the sqlite3_create_function() and
+** sqlite3_create_function16() routines that originally registered the
+** application defined function.
 */
 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
   assert( p && p->pFunc );
@@ -52044,8 +58774,7 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
 **     sqlite3_column_real()
 **     sqlite3_column_bytes()
 **     sqlite3_column_bytes16()
-**
-** But not for sqlite3_column_blob(), which never calls malloc().
+**     sqiite3_column_blob()
 */
 static void columnMallocFailure(sqlite3_stmt *pStmt)
 {
@@ -52313,6 +59042,12 @@ static int vdbeUnbind(Vdbe *p, int i){
 
   /* If the bit corresponding to this variable in Vdbe.expmask is set, then 
   ** binding a new value to this variable invalidates the current query plan.
+  **
+  ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host
+  ** parameter in the WHERE clause might influence the choice of query plan
+  ** for a statement, then the statement will be automatically recompiled,
+  ** as if there had been a schema change, on the first sqlite3_step() call
+  ** following any change to the bindings of that parameter.
   */
   if( p->isPrepareV2 &&
      ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
@@ -52811,6 +59546,17 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
 */
 
 /*
+** Invoke this macro on memory cells just prior to changing the
+** value of the cell.  This macro verifies that shallow copies are
+** not misused.
+*/
+#ifdef SQLITE_DEBUG
+# define memAboutToChange(P,M) sqlite3VdbeMemPrepareToChange(P,M)
+#else
+# define memAboutToChange(P,M)
+#endif
+
+/*
 ** The following global variable is incremented every time a cursor
 ** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test
 ** procedures use this information to make sure that indices are
@@ -53002,31 +59748,17 @@ static VdbeCursor *allocateCursor(
 */
 static void applyNumericAffinity(Mem *pRec){
   if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){
-    int realnum;
+    double rValue;
+    i64 iValue;
     u8 enc = pRec->enc;
-    sqlite3VdbeMemNulTerminate(pRec);
-    if( (pRec->flags&MEM_Str) && sqlite3IsNumber(pRec->z, &realnum, enc) ){
-      i64 value;
-      char *zUtf8 = pRec->z;
-#ifndef SQLITE_OMIT_UTF16
-      if( enc!=SQLITE_UTF8 ){
-        assert( pRec->db );
-        zUtf8 = sqlite3Utf16to8(pRec->db, pRec->z, pRec->n, enc);
-        if( !zUtf8 ) return;
-      }
-#endif
-      if( !realnum && sqlite3Atoi64(zUtf8, &value) ){
-        pRec->u.i = value;
-        MemSetTypeFlag(pRec, MEM_Int);
-      }else{
-        sqlite3AtoF(zUtf8, &pRec->r);
-        MemSetTypeFlag(pRec, MEM_Real);
-      }
-#ifndef SQLITE_OMIT_UTF16
-      if( enc!=SQLITE_UTF8 ){
-        sqlite3DbFree(pRec->db, zUtf8);
-      }
-#endif
+    if( (pRec->flags&MEM_Str)==0 ) return;
+    if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;
+    if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){
+      pRec->u.i = iValue;
+      pRec->flags |= MEM_Int;
+    }else{
+      pRec->r = rValue;
+      pRec->flags |= MEM_Real;
     }
   }
 }
@@ -53333,22 +60065,6 @@ SQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }
 #define CHECK_FOR_INTERRUPT \
    if( db->u1.isInterrupted ) goto abort_due_to_interrupt;
 
-#ifdef SQLITE_DEBUG
-static int fileExists(sqlite3 *db, const char *zFile){
-  int res = 0;
-  int rc = SQLITE_OK;
-#ifdef SQLITE_TEST
-  /* If we are currently testing IO errors, then do not call OsAccess() to
-  ** test for the presence of zFile. This is because any IO error that
-  ** occurs here will not be reported, causing the test to fail.
-  */
-  extern int sqlite3_io_error_pending;
-  if( sqlite3_io_error_pending<=0 )
-#endif
-    rc = sqlite3OsAccess(db->pVfs, zFile, SQLITE_ACCESS_EXISTS, &res);
-  return (res && rc==SQLITE_OK);
-}
-#endif
 
 #ifndef NDEBUG
 /*
@@ -53371,6 +60087,20 @@ static int checkSavepointCount(sqlite3 *db){
 #endif
 
 /*
+** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
+** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
+** in memory obtained from sqlite3DbMalloc).
+*/
+static void importVtabErrMsg(Vdbe *p, sqlite3_vtab *pVtab){
+  sqlite3 *db = p->db;
+  sqlite3DbFree(db, p->zErrMsg);
+  p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg);
+  sqlite3_free(pVtab->zErrMsg);
+  pVtab->zErrMsg = 0;
+}
+
+
+/*
 ** Execute as much of a VDBE program as we can then return.
 **
 ** sqlite3VdbeMakeReady() must be called before this routine in order to
@@ -53439,9 +60169,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       int pcDest;
     } aa;
     struct OP_Variable_stack_vars {
-      int p1;          /* Variable to copy from */
-      int p2;          /* Register to copy to */
-      int n;           /* Number of values left to copy */
       Mem *pVar;       /* Value being transferred */
     } ab;
     struct OP_Move_stack_vars {
@@ -53766,18 +60493,25 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     struct OP_AggFinal_stack_vars {
       Mem *pMem;
     } cc;
+    struct OP_JournalMode_stack_vars {
+      Btree *pBt;                     /* Btree to change journal mode of */
+      Pager *pPager;                  /* Pager associated with pBt */
+      int eNew;                       /* New journal mode */
+      int eOld;                       /* The old journal mode */
+      const char *zFilename;          /* Name of database file for pPager */
+    } cd;
     struct OP_IncrVacuum_stack_vars {
       Btree *pBt;
-    } cd;
+    } ce;
     struct OP_VBegin_stack_vars {
       VTable *pVTab;
-    } ce;
+    } cf;
     struct OP_VOpen_stack_vars {
       VdbeCursor *pCur;
       sqlite3_vtab_cursor *pVtabCursor;
       sqlite3_vtab *pVtab;
       sqlite3_module *pModule;
-    } cf;
+    } cg;
     struct OP_VFilter_stack_vars {
       int nArg;
       int iQuery;
@@ -53790,23 +60524,23 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       int res;
       int i;
       Mem **apArg;
-    } cg;
+    } ch;
     struct OP_VColumn_stack_vars {
       sqlite3_vtab *pVtab;
       const sqlite3_module *pModule;
       Mem *pDest;
       sqlite3_context sContext;
-    } ch;
+    } ci;
     struct OP_VNext_stack_vars {
       sqlite3_vtab *pVtab;
       const sqlite3_module *pModule;
       int res;
       VdbeCursor *pCur;
-    } ci;
+    } cj;
     struct OP_VRename_stack_vars {
       sqlite3_vtab *pVtab;
       Mem *pName;
-    } cj;
+    } ck;
     struct OP_VUpdate_stack_vars {
       sqlite3_vtab *pVtab;
       sqlite3_module *pModule;
@@ -53815,11 +60549,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       sqlite_int64 rowid;
       Mem **apArg;
       Mem *pX;
-    } ck;
-    struct OP_Pagecount_stack_vars {
-      int p1;
-      int nPage;
-      Pager *pPager;
     } cl;
     struct OP_Trace_stack_vars {
       char *zTrace;
@@ -53847,9 +60576,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
 #endif
 #ifdef SQLITE_DEBUG
   sqlite3BeginBenignMalloc();
-  if( p->pc==0 
-   && ((p->db->flags & SQLITE_VdbeListing) || fileExists(db, "vdbe_explain"))
-  ){
+  if( p->pc==0  && (p->db->flags & SQLITE_VdbeListing)!=0 ){
     int i;
     printf("VDBE Program Listing:\n");
     sqlite3VdbePrintSql(p);
@@ -53857,9 +60584,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       sqlite3VdbePrintOp(stdout, i, &aOp[i]);
     }
   }
-  if( fileExists(db, "vdbe_trace") ){
-    p->trace = stdout;
-  }
   sqlite3EndBenignMalloc();
 #endif
   for(pc=p->pc; rc==SQLITE_OK; pc++){
@@ -53881,13 +60605,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       }
       sqlite3VdbePrintOp(p->trace, pc, pOp);
     }
-    if( p->trace==0 && pc==0 ){
-      sqlite3BeginBenignMalloc();
-      if( fileExists(db, "vdbe_sqltrace") ){
-        sqlite3VdbePrintSql(p);
-      }
-      sqlite3EndBenignMalloc();
-    }
 #endif
       
 
@@ -53934,6 +60651,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
       assert( pOp->p2>0 );
       assert( pOp->p2<=p->nMem );
       pOut = &aMem[pOp->p2];
+      memAboutToChange(p, pOut);
       sqlite3VdbeMemReleaseExternal(pOut);
       pOut->flags = MEM_Int;
     }
@@ -53943,25 +60661,30 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
     if( (pOp->opflags & OPFLG_IN1)!=0 ){
       assert( pOp->p1>0 );
       assert( pOp->p1<=p->nMem );
+      assert( memIsValid(&aMem[pOp->p1]) );
       REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);
     }
     if( (pOp->opflags & OPFLG_IN2)!=0 ){
       assert( pOp->p2>0 );
       assert( pOp->p2<=p->nMem );
+      assert( memIsValid(&aMem[pOp->p2]) );
       REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);
     }
     if( (pOp->opflags & OPFLG_IN3)!=0 ){
       assert( pOp->p3>0 );
       assert( pOp->p3<=p->nMem );
+      assert( memIsValid(&aMem[pOp->p3]) );
       REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);
     }
     if( (pOp->opflags & OPFLG_OUT2)!=0 ){
       assert( pOp->p2>0 );
       assert( pOp->p2<=p->nMem );
+      memAboutToChange(p, &aMem[pOp->p2]);
     }
     if( (pOp->opflags & OPFLG_OUT3)!=0 ){
       assert( pOp->p3>0 );
       assert( pOp->p3<=p->nMem );
+      memAboutToChange(p, &aMem[pOp->p3]);
     }
 #endif
   
@@ -54023,6 +60746,7 @@ case OP_Goto: {             /* jump */
 case OP_Gosub: {            /* jump, in1 */
   pIn1 = &aMem[pOp->p1];
   assert( (pIn1->flags & MEM_Dyn)==0 );
+  memAboutToChange(p, pIn1);
   pIn1->flags = MEM_Int;
   pIn1->u.i = pc;
   REGISTER_TRACE(pOp->p1, pIn1);
@@ -54230,11 +60954,7 @@ case OP_Null: {           /* out2-prerelease */
 /* Opcode: Blob P1 P2 * P4
 **
 ** P4 points to a blob of data P1 bytes long.  Store this
-** blob in register P2. This instruction is not coded directly
-** by the compiler. Instead, the compiler layer specifies
-** an OP_HexBlob opcode, with the hex string representation of
-** the blob as P4. This opcode is transformed to an OP_Blob
-** the first time it is executed.
+** blob in register P2.
 */
 case OP_Blob: {                /* out2-prerelease */
   assert( pOp->p1 <= SQLITE_MAX_LENGTH );
@@ -54244,40 +60964,25 @@ case OP_Blob: {                /* out2-prerelease */
   break;
 }
 
-/* Opcode: Variable P1 P2 P3 P4 *
+/* Opcode: Variable P1 P2 * P4 *
 **
-** Transfer the values of bound parameters P1..P1+P3-1 into registers
-** P2..P2+P3-1.
+** Transfer the values of bound parameter P1 into register P2
 **
 ** If the parameter is named, then its name appears in P4 and P3==1.
 ** The P4 value is used by sqlite3_bind_parameter_name().
 */
-case OP_Variable: {
+case OP_Variable: {            /* out2-prerelease */
 #if 0  /* local variables moved into u.ab */
-  int p1;          /* Variable to copy from */
-  int p2;          /* Register to copy to */
-  int n;           /* Number of values left to copy */
   Mem *pVar;       /* Value being transferred */
 #endif /* local variables moved into u.ab */
 
-  u.ab.p1 = pOp->p1 - 1;
-  u.ab.p2 = pOp->p2;
-  u.ab.n = pOp->p3;
-  assert( u.ab.p1>=0 && u.ab.p1+u.ab.n<=p->nVar );
-  assert( u.ab.p2>=1 && u.ab.p2+u.ab.n-1<=p->nMem );
-  assert( pOp->p4.z==0 || pOp->p3==1 || pOp->p3==0 );
-
-  while( u.ab.n-- > 0 ){
-    u.ab.pVar = &p->aVar[u.ab.p1++];
-    if( sqlite3VdbeMemTooBig(u.ab.pVar) ){
-      goto too_big;
-    }
-    pOut = &aMem[u.ab.p2++];
-    sqlite3VdbeMemReleaseExternal(pOut);
-    pOut->flags = MEM_Null;
-    sqlite3VdbeMemShallowCopy(pOut, u.ab.pVar, MEM_Static);
-    UPDATE_MAX_BLOBSIZE(pOut);
+  assert( pOp->p1>0 && pOp->p1<=p->nVar );
+  u.ab.pVar = &p->aVar[pOp->p1 - 1];
+  if( sqlite3VdbeMemTooBig(u.ab.pVar) ){
+    goto too_big;
   }
+  sqlite3VdbeMemShallowCopy(pOut, u.ab.pVar, MEM_Static);
+  UPDATE_MAX_BLOBSIZE(pOut);
   break;
 }
 
@@ -54307,6 +61012,8 @@ case OP_Move: {
   while( u.ac.n-- ){
     assert( pOut<=&aMem[p->nMem] );
     assert( pIn1<=&aMem[p->nMem] );
+    assert( memIsValid(pIn1) );
+    memAboutToChange(p, pOut);
     u.ac.zMalloc = pOut->zMalloc;
     pOut->zMalloc = 0;
     sqlite3VdbeMemMove(pOut, pIn1);
@@ -54352,6 +61059,9 @@ case OP_SCopy: {            /* in1, out2 */
   pOut = &aMem[pOp->p2];
   assert( pOut!=pIn1 );
   sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
+#ifdef SQLITE_DEBUG
+  if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;
+#endif
   REGISTER_TRACE(pOp->p2, pOut);
   break;
 }
@@ -54412,6 +61122,10 @@ case OP_ResultRow: {
   */
   u.ad.pMem = p->pResultSet = &aMem[pOp->p1];
   for(u.ad.i=0; u.ad.i<pOp->p2; u.ad.i++){
+    assert( memIsValid(&u.ad.pMem[u.ad.i]) );
+    Deephemeralize(&u.ad.pMem[u.ad.i]);
+    assert( (u.ad.pMem[u.ad.i].flags & MEM_Ephem)==0
+            || (u.ad.pMem[u.ad.i].flags & (MEM_Str|MEM_Blob))==0 );
     sqlite3VdbeMemNulTerminate(&u.ad.pMem[u.ad.i]);
     sqlite3VdbeMemStoreType(&u.ad.pMem[u.ad.i]);
     REGISTER_TRACE(pOp->p1+u.ad.i, &u.ad.pMem[u.ad.i]);
@@ -54643,14 +61357,19 @@ case OP_Function: {
   u.ag.n = pOp->p5;
   u.ag.apVal = p->apArg;
   assert( u.ag.apVal || u.ag.n==0 );
+  assert( pOp->p3>0 && pOp->p3<=p->nMem );
+  pOut = &aMem[pOp->p3];
+  memAboutToChange(p, pOut);
 
   assert( u.ag.n==0 || (pOp->p2>0 && pOp->p2+u.ag.n<=p->nMem+1) );
   assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+u.ag.n );
   u.ag.pArg = &aMem[pOp->p2];
   for(u.ag.i=0; u.ag.i<u.ag.n; u.ag.i++, u.ag.pArg++){
+    assert( memIsValid(u.ag.pArg) );
     u.ag.apVal[u.ag.i] = u.ag.pArg;
+    Deephemeralize(u.ag.pArg);
     sqlite3VdbeMemStoreType(u.ag.pArg);
-    REGISTER_TRACE(pOp->p2, u.ag.pArg);
+    REGISTER_TRACE(pOp->p2+u.ag.i, u.ag.pArg);
   }
 
   assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );
@@ -54662,8 +61381,6 @@ case OP_Function: {
     u.ag.ctx.pFunc = u.ag.ctx.pVdbeFunc->pFunc;
   }
 
-  assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  pOut = &aMem[pOp->p3];
   u.ag.ctx.s.flags = MEM_Null;
   u.ag.ctx.s.db = db;
   u.ag.ctx.s.xDel = 0;
@@ -54683,7 +61400,7 @@ case OP_Function: {
     assert( pOp[-1].opcode==OP_CollSeq );
     u.ag.ctx.pColl = pOp[-1].p4.pColl;
   }
-  (*u.ag.ctx.pFunc->xFunc)(&u.ag.ctx, u.ag.n, u.ag.apVal);
+  (*u.ag.ctx.pFunc->xFunc)(&u.ag.ctx, u.ag.n, u.ag.apVal); /* IMP: R-24505-23230 */
   if( db->mallocFailed ){
     /* Even though a malloc() has failed, the implementation of the
     ** user function may have called an sqlite3_result_XXX() function
@@ -54735,7 +61452,7 @@ case OP_Function: {
 /* Opcode: ShiftLeft P1 P2 P3 * *
 **
 ** Shift the integer value in register P2 to the left by the
-** number of bits specified by the integer in regiser P1.
+** number of bits specified by the integer in register P1.
 ** Store the result in register P3.
 ** If either input is NULL, the result is NULL.
 */
@@ -54785,6 +61502,7 @@ case OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */
 */
 case OP_AddImm: {            /* in1 */
   pIn1 = &aMem[pOp->p1];
+  memAboutToChange(p, pIn1);
   sqlite3VdbeMemIntegerify(pIn1);
   pIn1->u.i += pOp->p2;
   break;
@@ -54799,6 +61517,7 @@ case OP_AddImm: {            /* in1 */
 */
 case OP_MustBeInt: {            /* jump, in1 */
   pIn1 = &aMem[pOp->p1];
+  memAboutToChange(p, pIn1);
   applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
   if( (pIn1->flags & MEM_Int)==0 ){
     if( pOp->p2==0 ){
@@ -54844,6 +61563,7 @@ case OP_RealAffinity: {                  /* in1 */
 */
 case OP_ToText: {                  /* same as TK_TO_TEXT, in1 */
   pIn1 = &aMem[pOp->p1];
+  memAboutToChange(p, pIn1);
   if( pIn1->flags & MEM_Null ) break;
   assert( MEM_Str==(MEM_Blob>>3) );
   pIn1->flags |= (pIn1->flags&MEM_Blob)>>3;
@@ -54890,16 +61610,14 @@ case OP_ToBlob: {                  /* same as TK_TO_BLOB, in1 */
 */
 case OP_ToNumeric: {                  /* same as TK_TO_NUMERIC, in1 */
   pIn1 = &aMem[pOp->p1];
-  if( (pIn1->flags & (MEM_Null|MEM_Int|MEM_Real))==0 ){
-    sqlite3VdbeMemNumerify(pIn1);
-  }
+  sqlite3VdbeMemNumerify(pIn1);
   break;
 }
 #endif /* SQLITE_OMIT_CAST */
 
 /* Opcode: ToInt P1 * * * *
 **
-** Force the value in register P1 be an integer.  If
+** Force the value in register P1 to be an integer.  If
 ** The value is currently a real number, drop its fractional part.
 ** If the value is text or blob, try to convert it to an integer using the
 ** equivalent of atoi() and store 0 if no such conversion is possible.
@@ -54926,6 +61644,7 @@ case OP_ToInt: {                  /* same as TK_TO_INT, in1 */
 */
 case OP_ToReal: {                  /* same as TK_TO_REAL, in1 */
   pIn1 = &aMem[pOp->p1];
+  memAboutToChange(p, pIn1);
   if( (pIn1->flags & MEM_Null)==0 ){
     sqlite3VdbeMemRealify(pIn1);
   }
@@ -54940,7 +61659,7 @@ case OP_ToReal: {                  /* same as TK_TO_REAL, in1 */
 **
 ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
 ** reg(P3) is NULL then take the jump.  If the SQLITE_JUMPIFNULL 
-** bit is clear then fall thru if either operand is NULL.
+** bit is clear then fall through if either operand is NULL.
 **
 ** The SQLITE_AFF_MASK portion of P5 must be an affinity character -
 ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made 
@@ -55070,6 +61789,7 @@ case OP_Ge: {             /* same as TK_GE, jump, in1, in3 */
 
   if( pOp->p5 & SQLITE_STOREP2 ){
     pOut = &aMem[pOp->p2];
+    memAboutToChange(p, pOut);
     MemSetTypeFlag(pOut, MEM_Int);
     pOut->u.i = u.ai.res;
     REGISTER_TRACE(pOp->p2, pOut);
@@ -55101,8 +61821,8 @@ case OP_Permutation: {
 
 /* Opcode: Compare P1 P2 P3 P4 *
 **
-** Compare to vectors of registers in reg(P1)..reg(P1+P3-1) (all this
-** one "A") and in reg(P2)..reg(P2+P3-1) ("B").  Save the result of
+** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this
+** vector "A") and in reg(P2)..reg(P2+P3-1) ("B").  Save the result of
 ** the comparison for use by the next OP_Jump instruct.
 **
 ** P4 is a KeyInfo structure that defines collating sequences and sort
@@ -55144,6 +61864,8 @@ case OP_Compare: {
 #endif /* SQLITE_DEBUG */
   for(u.aj.i=0; u.aj.i<u.aj.n; u.aj.i++){
     u.aj.idx = aPermute ? aPermute[u.aj.i] : u.aj.i;
+    assert( memIsValid(&aMem[u.aj.p1+u.aj.idx]) );
+    assert( memIsValid(&aMem[u.aj.p2+u.aj.idx]) );
     REGISTER_TRACE(u.aj.p1+u.aj.idx, &aMem[u.aj.p1+u.aj.idx]);
     REGISTER_TRACE(u.aj.p2+u.aj.idx, &aMem[u.aj.p2+u.aj.idx]);
     assert( u.aj.i<u.aj.pKeyInfo->nField );
@@ -55375,6 +62097,7 @@ case OP_Column: {
   assert( u.am.p1<p->nCursor );
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
   u.am.pDest = &aMem[pOp->p3];
+  memAboutToChange(p, u.am.pDest);
   MemSetTypeFlag(u.am.pDest, MEM_Null);
   u.am.zRec = 0;
 
@@ -55422,6 +62145,7 @@ case OP_Column: {
   }else if( u.am.pC->pseudoTableReg>0 ){
     u.am.pReg = &aMem[u.am.pC->pseudoTableReg];
     assert( u.am.pReg->flags & MEM_Blob );
+    assert( memIsValid(u.am.pReg) );
     u.am.payloadSize = u.am.pReg->n;
     u.am.zRec = u.am.pReg->z;
     u.am.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;
@@ -55646,6 +62370,7 @@ case OP_Affinity: {
   pIn1 = &aMem[pOp->p1];
   while( (u.an.cAff = *(u.an.zAffinity++))!=0 ){
     assert( pIn1 <= &p->aMem[p->nMem] );
+    assert( memIsValid(pIn1) );
     ExpandBlob(pIn1);
     applyAffinity(pIn1, u.an.cAff, encoding);
     pIn1++;
@@ -55655,12 +62380,9 @@ case OP_Affinity: {
 
 /* Opcode: MakeRecord P1 P2 P3 P4 *
 **
-** Convert P2 registers beginning with P1 into a single entry
-** suitable for use as a data record in a database table or as a key
-** in an index.  The details of the format are irrelevant as long as
-** the OP_Column opcode can decode the record later.
-** Refer to source code comments for the details of the record
-** format.
+** Convert P2 registers beginning with P1 into the [record format]
+** use as a data record in a database table or as a key
+** in an index.  The OP_Column opcode can decode the record later.
 **
 ** P4 may be a string that is P2 characters long.  The nth character of the
 ** string indicates the column affinity that should be used for the nth
@@ -55717,10 +62439,16 @@ case OP_MakeRecord: {
   u.ao.pLast = &u.ao.pData0[u.ao.nField-1];
   u.ao.file_format = p->minWriteFileFormat;
 
+  /* Identify the output register */
+  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
+  pOut = &aMem[pOp->p3];
+  memAboutToChange(p, pOut);
+
   /* Loop through the elements that will make up the record to figure
   ** out how much space is required for the new record.
   */
   for(u.ao.pRec=u.ao.pData0; u.ao.pRec<=u.ao.pLast; u.ao.pRec++){
+    assert( memIsValid(u.ao.pRec) );
     if( u.ao.zAffinity ){
       applyAffinity(u.ao.pRec, u.ao.zAffinity[u.ao.pRec-u.ao.pData0], encoding);
     }
@@ -55755,8 +62483,6 @@ case OP_MakeRecord: {
   ** be one of the input registers (because the following call to
   ** sqlite3VdbeMemGrow() could clobber the value before it is used).
   */
-  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );
-  pOut = &aMem[pOp->p3];
   if( sqlite3VdbeMemGrow(pOut, (int)u.ao.nByte, 0) ){
     goto no_mem;
   }
@@ -55929,6 +62655,7 @@ case OP_Savepoint: {
         if( u.aq.p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){
           sqlite3ExpirePreparedStatements(db);
           sqlite3ResetInternalSchema(db, 0);
+          db->flags = (db->flags | SQLITE_InternChanges);
         }
       }
 
@@ -56319,6 +63046,8 @@ case OP_OpenWrite: {
     assert( u.aw.p2>0 );
     assert( u.aw.p2<=p->nMem );
     pIn2 = &aMem[u.aw.p2];
+    assert( memIsValid(pIn2) );
+    assert( (pIn2->flags & MEM_Int)!=0 );
     sqlite3VdbeMemIntegerify(pIn2);
     u.aw.p2 = (int)pIn2->u.i;
     /* The u.aw.p2 value always comes from a prior OP_CreateTable opcode and
@@ -56341,6 +63070,7 @@ case OP_OpenWrite: {
   u.aw.pCur = allocateCursor(p, pOp->p1, u.aw.nField, u.aw.iDb, 1);
   if( u.aw.pCur==0 ) goto no_mem;
   u.aw.pCur->nullRow = 1;
+  u.aw.pCur->isOrdered = 1;
   rc = sqlite3BtreeCursor(u.aw.pX, u.aw.p2, u.aw.wrFlag, u.aw.pKeyInfo, u.aw.pCur->pCursor);
   u.aw.pCur->pKeyInfo = u.aw.pKeyInfo;
 
@@ -56367,10 +63097,10 @@ case OP_OpenWrite: {
 **
 ** Open a new cursor P1 to a transient table.
 ** The cursor is always opened read/write even if 
-** the main database is read-only.  The transient or virtual
+** the main database is read-only.  The ephemeral
 ** table is deleted automatically when the cursor is closed.
 **
-** P2 is the number of columns in the virtual table.
+** P2 is the number of columns in the ephemeral table.
 ** The cursor points to a BTree table if P4==0 and to a BTree index
 ** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure
 ** that defines the format of keys in the index.
@@ -56381,11 +63111,19 @@ case OP_OpenWrite: {
 ** this opcode.  Then this opcode was call OpenVirtual.  But
 ** that created confusion with the whole virtual-table idea.
 */
+/* Opcode: OpenAutoindex P1 P2 * P4 *
+**
+** This opcode works the same as OP_OpenEphemeral.  It has a
+** different name to distinguish its use.  Tables created using
+** by this opcode will be used for automatically created transient
+** indices in joins.
+*/
+case OP_OpenAutoindex: 
 case OP_OpenEphemeral: {
 #if 0  /* local variables moved into u.ax */
   VdbeCursor *pCx;
 #endif /* local variables moved into u.ax */
-  static const int openFlags =
+  static const int vfsFlags =
       SQLITE_OPEN_READWRITE |
       SQLITE_OPEN_CREATE |
       SQLITE_OPEN_EXCLUSIVE |
@@ -56396,21 +63134,21 @@ case OP_OpenEphemeral: {
   u.ax.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1);
   if( u.ax.pCx==0 ) goto no_mem;
   u.ax.pCx->nullRow = 1;
-  rc = sqlite3BtreeFactory(db, 0, 1, SQLITE_DEFAULT_TEMP_CACHE_SIZE, openFlags,
-                           &u.ax.pCx->pBt);
+  rc = sqlite3BtreeOpen(0, db, &u.ax.pCx->pBt,
+                        BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
   if( rc==SQLITE_OK ){
     rc = sqlite3BtreeBeginTrans(u.ax.pCx->pBt, 1);
   }
   if( rc==SQLITE_OK ){
     /* If a transient index is required, create it by calling
-    ** sqlite3BtreeCreateTable() with the BTREE_ZERODATA flag before
+    ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
     ** opening it. If a transient table is required, just use the
-    ** automatically created table with root-page 1 (an INTKEY table).
+    ** automatically created table with root-page 1 (an BLOB_INTKEY table).
     */
     if( pOp->p4.pKeyInfo ){
       int pgno;
       assert( pOp->p4type==P4_KEYINFO );
-      rc = sqlite3BtreeCreateTable(u.ax.pCx->pBt, &pgno, BTREE_ZERODATA);
+      rc = sqlite3BtreeCreateTable(u.ax.pCx->pBt, &pgno, BTREE_BLOBKEY);
       if( rc==SQLITE_OK ){
         assert( pgno==MASTER_ROOT+1 );
         rc = sqlite3BtreeCursor(u.ax.pCx->pBt, pgno, 1,
@@ -56424,6 +63162,7 @@ case OP_OpenEphemeral: {
       u.ax.pCx->isTable = 1;
     }
   }
+  u.ax.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
   u.ax.pCx->isIndex = !u.ax.pCx->isTable;
   break;
 }
@@ -56543,6 +63282,7 @@ case OP_SeekGt: {       /* jump, in3 */
   assert( OP_SeekLe == OP_SeekLt+1 );
   assert( OP_SeekGe == OP_SeekLt+2 );
   assert( OP_SeekGt == OP_SeekLt+3 );
+  assert( u.az.pC->isOrdered );
   if( u.az.pC->pCursor!=0 ){
     u.az.oc = pOp->opcode;
     u.az.pC->nullRow = 0;
@@ -56625,6 +63365,9 @@ case OP_SeekGt: {       /* jump, in3 */
       assert( u.az.oc!=OP_SeekLt || u.az.r.flags==0 );
 
       u.az.r.aMem = &aMem[pOp->p3];
+#ifdef SQLITE_DEBUG
+      { int i; for(i=0; i<u.az.r.nField; i++) assert( memIsValid(&u.az.r.aMem[i]) ); }
+#endif
       ExpandBlob(u.az.r.aMem);
       rc = sqlite3BtreeMovetoUnpacked(u.az.pC->pCursor, &u.az.r, 0, 0, &u.az.res);
       if( rc!=SQLITE_OK ){
@@ -56753,11 +63496,14 @@ case OP_Found: {        /* jump, in3 */
       u.bb.r.pKeyInfo = u.bb.pC->pKeyInfo;
       u.bb.r.nField = (u16)pOp->p4.i;
       u.bb.r.aMem = pIn3;
+#ifdef SQLITE_DEBUG
+      { int i; for(i=0; i<u.bb.r.nField; i++) assert( memIsValid(&u.bb.r.aMem[i]) ); }
+#endif
       u.bb.r.flags = UNPACKED_PREFIX_MATCH;
       u.bb.pIdxKey = &u.bb.r;
     }else{
       assert( pIn3->flags & MEM_Blob );
-      ExpandBlob(pIn3);
+      assert( (pIn3->flags & MEM_Zero)==0 );  /* zeroblobs already expanded */
       u.bb.pIdxKey = sqlite3VdbeRecordUnpack(u.bb.pC->pKeyInfo, pIn3->n, pIn3->z,
                                         u.bb.aTempRec, sizeof(u.bb.aTempRec));
       if( u.bb.pIdxKey==0 ){
@@ -56852,6 +63598,9 @@ case OP_IsUnique: {        /* jump, in3 */
     u.bc.r.nField = u.bc.nField + 1;
     u.bc.r.flags = UNPACKED_PREFIX_SEARCH;
     u.bc.r.aMem = u.bc.aMx;
+#ifdef SQLITE_DEBUG
+    { int i; for(i=0; i<u.bc.r.nField; i++) assert( memIsValid(&u.bc.r.aMem[i]) ); }
+#endif
 
     /* Extract the value of u.bc.R from register P3. */
     sqlite3VdbeMemIntegerify(pIn3);
@@ -56874,7 +63623,7 @@ case OP_IsUnique: {        /* jump, in3 */
 **
 ** Use the content of register P3 as a integer key.  If a record 
 ** with that key does not exist in table of P1, then jump to P2. 
-** If the record does exist, then fall thru.  The cursor is left 
+** If the record does exist, then fall through.  The cursor is left 
 ** pointing to the record if it exists.
 **
 ** The difference between this operation and NotFound is that this
@@ -57032,7 +63781,9 @@ case OP_NewRowid: {           /* out2-prerelease */
           /* Assert that P3 is a valid memory cell. */
           assert( pOp->p3<=p->nMem );
           u.be.pMem = &aMem[pOp->p3];
+          memAboutToChange(p, u.be.pMem);
         }
+        assert( memIsValid(u.be.pMem) );
 
         REGISTER_TRACE(pOp->p3, u.be.pMem);
         sqlite3VdbeMemIntegerify(u.be.pMem);
@@ -57051,29 +63802,36 @@ case OP_NewRowid: {           /* out2-prerelease */
       sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0);
     }
     if( u.be.pC->useRandomRowid ){
-      /* IMPLEMENTATION-OF: R-48598-02938 If the largest ROWID is equal to the
+      /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the
       ** largest possible integer (9223372036854775807) then the database
-      ** engine starts picking candidate ROWIDs at random until it finds one
-      ** that is not previously used.
-      */
+      ** engine starts picking positive candidate ROWIDs at random until
+      ** it finds one that is not previously used. */
       assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is
                              ** an AUTOINCREMENT table. */
+      /* on the first attempt, simply do one more than previous */
       u.be.v = db->lastRowid;
+      u.be.v &= (MAX_ROWID>>1); /* ensure doesn't go negative */
+      u.be.v++; /* ensure non-zero */
       u.be.cnt = 0;
-      do{
-        if( u.be.cnt==0 && (u.be.v&0xffffff)==u.be.v ){
-          u.be.v++;
+      while(   ((rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v,
+                                                 0, &u.be.res))==SQLITE_OK)
+            && (u.be.res==0)
+            && (++u.be.cnt<100)){
+        /* collision - try another random rowid */
+        sqlite3_randomness(sizeof(u.be.v), &u.be.v);
+        if( u.be.cnt<5 ){
+          /* try "small" random rowids for the initial attempts */
+          u.be.v &= 0xffffff;
         }else{
-          sqlite3_randomness(sizeof(u.be.v), &u.be.v);
-          if( u.be.cnt<5 ) u.be.v &= 0xffffff;
+          u.be.v &= (MAX_ROWID>>1); /* ensure doesn't go negative */
         }
-        rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res);
-        u.be.cnt++;
-      }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
+        u.be.v++; /* ensure non-zero */
+      }
       if( rc==SQLITE_OK && u.be.res==0 ){
         rc = SQLITE_FULL;   /* IMP: R-38219-53002 */
         goto abort_due_to_error;
       }
+      assert( u.be.v>0 );  /* EV: R-40812-03570 */
     }
     u.be.pC->rowidIsValid = 0;
     u.be.pC->deferredMoveto = 0;
@@ -57143,6 +63901,7 @@ case OP_InsertInt: {
 
   u.bf.pData = &aMem[pOp->p2];
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
+  assert( memIsValid(u.bf.pData) );
   u.bf.pC = p->apCsr[pOp->p1];
   assert( u.bf.pC!=0 );
   assert( u.bf.pC->pCursor!=0 );
@@ -57153,6 +63912,7 @@ case OP_InsertInt: {
   if( pOp->opcode==OP_Insert ){
     u.bf.pKey = &aMem[pOp->p3];
     assert( u.bf.pKey->flags & MEM_Int );
+    assert( memIsValid(u.bf.pKey) );
     REGISTER_TRACE(pOp->p3, u.bf.pKey);
     u.bf.iKey = u.bf.pKey->u.i;
   }else{
@@ -57304,6 +64064,7 @@ case OP_RowData: {
 #endif /* local variables moved into u.bh */
 
   pOut = &aMem[pOp->p2];
+  memAboutToChange(p, pOut);
 
   /* Note that RowKey and RowData are really exactly the same instruction */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
@@ -57388,9 +64149,7 @@ case OP_Rowid: {                 /* out2-prerelease */
     u.bi.pModule = u.bi.pVtab->pModule;
     assert( u.bi.pModule->xRowid );
     rc = u.bi.pModule->xRowid(u.bi.pC->pVtabCursor, &u.bi.v);
-    sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.bi.pVtab->zErrMsg;
-    u.bi.pVtab->zErrMsg = 0;
+    importVtabErrMsg(p, u.bi.pVtab);
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
   }else{
     assert( u.bi.pC->pCursor!=0 );
@@ -57502,14 +64261,13 @@ case OP_Rewind: {        /* jump */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   u.bl.pC = p->apCsr[pOp->p1];
   assert( u.bl.pC!=0 );
+  u.bl.res = 1;
   if( (u.bl.pCrsr = u.bl.pC->pCursor)!=0 ){
     rc = sqlite3BtreeFirst(u.bl.pCrsr, &u.bl.res);
     u.bl.pC->atFirst = u.bl.res==0 ?1:0;
     u.bl.pC->deferredMoveto = 0;
     u.bl.pC->cacheStatus = CACHE_STALE;
     u.bl.pC->rowidIsValid = 0;
-  }else{
-    u.bl.res = 1;
   }
   u.bl.pC->nullRow = (u8)u.bl.res;
   assert( pOp->p2>0 && pOp->p2<p->nOp );
@@ -57519,7 +64277,7 @@ case OP_Rewind: {        /* jump */
   break;
 }
 
-/* Opcode: Next P1 P2 * * *
+/* Opcode: Next P1 P2 * * P5
 **
 ** Advance cursor P1 so that it points to the next key/data pair in its
 ** table or index.  If there are no more key/value pairs then fall through
@@ -57528,9 +64286,12 @@ case OP_Rewind: {        /* jump */
 **
 ** The P1 cursor must be for a real table, not a pseudo-table.
 **
+** If P5 is positive and the jump is taken, then event counter
+** number P5-1 in the prepared statement is incremented.
+**
 ** See also: Prev
 */
-/* Opcode: Prev P1 P2 * * *
+/* Opcode: Prev P1 P2 * * P5
 **
 ** Back up cursor P1 so that it points to the previous key/data pair in its
 ** table or index.  If there is no previous key/value pairs then fall through
@@ -57538,6 +64299,9 @@ case OP_Rewind: {        /* jump */
 ** jump immediately to P2.
 **
 ** The P1 cursor must be for a real table, not a pseudo-table.
+**
+** If P5 is positive and the jump is taken, then event counter
+** number P5-1 in the prepared statement is incremented.
 */
 case OP_Prev:          /* jump */
 case OP_Next: {        /* jump */
@@ -57549,6 +64313,7 @@ case OP_Next: {        /* jump */
 
   CHECK_FOR_INTERRUPT;
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
+  assert( pOp->p5<=ArraySize(p->aCounter) );
   u.bm.pC = p->apCsr[pOp->p1];
   if( u.bm.pC==0 ){
     break;  /* See ticket #2273 */
@@ -57642,6 +64407,9 @@ case OP_IdxDelete: {
     u.bo.r.nField = (u16)pOp->p3;
     u.bo.r.flags = 0;
     u.bo.r.aMem = &aMem[pOp->p2];
+#ifdef SQLITE_DEBUG
+    { int i; for(i=0; i<u.bo.r.nField; i++) assert( memIsValid(&u.bo.r.aMem[i]) ); }
+#endif
     rc = sqlite3BtreeMovetoUnpacked(u.bo.pCrsr, &u.bo.r, 0, 0, &u.bo.res);
     if( rc==SQLITE_OK && u.bo.res==0 ){
       rc = sqlite3BtreeDelete(u.bo.pCrsr);
@@ -57703,7 +64471,7 @@ case OP_IdxRowid: {              /* out2-prerelease */
 ** that if the key from register P3 is a prefix of the key in the cursor,
 ** the result is false whereas it would be true with IdxGT.
 */
-/* Opcode: IdxLT P1 P2 P3 * P5
+/* Opcode: IdxLT P1 P2 P3 P4 P5
 **
 ** The P4 register values beginning with P3 form an unpacked index 
 ** key that omits the ROWID.  Compare this key value against the index 
@@ -57726,6 +64494,7 @@ case OP_IdxGE: {        /* jump */
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   u.bq.pC = p->apCsr[pOp->p1];
   assert( u.bq.pC!=0 );
+  assert( u.bq.pC->isOrdered );
   if( ALWAYS(u.bq.pC->pCursor!=0) ){
     assert( u.bq.pC->deferredMoveto==0 );
     assert( pOp->p5==0 || pOp->p5==1 );
@@ -57738,6 +64507,9 @@ case OP_IdxGE: {        /* jump */
       u.bq.r.flags = UNPACKED_IGNORE_ROWID;
     }
     u.bq.r.aMem = &aMem[pOp->p3];
+#ifdef SQLITE_DEBUG
+    { int i; for(i=0; i<u.bq.r.nField; i++) assert( memIsValid(&u.bq.r.aMem[i]) ); }
+#endif
     rc = sqlite3VdbeIdxKeyCompare(u.bq.pC, &u.bq.r, &u.bq.res);
     if( pOp->opcode==OP_IdxLT ){
       u.bq.res = -u.bq.res;
@@ -57841,6 +64613,8 @@ case OP_Clear: {
   if( pOp->p3 ){
     p->nChange += u.bs.nChange;
     if( pOp->p3>0 ){
+      assert( memIsValid(&aMem[pOp->p3]) );
+      memAboutToChange(p, &aMem[pOp->p3]);
       aMem[pOp->p3].u.i += u.bs.nChange;
     }
   }
@@ -57884,9 +64658,9 @@ case OP_CreateTable: {          /* out2-prerelease */
   assert( u.bt.pDb->pBt!=0 );
   if( pOp->opcode==OP_CreateTable ){
     /* u.bt.flags = BTREE_INTKEY; */
-    u.bt.flags = BTREE_LEAFDATA|BTREE_INTKEY;
+    u.bt.flags = BTREE_INTKEY;
   }else{
-    u.bt.flags = BTREE_ZERODATA;
+    u.bt.flags = BTREE_BLOBKEY;
   }
   rc = sqlite3BtreeCreateTable(u.bt.pDb->pBt, &u.bt.pgno, u.bt.flags);
   pOut->u.i = u.bt.pgno;
@@ -58215,6 +64989,7 @@ case OP_Program: {        /* jump */
 
   u.by.pProgram = pOp->p4.pProgram;
   u.by.pRt = &aMem[pOp->p3];
+  assert( memIsValid(u.by.pRt) );
   assert( u.by.pProgram->nOp>0 );
 
   /* If the p5 flag is clear, then recursive invocation of triggers is
@@ -58388,6 +65163,7 @@ case OP_MemMax: {        /* in2 */
   }else{
     u.ca.pIn1 = &aMem[pOp->p1];
   }
+  assert( memIsValid(u.ca.pIn1) );
   sqlite3VdbeMemIntegerify(u.ca.pIn1);
   pIn2 = &aMem[pOp->p2];
   sqlite3VdbeMemIntegerify(pIn2);
@@ -58474,7 +65250,9 @@ case OP_AggStep: {
   u.cb.apVal = p->apArg;
   assert( u.cb.apVal || u.cb.n==0 );
   for(u.cb.i=0; u.cb.i<u.cb.n; u.cb.i++, u.cb.pRec++){
+    assert( memIsValid(u.cb.pRec) );
     u.cb.apVal[u.cb.i] = u.cb.pRec;
+    memAboutToChange(p, u.cb.pRec);
     sqlite3VdbeMemStoreType(u.cb.pRec);
   }
   u.cb.ctx.pFunc = pOp->p4.pFunc;
@@ -58494,7 +65272,7 @@ case OP_AggStep: {
     assert( pOp[-1].opcode==OP_CollSeq );
     u.cb.ctx.pColl = pOp[-1].p4.pColl;
   }
-  (u.cb.ctx.pFunc->xStep)(&u.cb.ctx, u.cb.n, u.cb.apVal);
+  (u.cb.ctx.pFunc->xStep)(&u.cb.ctx, u.cb.n, u.cb.apVal); /* IMP: R-24505-23230 */
   if( u.cb.ctx.isError ){
     sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&u.cb.ctx.s));
     rc = u.cb.ctx.isError;
@@ -58534,6 +65312,141 @@ case OP_AggFinal: {
   break;
 }
 
+#ifndef SQLITE_OMIT_WAL
+/* Opcode: Checkpoint P1 * * * *
+**
+** Checkpoint database P1. This is a no-op if P1 is not currently in
+** WAL mode.
+*/
+case OP_Checkpoint: {
+  rc = sqlite3Checkpoint(db, pOp->p1);
+  break;
+};  
+#endif
+
+#ifndef SQLITE_OMIT_PRAGMA
+/* Opcode: JournalMode P1 P2 P3 * P5
+**
+** Change the journal mode of database P1 to P3. P3 must be one of the
+** PAGER_JOURNALMODE_XXX values. If changing between the various rollback
+** modes (delete, truncate, persist, off and memory), this is a simple
+** operation. No IO is required.
+**
+** If changing into or out of WAL mode the procedure is more complicated.
+**
+** Write a string containing the final journal-mode to register P2.
+*/
+case OP_JournalMode: {    /* out2-prerelease */
+#if 0  /* local variables moved into u.cd */
+  Btree *pBt;                     /* Btree to change journal mode of */
+  Pager *pPager;                  /* Pager associated with pBt */
+  int eNew;                       /* New journal mode */
+  int eOld;                       /* The old journal mode */
+  const char *zFilename;          /* Name of database file for pPager */
+#endif /* local variables moved into u.cd */
+
+  u.cd.eNew = pOp->p3;
+  assert( u.cd.eNew==PAGER_JOURNALMODE_DELETE
+       || u.cd.eNew==PAGER_JOURNALMODE_TRUNCATE
+       || u.cd.eNew==PAGER_JOURNALMODE_PERSIST
+       || u.cd.eNew==PAGER_JOURNALMODE_OFF
+       || u.cd.eNew==PAGER_JOURNALMODE_MEMORY
+       || u.cd.eNew==PAGER_JOURNALMODE_WAL
+       || u.cd.eNew==PAGER_JOURNALMODE_QUERY
+  );
+  assert( pOp->p1>=0 && pOp->p1<db->nDb );
+
+  /* This opcode is used in two places: PRAGMA journal_mode and ATTACH.
+  ** In PRAGMA journal_mode, the sqlite3VdbeUsesBtree() routine is called
+  ** when the statment is prepared and so p->aMutex.nMutex>0.  All mutexes
+  ** are already acquired.  But when used in ATTACH, sqlite3VdbeUsesBtree()
+  ** is not called when the statement is prepared because it requires the
+  ** iDb index of the database as a parameter, and the database has not
+  ** yet been attached so that index is unavailable.  We have to wait
+  ** until runtime (now) to get the mutex on the newly attached database.
+  ** No other mutexes are required by the ATTACH command so this is safe
+  ** to do.
+  */
+  assert( (p->btreeMask & (1<<pOp->p1))!=0 || p->aMutex.nMutex==0 );
+  if( p->aMutex.nMutex==0 ){
+    /* This occurs right after ATTACH.  Get a mutex on the newly ATTACHed
+    ** database. */
+    sqlite3VdbeUsesBtree(p, pOp->p1);
+    sqlite3VdbeMutexArrayEnter(p);
+  }
+
+  u.cd.pBt = db->aDb[pOp->p1].pBt;
+  u.cd.pPager = sqlite3BtreePager(u.cd.pBt);
+  u.cd.eOld = sqlite3PagerGetJournalMode(u.cd.pPager);
+  if( u.cd.eNew==PAGER_JOURNALMODE_QUERY ) u.cd.eNew = u.cd.eOld;
+  if( !sqlite3PagerOkToChangeJournalMode(u.cd.pPager) ) u.cd.eNew = u.cd.eOld;
+
+#ifndef SQLITE_OMIT_WAL
+  u.cd.zFilename = sqlite3PagerFilename(u.cd.pPager);
+
+  /* Do not allow a transition to journal_mode=WAL for a database
+  ** in temporary storage or if the VFS does not support shared memory
+  */
+  if( u.cd.eNew==PAGER_JOURNALMODE_WAL
+   && (u.cd.zFilename[0]==0                         /* Temp file */
+       || !sqlite3PagerWalSupported(u.cd.pPager))   /* No shared-memory support */
+  ){
+    u.cd.eNew = u.cd.eOld;
+  }
+
+  if( (u.cd.eNew!=u.cd.eOld)
+   && (u.cd.eOld==PAGER_JOURNALMODE_WAL || u.cd.eNew==PAGER_JOURNALMODE_WAL)
+  ){
+    if( !db->autoCommit || db->activeVdbeCnt>1 ){
+      rc = SQLITE_ERROR;
+      sqlite3SetString(&p->zErrMsg, db,
+          "cannot change %s wal mode from within a transaction",
+          (u.cd.eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
+      );
+      break;
+    }else{
+
+      if( u.cd.eOld==PAGER_JOURNALMODE_WAL ){
+        /* If leaving WAL mode, close the log file. If successful, the call
+        ** to PagerCloseWal() checkpoints and deletes the write-ahead-log
+        ** file. An EXCLUSIVE lock may still be held on the database file
+        ** after a successful return.
+        */
+        rc = sqlite3PagerCloseWal(u.cd.pPager);
+        if( rc==SQLITE_OK ){
+          sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew);
+        }
+      }else if( u.cd.eOld==PAGER_JOURNALMODE_MEMORY ){
+        /* Cannot transition directly from MEMORY to WAL.  Use mode OFF
+        ** as an intermediate */
+        sqlite3PagerSetJournalMode(u.cd.pPager, PAGER_JOURNALMODE_OFF);
+      }
+
+      /* Open a transaction on the database file. Regardless of the journal
+      ** mode, this transaction always uses a rollback journal.
+      */
+      assert( sqlite3BtreeIsInTrans(u.cd.pBt)==0 );
+      if( rc==SQLITE_OK ){
+        rc = sqlite3BtreeSetVersion(u.cd.pBt, (u.cd.eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));
+      }
+    }
+  }
+#endif /* ifndef SQLITE_OMIT_WAL */
+
+  if( rc ){
+    u.cd.eNew = u.cd.eOld;
+  }
+  u.cd.eNew = sqlite3PagerSetJournalMode(u.cd.pPager, u.cd.eNew);
+
+  pOut = &aMem[pOp->p2];
+  pOut->flags = MEM_Str|MEM_Static|MEM_Term;
+  pOut->z = (char *)sqlite3JournalModename(u.cd.eNew);
+  pOut->n = sqlite3Strlen30(pOut->z);
+  pOut->enc = SQLITE_UTF8;
+  sqlite3VdbeChangeEncoding(pOut, encoding);
+  break;
+};
+#endif /* SQLITE_OMIT_PRAGMA */
 
 #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
 /* Opcode: Vacuum * * * * *
@@ -58556,14 +65469,14 @@ case OP_Vacuum: {
 ** P2. Otherwise, fall through to the next instruction.
 */
 case OP_IncrVacuum: {        /* jump */
-#if 0  /* local variables moved into u.cd */
+#if 0  /* local variables moved into u.ce */
   Btree *pBt;
-#endif /* local variables moved into u.cd */
+#endif /* local variables moved into u.ce */
 
   assert( pOp->p1>=0 && pOp->p1<db->nDb );
   assert( (p->btreeMask & (1<<pOp->p1))!=0 );
-  u.cd.pBt = db->aDb[pOp->p1].pBt;
-  rc = sqlite3BtreeIncrVacuum(u.cd.pBt);
+  u.ce.pBt = db->aDb[pOp->p1].pBt;
+  rc = sqlite3BtreeIncrVacuum(u.ce.pBt);
   if( rc==SQLITE_DONE ){
     pc = pOp->p2 - 1;
     rc = SQLITE_OK;
@@ -58633,16 +65546,12 @@ case OP_TableLock: {
 ** code will be set to SQLITE_LOCKED.
 */
 case OP_VBegin: {
-#if 0  /* local variables moved into u.ce */
+#if 0  /* local variables moved into u.cf */
   VTable *pVTab;
-#endif /* local variables moved into u.ce */
-  u.ce.pVTab = pOp->p4.pVtab;
-  rc = sqlite3VtabBegin(db, u.ce.pVTab);
-  if( u.ce.pVTab ){
-    sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.ce.pVTab->pVtab->zErrMsg;
-    u.ce.pVTab->pVtab->zErrMsg = 0;
-  }
+#endif /* local variables moved into u.cf */
+  u.cf.pVTab = pOp->p4.pVtab;
+  rc = sqlite3VtabBegin(db, u.cf.pVTab);
+  if( u.cf.pVTab ) importVtabErrMsg(p, u.cf.pVTab->pVtab);
   break;
 }
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -58681,34 +65590,32 @@ case OP_VDestroy: {
 ** table and stores that cursor in P1.
 */
 case OP_VOpen: {
-#if 0  /* local variables moved into u.cf */
+#if 0  /* local variables moved into u.cg */
   VdbeCursor *pCur;
   sqlite3_vtab_cursor *pVtabCursor;
   sqlite3_vtab *pVtab;
   sqlite3_module *pModule;
-#endif /* local variables moved into u.cf */
+#endif /* local variables moved into u.cg */
 
-  u.cf.pCur = 0;
-  u.cf.pVtabCursor = 0;
-  u.cf.pVtab = pOp->p4.pVtab->pVtab;
-  u.cf.pModule = (sqlite3_module *)u.cf.pVtab->pModule;
-  assert(u.cf.pVtab && u.cf.pModule);
-  rc = u.cf.pModule->xOpen(u.cf.pVtab, &u.cf.pVtabCursor);
-  sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.cf.pVtab->zErrMsg;
-  u.cf.pVtab->zErrMsg = 0;
+  u.cg.pCur = 0;
+  u.cg.pVtabCursor = 0;
+  u.cg.pVtab = pOp->p4.pVtab->pVtab;
+  u.cg.pModule = (sqlite3_module *)u.cg.pVtab->pModule;
+  assert(u.cg.pVtab && u.cg.pModule);
+  rc = u.cg.pModule->xOpen(u.cg.pVtab, &u.cg.pVtabCursor);
+  importVtabErrMsg(p, u.cg.pVtab);
   if( SQLITE_OK==rc ){
     /* Initialize sqlite3_vtab_cursor base class */
-    u.cf.pVtabCursor->pVtab = u.cf.pVtab;
+    u.cg.pVtabCursor->pVtab = u.cg.pVtab;
 
     /* Initialise vdbe cursor object */
-    u.cf.pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
-    if( u.cf.pCur ){
-      u.cf.pCur->pVtabCursor = u.cf.pVtabCursor;
-      u.cf.pCur->pModule = u.cf.pVtabCursor->pVtab->pModule;
+    u.cg.pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
+    if( u.cg.pCur ){
+      u.cg.pCur->pVtabCursor = u.cg.pVtabCursor;
+      u.cg.pCur->pModule = u.cg.pVtabCursor->pVtab->pModule;
     }else{
       db->mallocFailed = 1;
-      u.cf.pModule->xClose(u.cf.pVtabCursor);
+      u.cg.pModule->xClose(u.cg.pVtabCursor);
     }
   }
   break;
@@ -58735,7 +65642,7 @@ case OP_VOpen: {
 ** A jump is made to P2 if the result set after filtering would be empty.
 */
 case OP_VFilter: {   /* jump */
-#if 0  /* local variables moved into u.cg */
+#if 0  /* local variables moved into u.ch */
   int nArg;
   int iQuery;
   const sqlite3_module *pModule;
@@ -58747,46 +65654,45 @@ case OP_VFilter: {   /* jump */
   int res;
   int i;
   Mem **apArg;
-#endif /* local variables moved into u.cg */
+#endif /* local variables moved into u.ch */
 
-  u.cg.pQuery = &aMem[pOp->p3];
-  u.cg.pArgc = &u.cg.pQuery[1];
-  u.cg.pCur = p->apCsr[pOp->p1];
-  REGISTER_TRACE(pOp->p3, u.cg.pQuery);
-  assert( u.cg.pCur->pVtabCursor );
-  u.cg.pVtabCursor = u.cg.pCur->pVtabCursor;
-  u.cg.pVtab = u.cg.pVtabCursor->pVtab;
-  u.cg.pModule = u.cg.pVtab->pModule;
+  u.ch.pQuery = &aMem[pOp->p3];
+  u.ch.pArgc = &u.ch.pQuery[1];
+  u.ch.pCur = p->apCsr[pOp->p1];
+  assert( memIsValid(u.ch.pQuery) );
+  REGISTER_TRACE(pOp->p3, u.ch.pQuery);
+  assert( u.ch.pCur->pVtabCursor );
+  u.ch.pVtabCursor = u.ch.pCur->pVtabCursor;
+  u.ch.pVtab = u.ch.pVtabCursor->pVtab;
+  u.ch.pModule = u.ch.pVtab->pModule;
 
   /* Grab the index number and argc parameters */
-  assert( (u.cg.pQuery->flags&MEM_Int)!=0 && u.cg.pArgc->flags==MEM_Int );
-  u.cg.nArg = (int)u.cg.pArgc->u.i;
-  u.cg.iQuery = (int)u.cg.pQuery->u.i;
+  assert( (u.ch.pQuery->flags&MEM_Int)!=0 && u.ch.pArgc->flags==MEM_Int );
+  u.ch.nArg = (int)u.ch.pArgc->u.i;
+  u.ch.iQuery = (int)u.ch.pQuery->u.i;
 
   /* Invoke the xFilter method */
   {
-    u.cg.res = 0;
-    u.cg.apArg = p->apArg;
-    for(u.cg.i = 0; u.cg.i<u.cg.nArg; u.cg.i++){
-      u.cg.apArg[u.cg.i] = &u.cg.pArgc[u.cg.i+1];
-      sqlite3VdbeMemStoreType(u.cg.apArg[u.cg.i]);
+    u.ch.res = 0;
+    u.ch.apArg = p->apArg;
+    for(u.ch.i = 0; u.ch.i<u.ch.nArg; u.ch.i++){
+      u.ch.apArg[u.ch.i] = &u.ch.pArgc[u.ch.i+1];
+      sqlite3VdbeMemStoreType(u.ch.apArg[u.ch.i]);
     }
 
     p->inVtabMethod = 1;
-    rc = u.cg.pModule->xFilter(u.cg.pVtabCursor, u.cg.iQuery, pOp->p4.z, u.cg.nArg, u.cg.apArg);
+    rc = u.ch.pModule->xFilter(u.ch.pVtabCursor, u.ch.iQuery, pOp->p4.z, u.ch.nArg, u.ch.apArg);
     p->inVtabMethod = 0;
-    sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.cg.pVtab->zErrMsg;
-    u.cg.pVtab->zErrMsg = 0;
+    importVtabErrMsg(p, u.ch.pVtab);
     if( rc==SQLITE_OK ){
-      u.cg.res = u.cg.pModule->xEof(u.cg.pVtabCursor);
+      u.ch.res = u.ch.pModule->xEof(u.ch.pVtabCursor);
     }
 
-    if( u.cg.res ){
+    if( u.ch.res ){
       pc = pOp->p2 - 1;
     }
   }
-  u.cg.pCur->nullRow = 0;
+  u.ch.pCur->nullRow = 0;
 
   break;
 }
@@ -58800,52 +65706,51 @@ case OP_VFilter: {   /* jump */
 ** P1 cursor is pointing to into register P3.
 */
 case OP_VColumn: {
-#if 0  /* local variables moved into u.ch */
+#if 0  /* local variables moved into u.ci */
   sqlite3_vtab *pVtab;
   const sqlite3_module *pModule;
   Mem *pDest;
   sqlite3_context sContext;
-#endif /* local variables moved into u.ch */
+#endif /* local variables moved into u.ci */
 
   VdbeCursor *pCur = p->apCsr[pOp->p1];
   assert( pCur->pVtabCursor );
   assert( pOp->p3>0 && pOp->p3<=p->nMem );
-  u.ch.pDest = &aMem[pOp->p3];
+  u.ci.pDest = &aMem[pOp->p3];
+  memAboutToChange(p, u.ci.pDest);
   if( pCur->nullRow ){
-    sqlite3VdbeMemSetNull(u.ch.pDest);
+    sqlite3VdbeMemSetNull(u.ci.pDest);
     break;
   }
-  u.ch.pVtab = pCur->pVtabCursor->pVtab;
-  u.ch.pModule = u.ch.pVtab->pModule;
-  assert( u.ch.pModule->xColumn );
-  memset(&u.ch.sContext, 0, sizeof(u.ch.sContext));
+  u.ci.pVtab = pCur->pVtabCursor->pVtab;
+  u.ci.pModule = u.ci.pVtab->pModule;
+  assert( u.ci.pModule->xColumn );
+  memset(&u.ci.sContext, 0, sizeof(u.ci.sContext));
 
   /* The output cell may already have a buffer allocated. Move
-  ** the current contents to u.ch.sContext.s so in case the user-function
+  ** the current contents to u.ci.sContext.s so in case the user-function
   ** can use the already allocated buffer instead of allocating a
   ** new one.
   */
-  sqlite3VdbeMemMove(&u.ch.sContext.s, u.ch.pDest);
-  MemSetTypeFlag(&u.ch.sContext.s, MEM_Null);
+  sqlite3VdbeMemMove(&u.ci.sContext.s, u.ci.pDest);
+  MemSetTypeFlag(&u.ci.sContext.s, MEM_Null);
 
-  rc = u.ch.pModule->xColumn(pCur->pVtabCursor, &u.ch.sContext, pOp->p2);
-  sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.ch.pVtab->zErrMsg;
-  u.ch.pVtab->zErrMsg = 0;
-  if( u.ch.sContext.isError ){
-    rc = u.ch.sContext.isError;
+  rc = u.ci.pModule->xColumn(pCur->pVtabCursor, &u.ci.sContext, pOp->p2);
+  importVtabErrMsg(p, u.ci.pVtab);
+  if( u.ci.sContext.isError ){
+    rc = u.ci.sContext.isError;
   }
 
   /* Copy the result of the function to the P3 register. We
   ** do this regardless of whether or not an error occurred to ensure any
-  ** dynamic allocation in u.ch.sContext.s (a Mem struct) is  released.
+  ** dynamic allocation in u.ci.sContext.s (a Mem struct) is  released.
   */
-  sqlite3VdbeChangeEncoding(&u.ch.sContext.s, encoding);
-  sqlite3VdbeMemMove(u.ch.pDest, &u.ch.sContext.s);
-  REGISTER_TRACE(pOp->p3, u.ch.pDest);
-  UPDATE_MAX_BLOBSIZE(u.ch.pDest);
+  sqlite3VdbeChangeEncoding(&u.ci.sContext.s, encoding);
+  sqlite3VdbeMemMove(u.ci.pDest, &u.ci.sContext.s);
+  REGISTER_TRACE(pOp->p3, u.ci.pDest);
+  UPDATE_MAX_BLOBSIZE(u.ci.pDest);
 
-  if( sqlite3VdbeMemTooBig(u.ch.pDest) ){
+  if( sqlite3VdbeMemTooBig(u.ci.pDest) ){
     goto too_big;
   }
   break;
@@ -58860,22 +65765,22 @@ case OP_VColumn: {
 ** the end of its result set, then fall through to the next instruction.
 */
 case OP_VNext: {   /* jump */
-#if 0  /* local variables moved into u.ci */
+#if 0  /* local variables moved into u.cj */
   sqlite3_vtab *pVtab;
   const sqlite3_module *pModule;
   int res;
   VdbeCursor *pCur;
-#endif /* local variables moved into u.ci */
+#endif /* local variables moved into u.cj */
 
-  u.ci.res = 0;
-  u.ci.pCur = p->apCsr[pOp->p1];
-  assert( u.ci.pCur->pVtabCursor );
-  if( u.ci.pCur->nullRow ){
+  u.cj.res = 0;
+  u.cj.pCur = p->apCsr[pOp->p1];
+  assert( u.cj.pCur->pVtabCursor );
+  if( u.cj.pCur->nullRow ){
     break;
   }
-  u.ci.pVtab = u.ci.pCur->pVtabCursor->pVtab;
-  u.ci.pModule = u.ci.pVtab->pModule;
-  assert( u.ci.pModule->xNext );
+  u.cj.pVtab = u.cj.pCur->pVtabCursor->pVtab;
+  u.cj.pModule = u.cj.pVtab->pModule;
+  assert( u.cj.pModule->xNext );
 
   /* Invoke the xNext() method of the module. There is no way for the
   ** underlying implementation to return an error if one occurs during
@@ -58884,16 +65789,14 @@ case OP_VNext: {   /* jump */
   ** some other method is next invoked on the save virtual table cursor.
   */
   p->inVtabMethod = 1;
-  rc = u.ci.pModule->xNext(u.ci.pCur->pVtabCursor);
+  rc = u.cj.pModule->xNext(u.cj.pCur->pVtabCursor);
   p->inVtabMethod = 0;
-  sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.ci.pVtab->zErrMsg;
-  u.ci.pVtab->zErrMsg = 0;
+  importVtabErrMsg(p, u.cj.pVtab);
   if( rc==SQLITE_OK ){
-    u.ci.res = u.ci.pModule->xEof(u.ci.pCur->pVtabCursor);
+    u.cj.res = u.cj.pModule->xEof(u.cj.pCur->pVtabCursor);
   }
 
-  if( !u.ci.res ){
+  if( !u.cj.res ){
     /* If there is data, jump to P2 */
     pc = pOp->p2 - 1;
   }
@@ -58909,20 +65812,20 @@ case OP_VNext: {   /* jump */
 ** in register P1 is passed as the zName argument to the xRename method.
 */
 case OP_VRename: {
-#if 0  /* local variables moved into u.cj */
+#if 0  /* local variables moved into u.ck */
   sqlite3_vtab *pVtab;
   Mem *pName;
-#endif /* local variables moved into u.cj */
+#endif /* local variables moved into u.ck */
 
-  u.cj.pVtab = pOp->p4.pVtab->pVtab;
-  u.cj.pName = &aMem[pOp->p1];
-  assert( u.cj.pVtab->pModule->xRename );
-  REGISTER_TRACE(pOp->p1, u.cj.pName);
-  assert( u.cj.pName->flags & MEM_Str );
-  rc = u.cj.pVtab->pModule->xRename(u.cj.pVtab, u.cj.pName->z);
-  sqlite3DbFree(db, p->zErrMsg);
-  p->zErrMsg = u.cj.pVtab->zErrMsg;
-  u.cj.pVtab->zErrMsg = 0;
+  u.ck.pVtab = pOp->p4.pVtab->pVtab;
+  u.ck.pName = &aMem[pOp->p1];
+  assert( u.ck.pVtab->pModule->xRename );
+  assert( memIsValid(u.ck.pName) );
+  REGISTER_TRACE(pOp->p1, u.ck.pName);
+  assert( u.ck.pName->flags & MEM_Str );
+  rc = u.ck.pVtab->pModule->xRename(u.ck.pVtab, u.ck.pName->z);
+  importVtabErrMsg(p, u.ck.pVtab);
+  p->expired = 0;
 
   break;
 }
@@ -58953,7 +65856,7 @@ case OP_VRename: {
 ** is set to the value of the rowid for the row just inserted.
 */
 case OP_VUpdate: {
-#if 0  /* local variables moved into u.ck */
+#if 0  /* local variables moved into u.cl */
   sqlite3_vtab *pVtab;
   sqlite3_module *pModule;
   int nArg;
@@ -58961,27 +65864,27 @@ case OP_VUpdate: {
   sqlite_int64 rowid;
   Mem **apArg;
   Mem *pX;
-#endif /* local variables moved into u.ck */
+#endif /* local variables moved into u.cl */
 
-  u.ck.pVtab = pOp->p4.pVtab->pVtab;
-  u.ck.pModule = (sqlite3_module *)u.ck.pVtab->pModule;
-  u.ck.nArg = pOp->p2;
+  u.cl.pVtab = pOp->p4.pVtab->pVtab;
+  u.cl.pModule = (sqlite3_module *)u.cl.pVtab->pModule;
+  u.cl.nArg = pOp->p2;
   assert( pOp->p4type==P4_VTAB );
-  if( ALWAYS(u.ck.pModule->xUpdate) ){
-    u.ck.apArg = p->apArg;
-    u.ck.pX = &aMem[pOp->p3];
-    for(u.ck.i=0; u.ck.i<u.ck.nArg; u.ck.i++){
-      sqlite3VdbeMemStoreType(u.ck.pX);
-      u.ck.apArg[u.ck.i] = u.ck.pX;
-      u.ck.pX++;
-    }
-    rc = u.ck.pModule->xUpdate(u.ck.pVtab, u.ck.nArg, u.ck.apArg, &u.ck.rowid);
-    sqlite3DbFree(db, p->zErrMsg);
-    p->zErrMsg = u.ck.pVtab->zErrMsg;
-    u.ck.pVtab->zErrMsg = 0;
+  if( ALWAYS(u.cl.pModule->xUpdate) ){
+    u.cl.apArg = p->apArg;
+    u.cl.pX = &aMem[pOp->p3];
+    for(u.cl.i=0; u.cl.i<u.cl.nArg; u.cl.i++){
+      assert( memIsValid(u.cl.pX) );
+      memAboutToChange(p, u.cl.pX);
+      sqlite3VdbeMemStoreType(u.cl.pX);
+      u.cl.apArg[u.cl.i] = u.cl.pX;
+      u.cl.pX++;
+    }
+    rc = u.cl.pModule->xUpdate(u.cl.pVtab, u.cl.nArg, u.cl.apArg, &u.cl.rowid);
+    importVtabErrMsg(p, u.cl.pVtab);
     if( rc==SQLITE_OK && pOp->p1 ){
-      assert( u.ck.nArg>1 && u.ck.apArg[0] && (u.ck.apArg[0]->flags&MEM_Null) );
-      db->lastRowid = u.ck.rowid;
+      assert( u.cl.nArg>1 && u.cl.apArg[0] && (u.cl.apArg[0]->flags&MEM_Null) );
+      db->lastRowid = u.cl.rowid;
     }
     p->nChange++;
   }
@@ -58995,21 +65898,7 @@ case OP_VUpdate: {
 ** Write the current number of pages in database P1 to memory cell P2.
 */
 case OP_Pagecount: {            /* out2-prerelease */
-#if 0  /* local variables moved into u.cl */
-  int p1;
-  int nPage;
-  Pager *pPager;
-#endif /* local variables moved into u.cl */
-
-  u.cl.p1 = pOp->p1;
-  u.cl.pPager = sqlite3BtreePager(db->aDb[u.cl.p1].pBt);
-  rc = sqlite3PagerPagecount(u.cl.pPager, &u.cl.nPage);
-  /* OP_Pagecount is always called from within a read transaction.  The
-  ** page count has already been successfully read and cached.  So the
-  ** sqlite3PagerPagecount() call above cannot fail. */
-  if( ALWAYS(rc==SQLITE_OK) ){
-    pOut->u.i = u.cl.nPage;
-  }
+  pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
   break;
 }
 #endif
@@ -59353,10 +66242,14 @@ SQLITE_API int sqlite3_blob_open(
       sqlite3VdbeUsesBtree(v, iDb); 
 
       /* Configure the OP_TableLock instruction */
+#ifdef SQLITE_OMIT_SHARED_CACHE
+      sqlite3VdbeChangeToNoop(v, 2, 1);
+#else
       sqlite3VdbeChangeP1(v, 2, iDb);
       sqlite3VdbeChangeP2(v, 2, pTab->tnum);
       sqlite3VdbeChangeP3(v, 2, flags);
       sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);
+#endif
 
       /* Remove either the OP_OpenWrite or OpenRead. Set the P2 
       ** parameter of the other to pTab->tnum.  */
@@ -59727,7 +66620,11 @@ static struct sqlite3_io_methods JournalFileMethods = {
   0,             /* xCheckReservedLock */
   0,             /* xFileControl */
   0,             /* xSectorSize */
-  0              /* xDeviceCharacteristics */
+  0,             /* xDeviceCharacteristics */
+  0,             /* xShmMap */
+  0,             /* xShmLock */
+  0,             /* xShmBarrier */
+  0              /* xShmUnmap */
 };
 
 /* 
@@ -59977,11 +66874,10 @@ static int memjrnlClose(sqlite3_file *pJfd){
 ** exists purely as a contingency, in case some malfunction in some other
 ** part of SQLite causes Sync to be called by mistake.
 */
-static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){   /*NO_TEST*/
-  UNUSED_PARAMETER2(NotUsed, NotUsed2);                        /*NO_TEST*/
-  assert( 0 );                                                 /*NO_TEST*/
-  return SQLITE_OK;                                            /*NO_TEST*/
-}                                                              /*NO_TEST*/
+static int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){
+  UNUSED_PARAMETER2(NotUsed, NotUsed2);
+  return SQLITE_OK;
+}
 
 /*
 ** Query the size of the file in bytes.
@@ -59995,7 +66891,7 @@ static int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){
 /*
 ** Table of methods for MemJournal sqlite3_file object.
 */
-static struct sqlite3_io_methods MemJournalMethods = {
+static const struct sqlite3_io_methods MemJournalMethods = {
   1,                /* iVersion */
   memjrnlClose,     /* xClose */
   memjrnlRead,      /* xRead */
@@ -60008,7 +66904,11 @@ static struct sqlite3_io_methods MemJournalMethods = {
   0,                /* xCheckReservedLock */
   0,                /* xFileControl */
   0,                /* xSectorSize */
-  0                 /* xDeviceCharacteristics */
+  0,                /* xDeviceCharacteristics */
+  0,                /* xShmMap */
+  0,                /* xShmLock */
+  0,                /* xShmBarrier */
+  0                 /* xShmUnlock */
 };
 
 /* 
@@ -60018,7 +66918,7 @@ SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){
   MemJournal *p = (MemJournal *)pJfd;
   assert( EIGHT_BYTE_ALIGNMENT(p) );
   memset(p, 0, sqlite3MemJournalSize());
-  p->pMethod = &MemJournalMethods;
+  p->pMethod = (sqlite3_io_methods*)&MemJournalMethods;
 }
 
 /*
@@ -60030,8 +66930,7 @@ SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *pJfd){
 }
 
 /* 
-** Return the number of bytes required to store a MemJournal that uses vfs
-** pVfs to create the underlying on-disk files.
+** Return the number of bytes required to store a MemJournal file descriptor.
 */
 SQLITE_PRIVATE int sqlite3MemJournalSize(void){
   return sizeof(MemJournal);
@@ -60531,6 +67430,7 @@ static int lookupName(
     }else{
       sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
     }
+    pParse->checkSchema = 1;
     pTopNC->nErr++;
   }
 
@@ -60577,7 +67477,7 @@ lookupname_end:
 
 /*
 ** Allocate and return a pointer to an expression to load the column iCol
-** from datasource iSrc datasource in SrcList pSrc.
+** from datasource iSrc in SrcList pSrc.
 */
 SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){
   Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);
@@ -60589,6 +67489,8 @@ SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSr
       p->iColumn = -1;
     }else{
       p->iColumn = (ynVar)iCol;
+      testcase( iCol==BMS );
+      testcase( iCol==BMS-1 );
       pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);
     }
     ExprSetProperty(p, EP_Resolved);
@@ -61433,24 +68335,31 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
 }
 
 /*
+** Set the explicit collating sequence for an expression to the
+** collating sequence supplied in the second argument.
+*/
+SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Expr *pExpr, CollSeq *pColl){
+  if( pExpr && pColl ){
+    pExpr->pColl = pColl;
+    pExpr->flags |= EP_ExpCollate;
+  }
+  return pExpr;
+}
+
+/*
 ** Set the collating sequence for expression pExpr to be the collating
 ** sequence named by pToken.   Return a pointer to the revised expression.
 ** The collating sequence is marked as "explicit" using the EP_ExpCollate
 ** flag.  An explicit collating sequence will override implicit
 ** collating sequences.
 */
-SQLITE_PRIVATE Expr *sqlite3ExprSetColl(Parse *pParse, Expr *pExpr, Token *pCollName){
+SQLITE_PRIVATE Expr *sqlite3ExprSetCollByToken(Parse *pParse, Expr *pExpr, Token *pCollName){
   char *zColl = 0;            /* Dequoted name of collation sequence */
   CollSeq *pColl;
   sqlite3 *db = pParse->db;
   zColl = sqlite3NameFromToken(db, pCollName);
-  if( pExpr && zColl ){
-    pColl = sqlite3LocateCollSeq(pParse, zColl);
-    if( pColl ){
-      pExpr->pColl = pColl;
-      pExpr->flags |= EP_ExpCollate;
-    }
-  }
+  pColl = sqlite3LocateCollSeq(pParse, zColl);
+  sqlite3ExprSetColl(pExpr, pColl);
   sqlite3DbFree(db, zColl);
   return pExpr;
 }
@@ -61924,18 +68833,19 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
   }else if( z[0]=='?' ){
     /* Wildcard of the form "?nnn".  Convert "nnn" to an integer and
     ** use it as the variable number */
-    int i = atoi((char*)&z[1]);
+    i64 i;
+    int bOk = 0==sqlite3Atoi64(&z[1], &i, sqlite3Strlen30(&z[1]), SQLITE_UTF8);
     pExpr->iColumn = (ynVar)i;
     testcase( i==0 );
     testcase( i==1 );
     testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );
     testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );
-    if( i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
+    if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
       sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
           db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
     }
     if( i>pParse->nVar ){
-      pParse->nVar = i;
+      pParse->nVar = (int)i;
     }
   }else{
     /* Wildcards like ":aaa", "$aaa" or "@aaa".  Reuse the same variable
@@ -62882,14 +69792,20 @@ SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
     /* Could not found an existing table or index to use as the RHS b-tree.
     ** We will have to generate an ephemeral table to do the job.
     */
+    double savedNQueryLoop = pParse->nQueryLoop;
     int rMayHaveNull = 0;
     eType = IN_INDEX_EPH;
     if( prNotFound ){
       *prNotFound = rMayHaveNull = ++pParse->nMem;
-    }else if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
-      eType = IN_INDEX_ROWID;
+    }else{
+      testcase( pParse->nQueryLoop>(double)1 );
+      pParse->nQueryLoop = (double)1;
+      if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){
+        eType = IN_INDEX_ROWID;
+      }
     }
     sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
+    pParse->nQueryLoop = savedNQueryLoop;
   }else{
     pX->iTable = iTab;
   }
@@ -62898,8 +69814,8 @@ SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){
 #endif
 
 /*
-** Generate code for scalar subqueries used as an expression
-** and IN operators.  Examples:
+** Generate code for scalar subqueries used as a subquery expression, EXISTS,
+** or IN operators.  Examples:
 **
 **     (SELECT a FROM b)          -- subquery
 **     EXISTS (SELECT a FROM b)   -- EXISTS subquery
@@ -62962,10 +69878,10 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
 
   switch( pExpr->op ){
     case TK_IN: {
-      char affinity;
-      KeyInfo keyInfo;
-      int addr;        /* Address of OP_OpenEphemeral instruction */
-      Expr *pLeft = pExpr->pLeft;
+      char affinity;              /* Affinity of the LHS of the IN */
+      KeyInfo keyInfo;            /* Keyinfo for the generated table */
+      int addr;                   /* Address of OP_OpenEphemeral instruction */
+      Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
 
       if( rMayHaveNull ){
         sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);
@@ -62988,6 +69904,7 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
       */
       pExpr->iTable = pParse->nTab++;
       addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);
+      if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
       memset(&keyInfo, 0, sizeof(keyInfo));
       keyInfo.nField = 1;
 
@@ -63012,7 +69929,7 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
           keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,
               pEList->a[0].pExpr);
         }
-      }else if( pExpr->x.pList!=0 ){
+      }else if( ALWAYS(pExpr->x.pList!=0) ){
         /* Case 2:     expr IN (exprlist)
         **
         ** For each expression, build an index key from the evaluation and
@@ -63082,7 +69999,6 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
       ** an integer 0 (not exists) or 1 (exists) into a memory cell
       ** and record that memory cell in iColumn.
       */
-      static const Token one = { "1", 1 };  /* Token for literal value 1 */
       Select *pSel;                         /* SELECT statement to encode */
       SelectDest dest;                      /* How to deal with SELECt result */
 
@@ -63103,7 +70019,8 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(
         VdbeComment((v, "Init EXISTS result"));
       }
       sqlite3ExprDelete(pParse->db, pSel->pLimit);
-      pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &one);
+      pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0,
+                                  &sqlite3IntTokens[1]);
       if( sqlite3Select(pParse, pSel, &dest) ){
         return 0;
       }
@@ -63171,8 +70088,20 @@ static void sqlite3ExprCodeIN(
   sqlite3ExprCachePush(pParse);
   r1 = sqlite3GetTempReg(pParse);
   sqlite3ExprCode(pParse, pExpr->pLeft, r1);
-  sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull);
 
+  /* If the LHS is NULL, then the result is either false or NULL depending
+  ** on whether the RHS is empty or not, respectively.
+  */
+  if( destIfNull==destIfFalse ){
+    /* Shortcut for the common case where the false and NULL outcomes are
+    ** the same. */
+    sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull);
+  }else{
+    int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1);
+    sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
+    sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
+    sqlite3VdbeJumpHere(v, addr1);
+  }
 
   if( eType==IN_INDEX_ROWID ){
     /* In this case, the RHS is the ROWID of table b-tree
@@ -63268,7 +70197,7 @@ static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
   if( ALWAYS(z!=0) ){
     double value;
     char *zV;
-    sqlite3AtoF(z, &value);
+    sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);
     assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */
     if( negateFlag ) value = -value;
     zV = dup8bytes(v, (char*)&value);
@@ -63282,9 +70211,7 @@ static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
 ** Generate an instruction that will put the integer describe by
 ** text z[0..n-1] into register iMem.
 **
-** The z[] string will probably not be zero-terminated.  But the 
-** z[n] character is guaranteed to be something that does not look
-** like the continuation of the number.
+** Expr.u.zToken is always UTF8 and zero-terminated.
 */
 static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
   Vdbe *v = pParse->pVdbe;
@@ -63293,13 +70220,14 @@ static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
     if( negFlag ) i = -i;
     sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
   }else{
+    int c;
+    i64 value;
     const char *z = pExpr->u.zToken;
     assert( z!=0 );
-    if( sqlite3FitsIn64Bits(z, negFlag) ){
-      i64 value;
+    c = sqlite3Atoi64(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);
+    if( c==0 || (c==2 && negFlag) ){
       char *zV;
-      sqlite3Atoi64(z, &value);
-      if( negFlag ) value = -value;
+      if( negFlag ){ value = -value; }
       zV = dup8bytes(v, (char*)&value);
       sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64);
     }else{
@@ -63460,6 +70388,27 @@ static void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){
 }
 
 /*
+** Generate code to extract the value of the iCol-th column of a table.
+*/
+SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
+  Vdbe *v,        /* The VDBE under construction */
+  Table *pTab,    /* The table containing the value */
+  int iTabCur,    /* The cursor for this table */
+  int iCol,       /* Index of the column to extract */
+  int regOut      /* Extract the valud into this register */
+){
+  if( iCol<0 || iCol==pTab->iPKey ){
+    sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
+  }else{
+    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
+    sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut);
+  }
+  if( iCol>=0 ){
+    sqlite3ColumnDefault(v, pTab, iCol, regOut);
+  }
+}
+
+/*
 ** Generate code that will extract the iColumn-th column from
 ** table pTab and store the column value in a register.  An effort
 ** is made to store the column value in register iReg, but this is
@@ -63487,13 +70436,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
     }
   }  
   assert( v!=0 );
-  if( iColumn<0 ){
-    sqlite3VdbeAddOp2(v, OP_Rowid, iTable, iReg);
-  }else if( ALWAYS(pTab!=0) ){
-    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;
-    sqlite3VdbeAddOp3(v, op, iTable, iColumn, iReg);
-    sqlite3ColumnDefault(v, pTab, iColumn, iReg);
-  }
+  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
   sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
   return iReg;
 }
@@ -63570,73 +70513,6 @@ static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
 #endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
 
 /*
-** If the last instruction coded is an ephemeral copy of any of
-** the registers in the nReg registers beginning with iReg, then
-** convert the last instruction from OP_SCopy to OP_Copy.
-*/
-SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse *pParse, int iReg, int nReg){
-  VdbeOp *pOp;
-  Vdbe *v;
-
-  assert( pParse->db->mallocFailed==0 );
-  v = pParse->pVdbe;
-  assert( v!=0 );
-  pOp = sqlite3VdbeGetOp(v, -1);
-  assert( pOp!=0 );
-  if( pOp->opcode==OP_SCopy && pOp->p1>=iReg && pOp->p1<iReg+nReg ){
-    pOp->opcode = OP_Copy;
-  }
-}
-
-/*
-** Generate code to store the value of the iAlias-th alias in register
-** target.  The first time this is called, pExpr is evaluated to compute
-** the value of the alias.  The value is stored in an auxiliary register
-** and the number of that register is returned.  On subsequent calls,
-** the register number is returned without generating any code.
-**
-** Note that in order for this to work, code must be generated in the
-** same order that it is executed.
-**
-** Aliases are numbered starting with 1.  So iAlias is in the range
-** of 1 to pParse->nAlias inclusive.  
-**
-** pParse->aAlias[iAlias-1] records the register number where the value
-** of the iAlias-th alias is stored.  If zero, that means that the
-** alias has not yet been computed.
-*/
-static int codeAlias(Parse *pParse, int iAlias, Expr *pExpr, int target){
-#if 0
-  sqlite3 *db = pParse->db;
-  int iReg;
-  if( pParse->nAliasAlloc<pParse->nAlias ){
-    pParse->aAlias = sqlite3DbReallocOrFree(db, pParse->aAlias,
-                                 sizeof(pParse->aAlias[0])*pParse->nAlias );
-    testcase( db->mallocFailed && pParse->nAliasAlloc>0 );
-    if( db->mallocFailed ) return 0;
-    memset(&pParse->aAlias[pParse->nAliasAlloc], 0,
-           (pParse->nAlias-pParse->nAliasAlloc)*sizeof(pParse->aAlias[0]));
-    pParse->nAliasAlloc = pParse->nAlias;
-  }
-  assert( iAlias>0 && iAlias<=pParse->nAlias );
-  iReg = pParse->aAlias[iAlias-1];
-  if( iReg==0 ){
-    if( pParse->iCacheLevel>0 ){
-      iReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
-    }else{
-      iReg = ++pParse->nMem;
-      sqlite3ExprCode(pParse, pExpr, iReg);
-      pParse->aAlias[iAlias-1] = iReg;
-    }
-  }
-  return iReg;
-#else
-  UNUSED_PARAMETER(iAlias);
-  return sqlite3ExprCodeTarget(pParse, pExpr, target);
-#endif
-}
-
-/*
 ** Generate code into the current Vdbe to evaluate the given
 ** expression.  Attempt to store the results in register "target".
 ** Return the register where results are stored.
@@ -63730,27 +70606,12 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
     }
 #endif
     case TK_VARIABLE: {
-      VdbeOp *pOp;
       assert( !ExprHasProperty(pExpr, EP_IntValue) );
       assert( pExpr->u.zToken!=0 );
       assert( pExpr->u.zToken[0]!=0 );
-      if( pExpr->u.zToken[1]==0
-         && (pOp = sqlite3VdbeGetOp(v, -1))->opcode==OP_Variable
-         && pOp->p1+pOp->p3==pExpr->iColumn
-         && pOp->p2+pOp->p3==target
-         && pOp->p4.z==0
-      ){
-        /* If the previous instruction was a copy of the previous unnamed
-        ** parameter into the previous register, then simply increment the
-        ** repeat count on the prior instruction rather than making a new
-        ** instruction.
-        */
-        pOp->p3++;
-      }else{
-        sqlite3VdbeAddOp3(v, OP_Variable, pExpr->iColumn, target, 1);
-        if( pExpr->u.zToken[1]!=0 ){
-          sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, 0);
-        }
+      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);
+      if( pExpr->u.zToken[1]!=0 ){
+        sqlite3VdbeChangeP4(v, -1, pExpr->u.zToken, 0);
       }
       break;
     }
@@ -63759,7 +70620,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
       break;
     }
     case TK_AS: {
-      inReg = codeAlias(pParse, pExpr->iTable, pExpr->pLeft, target);
+      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
       break;
     }
 #ifndef SQLITE_OMIT_CAST
@@ -64191,6 +71052,11 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
         opCompare.op = TK_EQ;
         opCompare.pLeft = &cacheX;
         pTest = &opCompare;
+        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
+        ** The value in regFree1 might get SCopy-ed into the file result.
+        ** So make sure that the regFree1 register is not reused for other
+        ** purposes and possibly overwritten.  */
+        regFree1 = 0;
       }
       for(i=0; i<nExpr; i=i+2){
         sqlite3ExprCachePush(pParse);
@@ -64284,10 +71150,14 @@ SQLITE_PRIVATE int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
   int inReg;
 
   assert( target>0 && target<=pParse->nMem );
-  inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
-  assert( pParse->pVdbe || pParse->db->mallocFailed );
-  if( inReg!=target && pParse->pVdbe ){
-    sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
+  if( pExpr && pExpr->op==TK_REGISTER ){
+    sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
+  }else{
+    inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
+    assert( pParse->pVdbe || pParse->db->mallocFailed );
+    if( inReg!=target && pParse->pVdbe ){
+      sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
+    }
   }
   return target;
 }
@@ -64460,19 +71330,14 @@ SQLITE_PRIVATE int sqlite3ExprCodeExprList(
   int i, n;
   assert( pList!=0 );
   assert( target>0 );
+  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */
   n = pList->nExpr;
   for(pItem=pList->a, i=0; i<n; i++, pItem++){
-    if( pItem->iAlias ){
-      int iReg = codeAlias(pParse, pItem->iAlias, pItem->pExpr, target+i);
-      Vdbe *v = sqlite3GetVdbe(pParse);
-      if( iReg!=target+i ){
-        sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target+i);
-      }
-    }else{
-      sqlite3ExprCode(pParse, pItem->pExpr, target+i);
-    }
-    if( doHardCopy && !pParse->db->mallocFailed ){
-      sqlite3ExprHardCopy(pParse, target, n);
+    Expr *pExpr = pItem->pExpr;
+    int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);
+    if( inReg!=target+i ){
+      sqlite3VdbeAddOp2(pParse->pVdbe, doHardCopy ? OP_Copy : OP_SCopy,
+                        inReg, target+i);
     }
   }
   return n;
@@ -64817,7 +71682,6 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
 ** an incorrect 0 or 1 could lead to a malfunction.
 */
 SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
-  int i;
   if( pA==0||pB==0 ){
     return pB==pA ? 0 : 2;
   }
@@ -64830,18 +71694,7 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
   if( pA->op!=pB->op ) return 2;
   if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;
   if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;
-
-  if( pA->x.pList && pB->x.pList ){
-    if( pA->x.pList->nExpr!=pB->x.pList->nExpr ) return 2;
-    for(i=0; i<pA->x.pList->nExpr; i++){
-      Expr *pExprA = pA->x.pList->a[i].pExpr;
-      Expr *pExprB = pB->x.pList->a[i].pExpr;
-      if( sqlite3ExprCompare(pExprA, pExprB) ) return 2;
-    }
-  }else if( pA->x.pList || pB->x.pList ){
-    return 2;
-  }
-
+  if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;
   if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;
   if( ExprHasProperty(pA, EP_IntValue) ){
     if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){
@@ -64858,6 +71711,31 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){
   return 0;
 }
 
+/*
+** Compare two ExprList objects.  Return 0 if they are identical and 
+** non-zero if they differ in any way.
+**
+** This routine might return non-zero for equivalent ExprLists.  The
+** only consequence will be disabled optimizations.  But this routine
+** must never return 0 if the two ExprList objects are different, or
+** a malfunction will result.
+**
+** Two NULL pointers are considered to be the same.  But a NULL pointer
+** always differs from a non-NULL pointer.
+*/
+SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){
+  int i;
+  if( pA==0 && pB==0 ) return 0;
+  if( pA==0 || pB==0 ) return 1;
+  if( pA->nExpr!=pB->nExpr ) return 1;
+  for(i=0; i<pA->nExpr; i++){
+    Expr *pExprA = pA->a[i].pExpr;
+    Expr *pExprB = pB->a[i].pExpr;
+    if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
+    if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;
+  }
+  return 0;
+}
 
 /*
 ** Add a new element to the pAggInfo->aCol[] array.  Return the index of
@@ -65354,17 +72232,23 @@ static void renameTriggerFunc(
 /*
 ** Register built-in functions used to help implement ALTER TABLE
 */
-SQLITE_PRIVATE void sqlite3AlterFunctions(sqlite3 *db){
-  sqlite3CreateFunc(db, "sqlite_rename_table", 2, SQLITE_UTF8, 0,
-                         renameTableFunc, 0, 0);
+SQLITE_PRIVATE void sqlite3AlterFunctions(void){
+  static SQLITE_WSD FuncDef aAlterTableFuncs[] = {
+    FUNCTION(sqlite_rename_table,   2, 0, 0, renameTableFunc),
 #ifndef SQLITE_OMIT_TRIGGER
-  sqlite3CreateFunc(db, "sqlite_rename_trigger", 2, SQLITE_UTF8, 0,
-                         renameTriggerFunc, 0, 0);
+    FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),
 #endif
 #ifndef SQLITE_OMIT_FOREIGN_KEY
-  sqlite3CreateFunc(db, "sqlite_rename_parent", 3, SQLITE_UTF8, 0,
-                         renameParentFunc, 0, 0);
+    FUNCTION(sqlite_rename_parent,  3, 0, 0, renameParentFunc),
 #endif
+  };
+  int i;
+  FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
+  FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aAlterTableFuncs);
+
+  for(i=0; i<ArraySize(aAlterTableFuncs); i++){
+    sqlite3FuncDefInsert(pHash, &aFunc[i]);
+  }
 }
 
 /*
@@ -65435,6 +72319,11 @@ static char *whereTempTriggers(Parse *pParse, Table *pTab){
       }
     }
   }
+  if( zWhere ){
+    char *zNew = sqlite3MPrintf(pParse->db, "type='trigger' AND (%s)", zWhere);
+    sqlite3DbFree(pParse->db, zWhere);
+    zWhere = zNew;
+  }
   return zWhere;
 }
 
@@ -65508,7 +72397,9 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
   char *zWhere = 0;         /* Where clause to locate temp triggers */
 #endif
   VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */
-  
+  int savedDbFlags;         /* Saved value of db->flags */
+
+  savedDbFlags = db->flags;  
   if( NEVER(db->mallocFailed) ) goto exit_rename_table;
   assert( pSrc->nSrc==1 );
   assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
@@ -65517,6 +72408,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
   if( !pTab ) goto exit_rename_table;
   iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
   zDb = db->aDb[iDb].zName;
+  db->flags |= SQLITE_PreferBuiltin;
 
   /* Get a NULL terminated version of the new table name. */
   zName = sqlite3NameFromToken(db, pName);
@@ -65684,6 +72576,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
 exit_rename_table:
   sqlite3SrcListDelete(db, pSrc);
   sqlite3DbFree(db, zName);
+  db->flags = savedDbFlags;
 }
 
 
@@ -65803,9 +72696,11 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
   zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
   if( zCol ){
     char *zEnd = &zCol[pColDef->n-1];
+    int savedDbFlags = db->flags;
     while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){
       *zEnd-- = '\0';
     }
+    db->flags |= SQLITE_PreferBuiltin;
     sqlite3NestedParse(pParse, 
         "UPDATE \"%w\".%s SET "
           "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) "
@@ -65814,6 +72709,7 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
       zTab
     );
     sqlite3DbFree(db, zCol);
+    db->flags = savedDbFlags;
   }
 
   /* If the default value of the new column is NULL, then set the file
@@ -65884,7 +72780,6 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
   if( !pNew ) goto exit_begin_add_column;
   pParse->pNewTable = pNew;
   pNew->nRef = 1;
-  pNew->dbMem = pTab->dbMem;
   pNew->nCol = pTab->nCol;
   assert( pNew->nCol>0 );
   nAlloc = (((pNew->nCol-1)/8)*8)+8;
@@ -65959,7 +72854,7 @@ static void openStatTable(
   int iStatCur,           /* Open the sqlite_stat1 table on this cursor */
   const char *zWhere      /* Delete entries associated with this table */
 ){
-  static struct {
+  static const struct {
     const char *zName;
     const char *zCols;
   } aTable[] = {
@@ -66036,7 +72931,8 @@ static void analyzeOneTable(
   int i;                       /* Loop counter */
   int topOfLoop;               /* The top of the loop */
   int endOfLoop;               /* The end of the loop */
-  int addr;                    /* The address of an instruction */
+  int addr = 0;                /* The address of an instruction */
+  int jZeroRows = 0;           /* Jump from here if number of rows is zero */
   int iDb;                     /* Index of database containing pTab */
   int regTabname = iMem++;     /* Register containing table name */
   int regIdxname = iMem++;     /* Register containing index name */
@@ -66055,8 +72951,15 @@ static void analyzeOneTable(
 #endif
 
   v = sqlite3GetVdbe(pParse);
-  if( v==0 || NEVER(pTab==0) || pTab->pIndex==0 ){
-    /* Do no analysis for tables that have no indices */
+  if( v==0 || NEVER(pTab==0) ){
+    return;
+  }
+  if( pTab->tnum==0 ){
+    /* Do not gather statistics on views or virtual tables */
+    return;
+  }
+  if( memcmp(pTab->zName, "sqlite_", 7)==0 ){
+    /* Do not gather statistics on system tables */
     return;
   }
   assert( sqlite3BtreeHoldsAllMutexes(db) );
@@ -66073,6 +72976,7 @@ static void analyzeOneTable(
   sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
 
   iIdxCur = pParse->nTab++;
+  sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0);
   for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
     int nCol = pIdx->nColumn;
     KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);
@@ -66087,10 +72991,7 @@ static void analyzeOneTable(
         (char *)pKey, P4_KEYINFO_HANDOFF);
     VdbeComment((v, "%s", pIdx->zName));
 
-    /* Populate the registers containing the table and index names. */
-    if( pTab->pIndex==pIdx ){
-      sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0);
-    }
+    /* Populate the register containing the index name. */
     sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0);
 
 #ifdef SQLITE_ENABLE_STAT2
@@ -66225,8 +73126,10 @@ static void analyzeOneTable(
     ** If K>0 then it is always the case the D>0 so division by zero
     ** is never possible.
     */
-    addr = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
     sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regSampleno);
+    if( jZeroRows==0 ){
+      jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);
+    }
     for(i=0; i<nCol; i++){
       sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0);
       sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno);
@@ -66240,13 +73143,35 @@ static void analyzeOneTable(
     sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid);
     sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid);
     sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
+  }
+
+  /* If the table has no indices, create a single sqlite_stat1 entry
+  ** containing NULL as the index name and the row count as the content.
+  */
+  if( pTab->pIndex==0 ){
+    sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);
+    VdbeComment((v, "%s", pTab->zName));
+    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regSampleno);
+    sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);
+  }else{
+    assert( jZeroRows>0 );
+    addr = sqlite3VdbeAddOp0(v, OP_Goto);
+    sqlite3VdbeJumpHere(v, jZeroRows);
+  }
+  sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);
+  sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0);
+  sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid);
+  sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid);
+  sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
+  if( pParse->nMem<regRec ) pParse->nMem = regRec;
+  if( jZeroRows ){
     sqlite3VdbeJumpHere(v, addr);
   }
 }
 
 /*
 ** Generate code that will cause the most recent index analysis to
-** be laoded into internal hash tables where is can be used.
+** be loaded into internal hash tables where is can be used.
 */
 static void loadAnalysis(Parse *pParse, int iDb){
   Vdbe *v = sqlite3GetVdbe(pParse);
@@ -66376,33 +73301,46 @@ struct analysisInfo {
 ** This callback is invoked once for each index when reading the
 ** sqlite_stat1 table.  
 **
-**     argv[0] = name of the index
-**     argv[1] = results of analysis - on integer for each column
+**     argv[0] = name of the table
+**     argv[1] = name of the index (might be NULL)
+**     argv[2] = results of analysis - on integer for each column
+**
+** Entries for which argv[1]==NULL simply record the number of rows in
+** the table.
 */
 static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){
   analysisInfo *pInfo = (analysisInfo*)pData;
   Index *pIndex;
-  int i, c;
+  Table *pTable;
+  int i, c, n;
   unsigned int v;
   const char *z;
 
-  assert( argc==2 );
+  assert( argc==3 );
   UNUSED_PARAMETER2(NotUsed, argc);
 
-  if( argv==0 || argv[0]==0 || argv[1]==0 ){
+  if( argv==0 || argv[0]==0 || argv[2]==0 ){
     return 0;
   }
-  pIndex = sqlite3FindIndex(pInfo->db, argv[0], pInfo->zDatabase);
-  if( pIndex==0 ){
+  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);
+  if( pTable==0 ){
     return 0;
   }
-  z = argv[1];
-  for(i=0; *z && i<=pIndex->nColumn; i++){
+  if( argv[1] ){
+    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
+  }else{
+    pIndex = 0;
+  }
+  n = pIndex ? pIndex->nColumn : 0;
+  z = argv[2];
+  for(i=0; *z && i<=n; i++){
     v = 0;
     while( (c=z[0])>='0' && c<='9' ){
       v = v*10 + c - '0';
       z++;
     }
+    if( i==0 ) pTable->nRowEst = v;
+    if( pIndex==0 ) break;
     pIndex->aiRowEst[i] = v;
     if( *z==' ' ) z++;
   }
@@ -66413,21 +73351,20 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){
 ** If the Index.aSample variable is not NULL, delete the aSample[] array
 ** and its contents.
 */
-SQLITE_PRIVATE void sqlite3DeleteIndexSamples(Index *pIdx){
+SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){
 #ifdef SQLITE_ENABLE_STAT2
   if( pIdx->aSample ){
     int j;
-    sqlite3 *dbMem = pIdx->pTable->dbMem;
     for(j=0; j<SQLITE_INDEX_SAMPLES; j++){
       IndexSample *p = &pIdx->aSample[j];
       if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){
-        sqlite3DbFree(pIdx->pTable->dbMem, p->u.z);
+        sqlite3DbFree(db, p->u.z);
       }
     }
-    sqlite3DbFree(dbMem, pIdx->aSample);
-    pIdx->aSample = 0;
+    sqlite3DbFree(db, pIdx->aSample);
   }
 #else
+  UNUSED_PARAMETER(db);
   UNUSED_PARAMETER(pIdx);
 #endif
 }
@@ -66466,7 +73403,8 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
   for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
     Index *pIdx = sqliteHashData(i);
     sqlite3DefaultRowEst(pIdx);
-    sqlite3DeleteIndexSamples(pIdx);
+    sqlite3DeleteIndexSamples(db, pIdx);
+    pIdx->aSample = 0;
   }
 
   /* Check to make sure the sqlite_stat1 table exists */
@@ -66478,7 +73416,7 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
 
   /* Load new statistics out of the sqlite_stat1 table */
   zSql = sqlite3MPrintf(db, 
-      "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
+      "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
   if( zSql==0 ){
     rc = SQLITE_NOMEM;
   }else{
@@ -66510,18 +73448,17 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
         Index *pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase);
         if( pIdx ){
           int iSample = sqlite3_column_int(pStmt, 1);
-          sqlite3 *dbMem = pIdx->pTable->dbMem;
-          assert( dbMem==db || dbMem==0 );
           if( iSample<SQLITE_INDEX_SAMPLES && iSample>=0 ){
             int eType = sqlite3_column_type(pStmt, 2);
 
             if( pIdx->aSample==0 ){
               static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES;
-              pIdx->aSample = (IndexSample *)sqlite3DbMallocZero(dbMem, sz);
+              pIdx->aSample = (IndexSample *)sqlite3DbMallocRaw(0, sz);
               if( pIdx->aSample==0 ){
                 db->mallocFailed = 1;
                 break;
               }
+	      memset(pIdx->aSample, 0, sz);
             }
 
             assert( pIdx->aSample );
@@ -66541,12 +73478,14 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
                   n = 24;
                 }
                 pSample->nByte = (u8)n;
-                pSample->u.z = sqlite3DbMallocRaw(dbMem, n);
-                if( pSample->u.z ){
-                  memcpy(pSample->u.z, z, n);
+                if( n < 1){
+                  pSample->u.z = 0;
                 }else{
-                  db->mallocFailed = 1;
-                  break;
+                  pSample->u.z = sqlite3DbStrNDup(0, z, n);
+                  if( pSample->u.z==0 ){
+                    db->mallocFailed = 1;
+                    break;
+                  }
                 }
               }
             }
@@ -66694,9 +73633,8 @@ static void attachFunc(
   ** it to obtain the database schema. At this point the schema may
   ** or may not be initialised.
   */
-  rc = sqlite3BtreeFactory(db, zFile, 0, SQLITE_DEFAULT_CACHE_SIZE,
-                           db->openFlags | SQLITE_OPEN_MAIN_DB,
-                           &aNew->pBt);
+  rc = sqlite3BtreeOpen(zFile, db, &aNew->pBt, 0,
+                        db->openFlags | SQLITE_OPEN_MAIN_DB);
   db->nDb++;
   if( rc==SQLITE_CONSTRAINT ){
     rc = SQLITE_ERROR;
@@ -66713,7 +73651,6 @@ static void attachFunc(
     }
     pPager = sqlite3BtreePager(aNew->pBt);
     sqlite3PagerLockingMode(pPager, db->dfltLockMode);
-    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
     sqlite3BtreeSecureDelete(aNew->pBt,
                              sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
   }
@@ -66858,7 +73795,7 @@ detach_error:
 static void codeAttach(
   Parse *pParse,       /* The parser context */
   int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */
-  FuncDef *pFunc,      /* FuncDef wrapper for detachFunc() or attachFunc() */
+  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */
   Expr *pAuthArg,      /* Expression to pass to authorization callback */
   Expr *pFilename,     /* Name of database file */
   Expr *pDbname,       /* Name of the database to use internally */
@@ -66928,7 +73865,7 @@ attach_end:
 **     DETACH pDbname
 */
 SQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){
-  static FuncDef detach_func = {
+  static const FuncDef detach_func = {
     1,                /* nArg */
     SQLITE_UTF8,      /* iPrefEnc */
     0,                /* flags */
@@ -66938,7 +73875,8 @@ SQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){
     0,                /* xStep */
     0,                /* xFinalize */
     "sqlite_detach",  /* zName */
-    0                 /* pHash */
+    0,                /* pHash */
+    0                 /* pDestructor */
   };
   codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);
 }
@@ -66949,7 +73887,7 @@ SQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){
 **     ATTACH p AS pDbname KEY pKey
 */
 SQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
-  static FuncDef attach_func = {
+  static const FuncDef attach_func = {
     3,                /* nArg */
     SQLITE_UTF8,      /* iPrefEnc */
     0,                /* flags */
@@ -66959,7 +73897,8 @@ SQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *p
     0,                /* xStep */
     0,                /* xFinalize */
     "sqlite_attach",  /* zName */
-    0                 /* pHash */
+    0,                /* pHash */
+    0                 /* pDestructor */
   };
   codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);
 }
@@ -67707,34 +74646,15 @@ SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const cha
 /*
 ** Reclaim the memory used by an index
 */
-static void freeIndex(Index *p){
-  sqlite3 *db = p->pTable->dbMem;
+static void freeIndex(sqlite3 *db, Index *p){
 #ifndef SQLITE_OMIT_ANALYZE
-  sqlite3DeleteIndexSamples(p);
+  sqlite3DeleteIndexSamples(db, p);
 #endif
   sqlite3DbFree(db, p->zColAff);
   sqlite3DbFree(db, p);
 }
 
 /*
-** Remove the given index from the index hash table, and free
-** its memory structures.
-**
-** The index is removed from the database hash tables but
-** it is not unlinked from the Table that it indexes.
-** Unlinking from the Table must be done by the calling function.
-*/
-static void sqlite3DeleteIndex(Index *p){
-  Index *pOld;
-  const char *zName = p->zName;
-
-  pOld = sqlite3HashInsert(&p->pSchema->idxHash, zName,
-                           sqlite3Strlen30(zName), 0);
-  assert( pOld==0 || pOld==p );
-  freeIndex(p);
-}
-
-/*
 ** For the index called zIdxName which is found in the database iDb,
 ** unlike that index from its Table then remove the index from
 ** the index hash table and free all memory structures associated
@@ -67760,7 +74680,7 @@ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char
         p->pNext = pIndex->pNext;
       }
     }
-    freeIndex(pIndex);
+    freeIndex(db, pIndex);
   }
   db->flags |= SQLITE_InternChanges;
 }
@@ -67831,13 +74751,12 @@ SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){
 }
 
 /*
-** Clear the column names from a table or view.
+** Delete memory allocated for the column names of a table or view (the
+** Table.aCol[] array).
 */
-static void sqliteResetColumnNames(Table *pTable){
+static void sqliteDeleteColumnNames(sqlite3 *db, Table *pTable){
   int i;
   Column *pCol;
-  sqlite3 *db = pTable->dbMem;
-  testcase( db==0 );
   assert( pTable!=0 );
   if( (pCol = pTable->aCol)!=0 ){
     for(i=0; i<pTable->nCol; i++, pCol++){
@@ -67849,8 +74768,6 @@ static void sqliteResetColumnNames(Table *pTable){
     }
     sqlite3DbFree(db, pTable->aCol);
   }
-  pTable->aCol = 0;
-  pTable->nCol = 0;
 }
 
 /*
@@ -67862,42 +74779,44 @@ static void sqliteResetColumnNames(Table *pTable){
 ** memory structures of the indices and foreign keys associated with 
 ** the table.
 */
-SQLITE_PRIVATE void sqlite3DeleteTable(Table *pTable){
+SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
   Index *pIndex, *pNext;
-  sqlite3 *db;
 
-  if( pTable==0 ) return;
-  db = pTable->dbMem;
-  testcase( db==0 );
+  assert( !pTable || pTable->nRef>0 );
 
   /* Do not delete the table until the reference count reaches zero. */
-  pTable->nRef--;
-  if( pTable->nRef>0 ){
-    return;
-  }
-  assert( pTable->nRef==0 );
+  if( !pTable ) return;
+  if( ((!db || db->pnBytesFreed==0) && (--pTable->nRef)>0) ) return;
 
-  /* Delete all indices associated with this table
-  */
+  /* Delete all indices associated with this table. */
   for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
     pNext = pIndex->pNext;
     assert( pIndex->pSchema==pTable->pSchema );
-    sqlite3DeleteIndex(pIndex);
+    if( !db || db->pnBytesFreed==0 ){
+      char *zName = pIndex->zName; 
+      TESTONLY ( Index *pOld = ) sqlite3HashInsert(
+	  &pIndex->pSchema->idxHash, zName, sqlite3Strlen30(zName), 0
+      );
+      assert( pOld==pIndex || pOld==0 );
+    }
+    freeIndex(db, pIndex);
   }
 
   /* Delete any foreign keys attached to this table. */
-  sqlite3FkDelete(pTable);
+  sqlite3FkDelete(db, pTable);
 
   /* Delete the Table structure itself.
   */
-  sqliteResetColumnNames(pTable);
+  sqliteDeleteColumnNames(db, pTable);
   sqlite3DbFree(db, pTable->zName);
   sqlite3DbFree(db, pTable->zColAff);
   sqlite3SelectDelete(db, pTable->pSelect);
 #ifndef SQLITE_OMIT_CHECK
   sqlite3ExprDelete(db, pTable->pCheck);
 #endif
-  sqlite3VtabClear(pTable);
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  sqlite3VtabClear(db, pTable);
+#endif
   sqlite3DbFree(db, pTable);
 }
 
@@ -67916,7 +74835,7 @@ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char
   pDb = &db->aDb[iDb];
   p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
                         sqlite3Strlen30(zTabName),0);
-  sqlite3DeleteTable(p);
+  sqlite3DeleteTable(db, p);
   db->flags |= SQLITE_InternChanges;
 }
 
@@ -68108,8 +75027,9 @@ SQLITE_PRIVATE void sqlite3StartTable(
   */
   iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
   if( iDb<0 ) return;
-  if( !OMIT_TEMPDB && isTemp && iDb>1 ){
-    /* If creating a temp table, the name may not be qualified */
+  if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){
+    /* If creating a temp table, the name may not be qualified. Unless 
+    ** the database name is "temp" anyway.  */
     sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
     return;
   }
@@ -68157,17 +75077,18 @@ SQLITE_PRIVATE void sqlite3StartTable(
   ** collisions.
   */
   if( !IN_DECLARE_VTAB ){
+    char *zDb = db->aDb[iDb].zName;
     if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
       goto begin_table_error;
     }
-    pTable = sqlite3FindTable(db, zName, db->aDb[iDb].zName);
+    pTable = sqlite3FindTable(db, zName, zDb);
     if( pTable ){
       if( !noErr ){
         sqlite3ErrorMsg(pParse, "table %T already exists", pName);
       }
       goto begin_table_error;
     }
-    if( sqlite3FindIndex(db, zName, 0)!=0 && (iDb==0 || !db->init.busy) ){
+    if( sqlite3FindIndex(db, zName, zDb)!=0 ){
       sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
       goto begin_table_error;
     }
@@ -68184,7 +75105,7 @@ SQLITE_PRIVATE void sqlite3StartTable(
   pTable->iPKey = -1;
   pTable->pSchema = db->aDb[iDb].pSchema;
   pTable->nRef = 1;
-  pTable->dbMem = 0;
+  pTable->nRowEst = 1000000;
   assert( pParse->pNewTable==0 );
   pParse->pNewTable = pTable;
 
@@ -68736,7 +75657,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){
     zEnd = "\n)";
   }
   n += 35 + 6*p->nCol;
-  zStmt = sqlite3Malloc( n );
+  zStmt = sqlite3DbMallocRaw(0, n);
   if( zStmt==0 ){
     db->mallocFailed = 1;
     return 0;
@@ -68917,7 +75838,7 @@ SQLITE_PRIVATE void sqlite3EndTable(
         p->aCol = pSelTab->aCol;
         pSelTab->nCol = 0;
         pSelTab->aCol = 0;
-        sqlite3DeleteTable(pSelTab);
+        sqlite3DeleteTable(db, pSelTab);
       }
     }
 
@@ -69031,12 +75952,10 @@ SQLITE_PRIVATE void sqlite3CreateView(
   }
   sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);
   p = pParse->pNewTable;
-  if( p==0 ){
+  if( p==0 || pParse->nErr ){
     sqlite3SelectDelete(db, pSelect);
     return;
   }
-  assert( pParse->nErr==0 ); /* If sqlite3StartTable return non-NULL then
-                             ** there could not have been an error */
   sqlite3TwoPartName(pParse, pName1, pName2, &pName);
   iDb = sqlite3SchemaToIndex(db, p->pSchema);
   if( sqlite3FixInit(&sFix, pParse, iDb, "view", pName)
@@ -69161,7 +76080,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
       pTable->aCol = pSelTab->aCol;
       pSelTab->nCol = 0;
       pSelTab->aCol = 0;
-      sqlite3DeleteTable(pSelTab);
+      sqlite3DeleteTable(db, pSelTab);
       pTable->pSchema->flags |= DB_UnresetViews;
     }else{
       pTable->nCol = 0;
@@ -69186,7 +76105,9 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){
   for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){
     Table *pTab = sqliteHashData(i);
     if( pTab->pSelect ){
-      sqliteResetColumnNames(pTab);
+      sqliteDeleteColumnNames(db, pTab);
+      pTab->aCol = 0;
+      pTab->nCol = 0;
     }
   }
   DbClearProperty(db, idx, DB_UnresetViews);
@@ -69976,6 +76897,7 @@ SQLITE_PRIVATE Index *sqlite3CreateIndex(
     if( j>=pTab->nCol ){
       sqlite3ErrorMsg(pParse, "table %s has no column named %s",
         pTab->zName, zColName);
+      pParse->checkSchema = 1;
       goto exit_create_index;
     }
     pIndex->aiColumn[i] = j;
@@ -70151,7 +77073,8 @@ SQLITE_PRIVATE Index *sqlite3CreateIndex(
       sqlite3RefillIndex(pParse, pIndex, iMem);
       sqlite3ChangeCookie(pParse, iDb);
       sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 0, 0,
-         sqlite3MPrintf(db, "name='%q'", pIndex->zName), P4_DYNAMIC);
+         sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName), 
+         P4_DYNAMIC);
       sqlite3VdbeAddOp1(v, OP_Expire, 0);
     }
   }
@@ -70182,7 +77105,7 @@ SQLITE_PRIVATE Index *sqlite3CreateIndex(
   /* Clean up before exiting */
 exit_create_index:
   if( pIndex ){
-    sqlite3_free(pIndex->zColAff);
+    sqlite3DbFree(db, pIndex->zColAff);
     sqlite3DbFree(db, pIndex);
   }
   sqlite3ExprListDelete(db, pList);
@@ -70212,14 +77135,14 @@ exit_create_index:
 SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){
   unsigned *a = pIdx->aiRowEst;
   int i;
+  unsigned n;
   assert( a!=0 );
-  a[0] = 1000000;
-  for(i=pIdx->nColumn; i>=5; i--){
-    a[i] = 5;
-  }
-  while( i>=1 ){
-    a[i] = 11 - i;
-    i--;
+  a[0] = pIdx->pTable->nRowEst;
+  if( a[0]<10 ) a[0] = 10;
+  n = 10;
+  for(i=1; i<=pIdx->nColumn; i++){
+    a[i] = n;
+    if( n>5 ) n--;
   }
   if( pIdx->onError!=OE_None ){
     a[pIdx->nColumn] = 1;
@@ -70279,7 +77202,7 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists
   if( v ){
     sqlite3BeginWriteOperation(pParse, 1, iDb);
     sqlite3NestedParse(pParse,
-       "DELETE FROM %Q.%s WHERE name=%Q",
+       "DELETE FROM %Q.%s WHERE name=%Q AND type='index'",
        db->aDb[iDb].zName, SCHEMA_TABLE(iDb),
        pIndex->zName
     );
@@ -70561,7 +77484,7 @@ SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){
     sqlite3DbFree(db, pItem->zName);
     sqlite3DbFree(db, pItem->zAlias);
     sqlite3DbFree(db, pItem->zIndex);
-    sqlite3DeleteTable(pItem->pTab);
+    sqlite3DeleteTable(db, pItem->pTab);
     sqlite3SelectDelete(db, pItem->pSelect);
     sqlite3ExprDelete(db, pItem->pOn);
     sqlite3IdListDelete(db, pItem->pUsing);
@@ -70744,7 +77667,7 @@ SQLITE_PRIVATE void sqlite3Savepoint(Parse *pParse, int op, Token *pName){
   if( zName ){
     Vdbe *v = sqlite3GetVdbe(pParse);
 #ifndef SQLITE_OMIT_AUTHORIZATION
-    static const char *az[] = { "BEGIN", "RELEASE", "ROLLBACK" };
+    static const char * const az[] = { "BEGIN", "RELEASE", "ROLLBACK" };
     assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );
 #endif
     if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){
@@ -70771,7 +77694,7 @@ SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){
           SQLITE_OPEN_DELETEONCLOSE |
           SQLITE_OPEN_TEMP_DB;
 
-    rc = sqlite3BtreeFactory(db, 0, 0, SQLITE_DEFAULT_CACHE_SIZE, flags, &pBt);
+    rc = sqlite3BtreeOpen(0, db, &pBt, 0, flags);
     if( rc!=SQLITE_OK ){
       sqlite3ErrorMsg(pParse, "unable to open a temporary database "
         "file for storing temporary tables");
@@ -70784,7 +77707,6 @@ SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){
       db->mallocFailed = 1;
       return 1;
     }
-    sqlite3PagerJournalMode(sqlite3BtreePager(pBt), db->dfltJournalMode);
   }
   return 0;
 }
@@ -71424,14 +78346,19 @@ SQLITE_PRIVATE FuncDef *sqlite3FindFunction(
 
   /* If no match is found, search the built-in functions.
   **
+  ** If the SQLITE_PreferBuiltin flag is set, then search the built-in
+  ** functions even if a prior app-defined function was found.  And give
+  ** priority to built-in functions.
+  **
   ** Except, if createFlag is true, that means that we are trying to
-  ** install a new function.  Whatever FuncDef structure is returned will
+  ** install a new function.  Whatever FuncDef structure is returned it will
   ** have fields overwritten with new information appropriate for the
   ** new function.  But the FuncDefs for built-in functions are read-only.
   ** So we must not search for built-ins when creating a new function.
   */ 
-  if( !createFlag && !pBest ){
+  if( !createFlag && (pBest==0 || (db->flags & SQLITE_PreferBuiltin)!=0) ){
     FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
+    bestScore = 0;
     p = functionSearch(pHash, h, zName, nName);
     while( p ){
       int score = matchQuality(p, nArg, enc);
@@ -71488,8 +78415,7 @@ SQLITE_PRIVATE void sqlite3SchemaFree(void *p){
   sqlite3HashInit(&pSchema->tblHash);
   for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
     Table *pTab = sqliteHashData(pElem);
-    assert( pTab->dbMem==0 );
-    sqlite3DeleteTable(pTab);
+    sqlite3DeleteTable(0, pTab);
   }
   sqlite3HashClear(&temp1);
   sqlite3HashClear(&pSchema->fkeyHash);
@@ -71506,7 +78432,7 @@ SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){
   if( pBt ){
     p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaFree);
   }else{
-    p = (Schema *)sqlite3MallocZero(sizeof(Schema));
+    p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));
   }
   if( !p ){
     db->mallocFailed = 1;
@@ -71547,7 +78473,7 @@ SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
   Table *pTab;
   assert( pItem && pSrc->nSrc==1 );
   pTab = sqlite3LocateTable(pParse, 0, pItem->zName, pItem->zDatabase);
-  sqlite3DeleteTable(pItem->pTab);
+  sqlite3DeleteTable(pParse->db, pItem->pTab);
   pItem->pTab = pTab;
   if( pTab ){
     pTab->nRef++;
@@ -72031,9 +78957,7 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete(
     sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld);
     for(iCol=0; iCol<pTab->nCol; iCol++){
       if( mask==0xffffffff || mask&(1<<iCol) ){
-        int iTarget = iOld + iCol + 1;
-        sqlite3VdbeAddOp3(v, OP_Column, iCur, iCol, iTarget);
-        sqlite3ColumnDefault(v, pTab, iCol, iTarget);
+        sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld+iCol+1);
       }
     }
 
@@ -72443,7 +79367,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
       sqlite3_result_error_nomem(context);
       return;
     }
-    sqlite3AtoF(zBuf, &r);
+    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
     sqlite3_free(zBuf);
   }
   sqlite3_result_double(context, r);
@@ -72946,8 +79870,10 @@ static void compileoptionusedFunc(
   const char *zOptName;
   assert( argc==1 );
   UNUSED_PARAMETER(argc);
-  /* IMP: R-xxxx This function is an SQL wrapper around the
-  ** sqlite3_compileoption_used() C interface. */
+  /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL
+  ** function is a wrapper around the sqlite3_compileoption_used() C/C++
+  ** function.
+  */
   if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){
     sqlite3_result_int(context, sqlite3_compileoption_used(zOptName));
   }
@@ -72968,8 +79894,9 @@ static void compileoptiongetFunc(
   int n;
   assert( argc==1 );
   UNUSED_PARAMETER(argc);
-  /* IMP: R-xxxx This function is an SQL wrapper around the
-  ** sqlite3_compileoption_get() C interface. */
+  /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function
+  ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.
+  */
   n = sqlite3_value_int(argv[0]);
   sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC);
 }
@@ -73168,14 +80095,14 @@ static void replaceFunc(
       testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );
       if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
         sqlite3_result_error_toobig(context);
-        sqlite3DbFree(db, zOut);
+        sqlite3_free(zOut);
         return;
       }
       zOld = zOut;
       zOut = sqlite3_realloc(zOut, (int)nOut);
       if( zOut==0 ){
         sqlite3_result_error_nomem(context);
-        sqlite3DbFree(db, zOld);
+        sqlite3_free(zOld);
         return;
       }
       memcpy(&zOut[j], zRep, nRep);
@@ -73536,7 +80463,7 @@ static void groupConcatStep(
   if( pAccum ){
     sqlite3 *db = sqlite3_context_db_handle(context);
     int firstTerm = pAccum->useMalloc==0;
-    pAccum->useMalloc = 1;
+    pAccum->useMalloc = 2;
     pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
     if( !firstTerm ){
       if( argc==2 ){
@@ -73569,20 +80496,15 @@ static void groupConcatFinalize(sqlite3_context *context){
 }
 
 /*
-** This function registered all of the above C functions as SQL
-** functions.  This should be the only routine in this file with
-** external linkage.
+** This routine does per-connection function registration.  Most
+** of the built-in functions above are part of the global function set.
+** This routine only deals with those that are not global.
 */
 SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
-#ifndef SQLITE_OMIT_ALTERTABLE
-  sqlite3AlterFunctions(db);
-#endif
-  if( !db->mallocFailed ){
-    int rc = sqlite3_overload_function(db, "MATCH", 2);
-    assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );
-    if( rc==SQLITE_NOMEM ){
-      db->mallocFailed = 1;
-    }
+  int rc = sqlite3_overload_function(db, "MATCH", 2);
+  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );
+  if( rc==SQLITE_NOMEM ){
+    db->mallocFailed = 1;
   }
 }
 
@@ -73610,10 +80532,10 @@ SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive)
   }else{
     pInfo = (struct compareInfo*)&likeInfoNorm;
   }
-  sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0);
-  sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0);
+  sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0);
+  sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0);
   sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, 
-      (struct compareInfo*)&globInfo, likeFunc, 0,0);
+      (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);
   setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);
   setLikeOptFlag(db, "like", 
       caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);
@@ -73697,10 +80619,10 @@ SQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void){
     FUNCTION(coalesce,           1, 0, 0, 0                ),
     FUNCTION(coalesce,           0, 0, 0, 0                ),
 /*  FUNCTION(coalesce,          -1, 0, 0, ifnullFunc       ), */
-    {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0},
+    {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0},
     FUNCTION(hex,                1, 0, 0, hexFunc          ),
 /*  FUNCTION(ifnull,             2, 0, 0, ifnullFunc       ), */
-    {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0},
+    {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0},
     FUNCTION(random,             0, 0, 0, randomFunc       ),
     FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
     FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
@@ -73727,7 +80649,7 @@ SQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void){
     AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),
     AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),
  /* AGGREGATE(count,             0, 0, 0, countStep,       countFinalize  ), */
-    {0,SQLITE_UTF8,SQLITE_FUNC_COUNT,0,0,0,countStep,countFinalize,"count",0},
+    {0,SQLITE_UTF8,SQLITE_FUNC_COUNT,0,0,0,countStep,countFinalize,"count",0,0},
     AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),
     AGGREGATE(group_concat,      1, 0, 0, groupConcatStep, groupConcatFinalize),
     AGGREGATE(group_concat,      2, 0, 0, groupConcatStep, groupConcatFinalize),
@@ -73750,6 +80672,9 @@ SQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void){
     sqlite3FuncDefInsert(pHash, &aFunc[i]);
   }
   sqlite3RegisterDateTimeFunctions();
+#ifndef SQLITE_OMIT_ALTERTABLE
+  sqlite3AlterFunctions();
+#endif
 }
 
 /************** End of func.c ************************************************/
@@ -74135,7 +81060,7 @@ static void fkLookupParent(
       sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);
       sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF);
       for(i=0; i<nCol; i++){
-        sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[i]+1+regData, regTemp+i);
+        sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);
       }
   
       /* If the parent table is the same as the child table, and we are about
@@ -74255,7 +81180,8 @@ static void fkScanChildren(
       if( pIdx ){
         Column *pCol;
         iCol = pIdx->aiColumn[i];
-        pCol = &pIdx->pTable->aCol[iCol];
+        pCol = &pTab->aCol[iCol];
+        if( pTab->iPKey==iCol ) iCol = -1;
         pLeft->iTable = regData+iCol+1;
         pLeft->affinity = pCol->affinity;
         pLeft->pColl = sqlite3LocateCollSeq(pParse, pCol->zColl);
@@ -74816,11 +81742,7 @@ static Trigger *fkActionTrigger(
       pWhere = 0;
     }
 
-    /* In the current implementation, pTab->dbMem==0 for all tables except
-    ** for temporary tables used to describe subqueries.  And temporary
-    ** tables do not have foreign key constraints.  Hence, pTab->dbMem
-    ** should always be 0 there.
-    */
+    /* Disable lookaside memory allocation */
     enableLookaside = db->lookaside.bEnabled;
     db->lookaside.bEnabled = 0;
 
@@ -74910,37 +81832,39 @@ SQLITE_PRIVATE void sqlite3FkActions(
 ** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash
 ** hash table.
 */
-SQLITE_PRIVATE void sqlite3FkDelete(Table *pTab){
+SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){
   FKey *pFKey;                    /* Iterator variable */
   FKey *pNext;                    /* Copy of pFKey->pNextFrom */
 
   for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){
 
     /* Remove the FK from the fkeyHash hash table. */
-    if( pFKey->pPrevTo ){
-      pFKey->pPrevTo->pNextTo = pFKey->pNextTo;
-    }else{
-      void *data = (void *)pFKey->pNextTo;
-      const char *z = (data ? pFKey->pNextTo->zTo : pFKey->zTo);
-      sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, sqlite3Strlen30(z), data);
-    }
-    if( pFKey->pNextTo ){
-      pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;
+    if( !db || db->pnBytesFreed==0 ){
+      if( pFKey->pPrevTo ){
+        pFKey->pPrevTo->pNextTo = pFKey->pNextTo;
+      }else{
+        void *p = (void *)pFKey->pNextTo;
+        const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo);
+        sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, sqlite3Strlen30(z), p);
+      }
+      if( pFKey->pNextTo ){
+        pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;
+      }
     }
 
-    /* Delete any triggers created to implement actions for this FK. */
-#ifndef SQLITE_OMIT_TRIGGER
-    fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[0]);
-    fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[1]);
-#endif
-
     /* EV: R-30323-21917 Each foreign key constraint in SQLite is
     ** classified as either immediate or deferred.
     */
     assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );
 
+    /* Delete any triggers created to implement actions for this FK. */
+#ifndef SQLITE_OMIT_TRIGGER
+    fkTriggerDelete(db, pFKey->apTrigger[0]);
+    fkTriggerDelete(db, pFKey->apTrigger[1]);
+#endif
+
     pNext = pFKey->pNextFrom;
-    sqlite3DbFree(pTab->dbMem, pFKey);
+    sqlite3DbFree(db, pFKey);
   }
 }
 #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */
@@ -75015,7 +81939,7 @@ SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){
     int n;
     Table *pTab = pIdx->pTable;
     sqlite3 *db = sqlite3VdbeDb(v);
-    pIdx->zColAff = (char *)sqlite3Malloc(pIdx->nColumn+2);
+    pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+2);
     if( !pIdx->zColAff ){
       db->mallocFailed = 1;
       return 0;
@@ -75057,7 +81981,7 @@ SQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){
     int i;
     sqlite3 *db = sqlite3VdbeDb(v);
 
-    zColAff = (char *)sqlite3Malloc(pTab->nCol+1);
+    zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);
     if( !zColAff ){
       db->mallocFailed = 1;
       return;
@@ -75675,7 +82599,7 @@ SQLITE_PRIVATE void sqlite3Insert(
         }else{
           sqlite3ErrorMsg(pParse, "table %S has no column named %s",
               pTabList, 0, pColumn->a[i].zName);
-          pParse->nErr++;
+          pParse->checkSchema = 1;
           goto insert_cleanup;
         }
       }
@@ -75794,7 +82718,7 @@ SQLITE_PRIVATE void sqlite3Insert(
           if( pColumn->a[j].idx==i ) break;
         }
       }
-      if( pColumn && j>=pColumn->nId ){
+      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId) ){
         sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);
       }else if( useTempTable ){
         sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); 
@@ -76168,6 +83092,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
     if( onError==OE_Ignore ){
       sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
     }else{
+      if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
       sqlite3HaltConstraint(pParse, onError, 0, 0);
     }
     sqlite3VdbeResolveLabel(v, allOk);
@@ -77682,13 +84607,11 @@ static int sqlite3LoadExtension(
   handle = sqlite3OsDlOpen(pVfs, zFile);
   if( handle==0 ){
     if( pzErrMsg ){
-      zErrmsg = sqlite3StackAllocZero(db, nMsg);
+      *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
       if( zErrmsg ){
         sqlite3_snprintf(nMsg, zErrmsg, 
             "unable to open shared library [%s]", zFile);
         sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
-        *pzErrMsg = sqlite3DbStrDup(0, zErrmsg);
-        sqlite3StackFree(db, zErrmsg);
       }
     }
     return SQLITE_ERROR;
@@ -77697,13 +84620,11 @@ static int sqlite3LoadExtension(
                    sqlite3OsDlSym(pVfs, handle, zProc);
   if( xInit==0 ){
     if( pzErrMsg ){
-      zErrmsg = sqlite3StackAllocZero(db, nMsg);
+      *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
       if( zErrmsg ){
         sqlite3_snprintf(nMsg, zErrmsg,
             "no entry point [%s] in shared library [%s]", zProc,zFile);
         sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
-        *pzErrMsg = sqlite3DbStrDup(0, zErrmsg);
-        sqlite3StackFree(db, zErrmsg);
       }
       sqlite3OsDlClose(pVfs, handle);
     }
@@ -78090,6 +85011,9 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){
     { "legacy_file_format",       SQLITE_LegacyFileFmt },
     { "fullfsync",                SQLITE_FullFSync     },
     { "reverse_unordered_selects", SQLITE_ReverseOrder  },
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+    { "automatic_index",          SQLITE_AutoIndex     },
+#endif
 #ifdef SQLITE_DEBUG
     { "sql_trace",                SQLITE_SqlTrace      },
     { "vdbe_listing",             SQLITE_VdbeListing   },
@@ -78171,6 +85095,31 @@ static const char *actionName(u8 action){
 }
 #endif
 
+
+/*
+** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants
+** defined in pager.h. This function returns the associated lowercase
+** journal-mode name.
+*/
+SQLITE_PRIVATE const char *sqlite3JournalModename(int eMode){
+  static char * const azModeName[] = {
+    "delete", "persist", "off", "truncate", "memory"
+#ifndef SQLITE_OMIT_WAL
+     , "wal"
+#endif
+  };
+  assert( PAGER_JOURNALMODE_DELETE==0 );
+  assert( PAGER_JOURNALMODE_PERSIST==1 );
+  assert( PAGER_JOURNALMODE_OFF==2 );
+  assert( PAGER_JOURNALMODE_TRUNCATE==3 );
+  assert( PAGER_JOURNALMODE_MEMORY==4 );
+  assert( PAGER_JOURNALMODE_WAL==5 );
+  assert( eMode>=0 && eMode<=ArraySize(azModeName) );
+
+  if( eMode==ArraySize(azModeName) ) return 0;
+  return azModeName[eMode];
+}
+
 /*
 ** Process a pragma statement.  
 **
@@ -78243,11 +85192,11 @@ SQLITE_PRIVATE void sqlite3Pragma(
   ** page cache size value and the persistent page cache size value
   ** stored in the database file.
   **
-  ** The default cache size is stored in meta-value 2 of page 1 of the
-  ** database file.  The cache size is actually the absolute value of
-  ** this memory location.  The sign of meta-value 2 determines the
-  ** synchronous setting.  A negative value means synchronous is off
-  ** and a positive value means synchronous is on.
+  ** Older versions of SQLite would set the default cache size to a
+  ** negative number to indicate synchronous=OFF.  These days, synchronous
+  ** is always on by default regardless of the sign of the default cache
+  ** size.  But continue to take the absolute value of the default cache
+  ** size of historical compatibility.
   */
   if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){
     static const VdbeOpList getCacheSize[] = {
@@ -78276,10 +85225,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
       if( size<0 ) size = -size;
       sqlite3BeginWriteOperation(pParse, 0, iDb);
       sqlite3VdbeAddOp2(v, OP_Integer, size, 1);
-      sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, 2, BTREE_DEFAULT_CACHE_SIZE);
-      addr = sqlite3VdbeAddOp2(v, OP_IfPos, 2, 0);
-      sqlite3VdbeAddOp2(v, OP_Integer, -size, 1);
-      sqlite3VdbeJumpHere(v, addr);
       sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);
       pDb->pSchema->cache_size = size;
       sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);
@@ -78424,62 +85369,49 @@ SQLITE_PRIVATE void sqlite3Pragma(
 
   /*
   **  PRAGMA [database.]journal_mode
-  **  PRAGMA [database.]journal_mode = (delete|persist|off|truncate|memory)
+  **  PRAGMA [database.]journal_mode =
+  **                      (delete|persist|off|truncate|memory|wal|off)
   */
   if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
-    int eMode;
-    static char * const azModeName[] = {
-      "delete", "persist", "off", "truncate", "memory"
-    };
+    int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */
+    int ii;           /* Loop counter */
+
+    /* Force the schema to be loaded on all databases.  This cases all
+    ** database files to be opened and the journal_modes set. */
+    if( sqlite3ReadSchema(pParse) ){
+      goto pragma_out;
+    }
+
+    sqlite3VdbeSetNumCols(v, 1);
+    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
 
     if( zRight==0 ){
+      /* If there is no "=MODE" part of the pragma, do a query for the
+      ** current mode */
       eMode = PAGER_JOURNALMODE_QUERY;
     }else{
+      const char *zMode;
       int n = sqlite3Strlen30(zRight);
-      eMode = sizeof(azModeName)/sizeof(azModeName[0]) - 1;
-      while( eMode>=0 && sqlite3StrNICmp(zRight, azModeName[eMode], n)!=0 ){
-        eMode--;
+      for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){
+        if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;
+      }
+      if( !zMode ){
+        /* If the "=MODE" part does not match any known journal mode,
+        ** then do a query */
+        eMode = PAGER_JOURNALMODE_QUERY;
       }
     }
-    if( pId2->n==0 && eMode==PAGER_JOURNALMODE_QUERY ){
-      /* Simple "PRAGMA journal_mode;" statement. This is a query for
-      ** the current default journal mode (which may be different to
-      ** the journal-mode of the main database).
-      */
-      eMode = db->dfltJournalMode;
-    }else{
-      Pager *pPager;
-      if( pId2->n==0 ){
-        /* This indicates that no database name was specified as part
-        ** of the PRAGMA command. In this case the journal-mode must be
-        ** set on all attached databases, as well as the main db file.
-        **
-        ** Also, the sqlite3.dfltJournalMode variable is set so that
-        ** any subsequently attached databases also use the specified
-        ** journal mode.
-        */
-        int ii;
-        assert(pDb==&db->aDb[0]);
-        for(ii=1; ii<db->nDb; ii++){
-          if( db->aDb[ii].pBt ){
-            pPager = sqlite3BtreePager(db->aDb[ii].pBt);
-            sqlite3PagerJournalMode(pPager, eMode);
-          }
-        }
-        db->dfltJournalMode = (u8)eMode;
+    if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){
+      /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */
+      iDb = 0;
+      pId2->n = 1;
+    }
+    for(ii=db->nDb-1; ii>=0; ii--){
+      if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
+        sqlite3VdbeUsesBtree(v, ii);
+        sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);
       }
-      pPager = sqlite3BtreePager(pDb->pBt);
-      eMode = sqlite3PagerJournalMode(pPager, eMode);
     }
-    assert( eMode==PAGER_JOURNALMODE_DELETE
-              || eMode==PAGER_JOURNALMODE_TRUNCATE
-              || eMode==PAGER_JOURNALMODE_PERSIST
-              || eMode==PAGER_JOURNALMODE_OFF
-              || eMode==PAGER_JOURNALMODE_MEMORY );
-    sqlite3VdbeSetNumCols(v, 1);
-    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC);
-    sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, 
-           azModeName[eMode], P4_STATIC);
     sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
   }else
 
@@ -78493,7 +85425,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
     Pager *pPager = sqlite3BtreePager(pDb->pBt);
     i64 iLimit = -2;
     if( zRight ){
-      sqlite3Atoi64(zRight, &iLimit);
+      sqlite3Atoi64(zRight, &iLimit, 1000000, SQLITE_UTF8);
       if( iLimit<-1 ) iLimit = -1;
     }
     iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);
@@ -78671,7 +85603,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
       }
       sqlite3_free(sqlite3_temp_directory);
       if( zRight[0] ){
-        sqlite3_temp_directory = sqlite3DbStrDup(0, zRight);
+        sqlite3_temp_directory = sqlite3_mprintf("%s", zRight);
       }else{
         sqlite3_temp_directory = 0;
       }
@@ -79297,6 +86229,36 @@ SQLITE_PRIVATE void sqlite3Pragma(
   }else
 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
 
+#ifndef SQLITE_OMIT_WAL
+  /*
+  **   PRAGMA [database.]wal_checkpoint
+  **
+  ** Checkpoint the database.
+  */
+  if( sqlite3StrICmp(zLeft, "wal_checkpoint")==0 ){
+    if( sqlite3ReadSchema(pParse) ) goto pragma_out;
+    sqlite3VdbeAddOp3(v, OP_Checkpoint, pId2->z?iDb:SQLITE_MAX_ATTACHED, 0, 0);
+  }else
+
+  /*
+  **   PRAGMA wal_autocheckpoint
+  **   PRAGMA wal_autocheckpoint = N
+  **
+  ** Configure a database connection to automatically checkpoint a database
+  ** after accumulating N frames in the log. Or query for the current value
+  ** of N.
+  */
+  if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
+    if( zRight ){
+      int nAuto = atoi(zRight);
+      sqlite3_wal_autocheckpoint(db, nAuto);
+    }
+    returnSingleInt(pParse, "wal_autocheckpoint", 
+       db->xWalCallback==sqlite3WalDefaultHook ? 
+           SQLITE_PTR_TO_INT(db->pWalArg) : 0);
+  }else
+#endif
+
 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   /*
   ** Report the current state of file logs for all databases
@@ -79465,15 +86427,18 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char
     ** or executed.  All the parser does is build the internal data
     ** structures that describe the table, index, or view.
     */
-    char *zErr;
     int rc;
+    sqlite3_stmt *pStmt;
+    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */
+
     assert( db->init.busy );
     db->init.iDb = iDb;
     db->init.newTnum = atoi(argv[1]);
     db->init.orphanTrigger = 0;
-    rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
+    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);
+    rc = db->errCode;
+    assert( (rc&0xFF)==(rcp&0xFF) );
     db->init.iDb = 0;
-    assert( rc!=SQLITE_OK || zErr==0 );
     if( SQLITE_OK!=rc ){
       if( db->init.orphanTrigger ){
         assert( iDb==1 );
@@ -79481,12 +86446,12 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char
         pData->rc = rc;
         if( rc==SQLITE_NOMEM ){
           db->mallocFailed = 1;
-        }else if( rc!=SQLITE_INTERRUPT && rc!=SQLITE_LOCKED ){
-          corruptSchema(pData, argv[0], zErr);
+        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){
+          corruptSchema(pData, argv[0], sqlite3_errmsg(db));
         }
       }
-      sqlite3DbFree(db, zErr);
     }
+    sqlite3_finalize(pStmt);
   }else if( argv[0]==0 ){
     corruptSchema(pData, 0, 0);
   }else{
@@ -79971,6 +86936,7 @@ static int sqlite3Prepare(
   sqlite3VtabUnlockList(db);
 
   pParse->db = db;
+  pParse->nQueryLoop = (double)1;
   if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
     char *zSqlCopy;
     int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
@@ -79992,6 +86958,7 @@ static int sqlite3Prepare(
   }else{
     sqlite3RunParser(pParse, zSql, &zErrMsg);
   }
+  assert( 1==(int)pParse->nQueryLoop );
 
   if( db->mallocFailed ){
     pParse->rc = SQLITE_NOMEM;
@@ -80057,7 +87024,6 @@ static int sqlite3Prepare(
   while( pParse->pTriggerPrg ){
     TriggerPrg *pT = pParse->pTriggerPrg;
     pParse->pTriggerPrg = pT->pNext;
-    sqlite3VdbeProgramDelete(db, pT->pProgram, 0);
     sqlite3DbFree(db, pT);
   }
 
@@ -80692,7 +87658,6 @@ static void pushOntoSorter(
     sqlite3VdbeAddOp1(v, OP_Last, pOrderBy->iECursor);
     sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy->iECursor);
     sqlite3VdbeJumpHere(v, addr2);
-    pSelect->iLimit = 0;
   }
 }
 
@@ -80741,11 +87706,13 @@ static void codeDistinct(
   sqlite3ReleaseTempReg(pParse, r1);
 }
 
+#ifndef SQLITE_OMIT_SUBQUERY
 /*
 ** Generate an error message when a SELECT is used within a subexpression
 ** (example:  "a IN (SELECT * FROM table)") but it has more than 1 result
-** column.  We do this in a subroutine because the error occurs in multiple
-** places.
+** column.  We do this in a subroutine because the error used to occur
+** in multiple places.  (The error only occurs in one place now, but we
+** retain the subroutine to minimize code disruption.)
 */
 static int checkForMultiColumnSelectError(
   Parse *pParse,       /* Parse context. */
@@ -80761,6 +87728,7 @@ static int checkForMultiColumnSelectError(
     return 0;
   }
 }
+#endif
 
 /*
 ** This routine generates the code for the inside of the inner loop
@@ -80840,10 +87808,6 @@ static void selectInnerLoop(
     }
   }
 
-  if( checkForMultiColumnSelectError(pParse, pDest, pEList->nExpr) ){
-    return;
-  }
-
   switch( eDest ){
     /* In this mode, write each query result to the key of the temporary
     ** table iParm.
@@ -80972,11 +87936,11 @@ static void selectInnerLoop(
 #endif
   }
 
-  /* Jump to the end of the loop if the LIMIT is reached.
+  /* Jump to the end of the loop if the LIMIT is reached.  Except, if
+  ** there is a sorter, in which case the sorter has already limited
+  ** the output for us.
   */
-  if( p->iLimit ){
-    assert( pOrderBy==0 );  /* If there is an ORDER BY, the call to
-                            ** pushOntoSorter() would have cleared p->iLimit */
+  if( pOrderBy==0 && p->iLimit ){
     sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
   }
 }
@@ -81111,10 +88075,6 @@ static void generateSortTail(
   sqlite3ReleaseTempReg(pParse, regRow);
   sqlite3ReleaseTempReg(pParse, regRowid);
 
-  /* LIMIT has been implemented by the pushOntoSorter() routine.
-  */
-  assert( p->iLimit==0 );
-
   /* The bottom of the loop
   */
   sqlite3VdbeResolveLabel(v, addrContinue);
@@ -81548,16 +88508,15 @@ SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
     return 0;
   }
   /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside
-  ** is disabled, so we might as well hard-code pTab->dbMem to NULL. */
+  ** is disabled */
   assert( db->lookaside.bEnabled==0 );
-  pTab->dbMem = 0;
   pTab->nRef = 1;
   pTab->zName = 0;
   selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);
   selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect);
   pTab->iPKey = -1;
   if( db->mallocFailed ){
-    sqlite3DeleteTable(pTab);
+    sqlite3DeleteTable(db, pTab);
     return 0;
   }
   return pTab;
@@ -81754,6 +88713,7 @@ static int multiSelect(
   if( dest.eDest==SRT_EphemTab ){
     assert( p->pEList );
     sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr);
+    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
     dest.eDest = SRT_Table;
   }
 
@@ -82049,7 +89009,7 @@ multi_select_end:
 ** regReturn is the number of the register holding the subroutine
 ** return address.
 **
-** If regPrev>0 then it is a the first register in a vector that
+** If regPrev>0 then it is the first register in a vector that
 ** records the previous output.  mem[regPrev] is a flag that is false
 ** if there has been no previous output.  If regPrev>0 then code is
 ** generated to suppress duplicates.  pKeyInfo is used for comparing
@@ -82432,7 +89392,6 @@ static int multiSelectOrderBy(
   /* Separate the left and the right query from one another
   */
   p->pPrior = 0;
-  pPrior->pRightmost = 0;
   sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER");
   if( pPrior->pPrior==0 ){
     sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
@@ -82746,12 +89705,13 @@ static void substSelect(
 **   (2)  The subquery is not an aggregate or the outer query is not a join.
 **
 **   (3)  The subquery is not the right operand of a left outer join
-**        (Originally ticket #306.  Strenghtened by ticket #3300)
+**        (Originally ticket #306.  Strengthened by ticket #3300)
 **
-**   (4)  The subquery is not DISTINCT or the outer query is not a join.
+**   (4)  The subquery is not DISTINCT.
 **
-**   (5)  The subquery is not DISTINCT or the outer query does not use
-**        aggregates.
+**  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT
+**        sub-queries that were excluded from this optimization. Restriction 
+**        (4) has since been expanded to exclude all DISTINCT subqueries.
 **
 **   (6)  The subquery does not use aggregates or the outer query is not
 **        DISTINCT.
@@ -82771,13 +89731,13 @@ static void substSelect(
 **  (**)  Not implemented.  Subsumed into restriction (3).  Was previously
 **        a separate restriction deriving from ticket #350.
 **
-**  (13)  The subquery and outer query do not both use LIMIT
+**  (13)  The subquery and outer query do not both use LIMIT.
 **
-**  (14)  The subquery does not use OFFSET
+**  (14)  The subquery does not use OFFSET.
 **
 **  (15)  The outer query is not part of a compound select or the
-**        subquery does not have both an ORDER BY and a LIMIT clause.
-**        (See ticket #2339)
+**        subquery does not have a LIMIT clause.
+**        (See ticket #2339 and ticket [02a8e81d44]).
 **
 **  (16)  The outer query is not an aggregate or the subquery does
 **        not contain ORDER BY.  (Ticket #2942)  This used to not matter
@@ -82860,13 +89820,13 @@ static int flattenSubquery(
   ** and (14). */
   if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */
   if( pSub->pOffset ) return 0;                          /* Restriction (14) */
-  if( p->pRightmost && pSub->pLimit && pSub->pOrderBy ){
+  if( p->pRightmost && pSub->pLimit ){
     return 0;                                            /* Restriction (15) */
   }
   if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */
-  if( ((pSub->selFlags & SF_Distinct)!=0 || pSub->pLimit) 
-         && (pSrc->nSrc>1 || isAgg) ){          /* Restrictions (4)(5)(8)(9) */
-     return 0;       
+  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (5)  */
+  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){
+     return 0;         /* Restrictions (8)(9) */
   }
   if( (p->selFlags & SF_Distinct)!=0 && subqueryIsAgg ){
      return 0;         /* Restriction (6)  */
@@ -83270,6 +90230,7 @@ SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pF
     );
     if( !pIdx ){
       sqlite3ErrorMsg(pParse, "no such index: %s", zIndex, 0);
+      pParse->checkSchema = 1;
       return SQLITE_ERROR;
     }
     pFrom->pIndex = pIdx;
@@ -83345,7 +90306,6 @@ static int selectExpander(Walker *pWalker, Select *p){
       sqlite3WalkSelect(pWalker, pSel);
       pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
       if( pTab==0 ) return WRC_Abort;
-      pTab->dbMem = db->lookaside.bEnabled ? db : 0;
       pTab->nRef = 1;
       pTab->zName = sqlite3MPrintf(db, "sqlite_subquery_%p_", (void*)pTab);
       while( pSel->pPrior ){ pSel = pSel->pPrior; }
@@ -83715,7 +90675,7 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
     if( pList ){
       nArg = pList->nExpr;
       regAgg = sqlite3GetTempRange(pParse, nArg);
-      sqlite3ExprCodeExprList(pParse, pList, regAgg, 0);
+      sqlite3ExprCodeExprList(pParse, pList, regAgg, 1);
     }else{
       nArg = 0;
       regAgg = 0;
@@ -83748,6 +90708,18 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
       sqlite3ExprCacheClear(pParse);
     }
   }
+
+  /* Before populating the accumulator registers, clear the column cache.
+  ** Otherwise, if any of the required column values are already present 
+  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value
+  ** to pC->iMem. But by the time the value is used, the original register
+  ** may have been used, invalidating the underlying buffer holding the
+  ** text or blob value. See ticket [883034dcb5].
+  **
+  ** Another solution would be to change the OP_SCopy used to copy cached
+  ** values to an OP_Copy.
+  */
+  sqlite3ExprCacheClear(pParse);
   for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){
     sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);
   }
@@ -83863,6 +90835,15 @@ SQLITE_PRIVATE int sqlite3Select(
   v = sqlite3GetVdbe(pParse);
   if( v==0 ) goto select_end;
 
+  /* If writing to memory or generating a set
+  ** only a single column may be output.
+  */
+#ifndef SQLITE_OMIT_SUBQUERY
+  if( checkForMultiColumnSelectError(pParse, pDest, pEList->nExpr) ){
+    goto select_end;
+  }
+#endif
+
   /* Generate code for all sub-queries in the FROM clause
   */
 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
@@ -83936,15 +90917,6 @@ SQLITE_PRIVATE int sqlite3Select(
   }
 #endif
 
-  /* If writing to memory or generating a set
-  ** only a single column may be output.
-  */
-#ifndef SQLITE_OMIT_SUBQUERY
-  if( checkForMultiColumnSelectError(pParse, pDest, pEList->nExpr) ){
-    goto select_end;
-  }
-#endif
-
   /* If possible, rewrite the query to use GROUP BY instead of DISTINCT.
   ** GROUP BY might use an index, DISTINCT never does.
   */
@@ -83956,6 +90928,18 @@ SQLITE_PRIVATE int sqlite3Select(
     isDistinct = 0;
   }
 
+  /* If there is both a GROUP BY and an ORDER BY clause and they are
+  ** identical, then disable the ORDER BY clause since the GROUP BY
+  ** will cause elements to come out in the correct order.  This is
+  ** an optimization - the correct answer should result regardless.
+  ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER
+  ** to disable this optimization for testing purposes.
+  */
+  if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0
+         && (db->flags & SQLITE_GroupByOrder)==0 ){
+    pOrderBy = 0;
+  }
+
   /* If there is an ORDER BY clause, then this sorting
   ** index might end up being unused if the data can be 
   ** extracted in pre-sorted order.  If that is the case, then the
@@ -83995,6 +90979,7 @@ SQLITE_PRIVATE int sqlite3Select(
     pKeyInfo = keyInfoFromExprList(pParse, p->pEList);
     sqlite3VdbeAddOp4(v, OP_OpenEphemeral, distinct, 0, 0,
                         (char*)pKeyInfo, P4_KEYINFO_HANDOFF);
+    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
   }else{
     distinct = -1;
   }
@@ -85231,6 +92216,7 @@ SQLITE_PRIVATE void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr)
     if( !noErr ){
       sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0);
     }
+    pParse->checkSchema = 1;
     goto drop_trigger_cleanup;
   }
   sqlite3DropTriggerPtr(pParse, pTrigger);
@@ -85534,6 +92520,7 @@ static TriggerPrg *codeRowTrigger(
   int iEndTrigger = 0;        /* Label to jump to if WHEN is false */
 
   assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
+  assert( pTop->pVdbe );
 
   /* Allocate the TriggerPrg and SubProgram objects. To ensure that they
   ** are freed if an error occurs, link them into the Parse.pTriggerPrg 
@@ -85544,7 +92531,7 @@ static TriggerPrg *codeRowTrigger(
   pTop->pTriggerPrg = pPrg;
   pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
   if( !pProgram ) return 0;
-  pProgram->nRef = 1;
+  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);
   pPrg->pTrigger = pTrigger;
   pPrg->orconf = orconf;
   pPrg->aColmask[0] = 0xffffffff;
@@ -85561,6 +92548,7 @@ static TriggerPrg *codeRowTrigger(
   pSubParse->pToplevel = pTop;
   pSubParse->zAuthContext = pTrigger->zName;
   pSubParse->eTriggerOp = pTrigger->op;
+  pSubParse->nQueryLoop = pParse->nQueryLoop;
 
   v = sqlite3GetVdbe(pSubParse);
   if( v ){
@@ -85677,8 +92665,9 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
   /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program 
   ** is a pointer to the sub-vdbe containing the trigger program.  */
   if( pPrg ){
+    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));
+
     sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);
-    pPrg->pProgram->nRef++;
     sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
     VdbeComment(
         (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf)));
@@ -85688,7 +92677,7 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
     ** invocation is disallowed if (a) the sub-program is really a trigger,
     ** not a foreign key action, and (b) the flag to enable recursive triggers
     ** is clear.  */
-    sqlite3VdbeChangeP5(v, (u8)(p->zName && !(pParse->db->flags&SQLITE_RecTriggers)));
+    sqlite3VdbeChangeP5(v, (u8)bRecursive);
   }
 }
 
@@ -86040,6 +93029,7 @@ SQLITE_PRIVATE void sqlite3Update(
         pRowidExpr = pChanges->a[i].pExpr;
       }else{
         sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName);
+        pParse->checkSchema = 1;
         goto update_cleanup;
       }
     }
@@ -86224,8 +93214,7 @@ SQLITE_PRIVATE void sqlite3Update(
     );
     for(i=0; i<pTab->nCol; i++){
       if( aXRef[i]<0 || oldmask==0xffffffff || (oldmask & (1<<i)) ){
-        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regOld+i);
-        sqlite3ColumnDefault(v, pTab, i, regOld+i);
+        sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld+i);
       }else{
         sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);
       }
@@ -86466,6 +93455,7 @@ static void updateVirtualTable(
   assert( v );
   ephemTab = pParse->nTab++;
   sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));
+  sqlite3VdbeChangeP5(v, BTREE_UNORDERED);
 
   /* fill the ephemeral table 
   */
@@ -86598,12 +93588,17 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   void (*saved_xTrace)(void*,const char*);  /* Saved db->xTrace */
   Db *pDb = 0;            /* Database to detach at end of vacuum */
   int isMemDb;            /* True if vacuuming a :memory: database */
-  int nRes;
+  int nRes;               /* Bytes of reserved space at the end of each page */
+  int nDb;                /* Number of attached databases */
 
   if( !db->autoCommit ){
     sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
     return SQLITE_ERROR;
   }
+  if( db->activeVdbeCnt>1 ){
+    sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
+    return SQLITE_ERROR;
+  }
 
   /* Save the current value of the database flags so that it can be 
   ** restored before returning. Then set the writable-schema flag, and
@@ -86612,7 +93607,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   saved_nChange = db->nChange;
   saved_nTotalChange = db->nTotalChange;
   saved_xTrace = db->xTrace;
-  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
+  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;
   db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
   db->xTrace = 0;
 
@@ -86633,15 +93628,18 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   ** time to parse and run the PRAGMA to turn journalling off than it does
   ** to write the journal header file.
   */
+  nDb = db->nDb;
   if( sqlite3TempInMemory(db) ){
     zSql = "ATTACH ':memory:' AS vacuum_db;";
   }else{
     zSql = "ATTACH '' AS vacuum_db;";
   }
   rc = execSql(db, pzErrMsg, zSql);
+  if( db->nDb>nDb ){
+    pDb = &db->aDb[db->nDb-1];
+    assert( strcmp(pDb->zName,"vacuum_db")==0 );
+  }
   if( rc!=SQLITE_OK ) goto end_of_vacuum;
-  pDb = &db->aDb[db->nDb-1];
-  assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
   pTemp = db->aDb[db->nDb-1].pBt;
 
   /* The call to execSql() to attach the temp database has left the file
@@ -86663,6 +93661,12 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
   }
 #endif
 
+  /* Do not attempt to change the page size for a WAL database */
+  if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))
+                                               ==PAGER_JOURNALMODE_WAL ){
+    db->nextPagesize = 0;
+  }
+
   if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)
    || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))
    || NEVER(db->mallocFailed)
@@ -86799,6 +93803,7 @@ end_of_vacuum:
   db->nChange = saved_nChange;
   db->nTotalChange = saved_nTotalChange;
   db->xTrace = saved_xTrace;
+  sqlite3BtreeSetPageSize(pMain, -1, -1, 1);
 
   /* Currently there is an SQL level transaction open on the vacuum
   ** database. No locks are held on any other files (since the main file
@@ -87045,14 +94050,14 @@ SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){
 ** in the list are moved to the sqlite3.pDisconnect list of the associated 
 ** database connection.
 */
-SQLITE_PRIVATE void sqlite3VtabClear(Table *p){
-  vtabDisconnectAll(0, p);
+SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
+  if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
   if( p->azModuleArg ){
     int i;
     for(i=0; i<p->nModuleArg; i++){
-      sqlite3DbFree(p->dbMem, p->azModuleArg[i]);
+      sqlite3DbFree(db, p->azModuleArg[i]);
     }
-    sqlite3DbFree(p->dbMem, p->azModuleArg);
+    sqlite3DbFree(db, p->azModuleArg);
   }
 }
 
@@ -87195,7 +94200,7 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
     sqlite3ChangeCookie(pParse, iDb);
 
     sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
-    zWhere = sqlite3MPrintf(db, "name='%q'", pTab->zName);
+    zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
     sqlite3VdbeAddOp4(v, OP_ParseSchema, iDb, 1, 0, zWhere, P4_DYNAMIC);
     sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, 
                          pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
@@ -87217,7 +94222,6 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
       assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */
       return;
     }
-    pSchema->db = pParse->db;
     pParse->pNewTable = 0;
   }
 }
@@ -87291,7 +94295,7 @@ static int vtabCallConstructor(
       *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
     }else {
       *pzErr = sqlite3MPrintf(db, "%s", zErr);
-      sqlite3DbFree(db, zErr);
+      sqlite3_free(zErr);
     }
     sqlite3DbFree(db, pVTable);
   }else if( ALWAYS(pVTable->pVtab) ){
@@ -87481,6 +94485,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
   }else{
     pParse->declareVtab = 1;
     pParse->db = db;
+    pParse->nQueryLoop = 1;
   
     if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr) 
      && pParse->pNewTable
@@ -87505,7 +94510,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
     if( pParse->pVdbe ){
       sqlite3VdbeFinalize(pParse->pVdbe);
     }
-    sqlite3DeleteTable(pParse->pNewTable);
+    sqlite3DeleteTable(db, pParse->pNewTable);
     sqlite3StackFree(db, pParse);
   }
 
@@ -87592,8 +94597,8 @@ SQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){
     if( pVtab && (x = pVtab->pModule->xSync)!=0 ){
       rc = x(pVtab);
       sqlite3DbFree(db, *pzErrmsg);
-      *pzErrmsg = pVtab->zErrMsg;
-      pVtab->zErrMsg = 0;
+      *pzErrmsg = sqlite3DbStrDup(db, pVtab->zErrMsg);
+      sqlite3_free(pVtab->zErrMsg);
     }
   }
   db->aVTrans = aVTrans;
@@ -88001,6 +95006,7 @@ struct WhereCost {
 #define WHERE_COLUMN_IN    0x00040000  /* x IN (...) */
 #define WHERE_COLUMN_NULL  0x00080000  /* x IS NULL */
 #define WHERE_INDEXED      0x000f0000  /* Anything that uses an index */
+#define WHERE_NOT_FULLSCAN 0x000f3000  /* Does not do a full table scan */
 #define WHERE_IN_ABLE      0x000f1000  /* Able to support an IN operator */
 #define WHERE_TOP_LIMIT    0x00100000  /* x<EXPR or x<=EXPR constraint */
 #define WHERE_BTM_LIMIT    0x00200000  /* x>EXPR or x>=EXPR constraint */
@@ -88010,6 +95016,7 @@ struct WhereCost {
 #define WHERE_UNIQUE       0x04000000  /* Selects no more than one row */
 #define WHERE_VIRTUALTABLE 0x08000000  /* Use virtual-table processing */
 #define WHERE_MULTI_OR     0x10000000  /* OR using multiple indices */
+#define WHERE_TEMP_INDEX   0x20000000  /* Uses an ephemeral index */
 
 /*
 ** Initialize a preallocated WhereClause structure.
@@ -88091,6 +95098,7 @@ static void whereClauseClear(WhereClause *pWC){
 static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
   WhereTerm *pTerm;
   int idx;
+  testcase( wtFlags & TERM_VIRTUAL );  /* EV: R-00211-15100 */
   if( pWC->nTerm>=pWC->nSlot ){
     WhereTerm *pOld = pWC->a;
     sqlite3 *db = pWC->pParse->db;
@@ -88236,6 +95244,13 @@ static Bitmask exprSelectTableUsage(WhereMaskSet *pMaskSet, Select *pS){
 ** Return TRUE if the given operator is one of the operators that is
 ** allowed for an indexable WHERE clause term.  The allowed operators are
 ** "=", "<", ">", "<=", ">=", and "IN".
+**
+** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be
+** of one of the following forms: column = expression column > expression
+** column >= expression column < expression column <= expression
+** expression = column expression > column expression >= column
+** expression < column expression <= column column IN
+** (expression-list) column IN (subquery) column IS NULL
 */
 static int allowedOp(int op){
   assert( TK_GT>TK_EQ && TK_GT<TK_GE );
@@ -88399,7 +95414,6 @@ static int isLikeOrGlob(
   int c;                     /* One character in z[] */
   int cnt;                   /* Number of non-wildcard prefix characters */
   char wc[3];                /* Wildcard characters */
-  CollSeq *pColl;            /* Collating sequence for LHS */
   sqlite3 *db = pParse->db;  /* Database connection */
   sqlite3_value *pVal = 0;
   int op;                    /* Opcode of pRight */
@@ -88418,19 +95432,6 @@ static int isLikeOrGlob(
     return 0;
   }
   assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
-  pColl = sqlite3ExprCollSeq(pParse, pLeft);
-  if( pColl==0 ) return 0;  /* Happens when LHS has an undefined collation */
-  if( (pColl->type!=SQLITE_COLL_BINARY || *pnoCase) &&
-      (pColl->type!=SQLITE_COLL_NOCASE || !*pnoCase) ){
-    /* IMP: R-09003-32046 For the GLOB operator, the column must use the
-    ** default BINARY collating sequence.
-    ** IMP: R-41408-28306 For the LIKE operator, if case_sensitive_like mode
-    ** is enabled then the column must use the default BINARY collating
-    ** sequence, or if case_sensitive_like mode is disabled then the column
-    ** must use the built-in NOCASE collating sequence.
-    */
-    return 0;
-  }
 
   pRight = pList->a[0].pExpr;
   op = pRight->op;
@@ -88439,11 +95440,12 @@ static int isLikeOrGlob(
   }
   if( op==TK_VARIABLE ){
     Vdbe *pReprepare = pParse->pReprepare;
-    pVal = sqlite3VdbeGetValue(pReprepare, pRight->iColumn, SQLITE_AFF_NONE);
+    int iCol = pRight->iColumn;
+    pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);
     if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){
       z = (char *)sqlite3_value_text(pVal);
     }
-    sqlite3VdbeSetVarmask(pParse->pVdbe, pRight->iColumn);
+    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); /* IMP: R-23257-02778 */
     assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
   }else if( op==TK_STRING ){
     z = pRight->u.zToken;
@@ -88453,15 +95455,15 @@ static int isLikeOrGlob(
     while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
       cnt++;
     }
-    if( cnt!=0 && c!=0 && 255!=(u8)z[cnt-1] ){
+    if( cnt!=0 && 255!=(u8)z[cnt-1] ){
       Expr *pPrefix;
-      *pisComplete = z[cnt]==wc[0] && z[cnt+1]==0;
+      *pisComplete = c==wc[0] && z[cnt+1]==0;
       pPrefix = sqlite3Expr(db, TK_STRING, z);
       if( pPrefix ) pPrefix->u.zToken[cnt] = 0;
       *ppPrefix = pPrefix;
       if( op==TK_VARIABLE ){
         Vdbe *v = pParse->pVdbe;
-        sqlite3VdbeSetVarmask(v, pRight->iColumn);
+        sqlite3VdbeSetVarmask(v, pRight->iColumn); /* IMP: R-23257-02778 */
         if( *pisComplete && pRight->u.zToken[1] ){
           /* If the rhs of the LIKE expression is a variable, and the current
           ** value of the variable means there is no need to invoke the LIKE
@@ -88794,6 +95796,8 @@ static void exprAnalyzeOrTerm(
     /* At this point, okToChngToIN is true if original pTerm satisfies
     ** case 1.  In that case, construct a new virtual term that is 
     ** pTerm converted into an IN operator.
+    **
+    ** EV: R-00211-15100
     */
     if( okToChngToIN ){
       Expr *pDup;            /* A transient duplicate expression */
@@ -89010,6 +96014,7 @@ static void exprAnalyze(
     Expr *pNewExpr2;
     int idxNew1;
     int idxNew2;
+    CollSeq *pColl;    /* Collating sequence to use */
 
     pLeft = pExpr->x.pList->a[1].pExpr;
     pStr2 = sqlite3ExprDup(db, pStr1, 0);
@@ -89024,17 +96029,23 @@ static void exprAnalyze(
         ** inequality.  To avoid this, make sure to also run the full
         ** LIKE on all candidate expressions by clearing the isComplete flag
         */
-        if( c=='A'-1 ) isComplete = 0;
+        if( c=='A'-1 ) isComplete = 0;   /* EV: R-64339-08207 */
+
 
         c = sqlite3UpperToLower[c];
       }
       *pC = c + 1;
     }
-    pNewExpr1 = sqlite3PExpr(pParse, TK_GE, sqlite3ExprDup(db,pLeft,0),pStr1,0);
+    pColl = sqlite3FindCollSeq(db, SQLITE_UTF8, noCase ? "NOCASE" : "BINARY",0);
+    pNewExpr1 = sqlite3PExpr(pParse, TK_GE, 
+                     sqlite3ExprSetColl(sqlite3ExprDup(db,pLeft,0), pColl),
+                     pStr1, 0);
     idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);
     testcase( idxNew1==0 );
     exprAnalyze(pSrc, pWC, idxNew1);
-    pNewExpr2 = sqlite3PExpr(pParse, TK_LT, sqlite3ExprDup(db,pLeft,0),pStr2,0);
+    pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
+                     sqlite3ExprSetColl(sqlite3ExprDup(db,pLeft,0), pColl),
+                     pStr2, 0);
     idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC);
     testcase( idxNew2==0 );
     exprAnalyze(pSrc, pWC, idxNew2);
@@ -89316,7 +96327,8 @@ static void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){
 ** Required because bestIndex() is called by bestOrClauseIndex() 
 */
 static void bestIndex(
-    Parse*, WhereClause*, struct SrcList_item*, Bitmask, ExprList*, WhereCost*);
+    Parse*, WhereClause*, struct SrcList_item*,
+    Bitmask, Bitmask, ExprList*, WhereCost*);
 
 /*
 ** This routine attempts to find an scanning strategy that can be used 
@@ -89329,7 +96341,8 @@ static void bestOrClauseIndex(
   Parse *pParse,              /* The parsing context */
   WhereClause *pWC,           /* The WHERE clause */
   struct SrcList_item *pSrc,  /* The FROM clause term to search */
-  Bitmask notReady,           /* Mask of cursors that are not available */
+  Bitmask notReady,           /* Mask of cursors not available for indexing */
+  Bitmask notValid,           /* Cursors not available for any purpose */
   ExprList *pOrderBy,         /* The ORDER BY clause */
   WhereCost *pCost            /* Lowest cost query plan */
 ){
@@ -89339,6 +96352,11 @@ static void bestOrClauseIndex(
   WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm];        /* End of pWC->a[] */
   WhereTerm *pTerm;                 /* A single term of the WHERE clause */
 
+  /* No OR-clause optimization allowed if the NOT INDEXED clause is used */
+  if( pSrc->notIndexed ){
+    return;
+  }
+
   /* Search the WHERE clause terms for a usable WO_OR term. */
   for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
     if( pTerm->eOperator==WO_OR 
@@ -89360,7 +96378,7 @@ static void bestOrClauseIndex(
         ));
         if( pOrTerm->eOperator==WO_AND ){
           WhereClause *pAndWC = &pOrTerm->u.pAndInfo->wc;
-          bestIndex(pParse, pAndWC, pSrc, notReady, 0, &sTermCost);
+          bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost);
         }else if( pOrTerm->leftCursor==iCur ){
           WhereClause tempWC;
           tempWC.pParse = pWC->pParse;
@@ -89368,7 +96386,7 @@ static void bestOrClauseIndex(
           tempWC.op = TK_AND;
           tempWC.a = pOrTerm;
           tempWC.nTerm = 1;
-          bestIndex(pParse, &tempWC, pSrc, notReady, 0, &sTermCost);
+          bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost);
         }else{
           continue;
         }
@@ -89381,8 +96399,9 @@ static void bestOrClauseIndex(
       /* If there is an ORDER BY clause, increase the scan cost to account 
       ** for the cost of the sort. */
       if( pOrderBy!=0 ){
+        WHERETRACE(("... sorting increases OR cost %.9g to %.9g\n",
+                    rTotal, rTotal+nRow*estLog(nRow)));
         rTotal += nRow*estLog(nRow);
-        WHERETRACE(("... sorting increases OR cost to %.9g\n", rTotal));
       }
 
       /* If the cost of scanning using this OR term for optimization is
@@ -89401,6 +96420,247 @@ static void bestOrClauseIndex(
 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
 }
 
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+/*
+** Return TRUE if the WHERE clause term pTerm is of a form where it
+** could be used with an index to access pSrc, assuming an appropriate
+** index existed.
+*/
+static int termCanDriveIndex(
+  WhereTerm *pTerm,              /* WHERE clause term to check */
+  struct SrcList_item *pSrc,     /* Table we are trying to access */
+  Bitmask notReady               /* Tables in outer loops of the join */
+){
+  char aff;
+  if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
+  if( pTerm->eOperator!=WO_EQ ) return 0;
+  if( (pTerm->prereqRight & notReady)!=0 ) return 0;
+  aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
+  if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
+  return 1;
+}
+#endif
+
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+/*
+** If the query plan for pSrc specified in pCost is a full table scan
+** and indexing is allows (if there is no NOT INDEXED clause) and it
+** possible to construct a transient index that would perform better
+** than a full table scan even when the cost of constructing the index
+** is taken into account, then alter the query plan to use the
+** transient index.
+*/
+static void bestAutomaticIndex(
+  Parse *pParse,              /* The parsing context */
+  WhereClause *pWC,           /* The WHERE clause */
+  struct SrcList_item *pSrc,  /* The FROM clause term to search */
+  Bitmask notReady,           /* Mask of cursors that are not available */
+  WhereCost *pCost            /* Lowest cost query plan */
+){
+  double nTableRow;           /* Rows in the input table */
+  double logN;                /* log(nTableRow) */
+  double costTempIdx;         /* per-query cost of the transient index */
+  WhereTerm *pTerm;           /* A single term of the WHERE clause */
+  WhereTerm *pWCEnd;          /* End of pWC->a[] */
+  Table *pTable;              /* Table tht might be indexed */
+
+  if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){
+    /* Automatic indices are disabled at run-time */
+    return;
+  }
+  if( (pCost->plan.wsFlags & WHERE_NOT_FULLSCAN)!=0 ){
+    /* We already have some kind of index in use for this query. */
+    return;
+  }
+  if( pSrc->notIndexed ){
+    /* The NOT INDEXED clause appears in the SQL. */
+    return;
+  }
+
+  assert( pParse->nQueryLoop >= (double)1 );
+  pTable = pSrc->pTab;
+  nTableRow = pTable->nRowEst;
+  logN = estLog(nTableRow);
+  costTempIdx = 2*logN*(nTableRow/pParse->nQueryLoop + 1);
+  if( costTempIdx>=pCost->rCost ){
+    /* The cost of creating the transient table would be greater than
+    ** doing the full table scan */
+    return;
+  }
+
+  /* Search for any equality comparison term */
+  pWCEnd = &pWC->a[pWC->nTerm];
+  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
+    if( termCanDriveIndex(pTerm, pSrc, notReady) ){
+      WHERETRACE(("auto-index reduces cost from %.2f to %.2f\n",
+                    pCost->rCost, costTempIdx));
+      pCost->rCost = costTempIdx;
+      pCost->nRow = logN + 1;
+      pCost->plan.wsFlags = WHERE_TEMP_INDEX;
+      pCost->used = pTerm->prereqRight;
+      break;
+    }
+  }
+}
+#else
+# define bestAutomaticIndex(A,B,C,D,E)  /* no-op */
+#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
+
+
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+/*
+** Generate code to construct the Index object for an automatic index
+** and to set up the WhereLevel object pLevel so that the code generator
+** makes use of the automatic index.
+*/
+static void constructAutomaticIndex(
+  Parse *pParse,              /* The parsing context */
+  WhereClause *pWC,           /* The WHERE clause */
+  struct SrcList_item *pSrc,  /* The FROM clause term to get the next index */
+  Bitmask notReady,           /* Mask of cursors that are not available */
+  WhereLevel *pLevel          /* Write new index here */
+){
+  int nColumn;                /* Number of columns in the constructed index */
+  WhereTerm *pTerm;           /* A single term of the WHERE clause */
+  WhereTerm *pWCEnd;          /* End of pWC->a[] */
+  int nByte;                  /* Byte of memory needed for pIdx */
+  Index *pIdx;                /* Object describing the transient index */
+  Vdbe *v;                    /* Prepared statement under construction */
+  int regIsInit;              /* Register set by initialization */
+  int addrInit;               /* Address of the initialization bypass jump */
+  Table *pTable;              /* The table being indexed */
+  KeyInfo *pKeyinfo;          /* Key information for the index */   
+  int addrTop;                /* Top of the index fill loop */
+  int regRecord;              /* Register holding an index record */
+  int n;                      /* Column counter */
+  int i;                      /* Loop counter */
+  int mxBitCol;               /* Maximum column in pSrc->colUsed */
+  CollSeq *pColl;             /* Collating sequence to on a column */
+  Bitmask idxCols;            /* Bitmap of columns used for indexing */
+  Bitmask extraCols;          /* Bitmap of additional columns */
+
+  /* Generate code to skip over the creation and initialization of the
+  ** transient index on 2nd and subsequent iterations of the loop. */
+  v = pParse->pVdbe;
+  assert( v!=0 );
+  regIsInit = ++pParse->nMem;
+  addrInit = sqlite3VdbeAddOp1(v, OP_If, regIsInit);
+  sqlite3VdbeAddOp2(v, OP_Integer, 1, regIsInit);
+
+  /* Count the number of columns that will be added to the index
+  ** and used to match WHERE clause constraints */
+  nColumn = 0;
+  pTable = pSrc->pTab;
+  pWCEnd = &pWC->a[pWC->nTerm];
+  idxCols = 0;
+  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
+    if( termCanDriveIndex(pTerm, pSrc, notReady) ){
+      int iCol = pTerm->u.leftColumn;
+      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;
+      testcase( iCol==BMS );
+      testcase( iCol==BMS-1 );
+      if( (idxCols & cMask)==0 ){
+        nColumn++;
+        idxCols |= cMask;
+      }
+    }
+  }
+  assert( nColumn>0 );
+  pLevel->plan.nEq = nColumn;
+
+  /* Count the number of additional columns needed to create a
+  ** covering index.  A "covering index" is an index that contains all
+  ** columns that are needed by the query.  With a covering index, the
+  ** original table never needs to be accessed.  Automatic indices must
+  ** be a covering index because the index will not be updated if the
+  ** original table changes and the index and table cannot both be used
+  ** if they go out of sync.
+  */
+  extraCols = pSrc->colUsed & (~idxCols | (((Bitmask)1)<<(BMS-1)));
+  mxBitCol = (pTable->nCol >= BMS-1) ? BMS-1 : pTable->nCol;
+  testcase( pTable->nCol==BMS-1 );
+  testcase( pTable->nCol==BMS-2 );
+  for(i=0; i<mxBitCol; i++){
+    if( extraCols & (((Bitmask)1)<<i) ) nColumn++;
+  }
+  if( pSrc->colUsed & (((Bitmask)1)<<(BMS-1)) ){
+    nColumn += pTable->nCol - BMS + 1;
+  }
+  pLevel->plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ;
+
+  /* Construct the Index object to describe this index */
+  nByte = sizeof(Index);
+  nByte += nColumn*sizeof(int);     /* Index.aiColumn */
+  nByte += nColumn*sizeof(char*);   /* Index.azColl */
+  nByte += nColumn;                 /* Index.aSortOrder */
+  pIdx = sqlite3DbMallocZero(pParse->db, nByte);
+  if( pIdx==0 ) return;
+  pLevel->plan.u.pIdx = pIdx;
+  pIdx->azColl = (char**)&pIdx[1];
+  pIdx->aiColumn = (int*)&pIdx->azColl[nColumn];
+  pIdx->aSortOrder = (u8*)&pIdx->aiColumn[nColumn];
+  pIdx->zName = "auto-index";
+  pIdx->nColumn = nColumn;
+  pIdx->pTable = pTable;
+  n = 0;
+  idxCols = 0;
+  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
+    if( termCanDriveIndex(pTerm, pSrc, notReady) ){
+      int iCol = pTerm->u.leftColumn;
+      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;
+      if( (idxCols & cMask)==0 ){
+        Expr *pX = pTerm->pExpr;
+        idxCols |= cMask;
+        pIdx->aiColumn[n] = pTerm->u.leftColumn;
+        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
+        pIdx->azColl[n] = pColl->zName;
+        n++;
+      }
+    }
+  }
+  assert( (u32)n==pLevel->plan.nEq );
+
+  /* Add additional columns needed to make the automatic index into
+  ** a covering index */
+  for(i=0; i<mxBitCol; i++){
+    if( extraCols & (((Bitmask)1)<<i) ){
+      pIdx->aiColumn[n] = i;
+      pIdx->azColl[n] = "BINARY";
+      n++;
+    }
+  }
+  if( pSrc->colUsed & (((Bitmask)1)<<(BMS-1)) ){
+    for(i=BMS-1; i<pTable->nCol; i++){
+      pIdx->aiColumn[n] = i;
+      pIdx->azColl[n] = "BINARY";
+      n++;
+    }
+  }
+  assert( n==nColumn );
+
+  /* Create the automatic index */
+  pKeyinfo = sqlite3IndexKeyinfo(pParse, pIdx);
+  assert( pLevel->iIdxCur>=0 );
+  sqlite3VdbeAddOp4(v, OP_OpenAutoindex, pLevel->iIdxCur, nColumn+1, 0,
+                    (char*)pKeyinfo, P4_KEYINFO_HANDOFF);
+  VdbeComment((v, "for %s", pTable->zName));
+
+  /* Fill the automatic index with content */
+  addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);
+  regRecord = sqlite3GetTempReg(pParse);
+  sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);
+  sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
+  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
+  sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
+  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
+  sqlite3VdbeJumpHere(v, addrTop);
+  sqlite3ReleaseTempReg(pParse, regRecord);
+  
+  /* Jump here when skipping the initialization */
+  sqlite3VdbeJumpHere(v, addrInit);
+}
+#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
+
 #ifndef SQLITE_OMIT_VIRTUALTABLE
 /*
 ** Allocate and populate an sqlite3_index_info structure. It is the 
@@ -89539,7 +96799,7 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
       sqlite3ErrorMsg(pParse, "%s", pVtab->zErrMsg);
     }
   }
-  sqlite3DbFree(pParse->db, pVtab->zErrMsg);
+  sqlite3_free(pVtab->zErrMsg);
   pVtab->zErrMsg = 0;
 
   for(i=0; i<p->nConstraint; i++){
@@ -89573,7 +96833,8 @@ static void bestVirtualIndex(
   Parse *pParse,                  /* The parsing context */
   WhereClause *pWC,               /* The WHERE clause */
   struct SrcList_item *pSrc,      /* The FROM clause term to search */
-  Bitmask notReady,               /* Mask of cursors that are not available */
+  Bitmask notReady,               /* Mask of cursors not available for index */
+  Bitmask notValid,               /* Cursors not valid for any purpose */
   ExprList *pOrderBy,             /* The order by clause */
   WhereCost *pCost,               /* Lowest cost query plan */
   sqlite3_index_info **ppIdxInfo  /* Index information passed to xBestIndex */
@@ -89585,6 +96846,7 @@ static void bestVirtualIndex(
   WhereTerm *pTerm;
   int i, j;
   int nOrderBy;
+  double rCost;
 
   /* Make sure wsFlags is initialized to some sane value. Otherwise, if the 
   ** malloc in allocateIndexInfo() fails and this function returns leaving
@@ -89671,6 +96933,15 @@ static void bestVirtualIndex(
     }
   }
 
+  /* If there is an ORDER BY clause, and the selected virtual table index
+  ** does not satisfy it, increase the cost of the scan accordingly. This
+  ** matches the processing for non-virtual tables in bestBtreeIndex().
+  */
+  rCost = pIdxInfo->estimatedCost;
+  if( pOrderBy && pIdxInfo->orderByConsumed==0 ){
+    rCost += estLog(rCost)*rCost;
+  }
+
   /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
   ** inital value of lowestCost in this loop. If it is, then the
   ** (cost<lowestCost) test below will never be true.
@@ -89678,10 +96949,10 @@ static void bestVirtualIndex(
   ** Use "(double)2" instead of "2.0" in case OMIT_FLOATING_POINT 
   ** is defined.
   */
-  if( (SQLITE_BIG_DBL/((double)2))<pIdxInfo->estimatedCost ){
+  if( (SQLITE_BIG_DBL/((double)2))<rCost ){
     pCost->rCost = (SQLITE_BIG_DBL/((double)2));
   }else{
-    pCost->rCost = pIdxInfo->estimatedCost;
+    pCost->rCost = rCost;
   }
   pCost->plan.u.pVtabIdx = pIdxInfo;
   if( pIdxInfo->orderByConsumed ){
@@ -89693,7 +96964,7 @@ static void bestVirtualIndex(
   /* Try to find a more efficient access pattern by using multiple indexes
   ** to optimize an OR expression within the WHERE clause. 
   */
-  bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost);
+  bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost);
 }
 #endif /* SQLITE_OMIT_VIRTUALTABLE */
 
@@ -89819,7 +97090,7 @@ static int valueFromExpr(
   assert( pExpr->op!=TK_VARIABLE );
   if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){
     int iVar = pExpr->iColumn;
-    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);
+    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */
     *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);
     return SQLITE_OK;
   }
@@ -89974,7 +97245,8 @@ static void bestBtreeIndex(
   Parse *pParse,              /* The parsing context */
   WhereClause *pWC,           /* The WHERE clause */
   struct SrcList_item *pSrc,  /* The FROM clause term to search */
-  Bitmask notReady,           /* Mask of cursors that are not available */
+  Bitmask notReady,           /* Mask of cursors not available for indexing */
+  Bitmask notValid,           /* Cursors not available for any purpose */
   ExprList *pOrderBy,         /* The ORDER BY clause */
   WhereCost *pCost            /* Lowest cost query plan */
 ){
@@ -90016,23 +97288,14 @@ static void bestBtreeIndex(
     sPk.nColumn = 1;
     sPk.aiColumn = &aiColumnPk;
     sPk.aiRowEst = aiRowEstPk;
-    aiRowEstPk[1] = 1;
     sPk.onError = OE_Replace;
     sPk.pTable = pSrc->pTab;
+    aiRowEstPk[0] = pSrc->pTab->nRowEst;
+    aiRowEstPk[1] = 1;
     pFirst = pSrc->pTab->pIndex;
     if( pSrc->notIndexed==0 ){
       sPk.pNext = pFirst;
     }
-    /* The aiRowEstPk[0] is an estimate of the total number of rows in the
-    ** table.  Get this information from the ANALYZE information if it is
-    ** available.  If not available, assume the table 1 million rows in size.
-    */
-    if( pFirst ){
-      assert( pFirst->aiRowEst!=0 ); /* Allocated together with pFirst */
-      aiRowEstPk[0] = pFirst->aiRowEst[0];
-    }else{
-      aiRowEstPk[0] = 1000000;
-    }
     pProbe = &sPk;
     wsFlagMask = ~(
         WHERE_COLUMN_IN|WHERE_COLUMN_EQ|WHERE_COLUMN_NULL|WHERE_COLUMN_RANGE
@@ -90082,14 +97345,14 @@ static void bestBtreeIndex(
     **    Set to true if there was at least one "x IN (SELECT ...)" term used 
     **    in determining the value of nInMul.
     **
-    **  nBound:
+    **  estBound:
     **    An estimate on the amount of the table that must be searched.  A
     **    value of 100 means the entire table is searched.  Range constraints
     **    might reduce this to a value less than 100 to indicate that only
     **    a fraction of the table needs searching.  In the absence of
     **    sqlite_stat2 ANALYZE data, a single inequality reduces the search
     **    space to 1/3rd its original size.  So an x>? constraint reduces
-    **    nBound to 33.  Two constraints (x>? AND x<?) reduce nBound to 11.
+    **    estBound to 33.  Two constraints (x>? AND x<?) reduce estBound to 11.
     **
     **  bSort:   
     **    Boolean. True if there is an ORDER BY clause that will require an 
@@ -90111,13 +97374,14 @@ static void bestBtreeIndex(
     int nEq;
     int bInEst = 0;
     int nInMul = 1;
-    int nBound = 100;
+    int estBound = 100;
+    int nBound = 0;             /* Number of range constraints seen */
     int bSort = 0;
     int bLookup = 0;
+    WhereTerm *pTerm;           /* A single term of the WHERE clause */
 
     /* Determine the values of nEq and nInMul */
     for(nEq=0; nEq<pProbe->nColumn; nEq++){
-      WhereTerm *pTerm;           /* A single term of the WHERE clause */
       int j = pProbe->aiColumn[nEq];
       pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pIdx);
       if( pTerm==0 ) break;
@@ -90128,7 +97392,7 @@ static void bestBtreeIndex(
         if( ExprHasProperty(pExpr, EP_xIsSelect) ){
           nInMul *= 25;
           bInEst = 1;
-        }else if( pExpr->x.pList ){
+        }else if( ALWAYS(pExpr->x.pList) ){
           nInMul *= pExpr->x.pList->nExpr + 1;
         }
       }else if( pTerm->eOperator & WO_ISNULL ){
@@ -90137,18 +97401,20 @@ static void bestBtreeIndex(
       used |= pTerm->prereqRight;
     }
 
-    /* Determine the value of nBound. */
+    /* Determine the value of estBound. */
     if( nEq<pProbe->nColumn ){
       int j = pProbe->aiColumn[nEq];
       if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){
         WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx);
         WhereTerm *pBtm = findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pIdx);
-        whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &nBound);
+        whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &estBound);
         if( pTop ){
+          nBound = 1;
           wsFlags |= WHERE_TOP_LIMIT;
           used |= pTop->prereqRight;
         }
         if( pBtm ){
+          nBound++;
           wsFlags |= WHERE_BTM_LIMIT;
           used |= pBtm->prereqRight;
         }
@@ -90179,7 +97445,7 @@ static void bestBtreeIndex(
 
     /* If currently calculating the cost of using an index (not the IPK
     ** index), determine if all required column data may be obtained without 
-    ** seeking to entries in the main table (i.e. if the index is a covering
+    ** using the main table (i.e. if the index is a covering
     ** index for this query). If it is, set the WHERE_IDX_ONLY flag in
     ** wsFlags. Otherwise, set the bLookup variable to true.  */
     if( pIdx && wsFlags ){
@@ -90198,8 +97464,7 @@ static void bestBtreeIndex(
       }
     }
 
-    /**** Begin adding up the cost of using this index (Needs improvements)
-    **
+    /*
     ** Estimate the number of rows of output.  For an IN operator,
     ** do not let the estimate exceed half the rows in the table.
     */
@@ -90218,8 +97483,8 @@ static void bestBtreeIndex(
     /* Adjust the number of rows and the cost downward to reflect rows
     ** that are excluded by range constraints.
     */
-    nRow = (nRow * (double)nBound) / (double)100;
-    cost = (cost * (double)nBound) / (double)100;
+    nRow = (nRow * (double)estBound) / (double)100;
+    cost = (cost * (double)estBound) / (double)100;
 
     /* Add in the estimated cost of sorting the result
     */
@@ -90236,17 +97501,75 @@ static void bestBtreeIndex(
     }
     /**** Cost of using this index has now been computed ****/
 
+    /* If there are additional constraints on this table that cannot
+    ** be used with the current index, but which might lower the number
+    ** of output rows, adjust the nRow value accordingly.  This only 
+    ** matters if the current index is the least costly, so do not bother
+    ** with this step if we already know this index will not be chosen.
+    ** Also, never reduce the output row count below 2 using this step.
+    **
+    ** It is critical that the notValid mask be used here instead of
+    ** the notReady mask.  When computing an "optimal" index, the notReady
+    ** mask will only have one bit set - the bit for the current table.
+    ** The notValid mask, on the other hand, always has all bits set for
+    ** tables that are not in outer loops.  If notReady is used here instead
+    ** of notValid, then a optimal index that depends on inner joins loops
+    ** might be selected even when there exists an optimal index that has
+    ** no such dependency.
+    */
+    if( nRow>2 && cost<=pCost->rCost ){
+      int k;                       /* Loop counter */
+      int nSkipEq = nEq;           /* Number of == constraints to skip */
+      int nSkipRange = nBound;     /* Number of < constraints to skip */
+      Bitmask thisTab;             /* Bitmap for pSrc */
+
+      thisTab = getMask(pWC->pMaskSet, iCur);
+      for(pTerm=pWC->a, k=pWC->nTerm; nRow>2 && k; k--, pTerm++){
+        if( pTerm->wtFlags & TERM_VIRTUAL ) continue;
+        if( (pTerm->prereqAll & notValid)!=thisTab ) continue;
+        if( pTerm->eOperator & (WO_EQ|WO_IN|WO_ISNULL) ){
+          if( nSkipEq ){
+            /* Ignore the first nEq equality matches since the index
+            ** has already accounted for these */
+            nSkipEq--;
+          }else{
+            /* Assume each additional equality match reduces the result
+            ** set size by a factor of 10 */
+            nRow /= 10;
+          }
+        }else if( pTerm->eOperator & (WO_LT|WO_LE|WO_GT|WO_GE) ){
+          if( nSkipRange ){
+            /* Ignore the first nBound range constraints since the index
+            ** has already accounted for these */
+            nSkipRange--;
+          }else{
+            /* Assume each additional range constraint reduces the result
+            ** set size by a factor of 3 */
+            nRow /= 3;
+          }
+        }else{
+          /* Any other expression lowers the output row count by half */
+          nRow /= 2;
+        }
+      }
+      if( nRow<2 ) nRow = 2;
+    }
+
+
     WHERETRACE((
-      "tbl=%s idx=%s nEq=%d nInMul=%d nBound=%d bSort=%d bLookup=%d"
-      " wsFlags=%d   (nRow=%.2f cost=%.2f)\n",
+      "%s(%s): nEq=%d nInMul=%d estBound=%d bSort=%d bLookup=%d wsFlags=0x%x\n"
+      "         notReady=0x%llx nRow=%.2f cost=%.2f used=0x%llx\n",
       pSrc->pTab->zName, (pIdx ? pIdx->zName : "ipk"), 
-      nEq, nInMul, nBound, bSort, bLookup, wsFlags, nRow, cost
+      nEq, nInMul, estBound, bSort, bLookup, wsFlags,
+      notReady, nRow, cost, used
     ));
 
     /* If this index is the best we have seen so far, then record this
     ** index and its cost in the pCost structure.
     */
-    if( (!pIdx || wsFlags) && cost<pCost->rCost ){
+    if( (!pIdx || wsFlags)
+     && (cost<pCost->rCost || (cost<=pCost->rCost && nRow<pCost->nRow))
+    ){
       pCost->rCost = cost;
       pCost->nRow = nRow;
       pCost->used = used;
@@ -90281,10 +97604,12 @@ static void bestBtreeIndex(
   );
 
   WHERETRACE(("best index is: %s\n", 
-    (pCost->plan.u.pIdx ? pCost->plan.u.pIdx->zName : "ipk")
+    ((pCost->plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ? "none" : 
+         pCost->plan.u.pIdx ? pCost->plan.u.pIdx->zName : "ipk")
   ));
   
-  bestOrClauseIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost);
+  bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost);
+  bestAutomaticIndex(pParse, pWC, pSrc, notReady, pCost);
   pCost->plan.wsFlags |= eqTermMask;
 }
 
@@ -90298,14 +97623,15 @@ static void bestIndex(
   Parse *pParse,              /* The parsing context */
   WhereClause *pWC,           /* The WHERE clause */
   struct SrcList_item *pSrc,  /* The FROM clause term to search */
-  Bitmask notReady,           /* Mask of cursors that are not available */
+  Bitmask notReady,           /* Mask of cursors not available for indexing */
+  Bitmask notValid,           /* Cursors not available for any purpose */
   ExprList *pOrderBy,         /* The ORDER BY clause */
   WhereCost *pCost            /* Lowest cost query plan */
 ){
 #ifndef SQLITE_OMIT_VIRTUALTABLE
   if( IsVirtual(pSrc->pTab) ){
     sqlite3_index_info *p = 0;
-    bestVirtualIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost, &p);
+    bestVirtualIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost,&p);
     if( p->needToFreeIdxStr ){
       sqlite3_free(p->idxStr);
     }
@@ -90313,7 +97639,7 @@ static void bestIndex(
   }else
 #endif
   {
-    bestBtreeIndex(pParse, pWC, pSrc, notReady, pOrderBy, pCost);
+    bestBtreeIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost);
   }
 }
 
@@ -90332,6 +97658,9 @@ static void bestIndex(
 ** in the ON clause.  The term is disabled in (3) because it is not part
 ** of a LEFT OUTER JOIN.  In (1), the term is not disabled.
 **
+** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are
+** completely satisfied by indices.
+**
 ** Disabling a term causes that term to not be tested in the inner loop
 ** of the join.  Disabling is an optimization.  When terms are satisfied
 ** by indices, we disable them to prevent redundant tests in the inner
@@ -90342,7 +97671,7 @@ static void bestIndex(
 */
 static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
   if( pTerm
-      && ALWAYS((pTerm->wtFlags & TERM_CODED)==0)
+      && (pTerm->wtFlags & TERM_CODED)==0
       && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
   ){
     pTerm->wtFlags |= TERM_CODED;
@@ -90540,7 +97869,10 @@ static int codeAllEqualityTerms(
     int k = pIdx->aiColumn[j];
     pTerm = findTerm(pWC, iCur, k, notReady, pLevel->plan.wsFlags, pIdx);
     if( NEVER(pTerm==0) ) break;
-    assert( (pTerm->wtFlags & TERM_CODED)==0 );
+    /* The following true for indices with redundant columns. 
+    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
+    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
+    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
     r1 = codeEqualityTerm(pParse, pTerm, pLevel, regBase+j);
     if( r1!=regBase+j ){
       if( nReg==1 ){
@@ -90684,6 +98016,7 @@ static Bitmask codeOneLoopStart(
     assert( pTerm->pExpr!=0 );
     assert( pTerm->leftCursor==iCur );
     assert( omitTable==0 );
+    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
     iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, iReleaseReg);
     addrNxt = pLevel->addrNxt;
     sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);
@@ -90724,6 +98057,7 @@ static Bitmask codeOneLoopStart(
       assert( TK_LT==TK_GT+2 );      /*  ... of the TK_xx values... */
       assert( TK_GE==TK_GT+3 );      /*  ... is correcct. */
 
+      testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
       pX = pStart->pExpr;
       assert( pX!=0 );
       assert( pStart->leftCursor==iCur );
@@ -90741,6 +98075,7 @@ static Bitmask codeOneLoopStart(
       pX = pEnd->pExpr;
       assert( pX!=0 );
       assert( pEnd->leftCursor==iCur );
+      testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
       memEndValue = ++pParse->nMem;
       sqlite3ExprCode(pParse, pX->pRight, memEndValue);
       if( pX->op==TK_LT || pX->op==TK_GT ){
@@ -90754,7 +98089,11 @@ static Bitmask codeOneLoopStart(
     pLevel->op = bRev ? OP_Prev : OP_Next;
     pLevel->p1 = iCur;
     pLevel->p2 = start;
-    pLevel->p5 = (pStart==0 && pEnd==0) ?1:0;
+    if( pStart==0 && pEnd==0 ){
+      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
+    }else{
+      assert( pLevel->p5==0 );
+    }
     if( testOp!=OP_Noop ){
       iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse);
       sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);
@@ -90794,7 +98133,7 @@ static Bitmask codeOneLoopStart(
     **         constraints but an index is selected anyway, in order
     **         to force the output order to conform to an ORDER BY.
     */  
-    int aStartOp[] = {
+    static const u8 aStartOp[] = {
       0,
       0,
       OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */
@@ -90804,12 +98143,12 @@ static Bitmask codeOneLoopStart(
       OP_SeekGe,           /* 6: (start_constraints  &&  startEq && !bRev) */
       OP_SeekLe            /* 7: (start_constraints  &&  startEq &&  bRev) */
     };
-    int aEndOp[] = {
+    static const u8 aEndOp[] = {
       OP_Noop,             /* 0: (!end_constraints) */
       OP_IdxGE,            /* 1: (end_constraints && !bRev) */
       OP_IdxLT             /* 2: (end_constraints && bRev) */
     };
-    int nEq = pLevel->plan.nEq;
+    int nEq = pLevel->plan.nEq;  /* Number of == or IN terms */
     int isMinQuery = 0;          /* If this is an optimized SELECT min(x).. */
     int regBase;                 /* Base register holding constraint values */
     int r1;                      /* Temp register */
@@ -90819,11 +98158,12 @@ static Bitmask codeOneLoopStart(
     int endEq;                   /* True if range end uses ==, >= or <= */
     int start_constraints;       /* Start of range is constrained */
     int nConstraint;             /* Number of constraint terms */
-    Index *pIdx;         /* The index we will be using */
-    int iIdxCur;         /* The VDBE cursor for the index */
-    int nExtraReg = 0;   /* Number of extra registers needed */
-    int op;              /* Instruction opcode */
-    char *zAff;
+    Index *pIdx;                 /* The index we will be using */
+    int iIdxCur;                 /* The VDBE cursor for the index */
+    int nExtraReg = 0;           /* Number of extra registers needed */
+    int op;                      /* Instruction opcode */
+    char *zStartAff;             /* Affinity for start of range constraint */
+    char *zEndAff;               /* Affinity for end of range constraint */
 
     pIdx = pLevel->plan.u.pIdx;
     iIdxCur = pLevel->iIdxCur;
@@ -90864,15 +98204,16 @@ static Bitmask codeOneLoopStart(
     ** starting at regBase.
     */
     regBase = codeAllEqualityTerms(
-        pParse, pLevel, pWC, notReady, nExtraReg, &zAff
+        pParse, pLevel, pWC, notReady, nExtraReg, &zStartAff
     );
+    zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
     addrNxt = pLevel->addrNxt;
 
     /* If we are doing a reverse order scan on an ascending index, or
     ** a forward order scan on a descending index, interchange the 
     ** start and end terms (pRangeStart and pRangeEnd).
     */
-    if( bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC) ){
+    if( nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC) ){
       SWAP(WhereTerm *, pRangeEnd, pRangeStart);
     }
 
@@ -90890,25 +98231,26 @@ static Bitmask codeOneLoopStart(
       Expr *pRight = pRangeStart->pExpr->pRight;
       sqlite3ExprCode(pParse, pRight, regBase+nEq);
       sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
-      if( zAff ){
-        if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
+      if( zStartAff ){
+        if( sqlite3CompareAffinity(pRight, zStartAff[nEq])==SQLITE_AFF_NONE){
           /* Since the comparison is to be performed with no conversions
           ** applied to the operands, set the affinity to apply to pRight to 
           ** SQLITE_AFF_NONE.  */
-          zAff[nConstraint] = SQLITE_AFF_NONE;
+          zStartAff[nEq] = SQLITE_AFF_NONE;
         }
-        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
-          zAff[nConstraint] = SQLITE_AFF_NONE;
+        if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
+          zStartAff[nEq] = SQLITE_AFF_NONE;
         }
       }  
       nConstraint++;
+      testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
     }else if( isMinQuery ){
       sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
       nConstraint++;
       startEq = 0;
       start_constraints = 1;
     }
-    codeApplyAffinity(pParse, regBase, nConstraint, zAff);
+    codeApplyAffinity(pParse, regBase, nConstraint, zStartAff);
     op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
     assert( op!=0 );
     testcase( op==OP_Rewind );
@@ -90928,21 +98270,23 @@ static Bitmask codeOneLoopStart(
       sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
       sqlite3ExprCode(pParse, pRight, regBase+nEq);
       sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
-      if( zAff ){
-        if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
+      if( zEndAff ){
+        if( sqlite3CompareAffinity(pRight, zEndAff[nEq])==SQLITE_AFF_NONE){
           /* Since the comparison is to be performed with no conversions
           ** applied to the operands, set the affinity to apply to pRight to 
           ** SQLITE_AFF_NONE.  */
-          zAff[nConstraint] = SQLITE_AFF_NONE;
+          zEndAff[nEq] = SQLITE_AFF_NONE;
         }
-        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[nConstraint]) ){
-          zAff[nConstraint] = SQLITE_AFF_NONE;
+        if( sqlite3ExprNeedsNoAffinityChange(pRight, zEndAff[nEq]) ){
+          zEndAff[nEq] = SQLITE_AFF_NONE;
         }
       }  
-      codeApplyAffinity(pParse, regBase, nEq+1, zAff);
+      codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
       nConstraint++;
+      testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
     }
-    sqlite3DbFree(pParse->db, zAff);
+    sqlite3DbFree(pParse->db, zStartAff);
+    sqlite3DbFree(pParse->db, zEndAff);
 
     /* Top of the loop body */
     pLevel->p2 = sqlite3VdbeCurrentAddr(v);
@@ -91146,11 +98490,15 @@ static Bitmask codeOneLoopStart(
 
   /* Insert code to test every subexpression that can be completely
   ** computed using the current set of tables.
+  **
+  ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
+  ** the use of indices become tests that are evaluated against each row of
+  ** the relevant input tables.
   */
   k = 0;
   for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
     Expr *pE;
-    testcase( pTerm->wtFlags & TERM_VIRTUAL );
+    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
     testcase( pTerm->wtFlags & TERM_CODED );
     if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
     if( (pTerm->prereqAll & notReady)!=0 ){
@@ -91178,7 +98526,7 @@ static Bitmask codeOneLoopStart(
     VdbeComment((v, "record LEFT JOIN hit"));
     sqlite3ExprCacheClear(pParse);
     for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
-      testcase( pTerm->wtFlags & TERM_VIRTUAL );
+      testcase( pTerm->wtFlags & TERM_VIRTUAL );  /* IMP: R-30575-11662 */
       testcase( pTerm->wtFlags & TERM_CODED );
       if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
       if( (pTerm->prereqAll & notReady)!=0 ){
@@ -91212,7 +98560,7 @@ static int nQPlan = 0;              /* Next free slow in _query_plan[] */
 ** Free a WhereInfo structure
 */
 static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
-  if( pWInfo ){
+  if( ALWAYS(pWInfo) ){
     int i;
     for(i=0; i<pWInfo->nLevel; i++){
       sqlite3_index_info *pInfo = pWInfo->a[i].pIdxInfo;
@@ -91223,6 +98571,13 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
         }
         sqlite3DbFree(db, pInfo);
       }
+      if( pWInfo->a[i].plan.wsFlags & WHERE_TEMP_INDEX ){
+        Index *pIdx = pWInfo->a[i].plan.u.pIdx;
+        if( pIdx ){
+          sqlite3DbFree(db, pIdx->zColAff);
+          sqlite3DbFree(db, pIdx);
+        }
+      }
     }
     whereClauseClear(pWInfo->pWC);
     sqlite3DbFree(db, pWInfo);
@@ -91342,6 +98697,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   /* The number of tables in the FROM clause is limited by the number of
   ** bits in a Bitmask 
   */
+  testcase( pTabList->nSrc==BMS );
   if( pTabList->nSrc>BMS ){
     sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
     return 0;
@@ -91369,6 +98725,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
       sizeof(WhereMaskSet)
   );
   if( db->mallocFailed ){
+    sqlite3DbFree(db, pWInfo);
+    pWInfo = 0;
     goto whereBeginError;
   }
   pWInfo->nLevel = nTabList;
@@ -91377,6 +98735,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   pWInfo->iBreak = sqlite3VdbeMakeLabel(v);
   pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo];
   pWInfo->wctrlFlags = wctrlFlags;
+  pWInfo->savedNQueryLoop = pParse->nQueryLoop;
   pMaskSet = (WhereMaskSet*)&pWC[1];
 
   /* Split the WHERE clause into separate subexpressions where each
@@ -91385,7 +98744,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   initMaskSet(pMaskSet);
   whereClauseInit(pWC, pParse, pMaskSet);
   sqlite3ExprCodeConstants(pParse, pWhere);
-  whereSplit(pWC, pWhere, TK_AND);
+  whereSplit(pWC, pWhere, TK_AND);   /* IMP: R-15842-53296 */
     
   /* Special case: a WHERE clause that is constant.  Evaluate the
   ** expression and either jump over all of the code or fall thru.
@@ -91473,25 +98832,38 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     int bestJ = -1;             /* The value of j */
     Bitmask m;                  /* Bitmask value for j or bestJ */
     int isOptimal;              /* Iterator for optimal/non-optimal search */
+    int nUnconstrained;         /* Number tables without INDEXED BY */
+    Bitmask notIndexed;         /* Mask of tables that cannot use an index */
 
     memset(&bestPlan, 0, sizeof(bestPlan));
     bestPlan.rCost = SQLITE_BIG_DBL;
 
     /* Loop through the remaining entries in the FROM clause to find the
-    ** next nested loop. The FROM clause entries may be iterated through
+    ** next nested loop. The loop tests all FROM clause entries
     ** either once or twice. 
     **
-    ** The first iteration, which is always performed, searches for the
-    ** FROM clause entry that permits the lowest-cost, "optimal" scan. In
+    ** The first test is always performed if there are two or more entries
+    ** remaining and never performed if there is only one FROM clause entry
+    ** to choose from.  The first test looks for an "optimal" scan.  In
     ** this context an optimal scan is one that uses the same strategy
     ** for the given FROM clause entry as would be selected if the entry
     ** were used as the innermost nested loop.  In other words, a table
     ** is chosen such that the cost of running that table cannot be reduced
-    ** by waiting for other tables to run first.
+    ** by waiting for other tables to run first.  This "optimal" test works
+    ** by first assuming that the FROM clause is on the inner loop and finding
+    ** its query plan, then checking to see if that query plan uses any
+    ** other FROM clause terms that are notReady.  If no notReady terms are
+    ** used then the "optimal" query plan works.
+    **
+    ** Note that the WhereCost.nRow parameter for an optimal scan might
+    ** not be as small as it would be if the table really were the innermost
+    ** join.  The nRow value can be reduced by WHERE clause constraints
+    ** that do not use indices.  But this nRow reduction only happens if the
+    ** table really is the innermost join.  
     **
-    ** The second iteration is only performed if no optimal scan strategies
-    ** were found by the first. This iteration is used to search for the
-    ** lowest cost scan overall.
+    ** The second loop iteration is only performed if no optimal scan
+    ** strategies were found by the first iteration. This second iteration
+    ** is used to search for the lowest cost scan overall.
     **
     ** Previous versions of SQLite performed only the second iteration -
     ** the next outermost loop was always that with the lowest overall
@@ -91504,14 +98876,15 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     **
     ** The best strategy is to iterate through table t1 first. However it
     ** is not possible to determine this with a simple greedy algorithm.
-    ** However, since the cost of a linear scan through table t2 is the same 
+    ** Since the cost of a linear scan through table t2 is the same 
     ** as the cost of a linear scan through table t1, a simple greedy 
     ** algorithm may choose to use t2 for the outer loop, which is a much
     ** costlier approach.
     */
-    for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){
-      Bitmask mask = (isOptimal ? 0 : notReady);
-      assert( (nTabList-iFrom)>1 || isOptimal );
+    nUnconstrained = 0;
+    notIndexed = 0;
+    for(isOptimal=(iFrom<nTabList-1); isOptimal>=0 && bestJ<0; isOptimal--){
+      Bitmask mask;             /* Mask of tables not yet ready */
       for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){
         int doNotReorder;    /* True if this table should not be reordered */
         WhereCost sCost;     /* Cost information from best[Virtual]Index() */
@@ -91524,23 +98897,64 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
           if( j==iFrom ) iFrom++;
           continue;
         }
+        mask = (isOptimal ? m : notReady);
         pOrderBy = ((i==0 && ppOrderBy )?*ppOrderBy:0);
+        if( pTabItem->pIndex==0 ) nUnconstrained++;
   
         assert( pTabItem->pTab );
 #ifndef SQLITE_OMIT_VIRTUALTABLE
         if( IsVirtual(pTabItem->pTab) ){
           sqlite3_index_info **pp = &pWInfo->a[j].pIdxInfo;
-          bestVirtualIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost, pp);
+          bestVirtualIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy,
+                           &sCost, pp);
         }else 
 #endif
         {
-          bestBtreeIndex(pParse, pWC, pTabItem, mask, pOrderBy, &sCost);
+          bestBtreeIndex(pParse, pWC, pTabItem, mask, notReady, pOrderBy,
+                         &sCost);
         }
         assert( isOptimal || (sCost.used&notReady)==0 );
 
-        if( (sCost.used&notReady)==0
-         && (j==iFrom || sCost.rCost<bestPlan.rCost) 
+        /* If an INDEXED BY clause is present, then the plan must use that
+        ** index if it uses any index at all */
+        assert( pTabItem->pIndex==0 
+                  || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN)==0
+                  || sCost.plan.u.pIdx==pTabItem->pIndex );
+
+        if( isOptimal && (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ){
+          notIndexed |= m;
+        }
+
+        /* Conditions under which this table becomes the best so far:
+        **
+        **   (1) The table must not depend on other tables that have not
+        **       yet run.
+        **
+        **   (2) A full-table-scan plan cannot supercede another plan unless
+        **       it is an "optimal" plan as defined above.
+        **
+        **   (3) All tables have an INDEXED BY clause or this table lacks an
+        **       INDEXED BY clause or this table uses the specific
+        **       index specified by its INDEXED BY clause.  This rule ensures
+        **       that a best-so-far is always selected even if an impossible
+        **       combination of INDEXED BY clauses are given.  The error
+        **       will be detected and relayed back to the application later.
+        **       The NEVER() comes about because rule (2) above prevents
+        **       An indexable full-table-scan from reaching rule (3).
+        **
+        **   (4) The plan cost must be lower than prior plans or else the
+        **       cost must be the same and the number of rows must be lower.
+        */
+        if( (sCost.used&notReady)==0                       /* (1) */
+            && (bestJ<0 || (notIndexed&m)!=0               /* (2) */
+                || (sCost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0)
+            && (nUnconstrained==0 || pTabItem->pIndex==0   /* (3) */
+                || NEVER((sCost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0))
+            && (bestJ<0 || sCost.rCost<bestPlan.rCost      /* (4) */
+                || (sCost.rCost<=bestPlan.rCost && sCost.nRow<bestPlan.nRow))
         ){
+          WHERETRACE(("... best so far with cost=%g and nRow=%g\n",
+                      sCost.rCost, sCost.nRow));
           bestPlan = sCost;
           bestJ = j;
         }
@@ -91556,13 +98970,16 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     }
     andFlags &= bestPlan.plan.wsFlags;
     pLevel->plan = bestPlan.plan;
-    if( bestPlan.plan.wsFlags & WHERE_INDEXED ){
+    testcase( bestPlan.plan.wsFlags & WHERE_INDEXED );
+    testcase( bestPlan.plan.wsFlags & WHERE_TEMP_INDEX );
+    if( bestPlan.plan.wsFlags & (WHERE_INDEXED|WHERE_TEMP_INDEX) ){
       pLevel->iIdxCur = pParse->nTab++;
     }else{
       pLevel->iIdxCur = -1;
     }
     notReady &= ~getMask(pMaskSet, pTabList->a[bestJ].iCursor);
     pLevel->iFrom = (u8)bestJ;
+    if( bestPlan.nRow>=(double)1 ) pParse->nQueryLoop *= bestPlan.nRow;
 
     /* Check that if the table scanned by this loop iteration had an
     ** INDEXED BY clause attached to it, that the named index is being
@@ -91609,6 +99026,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
   ** searching those tables.
   */
   sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
+  notReady = ~(Bitmask)0;
   for(i=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
     Table *pTab;     /* Table to open */
     int iDb;         /* Index of database containing table/index */
@@ -91621,7 +99039,9 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
       if( pItem->zAlias ){
         zMsg = sqlite3MAppendf(db, zMsg, "%s AS %s", zMsg, pItem->zAlias);
       }
-      if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
+      if( (pLevel->plan.wsFlags & WHERE_TEMP_INDEX)!=0 ){
+        zMsg = sqlite3MAppendf(db, zMsg, "%s WITH AUTOMATIC INDEX", zMsg);
+      }else if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
         zMsg = sqlite3MAppendf(db, zMsg, "%s WITH INDEX %s",
            zMsg, pLevel->plan.u.pIdx->zName);
       }else if( pLevel->plan.wsFlags & WHERE_MULTI_OR ){
@@ -91644,8 +99064,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
 #endif /* SQLITE_OMIT_EXPLAIN */
     pTabItem = &pTabList->a[pLevel->iFrom];
     pTab = pTabItem->pTab;
+    pLevel->iTabCur = pTabItem->iCursor;
     iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
-    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
+    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){
+      /* Do nothing */
+    }else
 #ifndef SQLITE_OMIT_VIRTUALTABLE
     if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){
       const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);
@@ -91657,6 +99080,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
          && (wctrlFlags & WHERE_OMIT_OPEN)==0 ){
       int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;
       sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);
+      testcase( pTab->nCol==BMS-1 );
+      testcase( pTab->nCol==BMS );
       if( !pWInfo->okOnePass && pTab->nCol<BMS ){
         Bitmask b = pTabItem->colUsed;
         int n = 0;
@@ -91668,7 +99093,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
     }else{
       sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);
     }
-    pLevel->iTabCur = pTabItem->iCursor;
+#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
+    if( (pLevel->plan.wsFlags & WHERE_TEMP_INDEX)!=0 ){
+      constructAutomaticIndex(pParse, pWC, pTabItem, notReady, pLevel);
+    }else
+#endif
     if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
       Index *pIx = pLevel->plan.u.pIdx;
       KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIx);
@@ -91680,8 +99109,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
       VdbeComment((v, "%s", pIx->zName));
     }
     sqlite3CodeVerifySchema(pParse, iDb);
+    notReady &= ~getMask(pWC->pMaskSet, pTabItem->iCursor);
   }
   pWInfo->iTop = sqlite3VdbeCurrentAddr(v);
+  if( db->mallocFailed ) goto whereBeginError;
 
   /* Generate the code to do the search.  Each iteration of the for
   ** loop below generates code for a single nested loop of the VM
@@ -91749,7 +99180,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
 
   /* Jump here if malloc fails */
 whereBeginError:
-  whereInfoFree(db, pWInfo);
+  if( pWInfo ){
+    pParse->nQueryLoop = pWInfo->savedNQueryLoop;
+    whereInfoFree(db, pWInfo);
+  }
   return 0;
 }
 
@@ -91819,12 +99253,15 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
     struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
     Table *pTab = pTabItem->pTab;
     assert( pTab!=0 );
-    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
-    if( (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 ){
-      if( !pWInfo->okOnePass && (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 ){
+    if( (pTab->tabFlags & TF_Ephemeral)==0
+     && pTab->pSelect==0
+     && (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0
+    ){
+      int ws = pLevel->plan.wsFlags;
+      if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){
         sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
       }
-      if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){
+      if( (ws & WHERE_INDEXED)!=0 && (ws & WHERE_TEMP_INDEX)==0 ){
         sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
       }
     }
@@ -91872,6 +99309,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
 
   /* Final cleanup
   */
+  pParse->nQueryLoop = pWInfo->savedNQueryLoop;
   whereInfoFree(db, pWInfo);
   return;
 }
@@ -92059,26 +99497,26 @@ struct AttachKey { int type;  Token key; };
 **                       defined, then do no error processing.
 */
 #define YYCODETYPE unsigned char
-#define YYNOCODE 254
+#define YYNOCODE 253
 #define YYACTIONTYPE unsigned short int
 #define YYWILDCARD 67
 #define sqlite3ParserTOKENTYPE Token
 typedef union {
   int yyinit;
   sqlite3ParserTOKENTYPE yy0;
-  Select* yy3;
-  ExprList* yy14;
-  SrcList* yy65;
-  struct LikeOp yy96;
-  Expr* yy132;
-  u8 yy186;
-  int yy328;
-  ExprSpan yy346;
-  struct TrigEvent yy378;
-  IdList* yy408;
-  struct {int value; int mask;} yy429;
-  TriggerStep* yy473;
-  struct LimitVal yy476;
+  int yy4;
+  struct TrigEvent yy90;
+  ExprSpan yy118;
+  TriggerStep* yy203;
+  u8 yy210;
+  struct {int value; int mask;} yy215;
+  SrcList* yy259;
+  struct LimitVal yy292;
+  Expr* yy314;
+  ExprList* yy322;
+  struct LikeOp yy342;
+  IdList* yy384;
+  Select* yy387;
 } YYMINORTYPE;
 #ifndef YYSTACKDEPTH
 #define YYSTACKDEPTH 100
@@ -92087,8 +99525,8 @@ typedef union {
 #define sqlite3ParserARG_PDECL ,Parse *pParse
 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
-#define YYNSTATE 631
-#define YYNRULE 330
+#define YYNSTATE 630
+#define YYNRULE 329
 #define YYFALLBACK 1
 #define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)
 #define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)
@@ -92158,472 +99596,473 @@ static const YYMINORTYPE yyzerominor = { 0 };
 **                     shifting non-terminals after a reduce.
 **  yy_default[]       Default action for each state.
 */
-#define YY_ACTTAB_COUNT (1550)
+#define YY_ACTTAB_COUNT (1557)
 static const YYACTIONTYPE yy_action[] = {
- /*     0 */   313,   49,  556,   46,  147,  172,  628,  598,   55,   55,
- /*    10 */    55,   55,  302,   53,   53,   53,   53,   52,   52,   51,
- /*    20 */    51,   51,   50,  238,  603,   66,  624,  623,  604,  598,
- /*    30 */   591,  585,   48,   53,   53,   53,   53,   52,   52,   51,
- /*    40 */    51,   51,   50,  238,   51,   51,   51,   50,  238,   56,
- /*    50 */    57,   47,  583,  582,  584,  584,   54,   54,   55,   55,
- /*    60 */    55,   55,  609,   53,   53,   53,   53,   52,   52,   51,
- /*    70 */    51,   51,   50,  238,  313,  598,  672,  330,  411,  217,
+ /*     0 */   313,  960,  186,  419,    2,  172,  627,  597,   55,   55,
+ /*    10 */    55,   55,   48,   53,   53,   53,   53,   52,   52,   51,
+ /*    20 */    51,   51,   50,  238,  302,  283,  623,  622,  516,  515,
+ /*    30 */   590,  584,   55,   55,   55,   55,  282,   53,   53,   53,
+ /*    40 */    53,   52,   52,   51,   51,   51,   50,  238,    6,   56,
+ /*    50 */    57,   47,  582,  581,  583,  583,   54,   54,   55,   55,
+ /*    60 */    55,   55,  608,   53,   53,   53,   53,   52,   52,   51,
+ /*    70 */    51,   51,   50,  238,  313,  597,  409,  330,  579,  579,
  /*    80 */    32,   53,   53,   53,   53,   52,   52,   51,   51,   51,
- /*    90 */    50,  238,  330,  414,  621,  620,  166,  598,  673,  382,
- /*   100 */   379,  378,  602,   73,  591,  585,  307,  424,  166,   58,
- /*   110 */   377,  382,  379,  378,  516,  515,  624,  623,  254,  200,
- /*   120 */   199,  198,  377,   56,   57,   47,  583,  582,  584,  584,
- /*   130 */    54,   54,   55,   55,   55,   55,  581,   53,   53,   53,
- /*   140 */    53,   52,   52,   51,   51,   51,   50,  238,  313,  270,
- /*   150 */   226,  422,  283,  133,  177,  139,  284,  385,  279,  384,
- /*   160 */   169,  197,  251,  282,  253,  226,  411,  275,  440,  167,
- /*   170 */   139,  284,  385,  279,  384,  169,  571,  236,  591,  585,
- /*   180 */   240,  414,  275,  622,  621,  620,  674,  437,  441,  442,
- /*   190 */   602,   88,  352,  266,  439,  268,  438,   56,   57,   47,
- /*   200 */   583,  582,  584,  584,   54,   54,   55,   55,   55,   55,
+ /*    90 */    50,  238,  330,  217,  620,  619,  166,  411,  624,  382,
+ /*   100 */   379,  378,    7,  491,  590,  584,  200,  199,  198,   58,
+ /*   110 */   377,  300,  414,  621,  481,   66,  623,  622,  621,  580,
+ /*   120 */   254,  601,   94,   56,   57,   47,  582,  581,  583,  583,
+ /*   130 */    54,   54,   55,   55,   55,   55,  671,   53,   53,   53,
+ /*   140 */    53,   52,   52,   51,   51,   51,   50,  238,  313,  532,
+ /*   150 */   226,  506,  507,  133,  177,  139,  284,  385,  279,  384,
+ /*   160 */   169,  197,  342,  398,  251,  226,  253,  275,  388,  167,
+ /*   170 */   139,  284,  385,  279,  384,  169,  570,  236,  590,  584,
+ /*   180 */   672,  240,  275,  157,  620,  619,  554,  437,   51,   51,
+ /*   190 */    51,   50,  238,  343,  439,  553,  438,   56,   57,   47,
+ /*   200 */   582,  581,  583,  583,   54,   54,   55,   55,   55,   55,
  /*   210 */   465,   53,   53,   53,   53,   52,   52,   51,   51,   51,
- /*   220 */    50,  238,  313,  471,   52,   52,   51,   51,   51,   50,
- /*   230 */   238,  234,  166,  491,  567,  382,  379,  378,    1,  440,
- /*   240 */   252,  176,  624,  623,  608,   67,  377,  513,  622,  443,
- /*   250 */   237,  577,  591,  585,  622,  172,  466,  598,  554,  441,
- /*   260 */   340,  409,  526,  580,  580,  349,  596,  553,  194,  482,
- /*   270 */   175,   56,   57,   47,  583,  582,  584,  584,   54,   54,
- /*   280 */    55,   55,   55,   55,  562,   53,   53,   53,   53,   52,
- /*   290 */    52,   51,   51,   51,   50,  238,  313,  594,  594,  594,
- /*   300 */   561,  578,  469,   65,  259,  351,  258,  411,  624,  623,
- /*   310 */   621,  620,  332,  576,  575,  240,  560,  568,  520,  411,
- /*   320 */   341,  237,  414,  624,  623,  598,  591,  585,  542,  519,
- /*   330 */   171,  602,   95,   68,  414,  624,  623,  624,  623,   38,
- /*   340 */   877,  506,  507,  602,   88,   56,   57,   47,  583,  582,
- /*   350 */   584,  584,   54,   54,   55,   55,   55,   55,  532,   53,
+ /*   220 */    50,  238,  313,  390,   52,   52,   51,   51,   51,   50,
+ /*   230 */   238,  391,  166,  491,  566,  382,  379,  378,  409,  440,
+ /*   240 */   579,  579,  252,  440,  607,   66,  377,  513,  621,   49,
+ /*   250 */    46,  147,  590,  584,  621,   16,  466,  189,  621,  441,
+ /*   260 */   442,  673,  526,  441,  340,  577,  595,   64,  194,  482,
+ /*   270 */   434,   56,   57,   47,  582,  581,  583,  583,   54,   54,
+ /*   280 */    55,   55,   55,   55,   30,   53,   53,   53,   53,   52,
+ /*   290 */    52,   51,   51,   51,   50,  238,  313,  593,  593,  593,
+ /*   300 */   387,  578,  606,  493,  259,  351,  258,  411,    1,  623,
+ /*   310 */   622,  496,  623,  622,   65,  240,  623,  622,  597,  443,
+ /*   320 */   237,  239,  414,  341,  237,  602,  590,  584,   18,  603,
+ /*   330 */   166,  601,   87,  382,  379,  378,   67,  623,  622,   38,
+ /*   340 */   623,  622,  176,  270,  377,   56,   57,   47,  582,  581,
+ /*   350 */   583,  583,   54,   54,   55,   55,   55,   55,  175,   53,
  /*   360 */    53,   53,   53,   52,   52,   51,   51,   51,   50,  238,
- /*   370 */   313,  411,  579,  398,  531,  237,  621,  620,  388,  625,
- /*   380 */   500,  206,  167,  396,  233,  312,  414,  387,  569,  492,
- /*   390 */   216,  621,  620,  566,  622,  602,   74,  533,  210,  491,
- /*   400 */   591,  585,  548,  621,  620,  621,  620,  300,  598,  466,
- /*   410 */   481,   67,  603,   35,  622,  601,  604,  547,    6,   56,
- /*   420 */    57,   47,  583,  582,  584,  584,   54,   54,   55,   55,
- /*   430 */    55,   55,  601,   53,   53,   53,   53,   52,   52,   51,
- /*   440 */    51,   51,   50,  238,  313,  411,  184,  409,  528,  580,
- /*   450 */   580,  551,  962,  186,  419,    2,  353,  259,  351,  258,
- /*   460 */   414,  409,  411,  580,  580,   44,  411,  544,  240,  602,
- /*   470 */    94,  190,    7,   62,  591,  585,  598,  414,  350,  607,
- /*   480 */   493,  414,  409,  317,  580,  580,  602,   95,  496,  565,
- /*   490 */   602,   80,  203,   56,   57,   47,  583,  582,  584,  584,
- /*   500 */    54,   54,   55,   55,   55,   55,  535,   53,   53,   53,
- /*   510 */    53,   52,   52,   51,   51,   51,   50,  238,  313,  202,
- /*   520 */   564,  293,  511,   49,  562,   46,  147,  411,  394,  183,
- /*   530 */   563,  549,  505,  549,  174,  409,  322,  580,  580,   39,
- /*   540 */   561,   37,  414,  624,  623,  192,  473,  383,  591,  585,
- /*   550 */   474,  602,   80,  601,  504,  544,  560,  364,  402,  210,
- /*   560 */   421,  952,  361,  952,  365,  201,  144,   56,   57,   47,
- /*   570 */   583,  582,  584,  584,   54,   54,   55,   55,   55,   55,
- /*   580 */   559,   53,   53,   53,   53,   52,   52,   51,   51,   51,
- /*   590 */    50,  238,  313,  601,  232,  264,  272,  321,  374,  484,
- /*   600 */   510,  146,  342,  146,  328,  425,  485,  407,  576,  575,
- /*   610 */   622,  621,  620,   49,  168,   46,  147,  353,  546,  491,
- /*   620 */   204,  240,  591,  585,  421,  951,  549,  951,  549,  168,
- /*   630 */   429,   67,  390,  343,  622,  434,  307,  423,  338,  360,
- /*   640 */   391,   56,   57,   47,  583,  582,  584,  584,   54,   54,
- /*   650 */    55,   55,   55,   55,  601,   53,   53,   53,   53,   52,
- /*   660 */    52,   51,   51,   51,   50,  238,  313,   34,  318,  425,
- /*   670 */   237,   21,  359,  273,  411,  167,  411,  276,  411,  540,
- /*   680 */   411,  422,   13,  318,  619,  618,  617,  622,  275,  414,
- /*   690 */   336,  414,  622,  414,  622,  414,  591,  585,  602,   69,
- /*   700 */   602,   97,  602,  100,  602,   98,  631,  629,  334,  475,
- /*   710 */   475,  367,  319,  148,  327,   56,   57,   47,  583,  582,
- /*   720 */   584,  584,   54,   54,   55,   55,   55,   55,  411,   53,
+ /*   370 */   313,  396,  233,  411,  531,  565,  317,  620,  619,   44,
+ /*   380 */   620,  619,  240,  206,  620,  619,  597,  266,  414,  268,
+ /*   390 */   409,  597,  579,  579,  352,  184,  505,  601,   73,  533,
+ /*   400 */   590,  584,  466,  548,  190,  620,  619,  576,  620,  619,
+ /*   410 */   547,  383,  551,   35,  332,  575,  574,  600,  504,   56,
+ /*   420 */    57,   47,  582,  581,  583,  583,   54,   54,   55,   55,
+ /*   430 */    55,   55,  567,   53,   53,   53,   53,   52,   52,   51,
+ /*   440 */    51,   51,   50,  238,  313,  411,  561,  561,  528,  364,
+ /*   450 */   259,  351,  258,  183,  361,  549,  524,  374,  411,  597,
+ /*   460 */   414,  240,  560,  560,  409,  604,  579,  579,  328,  601,
+ /*   470 */    93,  623,  622,  414,  590,  584,  237,  564,  559,  559,
+ /*   480 */   520,  402,  601,   87,  409,  210,  579,  579,  168,  421,
+ /*   490 */   950,  519,  950,   56,   57,   47,  582,  581,  583,  583,
+ /*   500 */    54,   54,   55,   55,   55,   55,  192,   53,   53,   53,
+ /*   510 */    53,   52,   52,   51,   51,   51,   50,  238,  313,  600,
+ /*   520 */   293,  563,  511,  234,  357,  146,  475,  475,  367,  411,
+ /*   530 */   562,  411,  358,  542,  425,  171,  411,  215,  144,  620,
+ /*   540 */   619,  544,  318,  353,  414,  203,  414,  275,  590,  584,
+ /*   550 */   549,  414,  174,  601,   94,  601,   79,  558,  471,   61,
+ /*   560 */   601,   79,  421,  949,  350,  949,   34,   56,   57,   47,
+ /*   570 */   582,  581,  583,  583,   54,   54,   55,   55,   55,   55,
+ /*   580 */   535,   53,   53,   53,   53,   52,   52,   51,   51,   51,
+ /*   590 */    50,  238,  313,  307,  424,  394,  272,   49,   46,  147,
+ /*   600 */   349,  322,    4,  411,  491,  312,  321,  425,  568,  492,
+ /*   610 */   216,  264,  407,  575,  574,  429,   66,  549,  414,  621,
+ /*   620 */   540,  602,  590,  584,   13,  603,  621,  601,   72,   12,
+ /*   630 */   618,  617,  616,  202,  210,  621,  546,  469,  422,  319,
+ /*   640 */   148,   56,   57,   47,  582,  581,  583,  583,   54,   54,
+ /*   650 */    55,   55,   55,   55,  338,   53,   53,   53,   53,   52,
+ /*   660 */    52,   51,   51,   51,   50,  238,  313,  600,  600,  411,
+ /*   670 */    39,   21,   37,  170,  237,  875,  411,  572,  572,  201,
+ /*   680 */   144,  473,  538,  331,  414,  474,  143,  146,  630,  628,
+ /*   690 */   334,  414,  353,  601,   68,  168,  590,  584,  132,  365,
+ /*   700 */   601,   96,  307,  423,  530,  336,   49,   46,  147,  568,
+ /*   710 */   406,  216,  549,  360,  529,   56,   57,   47,  582,  581,
+ /*   720 */   583,  583,   54,   54,   55,   55,   55,   55,  411,   53,
  /*   730 */    53,   53,   53,   52,   52,   51,   51,   51,   50,  238,
- /*   740 */   313,  411,  331,  414,  411,   49,  276,   46,  147,  569,
- /*   750 */   406,  216,  602,  106,  573,  573,  414,  354,  524,  414,
- /*   760 */   411,  622,  411,  224,    4,  602,  104,  605,  602,  108,
- /*   770 */   591,  585,  622,   20,  375,  414,  167,  414,  215,  144,
- /*   780 */   470,  239,  167,  225,  602,  109,  602,  134,   18,   56,
- /*   790 */    57,   47,  583,  582,  584,  584,   54,   54,   55,   55,
+ /*   740 */   313,  411,  605,  414,  484,  510,  172,  422,  597,  318,
+ /*   750 */   496,  485,  601,   99,  411,  142,  414,  411,  231,  411,
+ /*   760 */   540,  411,  359,  629,    2,  601,   97,  426,  308,  414,
+ /*   770 */   590,  584,  414,   20,  414,  621,  414,  621,  601,  106,
+ /*   780 */   503,  601,  105,  601,  108,  601,  109,  204,   28,   56,
+ /*   790 */    57,   47,  582,  581,  583,  583,   54,   54,   55,   55,
  /*   800 */    55,   55,  411,   53,   53,   53,   53,   52,   52,   51,
- /*   810 */    51,   51,   50,  238,  313,  411,  276,  414,   12,  459,
- /*   820 */   276,  171,  411,   16,  223,  189,  602,  135,  354,  170,
- /*   830 */   414,  622,  630,    2,  411,  622,  540,  414,  143,  602,
- /*   840 */    61,  359,  132,  622,  591,  585,  602,  105,  458,  414,
- /*   850 */    23,  622,  446,  326,   23,  538,  622,  325,  602,  103,
- /*   860 */   427,  530,  309,   56,   57,   47,  583,  582,  584,  584,
+ /*   810 */    51,   51,   50,  238,  313,  411,  597,  414,  411,  276,
+ /*   820 */   214,  600,  411,  366,  213,  381,  601,  134,  274,  500,
+ /*   830 */   414,  167,  130,  414,  621,  411,  354,  414,  376,  601,
+ /*   840 */   135,  129,  601,  100,  590,  584,  601,  104,  522,  521,
+ /*   850 */   414,  621,  224,  273,  600,  167,  327,  282,  600,  601,
+ /*   860 */   103,  468,  521,   56,   57,   47,  582,  581,  583,  583,
  /*   870 */    54,   54,   55,   55,   55,   55,  411,   53,   53,   53,
  /*   880 */    53,   52,   52,   51,   51,   51,   50,  238,  313,  411,
- /*   890 */   264,  414,  411,  276,  359,  219,  157,  214,  357,  366,
- /*   900 */   602,   96,  522,  521,  414,  622,  358,  414,  622,  622,
- /*   910 */   411,  613,  612,  602,  102,  142,  602,   77,  591,  585,
- /*   920 */   529,  540,  231,  426,  308,  414,  622,  622,  468,  521,
- /*   930 */   324,  601,  257,  263,  602,   99,  622,   56,   45,   47,
- /*   940 */   583,  582,  584,  584,   54,   54,   55,   55,   55,   55,
+ /*   890 */    27,  414,  411,  375,  276,  167,  359,  544,   50,  238,
+ /*   900 */   601,   95,  128,  223,  414,  411,  165,  414,  411,  621,
+ /*   910 */   411,  621,  612,  601,  102,  372,  601,   76,  590,  584,
+ /*   920 */   414,  570,  236,  414,  470,  414,  167,  621,  188,  601,
+ /*   930 */    98,  225,  601,  138,  601,  137,  232,   56,   45,   47,
+ /*   940 */   582,  581,  583,  583,   54,   54,   55,   55,   55,   55,
  /*   950 */   411,   53,   53,   53,   53,   52,   52,   51,   51,   51,
- /*   960 */    50,  238,  313,  264,  264,  414,  411,  213,  209,  544,
- /*   970 */   544,  207,  611,   28,  602,  138,   50,  238,  622,  622,
- /*   980 */   381,  414,  503,  140,  323,  222,  274,  622,  590,  589,
- /*   990 */   602,  137,  591,  585,  629,  334,  606,   30,  622,  571,
- /*  1000 */   236,  601,  601,  130,  496,  601,  453,  451,  288,  286,
- /*  1010 */   587,  586,   57,   47,  583,  582,  584,  584,   54,   54,
+ /*   960 */    50,  238,  313,  276,  276,  414,  411,  276,  544,  459,
+ /*   970 */   359,  171,  209,  479,  601,  136,  628,  334,  621,  621,
+ /*   980 */   125,  414,  621,  368,  411,  621,  257,  540,  589,  588,
+ /*   990 */   601,   75,  590,  584,  458,  446,   23,   23,  124,  414,
+ /*  1000 */   326,  325,  621,  427,  324,  309,  600,  288,  601,   92,
+ /*  1010 */   586,  585,   57,   47,  582,  581,  583,  583,   54,   54,
  /*  1020 */    55,   55,   55,   55,  411,   53,   53,   53,   53,   52,
- /*  1030 */    52,   51,   51,   51,   50,  238,  313,  588,  411,  414,
- /*  1040 */   411,  264,  410,  129,  595,  400,   27,  376,  602,  136,
- /*  1050 */   128,  165,  479,  414,  282,  414,  622,  622,  411,  622,
- /*  1060 */   622,  411,  602,   76,  602,   93,  591,  585,  188,  372,
- /*  1070 */   368,  125,  476,  414,  261,  160,  414,  171,  124,  472,
- /*  1080 */   123,   15,  602,   92,  450,  602,   75,   47,  583,  582,
- /*  1090 */   584,  584,   54,   54,   55,   55,   55,   55,  464,   53,
+ /*  1030 */    52,   51,   51,   51,   50,  238,  313,  587,  411,  414,
+ /*  1040 */   411,  207,  611,  476,  171,  472,  160,  123,  601,   91,
+ /*  1050 */   323,  261,   15,  414,  464,  414,  411,  621,  411,  354,
+ /*  1060 */   222,  411,  601,   74,  601,   90,  590,  584,  159,  264,
+ /*  1070 */   158,  414,  461,  414,  621,  600,  414,  121,  120,   25,
+ /*  1080 */   601,   89,  601,  101,  621,  601,   88,   47,  582,  581,
+ /*  1090 */   583,  583,   54,   54,   55,   55,   55,   55,  544,   53,
  /*  1100 */    53,   53,   53,   52,   52,   51,   51,   51,   50,  238,
- /*  1110 */    43,  405,  264,    3,  558,  264,  545,  415,  623,  159,
- /*  1120 */   541,  158,  539,  278,   25,  461,  121,  622,  408,  622,
- /*  1130 */   622,  622,   24,   43,  405,  622,    3,  622,  622,  120,
- /*  1140 */   415,  623,   11,  456,  411,  156,  452,  403,  509,  277,
- /*  1150 */   118,  408,  489,  113,  205,  449,  271,  567,  221,  414,
- /*  1160 */   269,  267,  155,  622,  622,  111,  411,  622,  602,   95,
- /*  1170 */   403,  622,  411,  110,   10,  622,  622,   40,   41,  534,
- /*  1180 */   567,  414,   64,  264,   42,  413,  412,  414,  601,  596,
- /*  1190 */   602,   91,  445,  436,  150,  435,  602,   90,  622,  265,
- /*  1200 */    40,   41,  337,  242,  411,  191,  333,   42,  413,  412,
- /*  1210 */   398,  420,  596,  316,  622,  399,  260,  107,  230,  414,
- /*  1220 */   594,  594,  594,  593,  592,   14,  220,  411,  602,  101,
- /*  1230 */   240,  622,   43,  405,  362,    3,  149,  315,  626,  415,
- /*  1240 */   623,  127,  414,  594,  594,  594,  593,  592,   14,  622,
- /*  1250 */   408,  602,   89,  411,  181,   33,  405,  463,    3,  411,
- /*  1260 */   264,  462,  415,  623,  616,  615,  614,  355,  414,  403,
- /*  1270 */   417,  416,  622,  408,  414,  622,  622,  602,   87,  567,
- /*  1280 */   418,  627,  622,  602,   86,    8,  241,  180,  126,  255,
- /*  1290 */   600,  178,  403,  240,  208,  455,  395,  294,  444,   40,
- /*  1300 */    41,  297,  567,  248,  622,  296,   42,  413,  412,  247,
- /*  1310 */   622,  596,  244,  622,   30,   60,   31,  243,  430,  624,
- /*  1320 */   623,  292,   40,   41,  622,  295,  145,  622,  601,   42,
- /*  1330 */   413,  412,  622,  622,  596,  393,  622,  397,  599,   59,
- /*  1340 */   235,  622,  594,  594,  594,  593,  592,   14,  218,  291,
- /*  1350 */   622,   36,  344,  305,  304,  303,  179,  301,  411,  567,
- /*  1360 */   454,  557,  173,  185,  622,  594,  594,  594,  593,  592,
- /*  1370 */    14,  411,   29,  414,  151,  289,  246,  523,  411,  196,
- /*  1380 */   195,  335,  602,   85,  411,  245,  414,  526,  392,  543,
- /*  1390 */   411,  596,  287,  414,  285,  602,   72,  537,  153,  414,
- /*  1400 */   466,  411,  602,   71,  154,  414,  411,  152,  602,   84,
- /*  1410 */   386,  536,  329,  411,  602,   83,  414,  518,  280,  411,
- /*  1420 */   513,  414,  594,  594,  594,  602,   82,  517,  414,  311,
- /*  1430 */   602,   81,  411,  514,  414,  512,  131,  602,   70,  229,
- /*  1440 */   228,  227,  494,  602,   17,  411,  488,  414,  259,  346,
- /*  1450 */   249,  389,  487,  486,  314,  164,  602,   79,  310,  240,
- /*  1460 */   414,  373,  480,  163,  262,  371,  414,  162,  369,  602,
- /*  1470 */    78,  212,  478,   26,  477,  602,    9,  161,  467,  363,
- /*  1480 */   141,  122,  339,  187,  119,  457,  348,  347,  117,  116,
- /*  1490 */   115,  112,  114,  448,  182,   22,  320,  433,  432,  431,
- /*  1500 */    19,  428,  610,  597,  574,  193,  572,   63,  298,  404,
- /*  1510 */   555,  552,  290,  281,  510,  460,  498,  499,  495,  447,
- /*  1520 */   356,  497,  256,  380,  306,  570,    5,  250,  345,  238,
- /*  1530 */   299,  550,  527,  490,  508,  525,  502,  401,  501,  963,
- /*  1540 */   211,  963,  483,  963,  963,  963,  963,  963,  963,  370,
+ /*  1110 */    43,  405,  263,    3,  610,  264,  140,  415,  622,   24,
+ /*  1120 */   410,   11,  456,  594,  118,  155,  219,  452,  408,  621,
+ /*  1130 */   621,  621,  156,   43,  405,  621,    3,  286,  621,  113,
+ /*  1140 */   415,  622,  111,  445,  411,  400,  557,  403,  545,   10,
+ /*  1150 */   411,  408,  264,  110,  205,  436,  541,  566,  453,  414,
+ /*  1160 */   621,  621,   63,  621,  435,  414,  411,  621,  601,   94,
+ /*  1170 */   403,  621,  411,  337,  601,   86,  150,   40,   41,  534,
+ /*  1180 */   566,  414,  242,  264,   42,  413,  412,  414,  600,  595,
+ /*  1190 */   601,   85,  191,  333,  107,  451,  601,   84,  621,  539,
+ /*  1200 */    40,   41,  420,  230,  411,  149,  316,   42,  413,  412,
+ /*  1210 */   398,  127,  595,  315,  621,  399,  278,  625,  181,  414,
+ /*  1220 */   593,  593,  593,  592,  591,   14,  450,  411,  601,   71,
+ /*  1230 */   240,  621,   43,  405,  264,    3,  615,  180,  264,  415,
+ /*  1240 */   622,  614,  414,  593,  593,  593,  592,  591,   14,  621,
+ /*  1250 */   408,  601,   70,  621,  417,   33,  405,  613,    3,  411,
+ /*  1260 */   264,  411,  415,  622,  418,  626,  178,  509,    8,  403,
+ /*  1270 */   241,  416,  126,  408,  414,  621,  414,  449,  208,  566,
+ /*  1280 */   240,  221,  621,  601,   83,  601,   82,  599,  297,  277,
+ /*  1290 */   296,   30,  403,   31,  395,  264,  295,  397,  489,   40,
+ /*  1300 */    41,  411,  566,  220,  621,  294,   42,  413,  412,  271,
+ /*  1310 */   621,  595,  600,  621,   59,   60,  414,  269,  267,  623,
+ /*  1320 */   622,   36,   40,   41,  621,  601,   81,  598,  235,   42,
+ /*  1330 */   413,  412,  621,  621,  595,  265,  344,  411,  248,  556,
+ /*  1340 */   173,  185,  593,  593,  593,  592,  591,   14,  218,   29,
+ /*  1350 */   621,  543,  414,  305,  304,  303,  179,  301,  411,  566,
+ /*  1360 */   454,  601,   80,  289,  335,  593,  593,  593,  592,  591,
+ /*  1370 */    14,  411,  287,  414,  151,  392,  246,  260,  411,  196,
+ /*  1380 */   195,  523,  601,   69,  411,  245,  414,  526,  537,  285,
+ /*  1390 */   389,  595,  621,  414,  536,  601,   17,  362,  153,  414,
+ /*  1400 */   466,  463,  601,   78,  154,  414,  462,  152,  601,   77,
+ /*  1410 */   355,  255,  621,  455,  601,    9,  621,  386,  444,  517,
+ /*  1420 */   247,  621,  593,  593,  593,  621,  621,  244,  621,  243,
+ /*  1430 */   430,  518,  292,  621,  329,  621,  145,  393,  280,  513,
+ /*  1440 */   291,  131,  621,  514,  621,  621,  311,  621,  259,  346,
+ /*  1450 */   249,  621,  621,  229,  314,  621,  228,  512,  227,  240,
+ /*  1460 */   494,  488,  310,  164,  487,  486,  373,  480,  163,  262,
+ /*  1470 */   369,  371,  162,   26,  212,  478,  477,  161,  141,  363,
+ /*  1480 */   467,  122,  339,  187,  119,  348,  347,  117,  116,  115,
+ /*  1490 */   114,  112,  182,  457,  320,   22,  433,  432,  448,   19,
+ /*  1500 */   609,  431,  428,   62,  193,  596,  573,  298,  555,  552,
+ /*  1510 */   571,  404,  290,  380,  498,  510,  495,  306,  281,  499,
+ /*  1520 */   250,    5,  497,  460,  345,  447,  569,  550,  238,  299,
+ /*  1530 */   527,  525,  508,  961,  502,  501,  961,  401,  961,  211,
+ /*  1540 */   490,  356,  256,  961,  483,  961,  961,  961,  961,  961,
+ /*  1550 */   961,  961,  961,  961,  961,  961,  370,
 };
 static const YYCODETYPE yy_lookahead[] = {
- /*     0 */    19,  222,  223,  224,  225,   24,    1,   26,   77,   78,
- /*    10 */    79,   80,   15,   82,   83,   84,   85,   86,   87,   88,
- /*    20 */    89,   90,   91,   92,  113,   22,   26,   27,  117,   26,
- /*    30 */    49,   50,   81,   82,   83,   84,   85,   86,   87,   88,
- /*    40 */    89,   90,   91,   92,   88,   89,   90,   91,   92,   68,
+ /*     0 */    19,  142,  143,  144,  145,   24,    1,   26,   77,   78,
+ /*    10 */    79,   80,   81,   82,   83,   84,   85,   86,   87,   88,
+ /*    20 */    89,   90,   91,   92,   15,   98,   26,   27,    7,    8,
+ /*    30 */    49,   50,   77,   78,   79,   80,  109,   82,   83,   84,
+ /*    40 */    85,   86,   87,   88,   89,   90,   91,   92,   22,   68,
  /*    50 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
  /*    60 */    79,   80,   23,   82,   83,   84,   85,   86,   87,   88,
- /*    70 */    89,   90,   91,   92,   19,   94,  118,   19,  150,   22,
+ /*    70 */    89,   90,   91,   92,   19,   94,  112,   19,  114,  115,
  /*    80 */    25,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*    90 */    91,   92,   19,  165,   94,   95,   96,   94,  118,   99,
- /*   100 */   100,  101,  174,  175,   49,   50,   22,   23,   96,   54,
- /*   110 */   110,   99,  100,  101,    7,    8,   26,   27,   16,  105,
- /*   120 */   106,  107,  110,   68,   69,   70,   71,   72,   73,   74,
- /*   130 */    75,   76,   77,   78,   79,   80,  113,   82,   83,   84,
- /*   140 */    85,   86,   87,   88,   89,   90,   91,   92,   19,   16,
- /*   150 */    92,   67,   98,   24,   96,   97,   98,   99,  100,  101,
- /*   160 */   102,   25,   60,  109,   62,   92,  150,  109,  150,   25,
+ /*    90 */    91,   92,   19,   22,   94,   95,   96,  150,  150,   99,
+ /*   100 */   100,  101,   76,  150,   49,   50,  105,  106,  107,   54,
+ /*   110 */   110,  158,  165,  165,  161,  162,   26,   27,  165,  113,
+ /*   120 */    16,  174,  175,   68,   69,   70,   71,   72,   73,   74,
+ /*   130 */    75,   76,   77,   78,   79,   80,  118,   82,   83,   84,
+ /*   140 */    85,   86,   87,   88,   89,   90,   91,   92,   19,   23,
+ /*   150 */    92,   97,   98,   24,   96,   97,   98,   99,  100,  101,
+ /*   160 */   102,   25,   97,  216,   60,   92,   62,  109,  221,   25,
  /*   170 */    97,   98,   99,  100,  101,  102,   86,   87,   49,   50,
- /*   180 */   116,  165,  109,  165,   94,   95,  118,   97,  170,  171,
- /*   190 */   174,  175,  128,   60,  104,   62,  106,   68,   69,   70,
+ /*   180 */   118,  116,  109,   25,   94,   95,   32,   97,   88,   89,
+ /*   190 */    90,   91,   92,  128,  104,   41,  106,   68,   69,   70,
  /*   200 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,
  /*   210 */    11,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*   220 */    91,   92,   19,   21,   86,   87,   88,   89,   90,   91,
- /*   230 */    92,  215,   96,  150,   66,   99,  100,  101,   22,  150,
- /*   240 */   138,  118,   26,   27,  161,  162,  110,  103,  165,  231,
- /*   250 */   232,   23,   49,   50,  165,   24,   57,   26,   32,  170,
- /*   260 */   171,  112,   94,  114,  115,   63,   98,   41,  185,  186,
- /*   270 */   118,   68,   69,   70,   71,   72,   73,   74,   75,   76,
- /*   280 */    77,   78,   79,   80,   12,   82,   83,   84,   85,   86,
+ /*   220 */    91,   92,   19,   19,   86,   87,   88,   89,   90,   91,
+ /*   230 */    92,   27,   96,  150,   66,   99,  100,  101,  112,  150,
+ /*   240 */   114,  115,  138,  150,  161,  162,  110,  103,  165,  222,
+ /*   250 */   223,  224,   49,   50,  165,   22,   57,   24,  165,  170,
+ /*   260 */   171,  118,   94,  170,  171,   23,   98,   25,  185,  186,
+ /*   270 */   243,   68,   69,   70,   71,   72,   73,   74,   75,   76,
+ /*   280 */    77,   78,   79,   80,  126,   82,   83,   84,   85,   86,
  /*   290 */    87,   88,   89,   90,   91,   92,   19,  129,  130,  131,
- /*   300 */    28,   23,  100,   25,  105,  106,  107,  150,   26,   27,
- /*   310 */    94,   95,  169,  170,  171,  116,   44,   23,   46,  150,
- /*   320 */   231,  232,  165,   26,   27,   94,   49,   50,   23,   57,
- /*   330 */    25,  174,  175,   22,  165,   26,   27,   26,   27,  136,
- /*   340 */   138,   97,   98,  174,  175,   68,   69,   70,   71,   72,
- /*   350 */    73,   74,   75,   76,   77,   78,   79,   80,   23,   82,
+ /*   300 */    88,   23,  172,  173,  105,  106,  107,  150,   22,   26,
+ /*   310 */    27,  181,   26,   27,   22,  116,   26,   27,   26,  230,
+ /*   320 */   231,  197,  165,  230,  231,  113,   49,   50,  204,  117,
+ /*   330 */    96,  174,  175,   99,  100,  101,   22,   26,   27,  136,
+ /*   340 */    26,   27,  118,   16,  110,   68,   69,   70,   71,   72,
+ /*   350 */    73,   74,   75,   76,   77,   78,   79,   80,  118,   82,
  /*   360 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,
- /*   370 */    19,  150,   23,  216,   23,  232,   94,   95,  221,  150,
- /*   380 */    23,  160,   25,  214,  215,  163,  165,   88,  166,  167,
- /*   390 */   168,   94,   95,   23,  165,  174,  175,   88,  160,  150,
- /*   400 */    49,   50,  120,   94,   95,   94,   95,  158,   26,   57,
- /*   410 */   161,  162,  113,  136,  165,  194,  117,  120,   22,   68,
+ /*   370 */    19,  214,  215,  150,   23,   23,  155,   94,   95,   22,
+ /*   380 */    94,   95,  116,  160,   94,   95,   94,   60,  165,   62,
+ /*   390 */   112,   26,  114,  115,  128,   23,   36,  174,  175,   88,
+ /*   400 */    49,   50,   57,  120,   22,   94,   95,   23,   94,   95,
+ /*   410 */   120,   51,   25,  136,  169,  170,  171,  194,   58,   68,
  /*   420 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
- /*   430 */    79,   80,  194,   82,   83,   84,   85,   86,   87,   88,
- /*   440 */    89,   90,   91,   92,   19,  150,   23,  112,   23,  114,
- /*   450 */   115,   25,  142,  143,  144,  145,  218,  105,  106,  107,
- /*   460 */   165,  112,  150,  114,  115,   22,  150,  166,  116,  174,
- /*   470 */   175,   22,   76,  235,   49,   50,   94,  165,  240,  172,
- /*   480 */   173,  165,  112,  155,  114,  115,  174,  175,  181,   11,
- /*   490 */   174,  175,   22,   68,   69,   70,   71,   72,   73,   74,
- /*   500 */    75,   76,   77,   78,   79,   80,  205,   82,   83,   84,
- /*   510 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  160,
- /*   520 */    23,  226,   23,  222,   12,  224,  225,  150,  216,   23,
- /*   530 */    23,   25,   36,   25,   25,  112,  220,  114,  115,  135,
- /*   540 */    28,  137,  165,   26,   27,  119,   30,   51,   49,   50,
- /*   550 */    34,  174,  175,  194,   58,  166,   44,  229,   46,  160,
- /*   560 */    22,   23,  234,   25,   48,  206,  207,   68,   69,   70,
+ /*   430 */    79,   80,   23,   82,   83,   84,   85,   86,   87,   88,
+ /*   440 */    89,   90,   91,   92,   19,  150,   12,   12,   23,  228,
+ /*   450 */   105,  106,  107,   23,  233,   25,  165,   19,  150,   94,
+ /*   460 */   165,  116,   28,   28,  112,  174,  114,  115,  108,  174,
+ /*   470 */   175,   26,   27,  165,   49,   50,  231,   11,   44,   44,
+ /*   480 */    46,   46,  174,  175,  112,  160,  114,  115,   50,   22,
+ /*   490 */    23,   57,   25,   68,   69,   70,   71,   72,   73,   74,
+ /*   500 */    75,   76,   77,   78,   79,   80,  119,   82,   83,   84,
+ /*   510 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  194,
+ /*   520 */   225,   23,   23,  215,   19,   95,  105,  106,  107,  150,
+ /*   530 */    23,  150,   27,   23,   67,   25,  150,  206,  207,   94,
+ /*   540 */    95,  166,  104,  218,  165,   22,  165,  109,   49,   50,
+ /*   550 */   120,  165,   25,  174,  175,  174,  175,   23,   21,  234,
+ /*   560 */   174,  175,   22,   23,  239,   25,   25,   68,   69,   70,
  /*   570 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,
- /*   580 */    23,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*   590 */    91,   92,   19,  194,  205,  150,   23,  220,   19,  181,
- /*   600 */   182,   95,   97,   95,  108,   67,  188,  169,  170,  171,
- /*   610 */   165,   94,   95,  222,   50,  224,  225,  218,  120,  150,
- /*   620 */   160,  116,   49,   50,   22,   23,  120,   25,  120,   50,
- /*   630 */   161,  162,   19,  128,  165,  244,   22,   23,  193,  240,
- /*   640 */    27,   68,   69,   70,   71,   72,   73,   74,   75,   76,
- /*   650 */    77,   78,   79,   80,  194,   82,   83,   84,   85,   86,
- /*   660 */    87,   88,   89,   90,   91,   92,   19,   25,  104,   67,
- /*   670 */   232,   24,  150,   23,  150,   25,  150,  150,  150,  150,
- /*   680 */   150,   67,   25,  104,    7,    8,    9,  165,  109,  165,
- /*   690 */   245,  165,  165,  165,  165,  165,   49,   50,  174,  175,
- /*   700 */   174,  175,  174,  175,  174,  175,    0,    1,    2,  105,
- /*   710 */   106,  107,  248,  249,  187,   68,   69,   70,   71,   72,
+ /*   580 */   205,   82,   83,   84,   85,   86,   87,   88,   89,   90,
+ /*   590 */    91,   92,   19,   22,   23,  216,   23,  222,  223,  224,
+ /*   600 */    63,  220,   35,  150,  150,  163,  220,   67,  166,  167,
+ /*   610 */   168,  150,  169,  170,  171,  161,  162,   25,  165,  165,
+ /*   620 */   150,  113,   49,   50,   25,  117,  165,  174,  175,   35,
+ /*   630 */     7,    8,    9,  160,  160,  165,  120,  100,   67,  247,
+ /*   640 */   248,   68,   69,   70,   71,   72,   73,   74,   75,   76,
+ /*   650 */    77,   78,   79,   80,  193,   82,   83,   84,   85,   86,
+ /*   660 */    87,   88,   89,   90,   91,   92,   19,  194,  194,  150,
+ /*   670 */   135,   24,  137,   35,  231,  138,  150,  129,  130,  206,
+ /*   680 */   207,   30,   27,  213,  165,   34,  118,   95,    0,    1,
+ /*   690 */     2,  165,  218,  174,  175,   50,   49,   50,   22,   48,
+ /*   700 */   174,  175,   22,   23,   23,  244,  222,  223,  224,  166,
+ /*   710 */   167,  168,  120,  239,   23,   68,   69,   70,   71,   72,
  /*   720 */    73,   74,   75,   76,   77,   78,   79,   80,  150,   82,
  /*   730 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,
- /*   740 */    19,  150,  213,  165,  150,  222,  150,  224,  225,  166,
- /*   750 */   167,  168,  174,  175,  129,  130,  165,  150,  165,  165,
- /*   760 */   150,  165,  150,  241,   35,  174,  175,  174,  174,  175,
- /*   770 */    49,   50,  165,   52,   23,  165,   25,  165,  206,  207,
- /*   780 */    23,  197,   25,  187,  174,  175,  174,  175,  204,   68,
+ /*   740 */    19,  150,  173,  165,  181,  182,   24,   67,   26,  104,
+ /*   750 */   181,  188,  174,  175,  150,   39,  165,  150,   52,  150,
+ /*   760 */   150,  150,  150,  144,  145,  174,  175,  249,  250,  165,
+ /*   770 */    49,   50,  165,   52,  165,  165,  165,  165,  174,  175,
+ /*   780 */    29,  174,  175,  174,  175,  174,  175,  160,   22,   68,
  /*   790 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,
  /*   800 */    79,   80,  150,   82,   83,   84,   85,   86,   87,   88,
- /*   810 */    89,   90,   91,   92,   19,  150,  150,  165,   35,   23,
- /*   820 */   150,   25,  150,   22,  217,   24,  174,  175,  150,   35,
- /*   830 */   165,  165,  144,  145,  150,  165,  150,  165,  118,  174,
- /*   840 */   175,  150,   22,  165,   49,   50,  174,  175,   23,  165,
- /*   850 */    25,  165,   23,  187,   25,   27,  165,  187,  174,  175,
- /*   860 */    23,   23,   25,   68,   69,   70,   71,   72,   73,   74,
+ /*   810 */    89,   90,   91,   92,   19,  150,   94,  165,  150,  150,
+ /*   820 */   160,  194,  150,  213,  160,   52,  174,  175,   23,   23,
+ /*   830 */   165,   25,   22,  165,  165,  150,  150,  165,   52,  174,
+ /*   840 */   175,   22,  174,  175,   49,   50,  174,  175,  190,  191,
+ /*   850 */   165,  165,  240,   23,  194,   25,  187,  109,  194,  174,
+ /*   860 */   175,  190,  191,   68,   69,   70,   71,   72,   73,   74,
  /*   870 */    75,   76,   77,   78,   79,   80,  150,   82,   83,   84,
  /*   880 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  150,
- /*   890 */   150,  165,  150,  150,  150,  217,   25,  160,   19,  213,
- /*   900 */   174,  175,  190,  191,  165,  165,   27,  165,  165,  165,
- /*   910 */   150,  150,  150,  174,  175,   39,  174,  175,   49,   50,
- /*   920 */    23,  150,   52,  250,  251,  165,  165,  165,  190,  191,
- /*   930 */   187,  194,  241,  193,  174,  175,  165,   68,   69,   70,
+ /*   890 */    22,  165,  150,   23,  150,   25,  150,  166,   91,   92,
+ /*   900 */   174,  175,   22,  217,  165,  150,  102,  165,  150,  165,
+ /*   910 */   150,  165,  150,  174,  175,   19,  174,  175,   49,   50,
+ /*   920 */   165,   86,   87,  165,   23,  165,   25,  165,   24,  174,
+ /*   930 */   175,  187,  174,  175,  174,  175,  205,   68,   69,   70,
  /*   940 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,
  /*   950 */   150,   82,   83,   84,   85,   86,   87,   88,   89,   90,
- /*   960 */    91,   92,   19,  150,  150,  165,  150,  160,  160,  166,
- /*   970 */   166,  160,  150,   22,  174,  175,   91,   92,  165,  165,
- /*   980 */    52,  165,   29,  150,  213,  241,   23,  165,   49,   50,
- /*   990 */   174,  175,   49,   50,    1,    2,  173,  126,  165,   86,
- /*  1000 */    87,  194,  194,   22,  181,  194,  193,  193,  205,  205,
+ /*   960 */    91,   92,   19,  150,  150,  165,  150,  150,  166,   23,
+ /*   970 */   150,   25,  160,   20,  174,  175,    1,    2,  165,  165,
+ /*   980 */   104,  165,  165,   43,  150,  165,  240,  150,   49,   50,
+ /*   990 */   174,  175,   49,   50,   23,   23,   25,   25,   53,  165,
+ /*  1000 */   187,  187,  165,   23,  187,   25,  194,  205,  174,  175,
  /*  1010 */    71,   72,   69,   70,   71,   72,   73,   74,   75,   76,
  /*  1020 */    77,   78,   79,   80,  150,   82,   83,   84,   85,   86,
  /*  1030 */    87,   88,   89,   90,   91,   92,   19,   98,  150,  165,
- /*  1040 */   150,  150,  150,   22,  150,  150,   22,   52,  174,  175,
- /*  1050 */    22,  102,   20,  165,  109,  165,  165,  165,  150,  165,
- /*  1060 */   165,  150,  174,  175,  174,  175,   49,   50,   24,   19,
- /*  1070 */    43,  104,   59,  165,  138,  104,  165,   25,   53,   53,
- /*  1080 */    22,    5,  174,  175,  193,  174,  175,   70,   71,   72,
- /*  1090 */    73,   74,   75,   76,   77,   78,   79,   80,    1,   82,
+ /*  1040 */   150,  160,  150,   59,   25,   53,  104,   22,  174,  175,
+ /*  1050 */   213,  138,    5,  165,    1,  165,  150,  165,  150,  150,
+ /*  1060 */   240,  150,  174,  175,  174,  175,   49,   50,  118,  150,
+ /*  1070 */    35,  165,   27,  165,  165,  194,  165,  108,  127,   76,
+ /*  1080 */   174,  175,  174,  175,  165,  174,  175,   70,   71,   72,
+ /*  1090 */    73,   74,   75,   76,   77,   78,   79,   80,  166,   82,
  /*  1100 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,
- /*  1110 */    19,   20,  150,   22,  150,  150,  150,   26,   27,  118,
- /*  1120 */   150,   35,  150,  150,   76,   27,  108,  165,   37,  165,
- /*  1130 */   165,  165,   76,   19,   20,  165,   22,  165,  165,  127,
- /*  1140 */    26,   27,   22,    1,  150,   16,   20,   56,  150,  150,
- /*  1150 */   119,   37,  150,  119,  160,  193,  150,   66,  193,  165,
- /*  1160 */   150,  150,  121,  165,  165,  108,  150,  165,  174,  175,
- /*  1170 */    56,  165,  150,  127,   22,  165,  165,   86,   87,   88,
- /*  1180 */    66,  165,   16,  150,   93,   94,   95,  165,  194,   98,
- /*  1190 */   174,  175,  128,   23,   15,   23,  174,  175,  165,  150,
- /*  1200 */    86,   87,   65,  140,  150,   22,    3,   93,   94,   95,
- /*  1210 */   216,    4,   98,  252,  165,  221,  150,  164,  180,  165,
+ /*  1110 */    19,   20,  193,   22,  150,  150,  150,   26,   27,   76,
+ /*  1120 */   150,   22,    1,  150,  119,  121,  217,   20,   37,  165,
+ /*  1130 */   165,  165,   16,   19,   20,  165,   22,  205,  165,  119,
+ /*  1140 */    26,   27,  108,  128,  150,  150,  150,   56,  150,   22,
+ /*  1150 */   150,   37,  150,  127,  160,   23,  150,   66,  193,  165,
+ /*  1160 */   165,  165,   16,  165,   23,  165,  150,  165,  174,  175,
+ /*  1170 */    56,  165,  150,   65,  174,  175,   15,   86,   87,   88,
+ /*  1180 */    66,  165,  140,  150,   93,   94,   95,  165,  194,   98,
+ /*  1190 */   174,  175,   22,    3,  164,  193,  174,  175,  165,  150,
+ /*  1200 */    86,   87,    4,  180,  150,  248,  251,   93,   94,   95,
+ /*  1210 */   216,  180,   98,  251,  165,  221,  150,  149,    6,  165,
  /*  1220 */   129,  130,  131,  132,  133,  134,  193,  150,  174,  175,
- /*  1230 */   116,  165,   19,   20,  150,   22,  249,  252,  149,   26,
- /*  1240 */    27,  180,  165,  129,  130,  131,  132,  133,  134,  165,
- /*  1250 */    37,  174,  175,  150,    6,   19,   20,  150,   22,  150,
- /*  1260 */   150,  150,   26,   27,  149,  149,   13,  150,  165,   56,
- /*  1270 */   149,  159,  165,   37,  165,  165,  165,  174,  175,   66,
- /*  1280 */   146,  147,  165,  174,  175,   25,  152,  151,  154,  150,
- /*  1290 */   194,  151,   56,  116,  160,  150,  123,  202,  150,   86,
- /*  1300 */    87,  199,   66,  193,  165,  200,   93,   94,   95,  150,
- /*  1310 */   165,   98,  150,  165,  126,   22,  124,  150,  150,   26,
- /*  1320 */    27,  150,   86,   87,  165,  201,  150,  165,  194,   93,
- /*  1330 */    94,   95,  165,  165,   98,  150,  165,  122,  203,  125,
- /*  1340 */   227,  165,  129,  130,  131,  132,  133,  134,    5,  150,
- /*  1350 */   165,  135,  218,   10,   11,   12,   13,   14,  150,   66,
- /*  1360 */    17,  157,  118,  157,  165,  129,  130,  131,  132,  133,
- /*  1370 */   134,  150,  104,  165,   31,  210,   33,  176,  150,   86,
- /*  1380 */    87,  247,  174,  175,  150,   42,  165,   94,  121,  211,
- /*  1390 */   150,   98,  210,  165,  210,  174,  175,  211,   55,  165,
+ /*  1230 */   116,  165,   19,   20,  150,   22,  149,  151,  150,   26,
+ /*  1240 */    27,  149,  165,  129,  130,  131,  132,  133,  134,  165,
+ /*  1250 */    37,  174,  175,  165,  149,   19,   20,   13,   22,  150,
+ /*  1260 */   150,  150,   26,   27,  146,  147,  151,  150,   25,   56,
+ /*  1270 */   152,  159,  154,   37,  165,  165,  165,  193,  160,   66,
+ /*  1280 */   116,  193,  165,  174,  175,  174,  175,  194,  199,  150,
+ /*  1290 */   200,  126,   56,  124,  123,  150,  201,  122,  150,   86,
+ /*  1300 */    87,  150,   66,  193,  165,  202,   93,   94,   95,  150,
+ /*  1310 */   165,   98,  194,  165,  125,   22,  165,  150,  150,   26,
+ /*  1320 */    27,  135,   86,   87,  165,  174,  175,  203,  226,   93,
+ /*  1330 */    94,   95,  165,  165,   98,  150,  218,  150,  193,  157,
+ /*  1340 */   118,  157,  129,  130,  131,  132,  133,  134,    5,  104,
+ /*  1350 */   165,  211,  165,   10,   11,   12,   13,   14,  150,   66,
+ /*  1360 */    17,  174,  175,  210,  246,  129,  130,  131,  132,  133,
+ /*  1370 */   134,  150,  210,  165,   31,  121,   33,  150,  150,   86,
+ /*  1380 */    87,  176,  174,  175,  150,   42,  165,   94,  211,  210,
+ /*  1390 */   150,   98,  165,  165,  211,  174,  175,  150,   55,  165,
  /*  1400 */    57,  150,  174,  175,   61,  165,  150,   64,  174,  175,
- /*  1410 */   104,  211,   47,  150,  174,  175,  165,  176,  176,  150,
- /*  1420 */   103,  165,  129,  130,  131,  174,  175,  184,  165,  179,
- /*  1430 */   174,  175,  150,  178,  165,  176,   22,  174,  175,  230,
- /*  1440 */    92,  230,  184,  174,  175,  150,  176,  165,  105,  106,
- /*  1450 */   107,  150,  176,  176,  111,  156,  174,  175,  179,  116,
- /*  1460 */   165,   18,  157,  156,  238,  157,  165,  156,   45,  174,
- /*  1470 */   175,  157,  157,  135,  239,  174,  175,  156,  189,  157,
- /*  1480 */    68,  189,  139,  219,   22,  199,  157,   18,  192,  192,
- /*  1490 */   192,  189,  192,  199,  219,  243,  157,   40,  157,  157,
- /*  1500 */   243,   38,  153,  166,  233,  196,  233,  246,  198,  228,
- /*  1510 */   177,  177,  209,  177,  182,  199,  166,  177,  166,  199,
- /*  1520 */   242,  177,  242,  178,  148,  166,  196,  209,  209,   92,
- /*  1530 */   195,  208,  174,  186,  183,  174,  183,  191,  183,  253,
- /*  1540 */   236,  253,  186,  253,  253,  253,  253,  253,  253,  237,
+ /*  1410 */   150,  150,  165,  150,  174,  175,  165,  104,  150,  184,
+ /*  1420 */   150,  165,  129,  130,  131,  165,  165,  150,  165,  150,
+ /*  1430 */   150,  176,  150,  165,   47,  165,  150,  150,  176,  103,
+ /*  1440 */   150,   22,  165,  178,  165,  165,  179,  165,  105,  106,
+ /*  1450 */   107,  165,  165,  229,  111,  165,   92,  176,  229,  116,
+ /*  1460 */   184,  176,  179,  156,  176,  176,   18,  157,  156,  237,
+ /*  1470 */    45,  157,  156,  135,  157,  157,  238,  156,   68,  157,
+ /*  1480 */   189,  189,  139,  219,   22,  157,   18,  192,  192,  192,
+ /*  1490 */   192,  189,  219,  199,  157,  242,   40,  157,  199,  242,
+ /*  1500 */   153,  157,   38,  245,  196,  166,  232,  198,  177,  177,
+ /*  1510 */   232,  227,  209,  178,  166,  182,  166,  148,  177,  177,
+ /*  1520 */   209,  196,  177,  199,  209,  199,  166,  208,   92,  195,
+ /*  1530 */   174,  174,  183,  252,  183,  183,  252,  191,  252,  235,
+ /*  1540 */   186,  241,  241,  252,  186,  252,  252,  252,  252,  252,
+ /*  1550 */   252,  252,  252,  252,  252,  252,  236,
 };
-#define YY_SHIFT_USE_DFLT (-90)
+#define YY_SHIFT_USE_DFLT (-74)
 #define YY_SHIFT_COUNT (418)
-#define YY_SHIFT_MIN   (-89)
-#define YY_SHIFT_MAX   (1469)
+#define YY_SHIFT_MIN   (-73)
+#define YY_SHIFT_MAX   (1468)
 static const short yy_shift_ofst[] = {
- /*     0 */   993, 1114, 1343, 1114, 1213, 1213,   90,   90,    0,  -19,
- /*    10 */  1213, 1213, 1213, 1213, 1213,  352,  517,  721, 1091, 1213,
+ /*     0 */   975, 1114, 1343, 1114, 1213, 1213,   90,   90,    0,  -19,
+ /*    10 */  1213, 1213, 1213, 1213, 1213,  345,  445,  721, 1091, 1213,
  /*    20 */  1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
  /*    30 */  1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
  /*    40 */  1213, 1213, 1213, 1213, 1213, 1213, 1213, 1236, 1213, 1213,
  /*    50 */  1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
- /*    60 */  1213,  -49,  199,  517,  517,  913,  913,  382, 1177,   55,
- /*    70 */   647,  573,  499,  425,  351,  277,  203,  129,  795,  795,
+ /*    60 */  1213,  199,  445,  445,  835,  835,  365, 1164,   55,  647,
+ /*    70 */   573,  499,  425,  351,  277,  203,  129,  795,  795,  795,
  /*    80 */   795,  795,  795,  795,  795,  795,  795,  795,  795,  795,
- /*    90 */   795,  795,  795,  795,  795,  795,  869,  795,  943, 1017,
- /*   100 */  1017,  -69,  -69,  -69,  -69,   -1,   -1,   58,  138,  -44,
- /*   110 */   517,  517,  517,  517,  517,  517,  517,  517,  517,  517,
- /*   120 */   517,  517,  517,  517,  517,  517,  202,  579,  517,  517,
- /*   130 */   517,  517,  517,  382,  885, 1437,  -90,  -90,  -90, 1293,
- /*   140 */    73,  272,  272,  309,  311,  297,  282,  216,  602,  538,
- /*   150 */   517,  517,  517,  517,  517,  517,  517,  517,  517,  517,
- /*   160 */   517,  517,  517,  517,  517,  517,  517,  517,  517,  517,
- /*   170 */   517,  517,  517,  517,  517,  517,  517,  517,  517,  517,
- /*   180 */   517,  517,  505,  231,  231,  231,  706,   64, 1177, 1177,
- /*   190 */  1177,  -90,  -90,  -90,  136,  168,  168,   12,  496,  496,
- /*   200 */   496,  506,  423,  512,  370,  349,  335,  149,  149,  149,
- /*   210 */   149,  604,  516,  149,  149,  508,    3,  299,  677,  871,
- /*   220 */   613,  613,  879,  871,  879,  144,  382,  226,  382,  226,
- /*   230 */   564,  226,  613,  226,  226,  404,  625,  625,  382,  426,
- /*   240 */   -89,  801, 1463, 1244, 1244, 1457, 1457, 1244, 1462, 1412,
- /*   250 */  1188, 1469, 1469, 1469, 1469, 1244, 1188, 1462, 1412, 1412,
- /*   260 */  1244, 1443, 1338, 1423, 1244, 1244, 1443, 1244, 1443, 1244,
- /*   270 */  1443, 1414, 1306, 1306, 1306, 1365, 1348, 1348, 1414, 1306,
- /*   280 */  1317, 1306, 1365, 1306, 1306, 1267, 1268, 1267, 1268, 1267,
- /*   290 */  1268, 1244, 1244, 1216, 1214, 1215, 1192, 1173, 1188, 1177,
- /*   300 */  1260, 1253, 1253, 1248, 1248, 1248, 1248,  -90,  -90,  -90,
- /*   310 */   -90,  -90,  -90,  939,  102,  614,   84,  133,   14,  837,
- /*   320 */   396,  829,  825,  796,  757,  751,  650,  357,  244,  107,
- /*   330 */    54,  305,  278, 1207, 1203, 1183, 1063, 1179, 1137, 1166,
- /*   340 */  1172, 1170, 1064, 1152, 1046, 1057, 1034, 1126, 1041, 1129,
- /*   350 */  1142, 1031, 1120, 1012, 1056, 1048, 1018, 1098, 1086, 1001,
- /*   360 */  1097, 1076, 1058,  971,  936, 1026, 1052, 1025, 1013, 1027,
- /*   370 */   967, 1044, 1032, 1050,  945,  949, 1028,  995, 1024, 1021,
- /*   380 */   963,  981,  928,  953,  951,  870,  876,  897,  838,  720,
- /*   390 */   828,  794,  820,  498,  642,  783,  657,  729,  642,  557,
- /*   400 */   507,  509,  497,  470,  478,  449,  294,  228,  443,   23,
- /*   410 */   152,  123,   68,  -20,  -42,   57,   39,   -3,    5,
+ /*    90 */   795,  795,  795,  795,  795,  869,  795,  943, 1017, 1017,
+ /*   100 */   -69,  -45,  -45,  -45,  -45,  -45,   -1,   58,  138,  100,
+ /*   110 */   445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
+ /*   120 */   445,  445,  445,  445,  445,  445,  537,  438,  445,  445,
+ /*   130 */   445,  445,  445,  365,  807, 1436,  -74,  -74,  -74, 1293,
+ /*   140 */    73,  434,  434,  311,  314,  290,  283,  286,  540,  467,
+ /*   150 */   445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
+ /*   160 */   445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
+ /*   170 */   445,  445,  445,  445,  445,  445,  445,  445,  445,  445,
+ /*   180 */   445,  445,   65,  722,  722,  722,  688,  266, 1164, 1164,
+ /*   190 */  1164,  -74,  -74,  -74,  136,  168,  168,  234,  360,  360,
+ /*   200 */   360,  430,  372,  435,  352,  278,  126,  -36,  -36,  -36,
+ /*   210 */   -36,  421,  651,  -36,  -36,  592,  292,  212,  623,  158,
+ /*   220 */   204,  204,  505,  158,  505,  144,  365,  154,  365,  154,
+ /*   230 */   645,  154,  204,  154,  154,  535,  548,  548,  365,  387,
+ /*   240 */   508,  233, 1464, 1222, 1222, 1456, 1456, 1222, 1462, 1410,
+ /*   250 */  1165, 1468, 1468, 1468, 1468, 1222, 1165, 1462, 1410, 1410,
+ /*   260 */  1222, 1448, 1338, 1425, 1222, 1222, 1448, 1222, 1448, 1222,
+ /*   270 */  1448, 1419, 1313, 1313, 1313, 1387, 1364, 1364, 1419, 1313,
+ /*   280 */  1336, 1313, 1387, 1313, 1313, 1254, 1245, 1254, 1245, 1254,
+ /*   290 */  1245, 1222, 1222, 1186, 1189, 1175, 1169, 1171, 1165, 1164,
+ /*   300 */  1243, 1244, 1244, 1212, 1212, 1212, 1212,  -74,  -74,  -74,
+ /*   310 */   -74,  -74,  -74,  939,  104,  680,  571,  327,    1,  980,
+ /*   320 */    26,  972,  971,  946,  901,  870,  830,  806,   54,   21,
+ /*   330 */   -73,  510,  242, 1198, 1190, 1170, 1042, 1161, 1108, 1146,
+ /*   340 */  1141, 1132, 1015, 1127, 1026, 1034, 1020, 1107, 1004, 1116,
+ /*   350 */  1121, 1005, 1099,  951, 1043, 1003,  969, 1045, 1035,  950,
+ /*   360 */  1053, 1047, 1025,  942,  913,  992, 1019,  945,  984,  940,
+ /*   370 */   876,  904,  953,  896,  748,  804,  880,  786,  868,  819,
+ /*   380 */   805,  810,  773,  751,  766,  706,  716,  691,  681,  568,
+ /*   390 */   655,  638,  676,  516,  541,  594,  599,  567,  541,  534,
+ /*   400 */   507,  527,  498,  523,  466,  382,  409,  384,  357,    6,
+ /*   410 */   240,  224,  143,   62,   18,   71,   39,    9,    5,
 };
-#define YY_REDUCE_USE_DFLT (-222)
+#define YY_REDUCE_USE_DFLT (-142)
 #define YY_REDUCE_COUNT (312)
-#define YY_REDUCE_MIN   (-221)
-#define YY_REDUCE_MAX   (1376)
+#define YY_REDUCE_MIN   (-141)
+#define YY_REDUCE_MAX   (1369)
 static const short yy_reduce_ofst[] = {
- /*     0 */   310,  994, 1134,  221,  169,  157,   89,   18,   83,  301,
- /*    10 */   377,  316,  312,   16,  295,  238,  249,  391, 1301, 1295,
- /*    20 */  1282, 1269, 1263, 1256, 1251, 1240, 1234, 1228, 1221, 1208,
- /*    30 */  1109, 1103, 1077, 1054, 1022, 1016,  911,  908,  890,  888,
- /*    40 */   874,  816,  800,  760,  742,  739,  726,  684,  672,  665,
- /*    50 */   652,  612,  610,  594,  591,  578,  530,  528,  526,  524,
- /*    60 */   -72, -221,  399,  469,  445,  438,  143,  222,  359,  523,
- /*    70 */   523,  523,  523,  523,  523,  523,  523,  523,  523,  523,
- /*    80 */   523,  523,  523,  523,  523,  523,  523,  523,  523,  523,
- /*    90 */   523,  523,  523,  523,  523,  523,  523,  523,  523,  523,
- /*   100 */   523,  523,  523,  523,  523,  523,  523,  307,  523,  523,
- /*   110 */  1110,  678, 1033,  965,  962,  891,  814,  813,  744,  771,
- /*   120 */   691,  607,  522,  743,  686,  740,  328,  418,  670,  666,
- /*   130 */   596,  527,  529,  583,  523,  523,  523,  523,  523,  593,
- /*   140 */   823,  738,  712,  892, 1199, 1185, 1176, 1171,  673,  673,
- /*   150 */  1168, 1167, 1162, 1159, 1148, 1145, 1139, 1117, 1111, 1107,
- /*   160 */  1084, 1066, 1049, 1011, 1010, 1006, 1002,  999,  998,  973,
- /*   170 */   972,  970,  966,  964,  895,  894,  892,  833,  822,  762,
- /*   180 */   761,  229,  811,  804,  803,  389,  688,  808,  807,  737,
- /*   190 */   460,  464,  572,  584, 1356, 1361, 1358, 1347, 1355, 1353,
- /*   200 */  1351, 1323, 1335, 1346, 1335, 1335, 1335, 1335, 1335, 1335,
- /*   210 */  1335, 1312, 1304, 1335, 1335, 1323, 1359, 1330, 1376, 1320,
- /*   220 */  1319, 1318, 1280, 1316, 1278, 1345, 1352, 1344, 1350, 1340,
- /*   230 */  1332, 1336, 1303, 1334, 1333, 1281, 1273, 1271, 1337, 1310,
- /*   240 */  1309, 1349, 1261, 1342, 1341, 1257, 1252, 1339, 1275, 1302,
- /*   250 */  1294, 1300, 1298, 1297, 1296, 1329, 1286, 1264, 1292, 1289,
- /*   260 */  1322, 1321, 1235, 1226, 1315, 1314, 1311, 1308, 1307, 1305,
- /*   270 */  1299, 1279, 1277, 1276, 1270, 1258, 1211, 1209, 1250, 1259,
- /*   280 */  1255, 1242, 1243, 1241, 1201, 1200, 1184, 1186, 1182, 1178,
- /*   290 */  1165, 1206, 1204, 1113, 1135, 1095, 1124, 1105, 1102, 1096,
- /*   300 */  1112, 1140, 1136, 1121, 1116, 1115, 1089,  985,  961,  987,
- /*   310 */  1061, 1038, 1053,
+ /*     0 */  -141,  994, 1118,  223,  157,  -53,   93,   89,   83,  375,
+ /*    10 */   386,  381,  379,  308,  295,  325,  -47,   27, 1240, 1234,
+ /*    20 */  1228, 1221, 1208, 1187, 1151, 1111, 1109, 1077, 1054, 1022,
+ /*    30 */  1016, 1000,  911,  908,  906,  890,  888,  874,  834,  816,
+ /*    40 */   800,  760,  758,  755,  742,  739,  726,  685,  672,  668,
+ /*    50 */   665,  652,  611,  609,  607,  604,  591,  578,  526,  519,
+ /*    60 */   453,  474,  454,  461,  443,  245,  442,  473,  484,  484,
+ /*    70 */   484,  484,  484,  484,  484,  484,  484,  484,  484,  484,
+ /*    80 */   484,  484,  484,  484,  484,  484,  484,  484,  484,  484,
+ /*    90 */   484,  484,  484,  484,  484,  484,  484,  484,  484,  484,
+ /*   100 */   484,  484,  484,  484,  484,  484,  484,  130,  484,  484,
+ /*   110 */  1145,  909, 1110, 1088, 1084, 1033, 1002,  965,  820,  837,
+ /*   120 */   746,  686,  612,  817,  610,  919,  221,  563,  814,  813,
+ /*   130 */   744,  669,  470,  543,  484,  484,  484,  484,  484,  291,
+ /*   140 */   569,  671,  658,  970, 1290, 1287, 1286, 1282,  518,  518,
+ /*   150 */  1280, 1279, 1277, 1270, 1268, 1263, 1261, 1260, 1256, 1251,
+ /*   160 */  1247, 1227, 1185, 1168, 1167, 1159, 1148, 1139, 1117, 1066,
+ /*   170 */  1049, 1006,  998,  996,  995,  973,  970,  966,  964,  892,
+ /*   180 */   762,  -52,  881,  932,  802,  731,  619,  812,  664,  660,
+ /*   190 */   627,  392,  331,  124, 1358, 1357, 1356, 1354, 1352, 1351,
+ /*   200 */  1349, 1319, 1334, 1346, 1334, 1334, 1334, 1334, 1334, 1334,
+ /*   210 */  1334, 1320, 1304, 1334, 1334, 1319, 1360, 1325, 1369, 1326,
+ /*   220 */  1315, 1311, 1301, 1324, 1300, 1335, 1350, 1345, 1348, 1342,
+ /*   230 */  1333, 1341, 1303, 1332, 1331, 1284, 1278, 1274, 1339, 1309,
+ /*   240 */  1308, 1347, 1258, 1344, 1340, 1257, 1253, 1337, 1273, 1302,
+ /*   250 */  1299, 1298, 1297, 1296, 1295, 1328, 1294, 1264, 1292, 1291,
+ /*   260 */  1322, 1321, 1238, 1232, 1318, 1317, 1316, 1314, 1312, 1310,
+ /*   270 */  1307, 1283, 1289, 1288, 1285, 1276, 1229, 1224, 1267, 1281,
+ /*   280 */  1265, 1262, 1235, 1255, 1205, 1183, 1179, 1177, 1162, 1140,
+ /*   290 */  1153, 1184, 1182, 1102, 1124, 1103, 1095, 1090, 1089, 1093,
+ /*   300 */  1112, 1115, 1086, 1105, 1092, 1087, 1068,  962,  955,  957,
+ /*   310 */  1031, 1023, 1030,
 };
 static const YYACTIONTYPE yy_default[] = {
- /*     0 */   636,  872,  961,  961,  961,  872,  901,  901,  961,  760,
- /*    10 */   961,  961,  961,  961,  870,  961,  961,  935,  961,  961,
- /*    20 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*    30 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*    40 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*    50 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*    60 */   961,  844,  961,  961,  961,  901,  901,  675,  764,  795,
- /*    70 */   961,  961,  961,  961,  961,  961,  961,  961,  934,  936,
- /*    80 */   810,  809,  803,  802,  914,  775,  800,  793,  786,  797,
- /*    90 */   873,  866,  867,  865,  869,  874,  961,  796,  832,  850,
- /*   100 */   831,  849,  856,  848,  834,  843,  833,  667,  835,  836,
- /*   110 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   120 */   961,  961,  961,  961,  961,  961,  662,  729,  961,  961,
- /*   130 */   961,  961,  961,  961,  837,  838,  853,  852,  851,  961,
- /*   140 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   150 */   961,  941,  939,  961,  885,  961,  961,  961,  961,  961,
- /*   160 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   170 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   180 */   961,  642,  961,  760,  760,  760,  636,  961,  961,  961,
- /*   190 */   961,  953,  764,  754,  720,  961,  961,  961,  961,  961,
- /*   200 */   961,  961,  961,  961,  961,  961,  961,  805,  743,  924,
- /*   210 */   926,  961,  907,  741,  664,  762,  677,  752,  644,  799,
- /*   220 */   777,  777,  919,  799,  919,  701,  961,  789,  961,  789,
- /*   230 */   698,  789,  777,  789,  789,  868,  961,  961,  961,  761,
- /*   240 */   752,  961,  946,  768,  768,  938,  938,  768,  811,  733,
- /*   250 */   799,  740,  740,  740,  740,  768,  799,  811,  733,  733,
- /*   260 */   768,  659,  913,  911,  768,  768,  659,  768,  659,  768,
- /*   270 */   659,  878,  731,  731,  731,  716,  882,  882,  878,  731,
- /*   280 */   701,  731,  716,  731,  731,  781,  776,  781,  776,  781,
- /*   290 */   776,  768,  768,  961,  794,  782,  792,  790,  799,  961,
- /*   300 */   719,  652,  652,  641,  641,  641,  641,  958,  958,  953,
- /*   310 */   703,  703,  685,  961,  961,  961,  961,  961,  961,  961,
- /*   320 */   887,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   330 */   961,  961,  961,  961,  637,  948,  961,  961,  945,  961,
- /*   340 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   350 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  917,
- /*   360 */   961,  961,  961,  961,  961,  961,  910,  909,  961,  961,
- /*   370 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   380 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  961,
- /*   390 */   961,  961,  961,  961,  791,  961,  783,  961,  871,  961,
- /*   400 */   961,  961,  961,  961,  961,  961,  961,  961,  961,  746,
- /*   410 */   820,  961,  819,  823,  818,  669,  961,  650,  961,  633,
- /*   420 */   638,  957,  960,  959,  956,  955,  954,  949,  947,  944,
- /*   430 */   943,  942,  940,  937,  933,  891,  889,  896,  895,  894,
- /*   440 */   893,  892,  890,  888,  886,  806,  804,  801,  798,  932,
- /*   450 */   884,  742,  739,  738,  658,  950,  916,  925,  923,  812,
- /*   460 */   922,  921,  920,  918,  915,  902,  808,  807,  734,  876,
- /*   470 */   875,  661,  906,  905,  904,  908,  912,  903,  770,  660,
- /*   480 */   657,  666,  723,  722,  730,  728,  727,  726,  725,  724,
- /*   490 */   721,  668,  676,  687,  715,  700,  699,  881,  883,  880,
- /*   500 */   879,  708,  707,  713,  712,  711,  710,  709,  706,  705,
- /*   510 */   704,  697,  696,  702,  695,  718,  717,  714,  694,  737,
- /*   520 */   736,  735,  732,  693,  692,  691,  823,  690,  689,  829,
- /*   530 */   828,  816,  860,  757,  756,  755,  767,  766,  779,  778,
- /*   540 */   814,  813,  780,  765,  759,  758,  774,  773,  772,  771,
- /*   550 */   763,  753,  785,  788,  787,  784,  845,  862,  769,  859,
- /*   560 */   931,  930,  929,  928,  927,  864,  863,  830,  827,  680,
- /*   570 */   681,  900,  898,  899,  897,  683,  682,  679,  678,  861,
- /*   580 */   748,  747,  857,  854,  846,  841,  858,  855,  847,  842,
- /*   590 */   840,  839,  825,  824,  822,  821,  817,  826,  671,  749,
- /*   600 */   745,  744,  815,  751,  750,  688,  686,  684,  665,  663,
- /*   610 */   656,  654,  653,  655,  651,  649,  648,  647,  646,  645,
- /*   620 */   674,  673,  672,  670,  669,  643,  640,  639,  635,  634,
- /*   630 */   632,
+ /*     0 */   635,  870,  959,  959,  959,  870,  899,  899,  959,  759,
+ /*    10 */   959,  959,  959,  959,  868,  959,  959,  933,  959,  959,
+ /*    20 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*    30 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*    40 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*    50 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*    60 */   959,  959,  959,  959,  899,  899,  674,  763,  794,  959,
+ /*    70 */   959,  959,  959,  959,  959,  959,  959,  932,  934,  809,
+ /*    80 */   808,  802,  801,  912,  774,  799,  792,  785,  796,  871,
+ /*    90 */   864,  865,  863,  867,  872,  959,  795,  831,  848,  830,
+ /*   100 */   842,  847,  854,  846,  843,  833,  832,  666,  834,  835,
+ /*   110 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   120 */   959,  959,  959,  959,  959,  959,  661,  728,  959,  959,
+ /*   130 */   959,  959,  959,  959,  836,  837,  851,  850,  849,  959,
+ /*   140 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   150 */   959,  939,  937,  959,  883,  959,  959,  959,  959,  959,
+ /*   160 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   170 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   180 */   959,  641,  959,  759,  759,  759,  635,  959,  959,  959,
+ /*   190 */   959,  951,  763,  753,  719,  959,  959,  959,  959,  959,
+ /*   200 */   959,  959,  959,  959,  959,  959,  959,  804,  742,  922,
+ /*   210 */   924,  959,  905,  740,  663,  761,  676,  751,  643,  798,
+ /*   220 */   776,  776,  917,  798,  917,  700,  959,  788,  959,  788,
+ /*   230 */   697,  788,  776,  788,  788,  866,  959,  959,  959,  760,
+ /*   240 */   751,  959,  944,  767,  767,  936,  936,  767,  810,  732,
+ /*   250 */   798,  739,  739,  739,  739,  767,  798,  810,  732,  732,
+ /*   260 */   767,  658,  911,  909,  767,  767,  658,  767,  658,  767,
+ /*   270 */   658,  876,  730,  730,  730,  715,  880,  880,  876,  730,
+ /*   280 */   700,  730,  715,  730,  730,  780,  775,  780,  775,  780,
+ /*   290 */   775,  767,  767,  959,  793,  781,  791,  789,  798,  959,
+ /*   300 */   718,  651,  651,  640,  640,  640,  640,  956,  956,  951,
+ /*   310 */   702,  702,  684,  959,  959,  959,  959,  959,  959,  959,
+ /*   320 */   885,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   330 */   959,  959,  959,  959,  636,  946,  959,  959,  943,  959,
+ /*   340 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   350 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  915,
+ /*   360 */   959,  959,  959,  959,  959,  959,  908,  907,  959,  959,
+ /*   370 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   380 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  959,
+ /*   390 */   959,  959,  959,  959,  790,  959,  782,  959,  869,  959,
+ /*   400 */   959,  959,  959,  959,  959,  959,  959,  959,  959,  745,
+ /*   410 */   819,  959,  818,  822,  817,  668,  959,  649,  959,  632,
+ /*   420 */   637,  955,  958,  957,  954,  953,  952,  947,  945,  942,
+ /*   430 */   941,  940,  938,  935,  931,  889,  887,  894,  893,  892,
+ /*   440 */   891,  890,  888,  886,  884,  805,  803,  800,  797,  930,
+ /*   450 */   882,  741,  738,  737,  657,  948,  914,  923,  921,  811,
+ /*   460 */   920,  919,  918,  916,  913,  900,  807,  806,  733,  874,
+ /*   470 */   873,  660,  904,  903,  902,  906,  910,  901,  769,  659,
+ /*   480 */   656,  665,  722,  721,  729,  727,  726,  725,  724,  723,
+ /*   490 */   720,  667,  675,  686,  714,  699,  698,  879,  881,  878,
+ /*   500 */   877,  707,  706,  712,  711,  710,  709,  708,  705,  704,
+ /*   510 */   703,  696,  695,  701,  694,  717,  716,  713,  693,  736,
+ /*   520 */   735,  734,  731,  692,  691,  690,  822,  689,  688,  828,
+ /*   530 */   827,  815,  858,  756,  755,  754,  766,  765,  778,  777,
+ /*   540 */   813,  812,  779,  764,  758,  757,  773,  772,  771,  770,
+ /*   550 */   762,  752,  784,  787,  786,  783,  860,  768,  857,  929,
+ /*   560 */   928,  927,  926,  925,  862,  861,  829,  826,  679,  680,
+ /*   570 */   898,  896,  897,  895,  682,  681,  678,  677,  859,  747,
+ /*   580 */   746,  855,  852,  844,  840,  856,  853,  845,  841,  839,
+ /*   590 */   838,  824,  823,  821,  820,  816,  825,  670,  748,  744,
+ /*   600 */   743,  814,  750,  749,  687,  685,  683,  664,  662,  655,
+ /*   610 */   653,  652,  654,  650,  648,  647,  646,  645,  644,  673,
+ /*   620 */   672,  671,  669,  668,  642,  639,  638,  634,  633,  631,
 };
 
 /* The next table maps tokens into fallback tokens.  If a construct
@@ -92837,15 +100276,14 @@ static const char *const yyTokenName[] = {
   "joinop",        "indexed_opt",   "on_opt",        "using_opt",   
   "joinop2",       "inscollist",    "sortlist",      "sortitem",    
   "nexprlist",     "setlist",       "insert_cmd",    "inscollist_opt",
-  "itemlist",      "exprlist",      "likeop",        "escape",      
-  "between_op",    "in_op",         "case_operand",  "case_exprlist",
-  "case_else",     "uniqueflag",    "collate",       "nmnum",       
-  "plus_opt",      "number",        "trigger_decl",  "trigger_cmd_list",
-  "trigger_time",  "trigger_event",  "foreach_clause",  "when_clause", 
-  "trigger_cmd",   "trnm",          "tridxby",       "database_kw_opt",
-  "key_opt",       "add_column_fullname",  "kwcolumn_opt",  "create_vtab", 
-  "vtabarglist",   "vtabarg",       "vtabargtoken",  "lp",          
-  "anylist",     
+  "itemlist",      "exprlist",      "likeop",        "between_op",  
+  "in_op",         "case_operand",  "case_exprlist",  "case_else",   
+  "uniqueflag",    "collate",       "nmnum",         "plus_opt",    
+  "number",        "trigger_decl",  "trigger_cmd_list",  "trigger_time",
+  "trigger_event",  "foreach_clause",  "when_clause",   "trigger_cmd", 
+  "trnm",          "tridxby",       "database_kw_opt",  "key_opt",     
+  "add_column_fullname",  "kwcolumn_opt",  "create_vtab",   "vtabarglist", 
+  "vtabarg",       "vtabargtoken",  "lp",            "anylist",     
 };
 #endif /* NDEBUG */
 
@@ -93065,124 +100503,123 @@ static const char *const yyRuleName[] = {
  /* 209 */ "likeop ::= NOT LIKE_KW",
  /* 210 */ "likeop ::= MATCH",
  /* 211 */ "likeop ::= NOT MATCH",
- /* 212 */ "escape ::= ESCAPE expr",
- /* 213 */ "escape ::=",
- /* 214 */ "expr ::= expr likeop expr escape",
- /* 215 */ "expr ::= expr ISNULL|NOTNULL",
- /* 216 */ "expr ::= expr NOT NULL",
- /* 217 */ "expr ::= expr IS expr",
- /* 218 */ "expr ::= expr IS NOT expr",
- /* 219 */ "expr ::= NOT expr",
- /* 220 */ "expr ::= BITNOT expr",
- /* 221 */ "expr ::= MINUS expr",
- /* 222 */ "expr ::= PLUS expr",
- /* 223 */ "between_op ::= BETWEEN",
- /* 224 */ "between_op ::= NOT BETWEEN",
- /* 225 */ "expr ::= expr between_op expr AND expr",
- /* 226 */ "in_op ::= IN",
- /* 227 */ "in_op ::= NOT IN",
- /* 228 */ "expr ::= expr in_op LP exprlist RP",
- /* 229 */ "expr ::= LP select RP",
- /* 230 */ "expr ::= expr in_op LP select RP",
- /* 231 */ "expr ::= expr in_op nm dbnm",
- /* 232 */ "expr ::= EXISTS LP select RP",
- /* 233 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 234 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 235 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 236 */ "case_else ::= ELSE expr",
- /* 237 */ "case_else ::=",
- /* 238 */ "case_operand ::= expr",
- /* 239 */ "case_operand ::=",
- /* 240 */ "exprlist ::= nexprlist",
- /* 241 */ "exprlist ::=",
- /* 242 */ "nexprlist ::= nexprlist COMMA expr",
- /* 243 */ "nexprlist ::= expr",
- /* 244 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
- /* 245 */ "uniqueflag ::= UNIQUE",
- /* 246 */ "uniqueflag ::=",
- /* 247 */ "idxlist_opt ::=",
- /* 248 */ "idxlist_opt ::= LP idxlist RP",
- /* 249 */ "idxlist ::= idxlist COMMA nm collate sortorder",
- /* 250 */ "idxlist ::= nm collate sortorder",
- /* 251 */ "collate ::=",
- /* 252 */ "collate ::= COLLATE ids",
- /* 253 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 254 */ "cmd ::= VACUUM",
- /* 255 */ "cmd ::= VACUUM nm",
- /* 256 */ "cmd ::= PRAGMA nm dbnm",
- /* 257 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 258 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 259 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 260 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 261 */ "nmnum ::= plus_num",
- /* 262 */ "nmnum ::= nm",
- /* 263 */ "nmnum ::= ON",
- /* 264 */ "nmnum ::= DELETE",
- /* 265 */ "nmnum ::= DEFAULT",
- /* 266 */ "plus_num ::= plus_opt number",
- /* 267 */ "minus_num ::= MINUS number",
- /* 268 */ "number ::= INTEGER|FLOAT",
- /* 269 */ "plus_opt ::= PLUS",
- /* 270 */ "plus_opt ::=",
- /* 271 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 272 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 273 */ "trigger_time ::= BEFORE",
- /* 274 */ "trigger_time ::= AFTER",
- /* 275 */ "trigger_time ::= INSTEAD OF",
- /* 276 */ "trigger_time ::=",
- /* 277 */ "trigger_event ::= DELETE|INSERT",
- /* 278 */ "trigger_event ::= UPDATE",
- /* 279 */ "trigger_event ::= UPDATE OF inscollist",
- /* 280 */ "foreach_clause ::=",
- /* 281 */ "foreach_clause ::= FOR EACH ROW",
- /* 282 */ "when_clause ::=",
- /* 283 */ "when_clause ::= WHEN expr",
- /* 284 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 285 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 286 */ "trnm ::= nm",
- /* 287 */ "trnm ::= nm DOT nm",
- /* 288 */ "tridxby ::=",
- /* 289 */ "tridxby ::= INDEXED BY nm",
- /* 290 */ "tridxby ::= NOT INDEXED",
- /* 291 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
- /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
- /* 293 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
- /* 294 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
- /* 295 */ "trigger_cmd ::= select",
- /* 296 */ "expr ::= RAISE LP IGNORE RP",
- /* 297 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 298 */ "raisetype ::= ROLLBACK",
- /* 299 */ "raisetype ::= ABORT",
- /* 300 */ "raisetype ::= FAIL",
- /* 301 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 302 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 303 */ "cmd ::= DETACH database_kw_opt expr",
- /* 304 */ "key_opt ::=",
- /* 305 */ "key_opt ::= KEY expr",
- /* 306 */ "database_kw_opt ::= DATABASE",
- /* 307 */ "database_kw_opt ::=",
- /* 308 */ "cmd ::= REINDEX",
- /* 309 */ "cmd ::= REINDEX nm dbnm",
- /* 310 */ "cmd ::= ANALYZE",
- /* 311 */ "cmd ::= ANALYZE nm dbnm",
- /* 312 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 313 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
- /* 314 */ "add_column_fullname ::= fullname",
- /* 315 */ "kwcolumn_opt ::=",
- /* 316 */ "kwcolumn_opt ::= COLUMNKW",
- /* 317 */ "cmd ::= create_vtab",
- /* 318 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 319 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
- /* 320 */ "vtabarglist ::= vtabarg",
- /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 322 */ "vtabarg ::=",
- /* 323 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 324 */ "vtabargtoken ::= ANY",
- /* 325 */ "vtabargtoken ::= lp anylist RP",
- /* 326 */ "lp ::= LP",
- /* 327 */ "anylist ::=",
- /* 328 */ "anylist ::= anylist LP anylist RP",
- /* 329 */ "anylist ::= anylist ANY",
+ /* 212 */ "expr ::= expr likeop expr",
+ /* 213 */ "expr ::= expr likeop expr ESCAPE expr",
+ /* 214 */ "expr ::= expr ISNULL|NOTNULL",
+ /* 215 */ "expr ::= expr NOT NULL",
+ /* 216 */ "expr ::= expr IS expr",
+ /* 217 */ "expr ::= expr IS NOT expr",
+ /* 218 */ "expr ::= NOT expr",
+ /* 219 */ "expr ::= BITNOT expr",
+ /* 220 */ "expr ::= MINUS expr",
+ /* 221 */ "expr ::= PLUS expr",
+ /* 222 */ "between_op ::= BETWEEN",
+ /* 223 */ "between_op ::= NOT BETWEEN",
+ /* 224 */ "expr ::= expr between_op expr AND expr",
+ /* 225 */ "in_op ::= IN",
+ /* 226 */ "in_op ::= NOT IN",
+ /* 227 */ "expr ::= expr in_op LP exprlist RP",
+ /* 228 */ "expr ::= LP select RP",
+ /* 229 */ "expr ::= expr in_op LP select RP",
+ /* 230 */ "expr ::= expr in_op nm dbnm",
+ /* 231 */ "expr ::= EXISTS LP select RP",
+ /* 232 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 233 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 234 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 235 */ "case_else ::= ELSE expr",
+ /* 236 */ "case_else ::=",
+ /* 237 */ "case_operand ::= expr",
+ /* 238 */ "case_operand ::=",
+ /* 239 */ "exprlist ::= nexprlist",
+ /* 240 */ "exprlist ::=",
+ /* 241 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 242 */ "nexprlist ::= expr",
+ /* 243 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
+ /* 244 */ "uniqueflag ::= UNIQUE",
+ /* 245 */ "uniqueflag ::=",
+ /* 246 */ "idxlist_opt ::=",
+ /* 247 */ "idxlist_opt ::= LP idxlist RP",
+ /* 248 */ "idxlist ::= idxlist COMMA nm collate sortorder",
+ /* 249 */ "idxlist ::= nm collate sortorder",
+ /* 250 */ "collate ::=",
+ /* 251 */ "collate ::= COLLATE ids",
+ /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 253 */ "cmd ::= VACUUM",
+ /* 254 */ "cmd ::= VACUUM nm",
+ /* 255 */ "cmd ::= PRAGMA nm dbnm",
+ /* 256 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 257 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 259 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 260 */ "nmnum ::= plus_num",
+ /* 261 */ "nmnum ::= nm",
+ /* 262 */ "nmnum ::= ON",
+ /* 263 */ "nmnum ::= DELETE",
+ /* 264 */ "nmnum ::= DEFAULT",
+ /* 265 */ "plus_num ::= plus_opt number",
+ /* 266 */ "minus_num ::= MINUS number",
+ /* 267 */ "number ::= INTEGER|FLOAT",
+ /* 268 */ "plus_opt ::= PLUS",
+ /* 269 */ "plus_opt ::=",
+ /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 272 */ "trigger_time ::= BEFORE",
+ /* 273 */ "trigger_time ::= AFTER",
+ /* 274 */ "trigger_time ::= INSTEAD OF",
+ /* 275 */ "trigger_time ::=",
+ /* 276 */ "trigger_event ::= DELETE|INSERT",
+ /* 277 */ "trigger_event ::= UPDATE",
+ /* 278 */ "trigger_event ::= UPDATE OF inscollist",
+ /* 279 */ "foreach_clause ::=",
+ /* 280 */ "foreach_clause ::= FOR EACH ROW",
+ /* 281 */ "when_clause ::=",
+ /* 282 */ "when_clause ::= WHEN expr",
+ /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 285 */ "trnm ::= nm",
+ /* 286 */ "trnm ::= nm DOT nm",
+ /* 287 */ "tridxby ::=",
+ /* 288 */ "tridxby ::= INDEXED BY nm",
+ /* 289 */ "tridxby ::= NOT INDEXED",
+ /* 290 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
+ /* 291 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
+ /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
+ /* 293 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
+ /* 294 */ "trigger_cmd ::= select",
+ /* 295 */ "expr ::= RAISE LP IGNORE RP",
+ /* 296 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 297 */ "raisetype ::= ROLLBACK",
+ /* 298 */ "raisetype ::= ABORT",
+ /* 299 */ "raisetype ::= FAIL",
+ /* 300 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 301 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 302 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 303 */ "key_opt ::=",
+ /* 304 */ "key_opt ::= KEY expr",
+ /* 305 */ "database_kw_opt ::= DATABASE",
+ /* 306 */ "database_kw_opt ::=",
+ /* 307 */ "cmd ::= REINDEX",
+ /* 308 */ "cmd ::= REINDEX nm dbnm",
+ /* 309 */ "cmd ::= ANALYZE",
+ /* 310 */ "cmd ::= ANALYZE nm dbnm",
+ /* 311 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 312 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
+ /* 313 */ "add_column_fullname ::= fullname",
+ /* 314 */ "kwcolumn_opt ::=",
+ /* 315 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 316 */ "cmd ::= create_vtab",
+ /* 317 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 318 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
+ /* 319 */ "vtabarglist ::= vtabarg",
+ /* 320 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 321 */ "vtabarg ::=",
+ /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 323 */ "vtabargtoken ::= ANY",
+ /* 324 */ "vtabargtoken ::= lp anylist RP",
+ /* 325 */ "lp ::= LP",
+ /* 326 */ "anylist ::=",
+ /* 327 */ "anylist ::= anylist LP anylist RP",
+ /* 328 */ "anylist ::= anylist ANY",
 };
 #endif /* NDEBUG */
 
@@ -93264,14 +100701,13 @@ static void yy_destructor(
     case 160: /* select */
     case 194: /* oneselect */
 {
-sqlite3SelectDelete(pParse->db, (yypminor->yy3));
+sqlite3SelectDelete(pParse->db, (yypminor->yy387));
 }
       break;
     case 174: /* term */
     case 175: /* expr */
-    case 223: /* escape */
 {
-sqlite3ExprDelete(pParse->db, (yypminor->yy346).pExpr);
+sqlite3ExprDelete(pParse->db, (yypminor->yy118).pExpr);
 }
       break;
     case 179: /* idxlist_opt */
@@ -93285,9 +100721,9 @@ sqlite3ExprDelete(pParse->db, (yypminor->yy346).pExpr);
     case 217: /* setlist */
     case 220: /* itemlist */
     case 221: /* exprlist */
-    case 227: /* case_exprlist */
+    case 226: /* case_exprlist */
 {
-sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
 }
       break;
     case 193: /* fullname */
@@ -93295,37 +100731,37 @@ sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
     case 206: /* seltablist */
     case 207: /* stl_prefix */
 {
-sqlite3SrcListDelete(pParse->db, (yypminor->yy65));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
 }
       break;
     case 199: /* where_opt */
     case 201: /* having_opt */
     case 210: /* on_opt */
     case 215: /* sortitem */
-    case 226: /* case_operand */
-    case 228: /* case_else */
-    case 239: /* when_clause */
-    case 244: /* key_opt */
+    case 225: /* case_operand */
+    case 227: /* case_else */
+    case 238: /* when_clause */
+    case 243: /* key_opt */
 {
-sqlite3ExprDelete(pParse->db, (yypminor->yy132));
+sqlite3ExprDelete(pParse->db, (yypminor->yy314));
 }
       break;
     case 211: /* using_opt */
     case 213: /* inscollist */
     case 219: /* inscollist_opt */
 {
-sqlite3IdListDelete(pParse->db, (yypminor->yy408));
+sqlite3IdListDelete(pParse->db, (yypminor->yy384));
 }
       break;
-    case 235: /* trigger_cmd_list */
-    case 240: /* trigger_cmd */
+    case 234: /* trigger_cmd_list */
+    case 239: /* trigger_cmd */
 {
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy473));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
 }
       break;
-    case 237: /* trigger_event */
+    case 236: /* trigger_event */
 {
-sqlite3IdListDelete(pParse->db, (yypminor->yy378).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
 }
       break;
     default:  break;   /* If no destructor action specified: do nothing */
@@ -93783,9 +101219,8 @@ static const struct {
   { 222, 2 },
   { 222, 1 },
   { 222, 2 },
-  { 223, 2 },
-  { 223, 0 },
-  { 175, 4 },
+  { 175, 3 },
+  { 175, 5 },
   { 175, 2 },
   { 175, 3 },
   { 175, 3 },
@@ -93794,36 +101229,36 @@ static const struct {
   { 175, 2 },
   { 175, 2 },
   { 175, 2 },
+  { 223, 1 },
+  { 223, 2 },
+  { 175, 5 },
   { 224, 1 },
   { 224, 2 },
   { 175, 5 },
-  { 225, 1 },
-  { 225, 2 },
-  { 175, 5 },
   { 175, 3 },
   { 175, 5 },
   { 175, 4 },
   { 175, 4 },
   { 175, 5 },
-  { 227, 5 },
-  { 227, 4 },
-  { 228, 2 },
-  { 228, 0 },
-  { 226, 1 },
-  { 226, 0 },
+  { 226, 5 },
+  { 226, 4 },
+  { 227, 2 },
+  { 227, 0 },
+  { 225, 1 },
+  { 225, 0 },
   { 221, 1 },
   { 221, 0 },
   { 216, 3 },
   { 216, 1 },
   { 147, 11 },
-  { 229, 1 },
-  { 229, 0 },
+  { 228, 1 },
+  { 228, 0 },
   { 179, 0 },
   { 179, 3 },
   { 187, 5 },
   { 187, 3 },
-  { 230, 0 },
-  { 230, 2 },
+  { 229, 0 },
+  { 229, 2 },
   { 147, 4 },
   { 147, 1 },
   { 147, 2 },
@@ -93832,41 +101267,41 @@ static const struct {
   { 147, 6 },
   { 147, 5 },
   { 147, 6 },
-  { 231, 1 },
-  { 231, 1 },
-  { 231, 1 },
-  { 231, 1 },
-  { 231, 1 },
+  { 230, 1 },
+  { 230, 1 },
+  { 230, 1 },
+  { 230, 1 },
+  { 230, 1 },
   { 170, 2 },
   { 171, 2 },
-  { 233, 1 },
   { 232, 1 },
-  { 232, 0 },
+  { 231, 1 },
+  { 231, 0 },
   { 147, 5 },
-  { 234, 11 },
+  { 233, 11 },
+  { 235, 1 },
+  { 235, 1 },
+  { 235, 2 },
+  { 235, 0 },
   { 236, 1 },
   { 236, 1 },
-  { 236, 2 },
-  { 236, 0 },
-  { 237, 1 },
-  { 237, 1 },
+  { 236, 3 },
+  { 237, 0 },
   { 237, 3 },
   { 238, 0 },
-  { 238, 3 },
-  { 239, 0 },
-  { 239, 2 },
-  { 235, 3 },
-  { 235, 2 },
-  { 241, 1 },
-  { 241, 3 },
-  { 242, 0 },
-  { 242, 3 },
-  { 242, 2 },
-  { 240, 7 },
-  { 240, 8 },
-  { 240, 5 },
-  { 240, 5 },
+  { 238, 2 },
+  { 234, 3 },
+  { 234, 2 },
   { 240, 1 },
+  { 240, 3 },
+  { 241, 0 },
+  { 241, 3 },
+  { 241, 2 },
+  { 239, 7 },
+  { 239, 8 },
+  { 239, 5 },
+  { 239, 5 },
+  { 239, 1 },
   { 175, 4 },
   { 175, 6 },
   { 191, 1 },
@@ -93875,32 +101310,32 @@ static const struct {
   { 147, 4 },
   { 147, 6 },
   { 147, 3 },
-  { 244, 0 },
-  { 244, 2 },
-  { 243, 1 },
   { 243, 0 },
+  { 243, 2 },
+  { 242, 1 },
+  { 242, 0 },
   { 147, 1 },
   { 147, 3 },
   { 147, 1 },
   { 147, 3 },
   { 147, 6 },
   { 147, 6 },
+  { 244, 1 },
+  { 245, 0 },
   { 245, 1 },
-  { 246, 0 },
-  { 246, 1 },
   { 147, 1 },
   { 147, 4 },
-  { 247, 7 },
-  { 248, 1 },
-  { 248, 3 },
-  { 249, 0 },
-  { 249, 2 },
+  { 246, 7 },
+  { 247, 1 },
+  { 247, 3 },
+  { 248, 0 },
+  { 248, 2 },
+  { 249, 1 },
+  { 249, 3 },
   { 250, 1 },
-  { 250, 3 },
-  { 251, 1 },
-  { 252, 0 },
-  { 252, 4 },
-  { 252, 2 },
+  { 251, 0 },
+  { 251, 4 },
+  { 251, 2 },
 };
 
 static void yy_accept(yyParser*);  /* Forward Declaration */
@@ -93968,17 +101403,17 @@ static void yy_reduce(
 { sqlite3FinishCoding(pParse); }
         break;
       case 9: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy328);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);}
         break;
       case 13: /* transtype ::= */
-{yygotominor.yy328 = TK_DEFERRED;}
+{yygotominor.yy4 = TK_DEFERRED;}
         break;
       case 14: /* transtype ::= DEFERRED */
       case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
       case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
       case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
       case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
-{yygotominor.yy328 = yymsp[0].major;}
+{yygotominor.yy4 = yymsp[0].major;}
         break;
       case 17: /* cmd ::= COMMIT trans_opt */
       case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
@@ -94004,7 +101439,7 @@ static void yy_reduce(
         break;
       case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
 {
-   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy328,0,0,yymsp[-2].minor.yy328);
+   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4);
 }
         break;
       case 27: /* createkw ::= CREATE */
@@ -94023,9 +101458,9 @@ static void yy_reduce(
       case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
       case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
       case 121: /* distinct ::= */ yytestcase(yyruleno==121);
-      case 223: /* between_op ::= BETWEEN */ yytestcase(yyruleno==223);
-      case 226: /* in_op ::= IN */ yytestcase(yyruleno==226);
-{yygotominor.yy328 = 0;}
+      case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222);
+      case 225: /* in_op ::= IN */ yytestcase(yyruleno==225);
+{yygotominor.yy4 = 0;}
         break;
       case 29: /* ifnotexists ::= IF NOT EXISTS */
       case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
@@ -94033,9 +101468,9 @@ static void yy_reduce(
       case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
       case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
       case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
-      case 224: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==224);
-      case 227: /* in_op ::= NOT IN */ yytestcase(yyruleno==227);
-{yygotominor.yy328 = 1;}
+      case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223);
+      case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226);
+{yygotominor.yy4 = 1;}
         break;
       case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
 {
@@ -94044,8 +101479,8 @@ static void yy_reduce(
         break;
       case 33: /* create_table_args ::= AS select */
 {
-  sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy3);
-  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
+  sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy387);
+  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
 }
         break;
       case 36: /* column ::= columnid type carglist */
@@ -94072,16 +101507,16 @@ static void yy_reduce(
       case 128: /* as ::= ids */ yytestcase(yyruleno==128);
       case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
       case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
-      case 252: /* collate ::= COLLATE ids */ yytestcase(yyruleno==252);
-      case 261: /* nmnum ::= plus_num */ yytestcase(yyruleno==261);
-      case 262: /* nmnum ::= nm */ yytestcase(yyruleno==262);
-      case 263: /* nmnum ::= ON */ yytestcase(yyruleno==263);
-      case 264: /* nmnum ::= DELETE */ yytestcase(yyruleno==264);
-      case 265: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==265);
-      case 266: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==266);
-      case 267: /* minus_num ::= MINUS number */ yytestcase(yyruleno==267);
-      case 268: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==268);
-      case 286: /* trnm ::= nm */ yytestcase(yyruleno==286);
+      case 251: /* collate ::= COLLATE ids */ yytestcase(yyruleno==251);
+      case 260: /* nmnum ::= plus_num */ yytestcase(yyruleno==260);
+      case 261: /* nmnum ::= nm */ yytestcase(yyruleno==261);
+      case 262: /* nmnum ::= ON */ yytestcase(yyruleno==262);
+      case 263: /* nmnum ::= DELETE */ yytestcase(yyruleno==263);
+      case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264);
+      case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265);
+      case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
+      case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
+      case 285: /* trnm ::= nm */ yytestcase(yyruleno==285);
 {yygotominor.yy0 = yymsp[0].minor.yy0;}
         break;
       case 45: /* type ::= typetoken */
@@ -94104,17 +101539,17 @@ static void yy_reduce(
         break;
       case 57: /* ccons ::= DEFAULT term */
       case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
-{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy346);}
+{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy118);}
         break;
       case 58: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy346);}
+{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy118);}
         break;
       case 60: /* ccons ::= DEFAULT MINUS term */
 {
   ExprSpan v;
-  v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy346.pExpr, 0, 0);
+  v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0);
   v.zStart = yymsp[-1].minor.yy0.z;
-  v.zEnd = yymsp[0].minor.yy346.zEnd;
+  v.zEnd = yymsp[0].minor.yy118.zEnd;
   sqlite3AddDefaultValue(pParse,&v);
 }
         break;
@@ -94126,62 +101561,62 @@ static void yy_reduce(
 }
         break;
       case 63: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy328);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);}
         break;
       case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy328,yymsp[0].minor.yy328,yymsp[-2].minor.yy328);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);}
         break;
       case 65: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy328,0,0,0,0);}
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0);}
         break;
       case 66: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy346.pExpr);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy118.pExpr);}
         break;
       case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy328);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);}
         break;
       case 68: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy328);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);}
         break;
       case 69: /* ccons ::= COLLATE ids */
 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
         break;
       case 72: /* refargs ::= */
-{ yygotominor.yy328 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yygotominor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */}
         break;
       case 73: /* refargs ::= refargs refarg */
-{ yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
+{ yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; }
         break;
       case 74: /* refarg ::= MATCH nm */
       case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75);
-{ yygotominor.yy429.value = 0;     yygotominor.yy429.mask = 0x000000; }
+{ yygotominor.yy215.value = 0;     yygotominor.yy215.mask = 0x000000; }
         break;
       case 76: /* refarg ::= ON DELETE refact */
-{ yygotominor.yy429.value = yymsp[0].minor.yy328;     yygotominor.yy429.mask = 0x0000ff; }
+{ yygotominor.yy215.value = yymsp[0].minor.yy4;     yygotominor.yy215.mask = 0x0000ff; }
         break;
       case 77: /* refarg ::= ON UPDATE refact */
-{ yygotominor.yy429.value = yymsp[0].minor.yy328<<8;  yygotominor.yy429.mask = 0x00ff00; }
+{ yygotominor.yy215.value = yymsp[0].minor.yy4<<8;  yygotominor.yy215.mask = 0x00ff00; }
         break;
       case 78: /* refact ::= SET NULL */
-{ yygotominor.yy328 = OE_SetNull;  /* EV: R-33326-45252 */}
+{ yygotominor.yy4 = OE_SetNull;  /* EV: R-33326-45252 */}
         break;
       case 79: /* refact ::= SET DEFAULT */
-{ yygotominor.yy328 = OE_SetDflt;  /* EV: R-33326-45252 */}
+{ yygotominor.yy4 = OE_SetDflt;  /* EV: R-33326-45252 */}
         break;
       case 80: /* refact ::= CASCADE */
-{ yygotominor.yy328 = OE_Cascade;  /* EV: R-33326-45252 */}
+{ yygotominor.yy4 = OE_Cascade;  /* EV: R-33326-45252 */}
         break;
       case 81: /* refact ::= RESTRICT */
-{ yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */}
         break;
       case 82: /* refact ::= NO ACTION */
-{ yygotominor.yy328 = OE_None;     /* EV: R-33326-45252 */}
+{ yygotominor.yy4 = OE_None;     /* EV: R-33326-45252 */}
         break;
       case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
       case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
       case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
       case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
-{yygotominor.yy328 = yymsp[0].minor.yy328;}
+{yygotominor.yy4 = yymsp[0].minor.yy4;}
         break;
       case 88: /* conslist_opt ::= */
 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
@@ -94190,101 +101625,101 @@ static void yy_reduce(
 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
         break;
       case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);}
         break;
       case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);}
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0);}
         break;
       case 96: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy118.pExpr);}
         break;
       case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
 {
-    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328);
-    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328);
+    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4);
+    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4);
 }
         break;
       case 100: /* onconf ::= */
-{yygotominor.yy328 = OE_Default;}
+{yygotominor.yy4 = OE_Default;}
         break;
       case 102: /* orconf ::= */
-{yygotominor.yy186 = OE_Default;}
+{yygotominor.yy210 = OE_Default;}
         break;
       case 103: /* orconf ::= OR resolvetype */
-{yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
+{yygotominor.yy210 = (u8)yymsp[0].minor.yy4;}
         break;
       case 105: /* resolvetype ::= IGNORE */
-{yygotominor.yy328 = OE_Ignore;}
+{yygotominor.yy4 = OE_Ignore;}
         break;
       case 106: /* resolvetype ::= REPLACE */
-{yygotominor.yy328 = OE_Replace;}
+{yygotominor.yy4 = OE_Replace;}
         break;
       case 107: /* cmd ::= DROP TABLE ifexists fullname */
 {
-  sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
+  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
 }
         break;
       case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
 {
-  sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328);
+  sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4);
 }
         break;
       case 111: /* cmd ::= DROP VIEW ifexists fullname */
 {
-  sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
+  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4);
 }
         break;
       case 112: /* cmd ::= select */
 {
   SelectDest dest = {SRT_Output, 0, 0, 0, 0};
-  sqlite3Select(pParse, yymsp[0].minor.yy3, &dest);
-  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
+  sqlite3Select(pParse, yymsp[0].minor.yy387, &dest);
+  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
 }
         break;
       case 113: /* select ::= oneselect */
-{yygotominor.yy3 = yymsp[0].minor.yy3;}
+{yygotominor.yy387 = yymsp[0].minor.yy387;}
         break;
       case 114: /* select ::= select multiselect_op oneselect */
 {
-  if( yymsp[0].minor.yy3 ){
-    yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
-    yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3;
+  if( yymsp[0].minor.yy387 ){
+    yymsp[0].minor.yy387->op = (u8)yymsp[-1].minor.yy4;
+    yymsp[0].minor.yy387->pPrior = yymsp[-2].minor.yy387;
   }else{
-    sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
+    sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy387);
   }
-  yygotominor.yy3 = yymsp[0].minor.yy3;
+  yygotominor.yy387 = yymsp[0].minor.yy387;
 }
         break;
       case 116: /* multiselect_op ::= UNION ALL */
-{yygotominor.yy328 = TK_ALL;}
+{yygotominor.yy4 = TK_ALL;}
         break;
       case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
 {
-  yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy65,yymsp[-4].minor.yy132,yymsp[-3].minor.yy14,yymsp[-2].minor.yy132,yymsp[-1].minor.yy14,yymsp[-7].minor.yy328,yymsp[0].minor.yy476.pLimit,yymsp[0].minor.yy476.pOffset);
+  yygotominor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy292.pLimit,yymsp[0].minor.yy292.pOffset);
 }
         break;
       case 122: /* sclp ::= selcollist COMMA */
-      case 248: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==248);
-{yygotominor.yy14 = yymsp[-1].minor.yy14;}
+      case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247);
+{yygotominor.yy322 = yymsp[-1].minor.yy322;}
         break;
       case 123: /* sclp ::= */
       case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
       case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159);
-      case 241: /* exprlist ::= */ yytestcase(yyruleno==241);
-      case 247: /* idxlist_opt ::= */ yytestcase(yyruleno==247);
-{yygotominor.yy14 = 0;}
+      case 240: /* exprlist ::= */ yytestcase(yyruleno==240);
+      case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246);
+{yygotominor.yy322 = 0;}
         break;
       case 124: /* selcollist ::= sclp expr as */
 {
-   yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr);
-   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1);
-   sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346);
+   yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr);
+   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[0].minor.yy0, 1);
+   sqlite3ExprListSetSpan(pParse,yygotominor.yy322,&yymsp[-1].minor.yy118);
 }
         break;
       case 125: /* selcollist ::= sclp STAR */
 {
   Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p);
 }
         break;
       case 126: /* selcollist ::= sclp nm DOT STAR */
@@ -94292,50 +101727,50 @@ static void yy_reduce(
   Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
   Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
   Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, pDot);
 }
         break;
       case 129: /* as ::= */
 {yygotominor.yy0.n = 0;}
         break;
       case 130: /* from ::= */
-{yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
+{yygotominor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy259));}
         break;
       case 131: /* from ::= FROM seltablist */
 {
-  yygotominor.yy65 = yymsp[0].minor.yy65;
-  sqlite3SrcListShiftJoinType(yygotominor.yy65);
+  yygotominor.yy259 = yymsp[0].minor.yy259;
+  sqlite3SrcListShiftJoinType(yygotominor.yy259);
 }
         break;
       case 132: /* stl_prefix ::= seltablist joinop */
 {
-   yygotominor.yy65 = yymsp[-1].minor.yy65;
-   if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328;
+   yygotominor.yy259 = yymsp[-1].minor.yy259;
+   if( ALWAYS(yygotominor.yy259 && yygotominor.yy259->nSrc>0) ) yygotominor.yy259->a[yygotominor.yy259->nSrc-1].jointype = (u8)yymsp[0].minor.yy4;
 }
         break;
       case 133: /* stl_prefix ::= */
-{yygotominor.yy65 = 0;}
+{yygotominor.yy259 = 0;}
         break;
       case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
 {
-  yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
-  sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0);
+  yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
+  sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, &yymsp[-2].minor.yy0);
 }
         break;
       case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
 {
-    yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
+    yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
   }
         break;
       case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
 {
-    if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){
-      yygotominor.yy65 = yymsp[-4].minor.yy65;
+    if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){
+      yygotominor.yy259 = yymsp[-4].minor.yy259;
     }else{
       Select *pSubquery;
-      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy65);
-      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,0,0,0);
-      yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
+      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259);
+      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,0,0,0);
+      yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
     }
   }
         break;
@@ -94344,158 +101779,157 @@ static void yy_reduce(
 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
         break;
       case 139: /* fullname ::= nm dbnm */
-{yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
+{yygotominor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
         break;
       case 140: /* joinop ::= COMMA|JOIN */
-{ yygotominor.yy328 = JT_INNER; }
+{ yygotominor.yy4 = JT_INNER; }
         break;
       case 141: /* joinop ::= JOIN_KW JOIN */
-{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
+{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
         break;
       case 142: /* joinop ::= JOIN_KW nm JOIN */
-{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
+{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
         break;
       case 143: /* joinop ::= JOIN_KW nm nm JOIN */
-{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
+{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
         break;
       case 144: /* on_opt ::= ON expr */
       case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155);
       case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162);
       case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169);
-      case 236: /* case_else ::= ELSE expr */ yytestcase(yyruleno==236);
-      case 238: /* case_operand ::= expr */ yytestcase(yyruleno==238);
-{yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;}
+      case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235);
+      case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237);
+{yygotominor.yy314 = yymsp[0].minor.yy118.pExpr;}
         break;
       case 145: /* on_opt ::= */
       case 161: /* having_opt ::= */ yytestcase(yyruleno==161);
       case 168: /* where_opt ::= */ yytestcase(yyruleno==168);
-      case 237: /* case_else ::= */ yytestcase(yyruleno==237);
-      case 239: /* case_operand ::= */ yytestcase(yyruleno==239);
-{yygotominor.yy132 = 0;}
+      case 236: /* case_else ::= */ yytestcase(yyruleno==236);
+      case 238: /* case_operand ::= */ yytestcase(yyruleno==238);
+{yygotominor.yy314 = 0;}
         break;
       case 148: /* indexed_opt ::= NOT INDEXED */
 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
         break;
       case 149: /* using_opt ::= USING LP inscollist RP */
       case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181);
-{yygotominor.yy408 = yymsp[-1].minor.yy408;}
+{yygotominor.yy384 = yymsp[-1].minor.yy384;}
         break;
       case 150: /* using_opt ::= */
       case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180);
-{yygotominor.yy408 = 0;}
+{yygotominor.yy384 = 0;}
         break;
       case 152: /* orderby_opt ::= ORDER BY sortlist */
       case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160);
-      case 240: /* exprlist ::= nexprlist */ yytestcase(yyruleno==240);
-{yygotominor.yy14 = yymsp[0].minor.yy14;}
+      case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239);
+{yygotominor.yy322 = yymsp[0].minor.yy322;}
         break;
       case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy132);
-  if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314);
+  if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4;
 }
         break;
       case 154: /* sortlist ::= sortitem sortorder */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy132);
-  if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328;
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314);
+  if( yygotominor.yy322 && ALWAYS(yygotominor.yy322->a) ) yygotominor.yy322->a[0].sortOrder = (u8)yymsp[0].minor.yy4;
 }
         break;
       case 156: /* sortorder ::= ASC */
       case 158: /* sortorder ::= */ yytestcase(yyruleno==158);
-{yygotominor.yy328 = SQLITE_SO_ASC;}
+{yygotominor.yy4 = SQLITE_SO_ASC;}
         break;
       case 157: /* sortorder ::= DESC */
-{yygotominor.yy328 = SQLITE_SO_DESC;}
+{yygotominor.yy4 = SQLITE_SO_DESC;}
         break;
       case 163: /* limit_opt ::= */
-{yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
+{yygotominor.yy292.pLimit = 0; yygotominor.yy292.pOffset = 0;}
         break;
       case 164: /* limit_opt ::= LIMIT expr */
-{yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
+{yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; yygotominor.yy292.pOffset = 0;}
         break;
       case 165: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
+{yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr;}
         break;
       case 166: /* limit_opt ::= LIMIT expr COMMA expr */
-{yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
+{yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;}
         break;
       case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
 {
-  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0);
-  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132);
+  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0);
+  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314);
 }
         break;
       case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
 {
-  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0);
-  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list"); 
-  sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186);
+  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0);
+  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); 
+  sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy210);
 }
         break;
       case 171: /* setlist ::= setlist COMMA nm EQ expr */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr);
-  sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr);
+  sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1);
 }
         break;
       case 172: /* setlist ::= nm EQ expr */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr);
-  sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr);
+  sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1);
 }
         break;
       case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
-{sqlite3Insert(pParse, yymsp[-5].minor.yy65, yymsp[-1].minor.yy14, 0, yymsp[-4].minor.yy408, yymsp[-7].minor.yy186);}
+{sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210);}
         break;
       case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
-{sqlite3Insert(pParse, yymsp[-2].minor.yy65, 0, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);}
+{sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);}
         break;
       case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
-{sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);}
+{sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210);}
         break;
       case 176: /* insert_cmd ::= INSERT orconf */
-{yygotominor.yy186 = yymsp[0].minor.yy186;}
+{yygotominor.yy210 = yymsp[0].minor.yy210;}
         break;
       case 177: /* insert_cmd ::= REPLACE */
-{yygotominor.yy186 = OE_Replace;}
+{yygotominor.yy210 = OE_Replace;}
         break;
       case 178: /* itemlist ::= itemlist COMMA expr */
-      case 242: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==242);
-{yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);}
+      case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241);
+{yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy118.pExpr);}
         break;
       case 179: /* itemlist ::= expr */
-      case 243: /* nexprlist ::= expr */ yytestcase(yyruleno==243);
-{yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
+      case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242);
+{yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy118.pExpr);}
         break;
       case 182: /* inscollist ::= inscollist COMMA nm */
-{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
+{yygotominor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);}
         break;
       case 183: /* inscollist ::= nm */
-{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
+{yygotominor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
         break;
       case 184: /* expr ::= term */
-      case 212: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==212);
-{yygotominor.yy346 = yymsp[0].minor.yy346;}
+{yygotominor.yy118 = yymsp[0].minor.yy118;}
         break;
       case 185: /* expr ::= LP expr RP */
-{yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
+{yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
         break;
       case 186: /* term ::= NULL */
       case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191);
       case 192: /* term ::= STRING */ yytestcase(yyruleno==192);
-{spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
+{spanExpr(&yygotominor.yy118, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
         break;
       case 187: /* expr ::= id */
       case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188);
-{spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
+{spanExpr(&yygotominor.yy118, pParse, TK_ID, &yymsp[0].minor.yy0);}
         break;
       case 189: /* expr ::= nm DOT nm */
 {
   Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
   Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
-  spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
+  spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
       case 190: /* expr ::= nm DOT nm DOT nm */
@@ -94504,8 +101938,8 @@ static void yy_reduce(
   Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
   Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
   Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
-  spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
+  spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
       case 193: /* expr ::= REGISTER */
@@ -94515,61 +101949,61 @@ static void yy_reduce(
   ** in the virtual machine.  #N is the N-th register. */
   if( pParse->nested==0 ){
     sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &yymsp[0].minor.yy0);
-    yygotominor.yy346.pExpr = 0;
+    yygotominor.yy118.pExpr = 0;
   }else{
-    yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);
-    if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable);
+    yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);
+    if( yygotominor.yy118.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy118.pExpr->iTable);
   }
-  spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
+  spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
       case 194: /* expr ::= VARIABLE */
 {
-  spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
-  sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr);
-  spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
+  spanExpr(&yygotominor.yy118, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
+  sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr);
+  spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
       case 195: /* expr ::= expr COLLATE ids */
 {
-  yygotominor.yy346.pExpr = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
-  yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
-  yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+  yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, &yymsp[0].minor.yy0);
+  yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart;
+  yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
       case 196: /* expr ::= CAST LP expr AS typetoken RP */
 {
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0);
-  spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, &yymsp[-1].minor.yy0);
+  spanSet(&yygotominor.yy118,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
       case 197: /* expr ::= ID LP distinct exprlist RP */
 {
-  if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
+  if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
     sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
   }
-  yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
-  spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
-  if( yymsp[-2].minor.yy328 && yygotominor.yy346.pExpr ){
-    yygotominor.yy346.pExpr->flags |= EP_Distinct;
+  yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
+  spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
+  if( yymsp[-2].minor.yy4 && yygotominor.yy118.pExpr ){
+    yygotominor.yy118.pExpr->flags |= EP_Distinct;
   }
 }
         break;
       case 198: /* expr ::= ID LP STAR RP */
 {
-  yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
-  spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
+  yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
+  spanSet(&yygotominor.yy118,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
 }
         break;
       case 199: /* term ::= CTIME_KW */
 {
   /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
   ** treated as functions that return constants */
-  yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
-  if( yygotominor.yy346.pExpr ){
-    yygotominor.yy346.pExpr->op = TK_CONST_FUNC;  
+  yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
+  if( yygotominor.yy118.pExpr ){
+    yygotominor.yy118.pExpr->op = TK_CONST_FUNC;  
   }
-  spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
+  spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
       case 200: /* expr ::= expr AND expr */
@@ -94580,295 +102014,315 @@ static void yy_reduce(
       case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205);
       case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206);
       case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207);
-{spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);}
+{spanBinaryExpr(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);}
         break;
       case 208: /* likeop ::= LIKE_KW */
       case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210);
-{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;}
+{yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 0;}
         break;
       case 209: /* likeop ::= NOT LIKE_KW */
       case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211);
-{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 1;}
+{yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 1;}
         break;
-      case 213: /* escape ::= */
-{memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));}
+      case 212: /* expr ::= expr likeop expr */
+{
+  ExprList *pList;
+  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy118.pExpr);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy118.pExpr);
+  yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy342.eOperator);
+  if( yymsp[-1].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
+  yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart;
+  yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd;
+  if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc;
+}
         break;
-      case 214: /* expr ::= expr likeop expr escape */
+      case 213: /* expr ::= expr likeop expr ESCAPE expr */
 {
   ExprList *pList;
-  pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy346.pExpr);
-  if( yymsp[0].minor.yy346.pExpr ){
-    pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
-  }
-  yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-2].minor.yy96.eOperator);
-  if( yymsp[-2].minor.yy96.not ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
-  yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
-  yygotominor.yy346.zEnd = yymsp[-1].minor.yy346.zEnd;
-  if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
+  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy118.pExpr);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr);
+  yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy342.eOperator);
+  if( yymsp[-3].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
+  yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart;
+  yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd;
+  if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc;
 }
         break;
-      case 215: /* expr ::= expr ISNULL|NOTNULL */
-{spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
+      case 214: /* expr ::= expr ISNULL|NOTNULL */
+{spanUnaryPostfix(&yygotominor.yy118,pParse,yymsp[0].major,&yymsp[-1].minor.yy118,&yymsp[0].minor.yy0);}
         break;
-      case 216: /* expr ::= expr NOT NULL */
-{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
+      case 215: /* expr ::= expr NOT NULL */
+{spanUnaryPostfix(&yygotominor.yy118,pParse,TK_NOTNULL,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy0);}
         break;
-      case 217: /* expr ::= expr IS expr */
+      case 216: /* expr ::= expr IS expr */
 {
-  spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
+  spanBinaryExpr(&yygotominor.yy118,pParse,TK_IS,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL);
 }
         break;
-      case 218: /* expr ::= expr IS NOT expr */
+      case 217: /* expr ::= expr IS NOT expr */
 {
-  spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
-  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
+  spanBinaryExpr(&yygotominor.yy118,pParse,TK_ISNOT,&yymsp[-3].minor.yy118,&yymsp[0].minor.yy118);
+  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL);
 }
         break;
-      case 219: /* expr ::= NOT expr */
-      case 220: /* expr ::= BITNOT expr */ yytestcase(yyruleno==220);
-{spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
+      case 218: /* expr ::= NOT expr */
+      case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
+{spanUnaryPrefix(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);}
         break;
-      case 221: /* expr ::= MINUS expr */
-{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
+      case 220: /* expr ::= MINUS expr */
+{spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UMINUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);}
         break;
-      case 222: /* expr ::= PLUS expr */
-{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
+      case 221: /* expr ::= PLUS expr */
+{spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UPLUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);}
         break;
-      case 225: /* expr ::= expr between_op expr AND expr */
+      case 224: /* expr ::= expr between_op expr AND expr */
 {
-  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
-  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0);
-  if( yygotominor.yy346.pExpr ){
-    yygotominor.yy346.pExpr->x.pList = pList;
+  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr);
+  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr);
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0);
+  if( yygotominor.yy118.pExpr ){
+    yygotominor.yy118.pExpr->x.pList = pList;
   }else{
     sqlite3ExprListDelete(pParse->db, pList);
   } 
-  if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
-  yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
-  yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
+  if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
+  yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart;
+  yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd;
 }
         break;
-      case 228: /* expr ::= expr in_op LP exprlist RP */
+      case 227: /* expr ::= expr in_op LP exprlist RP */
 {
-    yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
-    if( yygotominor.yy346.pExpr ){
-      yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
-      sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+    if( yymsp[-1].minor.yy322==0 ){
+      /* Expressions of the form
+      **
+      **      expr1 IN ()
+      **      expr1 NOT IN ()
+      **
+      ** simplify to constants 0 (false) and 1 (true), respectively,
+      ** regardless of the value of expr1.
+      */
+      yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy4]);
+      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy118.pExpr);
     }else{
-      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
+      yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0);
+      if( yygotominor.yy118.pExpr ){
+        yygotominor.yy118.pExpr->x.pList = yymsp[-1].minor.yy322;
+        sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr);
+      }else{
+        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+      }
+      if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
     }
-    if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
-    yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
-    yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+    yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart;
+    yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 229: /* expr ::= LP select RP */
+      case 228: /* expr ::= LP select RP */
 {
-    yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
-    if( yygotominor.yy346.pExpr ){
-      yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
-      ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
-      sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+    yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
+    if( yygotominor.yy118.pExpr ){
+      yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387;
+      ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect);
+      sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr);
     }else{
-      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
+      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387);
     }
-    yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z;
-    yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+    yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z;
+    yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 230: /* expr ::= expr in_op LP select RP */
+      case 229: /* expr ::= expr in_op LP select RP */
 {
-    yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
-    if( yygotominor.yy346.pExpr ){
-      yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
-      ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
-      sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+    yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0);
+    if( yygotominor.yy118.pExpr ){
+      yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387;
+      ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect);
+      sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr);
     }else{
-      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
+      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387);
     }
-    if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
-    yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
-    yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+    if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
+    yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart;
+    yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 231: /* expr ::= expr in_op nm dbnm */
+      case 230: /* expr ::= expr in_op nm dbnm */
 {
     SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
-    yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
-    if( yygotominor.yy346.pExpr ){
-      yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
-      ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
-      sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+    yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0);
+    if( yygotominor.yy118.pExpr ){
+      yygotominor.yy118.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
+      ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect);
+      sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr);
     }else{
       sqlite3SrcListDelete(pParse->db, pSrc);
     }
-    if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
-    yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
-    yygotominor.yy346.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
+    if( yymsp[-2].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0);
+    yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart;
+    yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
   }
         break;
-      case 232: /* expr ::= EXISTS LP select RP */
+      case 231: /* expr ::= EXISTS LP select RP */
 {
-    Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
+    Expr *p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
     if( p ){
-      p->x.pSelect = yymsp[-1].minor.yy3;
+      p->x.pSelect = yymsp[-1].minor.yy387;
       ExprSetProperty(p, EP_xIsSelect);
       sqlite3ExprSetHeight(pParse, p);
     }else{
-      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
+      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387);
     }
-    yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
-    yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+    yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z;
+    yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
   }
         break;
-      case 233: /* expr ::= CASE case_operand case_exprlist case_else END */
+      case 232: /* expr ::= CASE case_operand case_exprlist case_else END */
 {
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, yymsp[-1].minor.yy132, 0);
-  if( yygotominor.yy346.pExpr ){
-    yygotominor.yy346.pExpr->x.pList = yymsp[-2].minor.yy14;
-    sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0);
+  if( yygotominor.yy118.pExpr ){
+    yygotominor.yy118.pExpr->x.pList = yymsp[-2].minor.yy322;
+    sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr);
   }else{
-    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
+    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
   }
-  yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z;
-  yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+  yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z;
+  yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 234: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+      case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr);
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr);
 }
         break;
-      case 235: /* case_exprlist ::= WHEN expr THEN expr */
+      case 234: /* case_exprlist ::= WHEN expr THEN expr */
 {
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr);
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr);
 }
         break;
-      case 244: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
+      case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
 {
   sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, 
-                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy14, yymsp[-9].minor.yy328,
-                      &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy328);
+                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4,
+                      &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4);
 }
         break;
-      case 245: /* uniqueflag ::= UNIQUE */
-      case 299: /* raisetype ::= ABORT */ yytestcase(yyruleno==299);
-{yygotominor.yy328 = OE_Abort;}
+      case 244: /* uniqueflag ::= UNIQUE */
+      case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298);
+{yygotominor.yy4 = OE_Abort;}
         break;
-      case 246: /* uniqueflag ::= */
-{yygotominor.yy328 = OE_None;}
+      case 245: /* uniqueflag ::= */
+{yygotominor.yy4 = OE_None;}
         break;
-      case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */
+      case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */
 {
   Expr *p = 0;
   if( yymsp[-1].minor.yy0.n>0 ){
     p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
-    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
+    sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
   }
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
-  sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
-  sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
-  if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, p);
+  sqlite3ExprListSetName(pParse,yygotominor.yy322,&yymsp[-2].minor.yy0,1);
+  sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index");
+  if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4;
 }
         break;
-      case 250: /* idxlist ::= nm collate sortorder */
+      case 249: /* idxlist ::= nm collate sortorder */
 {
   Expr *p = 0;
   if( yymsp[-1].minor.yy0.n>0 ){
     p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
-    sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
+    sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
   }
-  yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
-  sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
-  sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
-  if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
+  yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, p);
+  sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1);
+  sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index");
+  if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4;
 }
         break;
-      case 251: /* collate ::= */
+      case 250: /* collate ::= */
 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
         break;
-      case 253: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
+      case 252: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
         break;
-      case 254: /* cmd ::= VACUUM */
-      case 255: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==255);
+      case 253: /* cmd ::= VACUUM */
+      case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254);
 {sqlite3Vacuum(pParse);}
         break;
-      case 256: /* cmd ::= PRAGMA nm dbnm */
+      case 255: /* cmd ::= PRAGMA nm dbnm */
 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
         break;
-      case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+      case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
         break;
-      case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+      case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
         break;
-      case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+      case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
         break;
-      case 260: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+      case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
         break;
-      case 271: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+      case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
 {
   Token all;
   all.z = yymsp[-3].minor.yy0.z;
   all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
-  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
+  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all);
 }
         break;
-      case 272: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+      case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
 {
-  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328);
+  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4);
   yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
 }
         break;
-      case 273: /* trigger_time ::= BEFORE */
-      case 276: /* trigger_time ::= */ yytestcase(yyruleno==276);
-{ yygotominor.yy328 = TK_BEFORE; }
+      case 272: /* trigger_time ::= BEFORE */
+      case 275: /* trigger_time ::= */ yytestcase(yyruleno==275);
+{ yygotominor.yy4 = TK_BEFORE; }
         break;
-      case 274: /* trigger_time ::= AFTER */
-{ yygotominor.yy328 = TK_AFTER;  }
+      case 273: /* trigger_time ::= AFTER */
+{ yygotominor.yy4 = TK_AFTER;  }
         break;
-      case 275: /* trigger_time ::= INSTEAD OF */
-{ yygotominor.yy328 = TK_INSTEAD;}
+      case 274: /* trigger_time ::= INSTEAD OF */
+{ yygotominor.yy4 = TK_INSTEAD;}
         break;
-      case 277: /* trigger_event ::= DELETE|INSERT */
-      case 278: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==278);
-{yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
+      case 276: /* trigger_event ::= DELETE|INSERT */
+      case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277);
+{yygotominor.yy90.a = yymsp[0].major; yygotominor.yy90.b = 0;}
         break;
-      case 279: /* trigger_event ::= UPDATE OF inscollist */
-{yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
+      case 278: /* trigger_event ::= UPDATE OF inscollist */
+{yygotominor.yy90.a = TK_UPDATE; yygotominor.yy90.b = yymsp[0].minor.yy384;}
         break;
-      case 282: /* when_clause ::= */
-      case 304: /* key_opt ::= */ yytestcase(yyruleno==304);
-{ yygotominor.yy132 = 0; }
+      case 281: /* when_clause ::= */
+      case 303: /* key_opt ::= */ yytestcase(yyruleno==303);
+{ yygotominor.yy314 = 0; }
         break;
-      case 283: /* when_clause ::= WHEN expr */
-      case 305: /* key_opt ::= KEY expr */ yytestcase(yyruleno==305);
-{ yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
+      case 282: /* when_clause ::= WHEN expr */
+      case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304);
+{ yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; }
         break;
-      case 284: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+      case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
 {
-  assert( yymsp[-2].minor.yy473!=0 );
-  yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473;
-  yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473;
-  yygotominor.yy473 = yymsp[-2].minor.yy473;
+  assert( yymsp[-2].minor.yy203!=0 );
+  yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203;
+  yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203;
+  yygotominor.yy203 = yymsp[-2].minor.yy203;
 }
         break;
-      case 285: /* trigger_cmd_list ::= trigger_cmd SEMI */
+      case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
 { 
-  assert( yymsp[-1].minor.yy473!=0 );
-  yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473;
-  yygotominor.yy473 = yymsp[-1].minor.yy473;
+  assert( yymsp[-1].minor.yy203!=0 );
+  yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
+  yygotominor.yy203 = yymsp[-1].minor.yy203;
 }
         break;
-      case 287: /* trnm ::= nm DOT nm */
+      case 286: /* trnm ::= nm DOT nm */
 {
   yygotominor.yy0 = yymsp[0].minor.yy0;
   sqlite3ErrorMsg(pParse, 
@@ -94876,121 +102330,121 @@ static void yy_reduce(
         "statements within triggers");
 }
         break;
-      case 289: /* tridxby ::= INDEXED BY nm */
+      case 288: /* tridxby ::= INDEXED BY nm */
 {
   sqlite3ErrorMsg(pParse,
         "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 290: /* tridxby ::= NOT INDEXED */
+      case 289: /* tridxby ::= NOT INDEXED */
 {
   sqlite3ErrorMsg(pParse,
         "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
         "within triggers");
 }
         break;
-      case 291: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
-{ yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); }
+      case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
+{ yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); }
         break;
-      case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
-{yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy408, yymsp[-1].minor.yy14, 0, yymsp[-7].minor.yy186);}
+      case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
+{yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210);}
         break;
-      case 293: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
-{yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, 0, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);}
+      case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
+{yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210);}
         break;
-      case 294: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
-{yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
+      case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
+{yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy314);}
         break;
-      case 295: /* trigger_cmd ::= select */
-{yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
+      case 294: /* trigger_cmd ::= select */
+{yygotominor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy387); }
         break;
-      case 296: /* expr ::= RAISE LP IGNORE RP */
+      case 295: /* expr ::= RAISE LP IGNORE RP */
 {
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); 
-  if( yygotominor.yy346.pExpr ){
-    yygotominor.yy346.pExpr->affinity = OE_Ignore;
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); 
+  if( yygotominor.yy118.pExpr ){
+    yygotominor.yy118.pExpr->affinity = OE_Ignore;
   }
-  yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
-  yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+  yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z;
+  yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 297: /* expr ::= RAISE LP raisetype COMMA nm RP */
+      case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */
 {
-  yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); 
-  if( yygotominor.yy346.pExpr ) {
-    yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328;
+  yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); 
+  if( yygotominor.yy118.pExpr ) {
+    yygotominor.yy118.pExpr->affinity = (char)yymsp[-3].minor.yy4;
   }
-  yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z;
-  yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
+  yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z;
+  yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
 }
         break;
-      case 298: /* raisetype ::= ROLLBACK */
-{yygotominor.yy328 = OE_Rollback;}
+      case 297: /* raisetype ::= ROLLBACK */
+{yygotominor.yy4 = OE_Rollback;}
         break;
-      case 300: /* raisetype ::= FAIL */
-{yygotominor.yy328 = OE_Fail;}
+      case 299: /* raisetype ::= FAIL */
+{yygotominor.yy4 = OE_Fail;}
         break;
-      case 301: /* cmd ::= DROP TRIGGER ifexists fullname */
+      case 300: /* cmd ::= DROP TRIGGER ifexists fullname */
 {
-  sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
+  sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
 }
         break;
-      case 302: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+      case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
 {
-  sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132);
+  sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314);
 }
         break;
-      case 303: /* cmd ::= DETACH database_kw_opt expr */
+      case 302: /* cmd ::= DETACH database_kw_opt expr */
 {
-  sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
+  sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr);
 }
         break;
-      case 308: /* cmd ::= REINDEX */
+      case 307: /* cmd ::= REINDEX */
 {sqlite3Reindex(pParse, 0, 0);}
         break;
-      case 309: /* cmd ::= REINDEX nm dbnm */
+      case 308: /* cmd ::= REINDEX nm dbnm */
 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 310: /* cmd ::= ANALYZE */
+      case 309: /* cmd ::= ANALYZE */
 {sqlite3Analyze(pParse, 0, 0);}
         break;
-      case 311: /* cmd ::= ANALYZE nm dbnm */
+      case 310: /* cmd ::= ANALYZE nm dbnm */
 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
         break;
-      case 312: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+      case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
 {
-  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
+  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0);
 }
         break;
-      case 313: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
+      case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
 {
   sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
 }
         break;
-      case 314: /* add_column_fullname ::= fullname */
+      case 313: /* add_column_fullname ::= fullname */
 {
   pParse->db->lookaside.bEnabled = 0;
-  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
+  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259);
 }
         break;
-      case 317: /* cmd ::= create_vtab */
+      case 316: /* cmd ::= create_vtab */
 {sqlite3VtabFinishParse(pParse,0);}
         break;
-      case 318: /* cmd ::= create_vtab LP vtabarglist RP */
+      case 317: /* cmd ::= create_vtab LP vtabarglist RP */
 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
         break;
-      case 319: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
+      case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
 {
     sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
 }
         break;
-      case 322: /* vtabarg ::= */
+      case 321: /* vtabarg ::= */
 {sqlite3VtabArgInit(pParse);}
         break;
-      case 324: /* vtabargtoken ::= ANY */
-      case 325: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==325);
-      case 326: /* lp ::= LP */ yytestcase(yyruleno==326);
+      case 323: /* vtabargtoken ::= ANY */
+      case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324);
+      case 325: /* lp ::= LP */ yytestcase(yyruleno==325);
 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
         break;
       default:
@@ -95019,21 +102473,21 @@ static void yy_reduce(
       /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
       /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
       /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
-      /* (269) plus_opt ::= PLUS */ yytestcase(yyruleno==269);
-      /* (270) plus_opt ::= */ yytestcase(yyruleno==270);
-      /* (280) foreach_clause ::= */ yytestcase(yyruleno==280);
-      /* (281) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==281);
-      /* (288) tridxby ::= */ yytestcase(yyruleno==288);
-      /* (306) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==306);
-      /* (307) database_kw_opt ::= */ yytestcase(yyruleno==307);
-      /* (315) kwcolumn_opt ::= */ yytestcase(yyruleno==315);
-      /* (316) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==316);
-      /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
-      /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
-      /* (323) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==323);
-      /* (327) anylist ::= */ yytestcase(yyruleno==327);
-      /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
-      /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);
+      /* (268) plus_opt ::= PLUS */ yytestcase(yyruleno==268);
+      /* (269) plus_opt ::= */ yytestcase(yyruleno==269);
+      /* (279) foreach_clause ::= */ yytestcase(yyruleno==279);
+      /* (280) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==280);
+      /* (287) tridxby ::= */ yytestcase(yyruleno==287);
+      /* (305) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==305);
+      /* (306) database_kw_opt ::= */ yytestcase(yyruleno==306);
+      /* (314) kwcolumn_opt ::= */ yytestcase(yyruleno==314);
+      /* (315) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==315);
+      /* (319) vtabarglist ::= vtabarg */ yytestcase(yyruleno==319);
+      /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==320);
+      /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
+      /* (326) anylist ::= */ yytestcase(yyruleno==326);
+      /* (327) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==327);
+      /* (328) anylist ::= anylist ANY */ yytestcase(yyruleno==328);
         break;
   };
   yygoto = yyRuleInfo[yyruleno].lhs;
@@ -96061,7 +103515,7 @@ abort_parse:
   }
 #endif
 #ifndef SQLITE_OMIT_VIRTUALTABLE
-  sqlite3DbFree(db, pParse->apVtabLock);
+  sqlite3_free(pParse->apVtabLock);
 #endif
 
   if( !IN_DECLARE_VTAB ){
@@ -96069,7 +103523,7 @@ abort_parse:
     ** structure built up in pParse->pNewTable. The calling code (see vtab.c)
     ** will take responsibility for freeing the Table structure.
     */
-    sqlite3DeleteTable(pParse->pNewTable);
+    sqlite3DeleteTable(db, pParse->pNewTable);
   }
 
   sqlite3DeleteTrigger(db, pParse->pNewTrigger);
@@ -96083,7 +103537,7 @@ abort_parse:
   while( pParse->pZombieTab ){
     Table *p = pParse->pZombieTab;
     pParse->pZombieTab = p->pNextZombie;
-    sqlite3DeleteTable(p);
+    sqlite3DeleteTable(db, p);
   }
   if( nErr>0 && pParse->rc==SQLITE_OK ){
     pParse->rc = SQLITE_ERROR;
@@ -96493,15 +103947,33 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db);
 /************** Continuing where we left off in main.c ***********************/
 #endif
 
-/*
-** The version of the library
-*/
 #ifndef SQLITE_AMALGAMATION
+/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant
+** contains the text of SQLITE_VERSION macro. 
+*/
 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
 #endif
+
+/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
+** a pointer to the to the sqlite3_version[] string constant. 
+*/
 SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
+
+/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
+** pointer to a string constant whose value is the same as the
+** SQLITE_SOURCE_ID C preprocessor macro. 
+*/
 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
+
+/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
+** returns an integer equal to SQLITE_VERSION_NUMBER.
+*/
 SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
+
+/* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns
+** zero if and only if SQLite was compiled mutexing code omitted due to
+** the SQLITE_THREADSAFE compile-time option being set to 0.
+*/
 SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
 
 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
@@ -96622,6 +104094,13 @@ SQLITE_API int sqlite3_initialize(void){
   ** sqlite3_initialize().  The recursive calls normally come through
   ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other
   ** recursive calls might also be possible.
+  **
+  ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls
+  ** to the xInit method, so the xInit method need not be threadsafe.
+  **
+  ** The following mutex is what serializes access to the appdef pcache xInit
+  ** methods.  The sqlite3_pcache_methods.xInit() all is embedded in the
+  ** call to sqlite3PcacheInitialize().
   */
   sqlite3_mutex_enter(sqlite3GlobalConfig.pInitMutex);
   if( sqlite3GlobalConfig.isInit==0 && sqlite3GlobalConfig.inProgress==0 ){
@@ -96902,12 +104381,12 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
     sz = 0;
     pStart = 0;
   }else if( pBuf==0 ){
-    sz = ROUND8(sz);
+    sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */
     sqlite3BeginBenignMalloc();
-    pStart = sqlite3Malloc( sz*cnt );
+    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */
     sqlite3EndBenignMalloc();
   }else{
-    sz = ROUNDDOWN8(sz);
+    sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */
     pStart = pBuf;
   }
   db->lookaside.pStart = pStart;
@@ -96950,14 +104429,14 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
   va_start(ap, op);
   switch( op ){
     case SQLITE_DBCONFIG_LOOKASIDE: {
-      void *pBuf = va_arg(ap, void*);
-      int sz = va_arg(ap, int);
-      int cnt = va_arg(ap, int);
+      void *pBuf = va_arg(ap, void*); /* IMP: R-21112-12275 */
+      int sz = va_arg(ap, int);       /* IMP: R-47871-25994 */
+      int cnt = va_arg(ap, int);      /* IMP: R-04460-53386 */
       rc = setupLookaside(db, pBuf, sz, cnt);
       break;
     }
     default: {
-      rc = SQLITE_ERROR;
+      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
       break;
     }
   }
@@ -97063,10 +104542,27 @@ SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *db){
 }
 
 /*
+** Invoke the destructor function associated with FuncDef p, if any. Except,
+** if this is not the last copy of the function, do not invoke it. Multiple
+** copies of a single function are created when create_function() is called
+** with SQLITE_ANY as the encoding.
+*/
+static void functionDestroy(sqlite3 *db, FuncDef *p){
+  FuncDestructor *pDestructor = p->pDestructor;
+  if( pDestructor ){
+    pDestructor->nRef--;
+    if( pDestructor->nRef==0 ){
+      pDestructor->xDestroy(pDestructor->pUserData);
+      sqlite3DbFree(db, pDestructor);
+    }
+  }
+}
+
+/*
 ** Close an existing SQLite database
 */
 SQLITE_API int sqlite3_close(sqlite3 *db){
-  HashElem *i;
+  HashElem *i;                    /* Hash table iterator */
   int j;
 
   if( !db ){
@@ -97134,6 +104630,7 @@ SQLITE_API int sqlite3_close(sqlite3 *db){
     for(p=db->aFunc.a[j]; p; p=pHash){
       pHash = p->pHash;
       while( p ){
+        functionDestroy(db, p);
         pNext = p->pNext;
         sqlite3DbFree(db, p);
         p = pNext;
@@ -97243,7 +104740,7 @@ SQLITE_PRIVATE const char *sqlite3ErrStr(int rc){
     /* SQLITE_NOTFOUND    */ 0,
     /* SQLITE_FULL        */ "database or disk is full",
     /* SQLITE_CANTOPEN    */ "unable to open database file",
-    /* SQLITE_PROTOCOL    */ 0,
+    /* SQLITE_PROTOCOL    */ "locking protocol",
     /* SQLITE_EMPTY       */ "table contains no data",
     /* SQLITE_SCHEMA      */ "database schema has changed",
     /* SQLITE_TOOBIG      */ "string or blob too big",
@@ -97408,7 +104905,8 @@ SQLITE_PRIVATE int sqlite3CreateFunc(
   void *pUserData,
   void (*xFunc)(sqlite3_context*,int,sqlite3_value **),
   void (*xStep)(sqlite3_context*,int,sqlite3_value **),
-  void (*xFinal)(sqlite3_context*)
+  void (*xFinal)(sqlite3_context*),
+  FuncDestructor *pDestructor
 ){
   FuncDef *p;
   int nName;
@@ -97436,10 +104934,10 @@ SQLITE_PRIVATE int sqlite3CreateFunc(
   }else if( enc==SQLITE_ANY ){
     int rc;
     rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,
-         pUserData, xFunc, xStep, xFinal);
+         pUserData, xFunc, xStep, xFinal, pDestructor);
     if( rc==SQLITE_OK ){
       rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,
-          pUserData, xFunc, xStep, xFinal);
+          pUserData, xFunc, xStep, xFinal, pDestructor);
     }
     if( rc!=SQLITE_OK ){
       return rc;
@@ -97472,6 +104970,15 @@ SQLITE_PRIVATE int sqlite3CreateFunc(
   if( !p ){
     return SQLITE_NOMEM;
   }
+
+  /* If an older version of the function with a configured destructor is
+  ** being replaced invoke the destructor function here. */
+  functionDestroy(db, p);
+
+  if( pDestructor ){
+    pDestructor->nRef++;
+  }
+  p->pDestructor = pDestructor;
   p->flags = 0;
   p->xFunc = xFunc;
   p->xStep = xStep;
@@ -97486,7 +104993,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc(
 */
 SQLITE_API int sqlite3_create_function(
   sqlite3 *db,
-  const char *zFunctionName,
+  const char *zFunc,
   int nArg,
   int enc,
   void *p,
@@ -97494,9 +105001,41 @@ SQLITE_API int sqlite3_create_function(
   void (*xStep)(sqlite3_context*,int,sqlite3_value **),
   void (*xFinal)(sqlite3_context*)
 ){
-  int rc;
+  return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
+                                    xFinal, 0);
+}
+
+SQLITE_API int sqlite3_create_function_v2(
+  sqlite3 *db,
+  const char *zFunc,
+  int nArg,
+  int enc,
+  void *p,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value **),
+  void (*xFinal)(sqlite3_context*),
+  void (*xDestroy)(void *)
+){
+  int rc = SQLITE_ERROR;
+  FuncDestructor *pArg = 0;
   sqlite3_mutex_enter(db->mutex);
-  rc = sqlite3CreateFunc(db, zFunctionName, nArg, enc, p, xFunc, xStep, xFinal);
+  if( xDestroy ){
+    pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));
+    if( !pArg ){
+      xDestroy(p);
+      goto out;
+    }
+    pArg->xDestroy = xDestroy;
+    pArg->pUserData = p;
+  }
+  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xFunc, xStep, xFinal, pArg);
+  if( pArg && pArg->nRef==0 ){
+    assert( rc!=SQLITE_OK );
+    xDestroy(p);
+    sqlite3DbFree(db, pArg);
+  }
+
+ out:
   rc = sqlite3ApiExit(db, rc);
   sqlite3_mutex_leave(db->mutex);
   return rc;
@@ -97518,7 +105057,7 @@ SQLITE_API int sqlite3_create_function16(
   sqlite3_mutex_enter(db->mutex);
   assert( !db->mallocFailed );
   zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
-  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
+  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal,0);
   sqlite3DbFree(db, zFunc8);
   rc = sqlite3ApiExit(db, rc);
   sqlite3_mutex_leave(db->mutex);
@@ -97549,7 +105088,7 @@ SQLITE_API int sqlite3_overload_function(
   sqlite3_mutex_enter(db->mutex);
   if( sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0)==0 ){
     sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,
-                      0, sqlite3InvalidFunction, 0, 0);
+                      0, sqlite3InvalidFunction, 0, 0, 0);
   }
   rc = sqlite3ApiExit(db, SQLITE_OK);
   sqlite3_mutex_leave(db->mutex);
@@ -97653,6 +105192,139 @@ SQLITE_API void *sqlite3_rollback_hook(
   return pRet;
 }
 
+#ifndef SQLITE_OMIT_WAL
+/*
+** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
+** Invoke sqlite3_wal_checkpoint if the number of frames in the log file
+** is greater than sqlite3.pWalArg cast to an integer (the value configured by
+** wal_autocheckpoint()).
+*/ 
+SQLITE_PRIVATE int sqlite3WalDefaultHook(
+  void *pClientData,     /* Argument */
+  sqlite3 *db,           /* Connection */
+  const char *zDb,       /* Database */
+  int nFrame             /* Size of WAL */
+){
+  if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){
+    sqlite3BeginBenignMalloc();
+    sqlite3_wal_checkpoint(db, zDb);
+    sqlite3EndBenignMalloc();
+  }
+  return SQLITE_OK;
+}
+#endif /* SQLITE_OMIT_WAL */
+
+/*
+** Configure an sqlite3_wal_hook() callback to automatically checkpoint
+** a database after committing a transaction if there are nFrame or
+** more frames in the log file. Passing zero or a negative value as the
+** nFrame parameter disables automatic checkpoints entirely.
+**
+** The callback registered by this function replaces any existing callback
+** registered using sqlite3_wal_hook(). Likewise, registering a callback
+** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
+** configured by this function.
+*/
+SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
+#ifdef SQLITE_OMIT_WAL
+  UNUSED_PARAMETER(db);
+  UNUSED_PARAMETER(nFrame);
+#else
+  if( nFrame>0 ){
+    sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));
+  }else{
+    sqlite3_wal_hook(db, 0, 0);
+  }
+#endif
+  return SQLITE_OK;
+}
+
+/*
+** Register a callback to be invoked each time a transaction is written
+** into the write-ahead-log by this database connection.
+*/
+SQLITE_API void *sqlite3_wal_hook(
+  sqlite3 *db,                    /* Attach the hook to this db handle */
+  int(*xCallback)(void *, sqlite3*, const char*, int),
+  void *pArg                      /* First argument passed to xCallback() */
+){
+#ifndef SQLITE_OMIT_WAL
+  void *pRet;
+  sqlite3_mutex_enter(db->mutex);
+  pRet = db->pWalArg;
+  db->xWalCallback = xCallback;
+  db->pWalArg = pArg;
+  sqlite3_mutex_leave(db->mutex);
+  return pRet;
+#else
+  return 0;
+#endif
+}
+
+
+/*
+** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
+** to contains a zero-length string, all attached databases are 
+** checkpointed.
+*/
+SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
+#ifdef SQLITE_OMIT_WAL
+  return SQLITE_OK;
+#else
+  int rc;                         /* Return code */
+  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */
+
+  sqlite3_mutex_enter(db->mutex);
+  if( zDb && zDb[0] ){
+    iDb = sqlite3FindDbName(db, zDb);
+  }
+  if( iDb<0 ){
+    rc = SQLITE_ERROR;
+    sqlite3Error(db, SQLITE_ERROR, "unknown database: %s", zDb);
+  }else{
+    rc = sqlite3Checkpoint(db, iDb);
+    sqlite3Error(db, rc, 0);
+  }
+  rc = sqlite3ApiExit(db, rc);
+  sqlite3_mutex_leave(db->mutex);
+  return rc;
+#endif
+}
+
+#ifndef SQLITE_OMIT_WAL
+/*
+** Run a checkpoint on database iDb. This is a no-op if database iDb is
+** not currently open in WAL mode.
+**
+** If a transaction is open on the database being checkpointed, this 
+** function returns SQLITE_LOCKED and a checkpoint is not attempted. If 
+** an error occurs while running the checkpoint, an SQLite error code is 
+** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.
+**
+** The mutex on database handle db should be held by the caller. The mutex
+** associated with the specific b-tree being checkpointed is taken by
+** this function while the checkpoint is running.
+**
+** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are
+** checkpointed. If an error is encountered it is returned immediately -
+** no attempt is made to checkpoint any remaining databases.
+*/
+SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb){
+  int rc = SQLITE_OK;             /* Return code */
+  int i;                          /* Used to iterate through attached dbs */
+
+  assert( sqlite3_mutex_held(db->mutex) );
+
+  for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
+    if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){
+      rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt);
+    }
+  }
+
+  return rc;
+}
+#endif /* SQLITE_OMIT_WAL */
+
 /*
 ** This function returns true if main-memory should be used instead of
 ** a temporary file for transient pager files and statement journals.
@@ -97688,60 +105360,6 @@ SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){
 }
 
 /*
-** This routine is called to create a connection to a database BTree
-** driver.  If zFilename is the name of a file, then that file is
-** opened and used.  If zFilename is the magic name ":memory:" then
-** the database is stored in memory (and is thus forgotten as soon as
-** the connection is closed.)  If zFilename is NULL then the database
-** is a "virtual" database for transient use only and is deleted as
-** soon as the connection is closed.
-**
-** A virtual database can be either a disk file (that is automatically
-** deleted when the file is closed) or it an be held entirely in memory.
-** The sqlite3TempInMemory() function is used to determine which.
-*/
-SQLITE_PRIVATE int sqlite3BtreeFactory(
-  sqlite3 *db,              /* Main database when opening aux otherwise 0 */
-  const char *zFilename,    /* Name of the file containing the BTree database */
-  int omitJournal,          /* if TRUE then do not journal this file */
-  int nCache,               /* How many pages in the page cache */
-  int vfsFlags,             /* Flags passed through to vfsOpen */
-  Btree **ppBtree           /* Pointer to new Btree object written here */
-){
-  int btFlags = 0;
-  int rc;
-  
-  assert( sqlite3_mutex_held(db->mutex) );
-  assert( ppBtree != 0);
-  if( omitJournal ){
-    btFlags |= BTREE_OMIT_JOURNAL;
-  }
-  if( db->flags & SQLITE_NoReadlock ){
-    btFlags |= BTREE_NO_READLOCK;
-  }
-#ifndef SQLITE_OMIT_MEMORYDB
-  if( zFilename==0 && sqlite3TempInMemory(db) ){
-    zFilename = ":memory:";
-  }
-#endif
-
-  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (zFilename==0 || *zFilename==0) ){
-    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;
-  }
-  rc = sqlite3BtreeOpen(zFilename, (sqlite3 *)db, ppBtree, btFlags, vfsFlags);
-
-  /* If the B-Tree was successfully opened, set the pager-cache size to the
-  ** default value. Except, if the call to BtreeOpen() returned a handle
-  ** open on an existing shared pager-cache, do not change the pager-cache 
-  ** size.
-  */
-  if( rc==SQLITE_OK && 0==sqlite3BtreeSchema(*ppBtree, 0, 0) ){
-    sqlite3BtreeSetCacheSize(*ppBtree, nCache);
-  }
-  return rc;
-}
-
-/*
 ** Return UTF-8 encoded English language explanation of the most recent
 ** error.
 */
@@ -97983,17 +105601,39 @@ static const int aHardLimit[] = {
 */
 SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
   int oldLimit;
+
+
+  /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME
+  ** there is a hard upper bound set at compile-time by a C preprocessor
+  ** macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to
+  ** "_MAX_".)
+  */
+  assert( aHardLimit[SQLITE_LIMIT_LENGTH]==SQLITE_MAX_LENGTH );
+  assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH]==SQLITE_MAX_SQL_LENGTH );
+  assert( aHardLimit[SQLITE_LIMIT_COLUMN]==SQLITE_MAX_COLUMN );
+  assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH]==SQLITE_MAX_EXPR_DEPTH );
+  assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT]==SQLITE_MAX_COMPOUND_SELECT);
+  assert( aHardLimit[SQLITE_LIMIT_VDBE_OP]==SQLITE_MAX_VDBE_OP );
+  assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG]==SQLITE_MAX_FUNCTION_ARG );
+  assert( aHardLimit[SQLITE_LIMIT_ATTACHED]==SQLITE_MAX_ATTACHED );
+  assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]==
+                                               SQLITE_MAX_LIKE_PATTERN_LENGTH );
+  assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER]==SQLITE_MAX_VARIABLE_NUMBER);
+  assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH]==SQLITE_MAX_TRIGGER_DEPTH );
+  assert( SQLITE_LIMIT_TRIGGER_DEPTH==(SQLITE_N_LIMIT-1) );
+
+
   if( limitId<0 || limitId>=SQLITE_N_LIMIT ){
     return -1;
   }
   oldLimit = db->aLimit[limitId];
-  if( newLimit>=0 ){
+  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */
     if( newLimit>aHardLimit[limitId] ){
-      newLimit = aHardLimit[limitId];
+      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */
     }
     db->aLimit[limitId] = newLimit;
   }
-  return oldLimit;
+  return oldLimit;                     /* IMP: R-53341-35419 */
 }
 
 /*
@@ -98017,6 +105657,24 @@ static int openDatabase(
   if( rc ) return rc;
 #endif
 
+  /* Only allow sensible combinations of bits in the flags argument.  
+  ** Throw an error if any non-sense combination is used.  If we
+  ** do not block illegal combinations here, it could trigger
+  ** assert() statements in deeper layers.  Sensible combinations
+  ** are:
+  **
+  **  1:  SQLITE_OPEN_READONLY
+  **  2:  SQLITE_OPEN_READWRITE
+  **  6:  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
+  */
+  assert( SQLITE_OPEN_READONLY  == 0x01 );
+  assert( SQLITE_OPEN_READWRITE == 0x02 );
+  assert( SQLITE_OPEN_CREATE    == 0x04 );
+  testcase( (1<<(flags&7))==0x02 ); /* READONLY */
+  testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
+  testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
+  if( ((1<<(flags&7)) & 0x46)==0 ) return SQLITE_MISUSE;
+
   if( sqlite3GlobalConfig.bCoreMutex==0 ){
     isThreadsafe = 0;
   }else if( flags & SQLITE_OPEN_NOMUTEX ){
@@ -98050,7 +105708,8 @@ static int openDatabase(
                SQLITE_OPEN_SUBJOURNAL | 
                SQLITE_OPEN_MASTER_JOURNAL |
                SQLITE_OPEN_NOMUTEX |
-               SQLITE_OPEN_FULLMUTEX
+               SQLITE_OPEN_FULLMUTEX |
+               SQLITE_OPEN_WAL
              );
 
   /* Allocate the sqlite data structure */
@@ -98075,7 +105734,7 @@ static int openDatabase(
   db->autoCommit = 1;
   db->nextAutovac = -1;
   db->nextPagesize = 0;
-  db->flags |= SQLITE_ShortColNames
+  db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex
 #if SQLITE_DEFAULT_FILE_FORMAT<4
                  | SQLITE_LegacyFileFmt
 #endif
@@ -98122,9 +105781,8 @@ static int openDatabase(
 
   /* Open the backend database driver */
   db->openFlags = flags;
-  rc = sqlite3BtreeFactory(db, zFilename, 0, SQLITE_DEFAULT_CACHE_SIZE, 
-                           flags | SQLITE_OPEN_MAIN_DB,
-                           &db->aDb[0].pBt);
+  rc = sqlite3BtreeOpen(zFilename, db, &db->aDb[0].pBt, 0,
+                        flags | SQLITE_OPEN_MAIN_DB);
   if( rc!=SQLITE_OK ){
     if( rc==SQLITE_IOERR_NOMEM ){
       rc = SQLITE_NOMEM;
@@ -98213,6 +105871,8 @@ static int openDatabase(
   setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,
                         sqlite3GlobalConfig.nLookaside);
 
+  sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
+
 opendb_out:
   if( db ){
     assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 );
@@ -98387,7 +106047,6 @@ SQLITE_API int sqlite3_collation_needed16(
 }
 #endif /* SQLITE_OMIT_UTF16 */
 
-#ifndef SQLITE_OMIT_GLOBALRECOVER
 #ifndef SQLITE_OMIT_DEPRECATED
 /*
 ** This function is now an anachronism. It used to be used to recover from a
@@ -98397,7 +106056,6 @@ SQLITE_API int sqlite3_global_recover(void){
   return SQLITE_OK;
 }
 #endif
-#endif
 
 /*
 ** Test to see whether or not the database connection is in autocommit
@@ -98425,17 +106083,22 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
 SQLITE_PRIVATE int sqlite3CorruptError(int lineno){
   testcase( sqlite3GlobalConfig.xLog!=0 );
   sqlite3_log(SQLITE_CORRUPT,
-              "database corruption found by source line %d", lineno);
+              "database corruption at line %d of [%.10s]",
+              lineno, 20+sqlite3_sourceid());
   return SQLITE_CORRUPT;
 }
 SQLITE_PRIVATE int sqlite3MisuseError(int lineno){
   testcase( sqlite3GlobalConfig.xLog!=0 );
-  sqlite3_log(SQLITE_MISUSE, "misuse detected by source line %d", lineno);
+  sqlite3_log(SQLITE_MISUSE, 
+              "misuse at line %d of [%.10s]",
+              lineno, 20+sqlite3_sourceid());
   return SQLITE_MISUSE;
 }
 SQLITE_PRIVATE int sqlite3CantopenError(int lineno){
   testcase( sqlite3GlobalConfig.xLog!=0 );
-  sqlite3_log(SQLITE_CANTOPEN, "cannot open file at source line %d", lineno);
+  sqlite3_log(SQLITE_CANTOPEN, 
+              "cannot open file at line %d of [%.10s]",
+              lineno, 20+sqlite3_sourceid());
   return SQLITE_CANTOPEN;
 }
 
@@ -98707,9 +106370,13 @@ SQLITE_API int sqlite3_test_control(int op, ...){
     ** dileterious behavior.
     */
     case SQLITE_TESTCTRL_PENDING_BYTE: {
-      unsigned int newVal = va_arg(ap, unsigned int);
-      rc = sqlite3PendingByte;
-      if( newVal ) sqlite3PendingByte = newVal;
+      rc = PENDING_BYTE;
+#ifndef SQLITE_OMIT_WSD
+      {
+        unsigned int newVal = va_arg(ap, unsigned int);
+        if( newVal ) sqlite3PendingByte = newVal;
+      }
+#endif
       break;
     }
 
@@ -98813,6 +106480,31 @@ SQLITE_API int sqlite3_test_control(int op, ...){
     }
 #endif 
 
+    /* sqlite3_test_control(SQLITE_TESTCTRL_PGHDRSZ)
+    **
+    ** Return the size of a pcache header in bytes.
+    */
+    case SQLITE_TESTCTRL_PGHDRSZ: {
+      rc = sizeof(PgHdr);
+      break;
+    }
+
+    /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree);
+    **
+    ** Pass pFree into sqlite3ScratchFree(). 
+    ** If sz>0 then allocate a scratch buffer into pNew.  
+    */
+    case SQLITE_TESTCTRL_SCRATCHMALLOC: {
+      void *pFree, **ppNew;
+      int sz;
+      sz = va_arg(ap, int);
+      ppNew = va_arg(ap, void**);
+      pFree = va_arg(ap, void*);
+      if( sz ) *ppNew = sqlite3ScratchMalloc(sz);
+      sqlite3ScratchFree(pFree);
+      break;
+    }
+
   }
   va_end(ap);
 #endif /* SQLITE_OMIT_BUILTIN_TEST */
@@ -98978,6 +106670,7 @@ SQLITE_API int sqlite3_unlock_notify(
 
   if( xNotify==0 ){
     removeFromBlockedList(db);
+    db->pBlockingConnection = 0;
     db->pUnlockConnection = 0;
     db->xUnlockNotify = 0;
     db->pUnlockArg = 0;
@@ -99075,7 +106768,7 @@ SQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){
       assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );
       assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );
       if( (!aDyn && nArg==(int)ArraySize(aStatic))
-       || (aDyn && nArg==(int)(sqlite3DbMallocSize(db, aDyn)/sizeof(void*)))
+       || (aDyn && nArg==(int)(sqlite3MallocSize(aDyn)/sizeof(void*)))
       ){
         /* The aArg[] array needs to grow. */
         void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);
@@ -99203,7 +106896,7 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 ** This is similar in concept to how sqlite encodes "varints" but
 ** the encoding is not the same.  SQLite varints are big-endian
 ** are are limited to 9 bytes in length whereas FTS3 varints are
-** little-endian and can be upt to 10 bytes in length (in theory).
+** little-endian and can be up to 10 bytes in length (in theory).
 **
 ** Example encodings:
 **
@@ -99214,26 +106907,26 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 **
 **** Document lists ****
 ** A doclist (document list) holds a docid-sorted list of hits for a
-** given term.  Doclists hold docids, and can optionally associate
-** token positions and offsets with docids.  A position is the index
-** of a word within the document.  The first word of the document has
-** a position of 0.
+** given term.  Doclists hold docids and associated token positions.
+** A docid is the unique integer identifier for a single document.
+** A position is the index of a word within the document.  The first 
+** word of the document has a position of 0.
 **
 ** FTS3 used to optionally store character offsets using a compile-time
 ** option.  But that functionality is no longer supported.
 **
-** A DL_POSITIONS_OFFSETS doclist is stored like this:
+** A doclist is stored like this:
 **
 ** array {
 **   varint docid;
 **   array {                (position list for column 0)
-**     varint position;     (delta from previous position plus POS_BASE)
+**     varint position;     (2 more than the delta from previous position)
 **   }
 **   array {
 **     varint POS_COLUMN;   (marks start of position list for new column)
 **     varint column;       (index of new column)
 **     array {
-**       varint position;   (delta from previous position plus POS_BASE)
+**       varint position;   (2 more than the delta from previous position)
 **     }
 **   }
 **   varint POS_END;        (marks end of positions for this document.
@@ -99245,7 +106938,7 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 ** in the same logical place as the position element, and act as sentinals
 ** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.
 ** The positions numbers are not stored literally but rather as two more
-** the difference from the prior position, or the just the position plus
+** than the difference from the prior position, or the just the position plus
 ** 2 for the first position.  Example:
 **
 **   label:       A B C D E  F  G H   I  J K
@@ -99259,14 +106952,14 @@ SQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){
 ** 234 at I is the next docid.  It has one position 72 (72-2) and then
 ** terminates with the 0 at K.
 **
-** A DL_POSITIONS doclist omits the startOffset and endOffset
-** information.  A DL_DOCIDS doclist omits both the position and
-** offset information, becoming an array of varint-encoded docids.
-**
-** On-disk data is stored as type DL_DEFAULT, so we don't serialize
-** the type.  Due to how deletion is implemented in the segmentation
-** system, on-disk doclists MUST store at least positions.
+** A "position-list" is the list of positions for multiple columns for
+** a single docid.  A "column-list" is the set of positions for a single
+** column.  Hence, a position-list consists of one or more column-lists,
+** a document record consists of a docid followed by a position-list and
+** a doclist consists of one or more document records.
 **
+** A bare doclist omits the position information, becoming an 
+** array of varint-encoded docids.
 **
 **** Segment leaf nodes ****
 ** Segment leaf nodes store terms and doclists, ordered by term.  Leaf
@@ -99781,6 +107474,20 @@ SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const voi
 #define FTS3_VARINT_MAX 10
 
 /*
+** The testcase() macro is only used by the amalgamation.  If undefined,
+** make it a no-op.
+*/
+#ifndef testcase
+# define testcase(X)
+#endif
+
+/*
+** Terminator values for position-lists and column-lists.
+*/
+#define POS_COLUMN  (1)     /* Column-list terminator */
+#define POS_END     (0)     /* Position-list terminator */ 
+
+/*
 ** This section provides definitions to allow the
 ** FTS3 extension to be compiled outside of the 
 ** amalgamation.
@@ -99986,6 +107693,7 @@ SQLITE_PRIVATE int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char const**,
 SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table*, sqlite3_stmt **);
 SQLITE_PRIVATE int sqlite3Fts3MatchinfoDocsizeLocal(Fts3Cursor*, u32*);
 SQLITE_PRIVATE int sqlite3Fts3MatchinfoDocsizeGlobal(Fts3Cursor*, u32*);
+SQLITE_PRIVATE int sqlite3Fts3ReadLock(Fts3Table *);
 
 /* Flags allowed as part of the 4th argument to SegmentReaderIterate() */
 #define FTS3_SEGMENT_REQUIRE_POS   0x00000001
@@ -100091,8 +107799,7 @@ SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
 }
 
 /*
-** Return the number of bytes required to store the value passed as the
-** first argument in varint form.
+** Return the number of bytes required to encode v as a varint
 */
 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64 v){
   int i = 0;
@@ -100143,7 +107850,7 @@ SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){
 
 /*
 ** Read a single varint from the doclist at *pp and advance *pp to point
-** to the next element of the varlist.  Add the value of the varint
+** to the first byte past the end of the varint.  Add the value of the varint
 ** to *pVal.
 */
 static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){
@@ -100199,7 +107906,7 @@ static int fts3DisconnectMethod(sqlite3_vtab *pVtab){
 **
 ** If *pRc is initially non-zero then this routine is a no-op.
 */
-void fts3DbExec(
+static void fts3DbExec(
   int *pRc,              /* Success code */
   sqlite3 *db,           /* Database in which to run SQL */
   const char *zFormat,   /* Format string for SQL */
@@ -100279,6 +107986,10 @@ static int fts3DeclareVtab(Fts3Table *p){
 ** Create the backing store tables (%_content, %_segments and %_segdir)
 ** required by the FTS3 table passed as the only argument. This is done
 ** as part of the vtab xCreate() method.
+**
+** If the p->bHasDocsize boolean is true (indicating that this is an
+** FTS4 table, not an FTS3 table) then also create the %_docsize and
+** %_stat tables required by FTS4.
 */
 static int fts3CreateTables(Fts3Table *p){
   int rc = SQLITE_OK;             /* Return code */
@@ -100336,6 +108047,9 @@ static int fts3CreateTables(Fts3Table *p){
 ** An sqlite3_exec() callback for fts3TableExists.
 */
 static int fts3TableExistsCallback(void *pArg, int n, char **pp1, char **pp2){
+  UNUSED_PARAMETER(n);
+  UNUSED_PARAMETER(pp1);
+  UNUSED_PARAMETER(pp2);
   *(int*)pArg = 1;
   return 1;
 }
@@ -100361,7 +108075,7 @@ static void fts3TableExists(
   );    
   rc = sqlite3_exec(db, zSql, fts3TableExistsCallback, &res, 0);
   sqlite3_free(zSql);
-  *pResult = res & 0xff;
+  *pResult = (u8)(res & 0xff);
   if( rc!=SQLITE_ABORT ) *pRc = rc;
 }
 
@@ -100371,7 +108085,7 @@ static void fts3TableExists(
 **
 ** The argv[] array contains the following:
 **
-**   argv[0]   -> module name
+**   argv[0]   -> module name  ("fts3" or "fts4")
 **   argv[1]   -> database name
 **   argv[2]   -> table name
 **   argv[...] -> "column name" and other module argument fields.
@@ -100390,12 +108104,12 @@ static int fts3InitVtab(
   int rc;                         /* Return code */
   int i;                          /* Iterator variable */
   int nByte;                      /* Size of allocation used for *p */
-  int iCol;
-  int nString = 0;
-  int nCol = 0;
-  char *zCsr;
-  int nDb;
-  int nName;
+  int iCol;                       /* Column index */
+  int nString = 0;                /* Bytes required to hold all column names */
+  int nCol = 0;                   /* Number of columns in the FTS table */
+  char *zCsr;                     /* Space for holding column names */
+  int nDb;                        /* Bytes required to hold database name */
+  int nName;                      /* Bytes required to hold table name */
 
   const char *zTokenizer = 0;               /* Name of tokenizer to use */
   sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */
@@ -100625,6 +108339,11 @@ static int fulltextClose(sqlite3_vtab_cursor *pCursor){
   return SQLITE_OK;
 }
 
+/*
+** Position the pCsr->pStmt statement so that it is on the row
+** of the %_content table that contains the last match.  Return
+** SQLITE_OK on success.  
+*/
 static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
   if( pCsr->isRequireSeek ){
     pCsr->isRequireSeek = 0;
@@ -100651,6 +108370,17 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
   }
 }
 
+/*
+** Advance the cursor to the next row in the %_content table that
+** matches the search criteria.  For a MATCH search, this will be
+** the next row that matches.  For a full-table scan, this will be
+** simply the next row in the %_content table.  For a docid lookup,
+** this routine simply sets the EOF flag.
+**
+** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned
+** even if we reach end-of-file.  The fts3EofMethod() will be called
+** subsequently to determine whether or not an EOF was hit.
+*/
 static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){
   int rc = SQLITE_OK;             /* Return code */
   Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
@@ -100787,6 +108517,11 @@ static void fts3PutDeltaVarint(
 ** start of a position-list. After it returns, *ppPoslist points to the
 ** first byte after the position-list.
 **
+** A position list is list of positions (delta encoded) and columns for 
+** a single document record of a doclist.  So, in other words, this
+** routine advances *ppPoslist so that it points to the next docid in
+** the doclist, or to the first byte past the end of the doclist.
+**
 ** If pp is not NULL, then the contents of the position list are copied
 ** to *pp. *pp is set to point to the first byte past the last byte copied
 ** before this function returns.
@@ -100796,17 +108531,20 @@ static void fts3PoslistCopy(char **pp, char **ppPoslist){
   char c = 0;
 
   /* The end of a position list is marked by a zero encoded as an FTS3 
-  ** varint. A single 0x00 byte. Except, if the 0x00 byte is preceded by
+  ** varint. A single POS_END (0) byte. Except, if the 0 byte is preceded by
   ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail
   ** of some other, multi-byte, value.
   **
-  ** The following block moves pEnd to point to the first byte that is not 
+  ** The following while-loop moves pEnd to point to the first byte that is not 
   ** immediately preceded by a byte with the 0x80 bit set. Then increments
   ** pEnd once more so that it points to the byte immediately following the
   ** last byte in the position-list.
   */
-  while( *pEnd | c ) c = *pEnd++ & 0x80;
-  pEnd++;
+  while( *pEnd | c ){
+    c = *pEnd++ & 0x80;
+    testcase( c!=0 && (*pEnd)==0 );
+  }
+  pEnd++;  /* Advance past the POS_END terminator byte */
 
   if( pp ){
     int n = (int)(pEnd - *ppPoslist);
@@ -100818,12 +108556,34 @@ static void fts3PoslistCopy(char **pp, char **ppPoslist){
   *ppPoslist = pEnd;
 }
 
+/*
+** When this function is called, *ppPoslist is assumed to point to the 
+** start of a column-list. After it returns, *ppPoslist points to the
+** to the terminator (POS_COLUMN or POS_END) byte of the column-list.
+**
+** A column-list is list of delta-encoded positions for a single column
+** within a single document within a doclist.
+**
+** The column-list is terminated either by a POS_COLUMN varint (1) or
+** a POS_END varint (0).  This routine leaves *ppPoslist pointing to
+** the POS_COLUMN or POS_END that terminates the column-list.
+**
+** If pp is not NULL, then the contents of the column-list are copied
+** to *pp. *pp is set to point to the first byte past the last byte copied
+** before this function returns.  The POS_COLUMN or POS_END terminator
+** is not copied into *pp.
+*/
 static void fts3ColumnlistCopy(char **pp, char **ppPoslist){
   char *pEnd = *ppPoslist;
   char c = 0;
 
-  /* A column-list is terminated by either a 0x01 or 0x00. */
-  while( 0xFE & (*pEnd | c) ) c = *pEnd++ & 0x80;
+  /* A column-list is terminated by either a 0x01 or 0x00 byte that is
+  ** not part of a multi-byte varint.
+  */
+  while( 0xFE & (*pEnd | c) ){
+    c = *pEnd++ & 0x80;
+    testcase( c!=0 && ((*pEnd)&0xfe)==0 );
+  }
   if( pp ){
     int n = (int)(pEnd - *ppPoslist);
     char *p = *pp;
@@ -100835,37 +108595,45 @@ static void fts3ColumnlistCopy(char **pp, char **ppPoslist){
 }
 
 /*
-** Value used to signify the end of an offset-list. This is safe because
+** Value used to signify the end of an position-list. This is safe because
 ** it is not possible to have a document with 2^31 terms.
 */
-#define OFFSET_LIST_END 0x7fffffff
+#define POSITION_LIST_END 0x7fffffff
 
 /*
-** This function is used to help parse offset-lists. When this function is
-** called, *pp may point to the start of the next varint in the offset-list
-** being parsed, or it may point to 1 byte past the end of the offset-list
-** (in which case **pp will be 0x00 or 0x01).
+** This function is used to help parse position-lists. When this function is
+** called, *pp may point to the start of the next varint in the position-list
+** being parsed, or it may point to 1 byte past the end of the position-list
+** (in which case **pp will be a terminator bytes POS_END (0) or
+** (1)).
 **
-** If *pp points past the end of the current offset list, set *pi to 
-** OFFSET_LIST_END and return. Otherwise, read the next varint from *pp,
+** If *pp points past the end of the current position-list, set *pi to 
+** POSITION_LIST_END and return. Otherwise, read the next varint from *pp,
 ** increment the current value of *pi by the value read, and set *pp to
 ** point to the next value before returning.
+**
+** Before calling this routine *pi must be initialized to the value of
+** the previous position, or zero if we are reading the first position
+** in the position-list.  Because positions are delta-encoded, the value
+** of the previous position is needed in order to compute the value of
+** the next position.
 */
 static void fts3ReadNextPos(
-  char **pp,                      /* IN/OUT: Pointer into offset-list buffer */
-  sqlite3_int64 *pi               /* IN/OUT: Value read from offset-list */
+  char **pp,                    /* IN/OUT: Pointer into position-list buffer */
+  sqlite3_int64 *pi             /* IN/OUT: Value read from position-list */
 ){
-  if( **pp&0xFE ){
+  if( (**pp)&0xFE ){
     fts3GetDeltaVarint(pp, pi);
     *pi -= 2;
   }else{
-    *pi = OFFSET_LIST_END;
+    *pi = POSITION_LIST_END;
   }
 }
 
 /*
-** If parameter iCol is not 0, write an 0x01 byte followed by the value of
-** iCol encoded as a varint to *pp. 
+** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by
+** the value of iCol encoded as a varint to *pp.   This will start a new
+** column list.
 **
 ** Set *pp to point to the byte just after the last byte written before 
 ** returning (do not modify it if iCol==0). Return the total number of bytes
@@ -100883,7 +108651,11 @@ static int fts3PutColNumber(char **pp, int iCol){
 }
 
 /*
-**
+** Compute the union of two position lists.  The output written
+** into *pp contains all positions of both *pp1 and *pp2 in sorted
+** order and with any duplicates removed.  All pointers are
+** updated appropriately.   The caller is responsible for insuring
+** that there is enough space in *pp to hold the complete output.
 */
 static void fts3PoslistMerge(
   char **pp,                      /* Output buffer */
@@ -100895,32 +108667,33 @@ static void fts3PoslistMerge(
   char *p2 = *pp2;
 
   while( *p1 || *p2 ){
-    int iCol1;
-    int iCol2;
+    int iCol1;         /* The current column index in pp1 */
+    int iCol2;         /* The current column index in pp2 */
 
-    if( *p1==0x01 ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);
-    else if( *p1==0x00 ) iCol1 = OFFSET_LIST_END;
+    if( *p1==POS_COLUMN ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);
+    else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
     else iCol1 = 0;
 
-    if( *p2==0x01 ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);
-    else if( *p2==0x00 ) iCol2 = OFFSET_LIST_END;
+    if( *p2==POS_COLUMN ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);
+    else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
     else iCol2 = 0;
 
     if( iCol1==iCol2 ){
-      sqlite3_int64 i1 = 0;
-      sqlite3_int64 i2 = 0;
+      sqlite3_int64 i1 = 0;       /* Last position from pp1 */
+      sqlite3_int64 i2 = 0;       /* Last position from pp2 */
       sqlite3_int64 iPrev = 0;
       int n = fts3PutColNumber(&p, iCol1);
       p1 += n;
       p2 += n;
 
-      /* At this point, both p1 and p2 point to the start of offset-lists.
-      ** An offset-list is a list of non-negative delta-encoded varints, each 
-      ** incremented by 2 before being stored. Each list is terminated by a 0 
-      ** or 1 value (0x00 or 0x01). The following block merges the two lists
+      /* At this point, both p1 and p2 point to the start of column-lists
+      ** for the same column (the column with index iCol1 and iCol2).
+      ** A column-list is a list of non-negative delta-encoded varints, each 
+      ** incremented by 2 before being stored. Each list is terminated by a
+      ** POS_END (0) or POS_COLUMN (1). The following block merges the two lists
       ** and writes the results to buffer p. p is left pointing to the byte
-      ** after the list written. No terminator (0x00 or 0x01) is written to
-      ** the output.
+      ** after the list written. No terminator (POS_END or POS_COLUMN) is
+      ** written to the output.
       */
       fts3GetDeltaVarint(&p1, &i1);
       fts3GetDeltaVarint(&p2, &i2);
@@ -100935,7 +108708,7 @@ static void fts3PoslistMerge(
         }else{
           fts3ReadNextPos(&p2, &i2);
         }
-      }while( i1!=OFFSET_LIST_END || i2!=OFFSET_LIST_END );
+      }while( i1!=POSITION_LIST_END || i2!=POSITION_LIST_END );
     }else if( iCol1<iCol2 ){
       p1 += fts3PutColNumber(&p, iCol1);
       fts3ColumnlistCopy(&p, &p1);
@@ -100945,7 +108718,7 @@ static void fts3PoslistMerge(
     }
   }
 
-  *p++ = '\0';
+  *p++ = POS_END;
   *pp = p;
   *pp1 = p1 + 1;
   *pp2 = p2 + 1;
@@ -100968,11 +108741,11 @@ static int fts3PoslistPhraseMerge(
   int iCol1 = 0;
   int iCol2 = 0;
   assert( *p1!=0 && *p2!=0 );
-  if( *p1==0x01 ){ 
+  if( *p1==POS_COLUMN ){ 
     p1++;
     p1 += sqlite3Fts3GetVarint32(p1, &iCol1);
   }
-  if( *p2==0x01 ){ 
+  if( *p2==POS_COLUMN ){ 
     p2++;
     p2 += sqlite3Fts3GetVarint32(p2, &iCol2);
   }
@@ -100985,11 +108758,12 @@ static int fts3PoslistPhraseMerge(
       sqlite3_int64 iPos2 = 0;
 
       if( pp && iCol1 ){
-        *p++ = 0x01;
+        *p++ = POS_COLUMN;
         p += sqlite3Fts3PutVarint(p, iCol1);
       }
 
-      assert( *p1!=0x00 && *p2!=0x00 && *p1!=0x01 && *p2!=0x01 );
+      assert( *p1!=POS_END && *p1!=POS_COLUMN );
+      assert( *p2!=POS_END && *p2!=POS_COLUMN );
       fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
       fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
 
@@ -101241,6 +109015,7 @@ static int fts3DoclistMerge(
     default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); {
       char *aTmp = 0;
       char **ppPos = 0;
+
       if( mergetype==MERGE_POS_NEAR ){
         ppPos = &p;
         aTmp = sqlite3_malloc(2*(n1+n2+1));
@@ -101286,11 +109061,59 @@ static int fts3DoclistMerge(
 typedef struct TermSelect TermSelect;
 struct TermSelect {
   int isReqPos;
-  char *aOutput;                  /* Malloc'd output buffer */
-  int nOutput;                    /* Size of output in bytes */
+  char *aaOutput[16];             /* Malloc'd output buffer */
+  int anOutput[16];               /* Size of output in bytes */
 };
 
 /*
+** Merge all doclists in the TermSelect.aaOutput[] array into a single
+** doclist stored in TermSelect.aaOutput[0]. If successful, delete all
+** other doclists (except the aaOutput[0] one) and return SQLITE_OK.
+**
+** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
+** the responsibility of the caller to free any doclists left in the
+** TermSelect.aaOutput[] array.
+*/
+static int fts3TermSelectMerge(TermSelect *pTS){
+  int mergetype = (pTS->isReqPos ? MERGE_POS_OR : MERGE_OR);
+  char *aOut = 0;
+  int nOut = 0;
+  int i;
+
+  /* Loop through the doclists in the aaOutput[] array. Merge them all
+  ** into a single doclist.
+  */
+  for(i=0; i<SizeofArray(pTS->aaOutput); i++){
+    if( pTS->aaOutput[i] ){
+      if( !aOut ){
+        aOut = pTS->aaOutput[i];
+        nOut = pTS->anOutput[i];
+        pTS->aaOutput[0] = 0;
+      }else{
+        int nNew = nOut + pTS->anOutput[i];
+        char *aNew = sqlite3_malloc(nNew);
+        if( !aNew ){
+          sqlite3_free(aOut);
+          return SQLITE_NOMEM;
+        }
+        fts3DoclistMerge(mergetype, 0, 0,
+            aNew, &nNew, pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut
+        );
+        sqlite3_free(pTS->aaOutput[i]);
+        sqlite3_free(aOut);
+        pTS->aaOutput[i] = 0;
+        aOut = aNew;
+        nOut = nNew;
+      }
+    }
+  }
+
+  pTS->aaOutput[0] = aOut;
+  pTS->anOutput[0] = nOut;
+  return SQLITE_OK;
+}
+
+/*
 ** This function is used as the sqlite3Fts3SegReaderIterate() callback when
 ** querying the full-text index for a doclist associated with a term or
 ** term-prefix.
@@ -101304,38 +109127,63 @@ static int fts3TermSelectCb(
   int nDoclist
 ){
   TermSelect *pTS = (TermSelect *)pContext;
-  int nNew = pTS->nOutput + nDoclist;
-  char *aNew = sqlite3_malloc(nNew);
 
   UNUSED_PARAMETER(p);
   UNUSED_PARAMETER(zTerm);
   UNUSED_PARAMETER(nTerm);
 
-  if( !aNew ){
-    return SQLITE_NOMEM;
-  }
-
-  if( pTS->nOutput==0 ){
+  if( pTS->aaOutput[0]==0 ){
     /* If this is the first term selected, copy the doclist to the output
     ** buffer using memcpy(). TODO: Add a way to transfer control of the
     ** aDoclist buffer from the caller so as to avoid the memcpy().
     */
-    memcpy(aNew, aDoclist, nDoclist);
+    pTS->aaOutput[0] = sqlite3_malloc(nDoclist);
+    pTS->anOutput[0] = nDoclist;
+    if( pTS->aaOutput[0] ){
+      memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
+    }else{
+      return SQLITE_NOMEM;
+    }
   }else{
-    /* The output buffer is not empty. Merge doclist aDoclist with the
-    ** existing output. This can only happen with prefix-searches (as
-    ** searches for exact terms return exactly one doclist).
-    */
     int mergetype = (pTS->isReqPos ? MERGE_POS_OR : MERGE_OR);
-    fts3DoclistMerge(mergetype, 0, 0,
-        aNew, &nNew, pTS->aOutput, pTS->nOutput, aDoclist, nDoclist
-    );
-  }
+    char *aMerge = aDoclist;
+    int nMerge = nDoclist;
+    int iOut;
+
+    for(iOut=0; iOut<SizeofArray(pTS->aaOutput); iOut++){
+      char *aNew;
+      int nNew;
+      if( pTS->aaOutput[iOut]==0 ){
+        assert( iOut>0 );
+        pTS->aaOutput[iOut] = aMerge;
+        pTS->anOutput[iOut] = nMerge;
+        break;
+      }
 
-  sqlite3_free(pTS->aOutput);
-  pTS->aOutput = aNew;
-  pTS->nOutput = nNew;
+      nNew = nMerge + pTS->anOutput[iOut];
+      aNew = sqlite3_malloc(nNew);
+      if( !aNew ){
+        if( aMerge!=aDoclist ){
+          sqlite3_free(aMerge);
+        }
+        return SQLITE_NOMEM;
+      }
+      fts3DoclistMerge(mergetype, 0, 0,
+          aNew, &nNew, pTS->aaOutput[iOut], pTS->anOutput[iOut], aMerge, nMerge
+      );
 
+      if( iOut>0 ) sqlite3_free(aMerge);
+      sqlite3_free(pTS->aaOutput[iOut]);
+      pTS->aaOutput[iOut] = 0;
+
+      aMerge = aNew;
+      nMerge = nNew;
+      if( (iOut+1)==SizeofArray(pTS->aaOutput) ){
+        pTS->aaOutput[iOut] = aMerge;
+        pTS->anOutput[iOut] = nMerge;
+      }
+    }
+  }
   return SQLITE_OK;
 }
 
@@ -101345,9 +109193,9 @@ static int fts3TermSelectCb(
 **
 ** The returned doclist may be in one of two formats, depending on the 
 ** value of parameter isReqPos. If isReqPos is zero, then the doclist is
-** a sorted list of delta-compressed docids. If isReqPos is non-zero, 
-** then the returned list is in the same format as is stored in the
-** database without the found length specifier at the start of on-disk
+** a sorted list of delta-compressed docids (a bare doclist). If isReqPos
+** is non-zero, then the returned list is in the same format as is stored 
+** in the database without the found length specifier at the start of on-disk
 ** doclists.
 */
 static int fts3TermSelect(
@@ -101459,12 +109307,17 @@ static int fts3TermSelect(
   rc = sqlite3Fts3SegReaderIterate(p, apSegment, nSegment, &filter,
       fts3TermSelectCb, (void *)&tsc
   );
+  if( rc==SQLITE_OK ){
+    rc = fts3TermSelectMerge(&tsc);
+  }
 
   if( rc==SQLITE_OK ){
-    *ppOut = tsc.aOutput;
-    *pnOut = tsc.nOutput;
+    *ppOut = tsc.aaOutput[0];
+    *pnOut = tsc.anOutput[0];
   }else{
-    sqlite3_free(tsc.aOutput);
+    for(i=0; i<SizeofArray(tsc.aaOutput); i++){
+      sqlite3_free(tsc.aaOutput[i]);
+    }
   }
 
 finished:
@@ -101607,7 +109460,9 @@ SQLITE_PRIVATE int sqlite3Fts3ExprNearTrim(Fts3Expr *pLeft, Fts3Expr *pRight, in
 
 /*
 ** Evaluate the full-text expression pExpr against fts3 table pTab. Store
-** the resulting doclist in *paOut and *pnOut.
+** the resulting doclist in *paOut and *pnOut.  This routine mallocs for
+** the space needed to store the output.  The caller is responsible for
+** freeing the space when it has finished.
 */
 static int evalFts3Expr(
   Fts3Table *p,                   /* Virtual table handle */
@@ -101788,6 +109643,9 @@ static int fts3FilterMethod(
       return rc;
     }
 
+    rc = sqlite3Fts3ReadLock(p);
+    if( rc!=SQLITE_OK ) return rc;
+
     rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
     pCsr->pNextId = pCsr->aDoclist;
     pCsr->iPrevId = 0;
@@ -102166,11 +110024,14 @@ static int fts3RenameMethod(
   const char *zName               /* New name of table */
 ){
   Fts3Table *p = (Fts3Table *)pVtab;
-  sqlite3 *db;                    /* Database connection */
+  sqlite3 *db = p->db;            /* Database connection */
   int rc;                         /* Return Code */
- 
-  db = p->db;
-  rc = SQLITE_OK;
+
+  rc = sqlite3Fts3PendingTermsFlush(p);
+  if( rc!=SQLITE_OK ){
+    return rc;
+  }
+
   fts3DbExec(&rc, db,
     "ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';",
     p->zDb, p->zName, zName
@@ -102238,7 +110099,7 @@ static void hashDestroy(void *p){
 ** used to retrieve the respective implementations.
 **
 ** Calling sqlite3Fts3SimpleTokenizerModule() sets the value pointed
-** to by the argument to point a the "simple" tokenizer implementation.
+** to by the argument to point to the "simple" tokenizer implementation.
 ** Function ...PorterTokenizerModule() sets *pModule to point to the
 ** porter tokenizer/stemmer implementation.
 */
@@ -102440,7 +110301,7 @@ struct ParseContext {
 ** negative values).
 */
 static int fts3isspace(char c){
-  return (c&0x80)==0 ? isspace(c) : 0;
+  return c==' ' || c=='\t' || c=='\n' || c=='\r' || c=='\v' || c=='\f';
 }
 
 /*
@@ -104827,6 +112688,9 @@ typedef struct simple_tokenizer_cursor {
 static int simpleDelim(simple_tokenizer *t, unsigned char c){
   return c<0x80 && t->delim[c];
 }
+static int fts3_isalnum(int x){
+  return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');
+}
 
 /*
 ** Create a new tokenizer instance.
@@ -104861,7 +112725,7 @@ static int simpleCreate(
     /* Mark non-alphanumeric ASCII characters as delimiters */
     int i;
     for(i=1; i<0x80; i++){
-      t->delim[i] = !isalnum(i) ? -1 : 0;
+      t->delim[i] = !fts3_isalnum(i) ? -1 : 0;
     }
   }
 
@@ -104967,7 +112831,7 @@ static int simpleNext(
         ** case-insensitivity.
         */
         unsigned char ch = p[iStartOffset+i];
-        c->pToken[i] = (char)(ch<0x80 ? tolower(ch) : ch);
+        c->pToken[i] = (char)((ch>='A' && ch<='Z') ? ch-'A'+'a' : ch);
       }
       *ppToken = c->pToken;
       *pnBytes = n;
@@ -105328,6 +113192,36 @@ SQLITE_PRIVATE int sqlite3Fts3ReadBlock(
 }
 
 /*
+** This function ensures that the caller has obtained a shared-cache
+** table-lock on the %_content table. This is required before reading
+** data from the fts3 table. If this lock is not acquired first, then
+** the caller may end up holding read-locks on the %_segments and %_segdir
+** tables, but no read-lock on the %_content table. If this happens 
+** a second connection will be able to write to the fts3 table, but
+** attempting to commit those writes might return SQLITE_LOCKED or
+** SQLITE_LOCKED_SHAREDCACHE (because the commit attempts to obtain 
+** write-locks on the %_segments and %_segdir ** tables). 
+**
+** We try to avoid this because if FTS3 returns any error when committing
+** a transaction, the whole transaction will be rolled back. And this is
+** not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. It can
+** still happen if the user reads data directly from the %_segments or
+** %_segdir tables instead of going through FTS3 though.
+*/
+SQLITE_PRIVATE int sqlite3Fts3ReadLock(Fts3Table *p){
+  int rc;                         /* Return code */
+  sqlite3_stmt *pStmt;            /* Statement used to obtain lock */
+
+  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pStmt, 0);
+  if( rc==SQLITE_OK ){
+    sqlite3_bind_null(pStmt, 1);
+    sqlite3_step(pStmt);
+    rc = sqlite3_reset(pStmt);
+  }
+  return rc;
+}
+
+/*
 ** Set *ppStmt to a statement handle that may be used to iterate through
 ** all rows in the %_segdir table, from oldest to newest. If successful,
 ** return SQLITE_OK. If an error occurs while preparing the statement, 
@@ -108167,7 +116061,7 @@ static int fts3StringAppend(
 ** is no way for fts3BestSnippet() to know whether or not the document 
 ** actually contains terms that follow the final highlighted term. 
 */
-int fts3SnippetShift(
+static int fts3SnippetShift(
   Fts3Table *pTab,                /* FTS3 table snippet comes from */
   int nSnippet,                   /* Number of tokens desired for snippet */
   const char *zDoc,               /* Document text to extract snippet from */
@@ -108818,6 +116712,45 @@ SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *
 ** algorithms packaged as an SQLite virtual table module.
 */
 
+/*
+** Database Format of R-Tree Tables
+** --------------------------------
+**
+** The data structure for a single virtual r-tree table is stored in three 
+** native SQLite tables declared as follows. In each case, the '%' character
+** in the table name is replaced with the user-supplied name of the r-tree
+** table.
+**
+**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)
+**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)
+**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)
+**
+** The data for each node of the r-tree structure is stored in the %_node
+** table. For each node that is not the root node of the r-tree, there is
+** an entry in the %_parent table associating the node with its parent.
+** And for each row of data in the table, there is an entry in the %_rowid
+** table that maps from the entries rowid to the id of the node that it
+** is stored on.
+**
+** The root node of an r-tree always exists, even if the r-tree table is
+** empty. The nodeno of the root node is always 1. All other nodes in the
+** table must be the same size as the root node. The content of each node
+** is formatted as follows:
+**
+**   1. If the node is the root node (node 1), then the first 2 bytes
+**      of the node contain the tree depth as a big-endian integer.
+**      For non-root nodes, the first 2 bytes are left unused.
+**
+**   2. The next 2 bytes contain the number of entries currently 
+**      stored in the node.
+**
+**   3. The remainder of the node contains the node entries. Each entry
+**      consists of a single 8-byte integer followed by an even number
+**      of 4-byte coordinates. For leaf nodes the integer is the rowid
+**      of a record. For internal nodes it is the node number of a
+**      child page.
+*/
+
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)
 
 /*
@@ -108858,6 +116791,9 @@ SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *
   #define AssignCells splitNodeStartree
 #endif
 
+#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) 
+# define NDEBUG 1
+#endif
 
 #ifndef SQLITE_CORE
   SQLITE_EXTENSION_INIT1
@@ -108866,6 +116802,7 @@ SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *
 
 
 #ifndef SQLITE_AMALGAMATION
+#include "sqlite3rtree.h"
 typedef sqlite3_int64 i64;
 typedef unsigned char u8;
 typedef unsigned int u32;
@@ -108876,6 +116813,8 @@ typedef struct RtreeCursor RtreeCursor;
 typedef struct RtreeNode RtreeNode;
 typedef struct RtreeCell RtreeCell;
 typedef struct RtreeConstraint RtreeConstraint;
+typedef struct RtreeMatchArg RtreeMatchArg;
+typedef struct RtreeGeomCallback RtreeGeomCallback;
 typedef union RtreeCoord RtreeCoord;
 
 /* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */
@@ -108945,6 +116884,15 @@ struct Rtree {
 #define RTREE_REINSERT(p) RTREE_MINCELLS(p)
 #define RTREE_MAXCELLS 51
 
+/*
+** The smallest possible node-size is (512-64)==448 bytes. And the largest
+** supported cell size is 48 bytes (8 byte rowid + ten 4 byte coordinates).
+** Therefore all non-root nodes must contain at least 3 entries. Since 
+** 2^40 is greater than 2^64, an r-tree structure always has a depth of
+** 40 or less.
+*/
+#define RTREE_MAX_DEPTH 40
+
 /* 
 ** An rtree cursor object.
 */
@@ -108977,35 +116925,23 @@ union RtreeCoord {
 ** A search constraint.
 */
 struct RtreeConstraint {
-  int iCoord;                       /* Index of constrained coordinate */
-  int op;                           /* Constraining operation */
-  double rValue;                    /* Constraint value. */
+  int iCoord;                     /* Index of constrained coordinate */
+  int op;                         /* Constraining operation */
+  double rValue;                  /* Constraint value. */
+  int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
+  sqlite3_rtree_geometry *pGeom;  /* Constraint callback argument for a MATCH */
 };
 
 /* Possible values for RtreeConstraint.op */
-#define RTREE_EQ 0x41
-#define RTREE_LE 0x42
-#define RTREE_LT 0x43
-#define RTREE_GE 0x44
-#define RTREE_GT 0x45
+#define RTREE_EQ    0x41
+#define RTREE_LE    0x42
+#define RTREE_LT    0x43
+#define RTREE_GE    0x44
+#define RTREE_GT    0x45
+#define RTREE_MATCH 0x46
 
 /* 
 ** An rtree structure node.
-**
-** Data format (RtreeNode.zData):
-**
-**   1. If the node is the root node (node 1), then the first 2 bytes
-**      of the node contain the tree depth as a big-endian integer.
-**      For non-root nodes, the first 2 bytes are left unused.
-**
-**   2. The next 2 bytes contain the number of entries currently 
-**      stored in the node.
-**
-**   3. The remainder of the node contains the node entries. Each entry
-**      consists of a single 8-byte integer followed by an even number
-**      of 4-byte coordinates. For leaf nodes the integer is the rowid
-**      of a record. For internal nodes it is the node number of a
-**      child page.
 */
 struct RtreeNode {
   RtreeNode *pParent;               /* Parent node */
@@ -109025,6 +116961,40 @@ struct RtreeCell {
   RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2];
 };
 
+
+/*
+** Value for the first field of every RtreeMatchArg object. The MATCH
+** operator tests that the first field of a blob operand matches this
+** value to avoid operating on invalid blobs (which could cause a segfault).
+*/
+#define RTREE_GEOMETRY_MAGIC 0x891245AB
+
+/*
+** An instance of this structure must be supplied as a blob argument to
+** the right-hand-side of an SQL MATCH operator used to constrain an
+** r-tree query.
+*/
+struct RtreeMatchArg {
+  u32 magic;                      /* Always RTREE_GEOMETRY_MAGIC */
+  int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
+  void *pContext;
+  int nParam;
+  double aParam[1];
+};
+
+/*
+** When a geometry callback is created (see sqlite3_rtree_geometry_callback),
+** a single instance of the following structure is allocated. It is used
+** as the context for the user-function created by by s_r_g_c(). The object
+** is eventually deleted by the destructor mechanism provided by
+** sqlite3_create_function_v2() (which is called by s_r_g_c() to create
+** the geometry callback function).
+*/
+struct RtreeGeomCallback {
+  int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
+  void *pContext;
+};
+
 #ifndef MAX
 # define MAX(x,y) ((x) < (y) ? (y) : (x))
 #endif
@@ -109107,10 +117077,8 @@ static void nodeReference(RtreeNode *p){
 ** Clear the content of node p (set all bytes to 0x00).
 */
 static void nodeZero(Rtree *pRtree, RtreeNode *p){
-  if( p ){
-    memset(&p->zData[2], 0, pRtree->iNodeSize-2);
-    p->isDirty = 1;
-  }
+  memset(&p->zData[2], 0, pRtree->iNodeSize-2);
+  p->isDirty = 1;
 }
 
 /*
@@ -109130,7 +117098,6 @@ static int nodeHash(i64 iNode){
 */
 static RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){
   RtreeNode *p;
-  assert( iNode!=0 );
   for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext);
   return p;
 }
@@ -109139,13 +117106,11 @@ static RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){
 ** Add node pNode to the node hash table.
 */
 static void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){
-  if( pNode ){
-    int iHash;
-    assert( pNode->pNext==0 );
-    iHash = nodeHash(pNode->iNode);
-    pNode->pNext = pRtree->aHash[iHash];
-    pRtree->aHash[iHash] = pNode;
-  }
+  int iHash;
+  assert( pNode->pNext==0 );
+  iHash = nodeHash(pNode->iNode);
+  pNode->pNext = pRtree->aHash[iHash];
+  pRtree->aHash[iHash] = pNode;
 }
 
 /*
@@ -109167,11 +117132,11 @@ static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
 ** assigned a node number when nodeWrite() is called to write the
 ** node contents out to the database.
 */
-static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent, int zero){
+static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
   RtreeNode *pNode;
   pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
   if( pNode ){
-    memset(pNode, 0, sizeof(RtreeNode) + (zero?pRtree->iNodeSize:0));
+    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
     pNode->zData = (u8 *)&pNode[1];
     pNode->nRef = 1;
     pNode->pParent = pParent;
@@ -109192,6 +117157,7 @@ nodeAcquire(
   RtreeNode **ppNode         /* OUT: Acquired node */
 ){
   int rc;
+  int rc2 = SQLITE_OK;
   RtreeNode *pNode;
 
   /* Check if the requested node is already in the hash table. If so,
@@ -109208,39 +117174,63 @@ nodeAcquire(
     return SQLITE_OK;
   }
 
-  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
-  if( !pNode ){
-    *ppNode = 0;
-    return SQLITE_NOMEM;
-  }
-  pNode->pParent = pParent;
-  pNode->zData = (u8 *)&pNode[1];
-  pNode->nRef = 1;
-  pNode->iNode = iNode;
-  pNode->isDirty = 0;
-  pNode->pNext = 0;
-
   sqlite3_bind_int64(pRtree->pReadNode, 1, iNode);
   rc = sqlite3_step(pRtree->pReadNode);
   if( rc==SQLITE_ROW ){
     const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0);
-    assert( sqlite3_column_bytes(pRtree->pReadNode, 0)==pRtree->iNodeSize );
-    memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
-    nodeReference(pParent);
-  }else{
-    sqlite3_free(pNode);
-    pNode = 0;
+    if( pRtree->iNodeSize==sqlite3_column_bytes(pRtree->pReadNode, 0) ){
+      pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
+      if( !pNode ){
+        rc2 = SQLITE_NOMEM;
+      }else{
+        pNode->pParent = pParent;
+        pNode->zData = (u8 *)&pNode[1];
+        pNode->nRef = 1;
+        pNode->iNode = iNode;
+        pNode->isDirty = 0;
+        pNode->pNext = 0;
+        memcpy(pNode->zData, zBlob, pRtree->iNodeSize);
+        nodeReference(pParent);
+      }
+    }
   }
-
-  *ppNode = pNode;
   rc = sqlite3_reset(pRtree->pReadNode);
+  if( rc==SQLITE_OK ) rc = rc2;
 
-  if( rc==SQLITE_OK && iNode==1 ){
+  /* If the root node was just loaded, set pRtree->iDepth to the height
+  ** of the r-tree structure. A height of zero means all data is stored on
+  ** the root node. A height of one means the children of the root node
+  ** are the leaves, and so on. If the depth as specified on the root node
+  ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.
+  */
+  if( pNode && iNode==1 ){
     pRtree->iDepth = readInt16(pNode->zData);
+    if( pRtree->iDepth>RTREE_MAX_DEPTH ){
+      rc = SQLITE_CORRUPT;
+    }
   }
 
-  assert( (rc==SQLITE_OK && pNode) || (pNode==0 && rc!=SQLITE_OK) );
-  nodeHashInsert(pRtree, pNode);
+  /* If no error has occurred so far, check if the "number of entries"
+  ** field on the node is too large. If so, set the return code to 
+  ** SQLITE_CORRUPT.
+  */
+  if( pNode && rc==SQLITE_OK ){
+    if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
+      rc = SQLITE_CORRUPT;
+    }
+  }
+
+  if( rc==SQLITE_OK ){
+    if( pNode!=0 ){
+      nodeHashInsert(pRtree, pNode);
+    }else{
+      rc = SQLITE_CORRUPT;
+    }
+    *ppNode = pNode;
+  }else{
+    sqlite3_free(pNode);
+    *ppNode = 0;
+  }
 
   return rc;
 }
@@ -109293,8 +117283,7 @@ nodeInsertCell(
   nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell;
   nCell = NCELL(pNode);
 
-  assert(nCell<=nMaxCell);
-
+  assert( nCell<=nMaxCell );
   if( nCell<nMaxCell ){
     nodeOverwriteCell(pRtree, pNode, pCell, nCell);
     writeInt16(&pNode->zData[2], nCell+1);
@@ -109514,6 +117503,25 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
   return rc;
 }
 
+
+/*
+** Free the RtreeCursor.aConstraint[] array and its contents.
+*/
+static void freeCursorConstraints(RtreeCursor *pCsr){
+  if( pCsr->aConstraint ){
+    int i;                        /* Used to iterate through constraint array */
+    for(i=0; i<pCsr->nConstraint; i++){
+      sqlite3_rtree_geometry *pGeom = pCsr->aConstraint[i].pGeom;
+      if( pGeom ){
+        if( pGeom->xDelUser ) pGeom->xDelUser(pGeom->pUser);
+        sqlite3_free(pGeom);
+      }
+    }
+    sqlite3_free(pCsr->aConstraint);
+    pCsr->aConstraint = 0;
+  }
+}
+
 /* 
 ** Rtree virtual table module xClose method.
 */
@@ -109521,7 +117529,7 @@ static int rtreeClose(sqlite3_vtab_cursor *cur){
   Rtree *pRtree = (Rtree *)(cur->pVtab);
   int rc;
   RtreeCursor *pCsr = (RtreeCursor *)cur;
-  sqlite3_free(pCsr->aConstraint);
+  freeCursorConstraints(pCsr);
   rc = nodeRelease(pRtree, pCsr->pNode);
   sqlite3_free(pCsr);
   return rc;
@@ -109538,13 +117546,39 @@ static int rtreeEof(sqlite3_vtab_cursor *cur){
   return (pCsr->pNode==0);
 }
 
+/*
+** The r-tree constraint passed as the second argument to this function is
+** guaranteed to be a MATCH constraint.
+*/
+static int testRtreeGeom(
+  Rtree *pRtree,                  /* R-Tree object */
+  RtreeConstraint *pConstraint,   /* MATCH constraint to test */
+  RtreeCell *pCell,               /* Cell to test */
+  int *pbRes                      /* OUT: Test result */
+){
+  int i;
+  double aCoord[RTREE_MAX_DIMENSIONS*2];
+  int nCoord = pRtree->nDim*2;
+
+  assert( pConstraint->op==RTREE_MATCH );
+  assert( pConstraint->pGeom );
+
+  for(i=0; i<nCoord; i++){
+    aCoord[i] = DCOORD(pCell->aCoord[i]);
+  }
+  return pConstraint->xGeom(pConstraint->pGeom, nCoord, aCoord, pbRes);
+}
+
 /* 
 ** Cursor pCursor currently points to a cell in a non-leaf page.
-** Return true if the sub-tree headed by the cell is filtered
+** Set *pbEof to true if the sub-tree headed by the cell is filtered
 ** (excluded) by the constraints in the pCursor->aConstraint[] 
 ** array, or false otherwise.
+**
+** Return SQLITE_OK if successful or an SQLite error code if an error
+** occurs within a geometry callback.
 */
-static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor){
+static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){
   RtreeCell cell;
   int ii;
   int bRes = 0;
@@ -109556,31 +117590,55 @@ static int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor){
     double cell_max = DCOORD(cell.aCoord[(p->iCoord>>1)*2+1]);
 
     assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE 
-        || p->op==RTREE_GT || p->op==RTREE_EQ
+        || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_MATCH
     );
 
     switch( p->op ){
-      case RTREE_LE: case RTREE_LT: bRes = p->rValue<cell_min; break;
-      case RTREE_GE: case RTREE_GT: bRes = p->rValue>cell_max; break;
-      case RTREE_EQ: 
+      case RTREE_LE: case RTREE_LT: 
+        bRes = p->rValue<cell_min; 
+        break;
+
+      case RTREE_GE: case RTREE_GT: 
+        bRes = p->rValue>cell_max; 
+        break;
+
+      case RTREE_EQ:
         bRes = (p->rValue>cell_max || p->rValue<cell_min);
         break;
+
+      default: {
+        int rc;
+        assert( p->op==RTREE_MATCH );
+        rc = testRtreeGeom(pRtree, p, &cell, &bRes);
+        if( rc!=SQLITE_OK ){
+          return rc;
+        }
+        bRes = !bRes;
+        break;
+      }
     }
   }
 
-  return bRes;
+  *pbEof = bRes;
+  return SQLITE_OK;
 }
 
 /* 
-** Return true if the cell that cursor pCursor currently points to
+** Test if the cell that cursor pCursor currently points to
 ** would be filtered (excluded) by the constraints in the 
-** pCursor->aConstraint[] array, or false otherwise.
+** pCursor->aConstraint[] array. If so, set *pbEof to true before
+** returning. If the cell is not filtered (excluded) by the constraints,
+** set pbEof to zero.
+**
+** Return SQLITE_OK if successful or an SQLite error code if an error
+** occurs within a geometry callback.
 **
 ** This function assumes that the cell is part of a leaf node.
 */
-static int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor){
+static int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){
   RtreeCell cell;
   int ii;
+  *pbEof = 0;
 
   nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);
   for(ii=0; ii<pCursor->nConstraint; ii++){
@@ -109588,7 +117646,7 @@ static int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor){
     double coord = DCOORD(cell.aCoord[p->iCoord]);
     int res;
     assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE 
-        || p->op==RTREE_GT || p->op==RTREE_EQ
+        || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_MATCH
     );
     switch( p->op ){
       case RTREE_LE: res = (coord<=p->rValue); break;
@@ -109596,12 +117654,24 @@ static int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor){
       case RTREE_GE: res = (coord>=p->rValue); break;
       case RTREE_GT: res = (coord>p->rValue);  break;
       case RTREE_EQ: res = (coord==p->rValue); break;
+      default: {
+        int rc;
+        assert( p->op==RTREE_MATCH );
+        rc = testRtreeGeom(pRtree, p, &cell, &res);
+        if( rc!=SQLITE_OK ){
+          return rc;
+        }
+        break;
+      }
     }
 
-    if( !res ) return 1;
+    if( !res ){
+      *pbEof = 1;
+      return SQLITE_OK;
+    }
   }
 
-  return 0;
+  return SQLITE_OK;
 }
 
 /*
@@ -109628,13 +117698,13 @@ static int descendToCell(
   assert( iHeight>=0 );
 
   if( iHeight==0 ){
-    isEof = testRtreeEntry(pRtree, pCursor);
+    rc = testRtreeEntry(pRtree, pCursor, &isEof);
   }else{
-    isEof = testRtreeCell(pRtree, pCursor);
+    rc = testRtreeCell(pRtree, pCursor, &isEof);
   }
-  if( isEof || iHeight==0 ){
+  if( rc!=SQLITE_OK || isEof || iHeight==0 ){
     *pEof = isEof;
-    return SQLITE_OK;
+    return rc;
   }
 
   iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);
@@ -109670,24 +117740,34 @@ static int descendToCell(
 ** One of the cells in node pNode is guaranteed to have a 64-bit 
 ** integer value equal to iRowid. Return the index of this cell.
 */
-static int nodeRowidIndex(Rtree *pRtree, RtreeNode *pNode, i64 iRowid){
+static int nodeRowidIndex(
+  Rtree *pRtree, 
+  RtreeNode *pNode, 
+  i64 iRowid,
+  int *piIndex
+){
   int ii;
-  for(ii=0; nodeGetRowid(pRtree, pNode, ii)!=iRowid; ii++){
-    assert( ii<(NCELL(pNode)-1) );
+  int nCell = NCELL(pNode);
+  for(ii=0; ii<nCell; ii++){
+    if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
+      *piIndex = ii;
+      return SQLITE_OK;
+    }
   }
-  return ii;
+  return SQLITE_CORRUPT;
 }
 
 /*
 ** Return the index of the cell containing a pointer to node pNode
 ** in its parent. If pNode is the root node, return -1.
 */
-static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode){
+static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){
   RtreeNode *pParent = pNode->pParent;
   if( pParent ){
-    return nodeRowidIndex(pRtree, pParent, pNode->iNode);
+    return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);
   }
-  return -1;
+  *piIndex = -1;
+  return SQLITE_OK;
 }
 
 /* 
@@ -109698,13 +117778,17 @@ static int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){
   RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;
   int rc = SQLITE_OK;
 
+  /* RtreeCursor.pNode must not be NULL. If is is NULL, then this cursor is
+  ** already at EOF. It is against the rules to call the xNext() method of
+  ** a cursor that has already reached EOF.
+  */
+  assert( pCsr->pNode );
+
   if( pCsr->iStrategy==1 ){
     /* This "scan" is a direct lookup by rowid. There is no next entry. */
     nodeRelease(pRtree, pCsr->pNode);
     pCsr->pNode = 0;
-  }
-
-  else if( pCsr->pNode ){
+  }else{
     /* Move to the next entry that matches the configured constraints. */
     int iHeight = 0;
     while( pCsr->pNode ){
@@ -109718,7 +117802,10 @@ static int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){
         }
       }
       pCsr->pNode = pNode->pParent;
-      pCsr->iCell = nodeParentIndex(pRtree, pNode);
+      rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
       nodeReference(pCsr->pNode);
       nodeRelease(pRtree, pNode);
       iHeight++;
@@ -109786,6 +117873,51 @@ static int findLeafNode(Rtree *pRtree, i64 iRowid, RtreeNode **ppLeaf){
   return rc;
 }
 
+/*
+** This function is called to configure the RtreeConstraint object passed
+** as the second argument for a MATCH constraint. The value passed as the
+** first argument to this function is the right-hand operand to the MATCH
+** operator.
+*/
+static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
+  RtreeMatchArg *p;
+  sqlite3_rtree_geometry *pGeom;
+  int nBlob;
+
+  /* Check that value is actually a blob. */
+  if( !sqlite3_value_type(pValue)==SQLITE_BLOB ) return SQLITE_ERROR;
+
+  /* Check that the blob is roughly the right size. */
+  nBlob = sqlite3_value_bytes(pValue);
+  if( nBlob<sizeof(RtreeMatchArg) 
+   || ((nBlob-sizeof(RtreeMatchArg))%sizeof(double))!=0
+  ){
+    return SQLITE_ERROR;
+  }
+
+  pGeom = (sqlite3_rtree_geometry *)sqlite3_malloc(
+      sizeof(sqlite3_rtree_geometry) + nBlob
+  );
+  if( !pGeom ) return SQLITE_NOMEM;
+  memset(pGeom, 0, sizeof(sqlite3_rtree_geometry));
+  p = (RtreeMatchArg *)&pGeom[1];
+
+  memcpy(p, sqlite3_value_blob(pValue), nBlob);
+  if( p->magic!=RTREE_GEOMETRY_MAGIC 
+   || nBlob!=(sizeof(RtreeMatchArg) + (p->nParam-1)*sizeof(double))
+  ){
+    sqlite3_free(pGeom);
+    return SQLITE_ERROR;
+  }
+
+  pGeom->pContext = p->pContext;
+  pGeom->nParam = p->nParam;
+  pGeom->aParam = p->aParam;
+
+  pCons->xGeom = p->xGeom;
+  pCons->pGeom = pGeom;
+  return SQLITE_OK;
+}
 
 /* 
 ** Rtree virtual table module xFilter method.
@@ -109804,8 +117936,7 @@ static int rtreeFilter(
 
   rtreeReference(pRtree);
 
-  sqlite3_free(pCsr->aConstraint);
-  pCsr->aConstraint = 0;
+  freeCursorConstraints(pCsr);
   pCsr->iStrategy = idxNum;
 
   if( idxNum==1 ){
@@ -109814,8 +117945,9 @@ static int rtreeFilter(
     i64 iRowid = sqlite3_value_int64(argv[0]);
     rc = findLeafNode(pRtree, iRowid, &pLeaf);
     pCsr->pNode = pLeaf; 
-    if( pLeaf && rc==SQLITE_OK ){
-      pCsr->iCell = nodeRowidIndex(pRtree, pLeaf, iRowid);
+    if( pLeaf ){
+      assert( rc==SQLITE_OK );
+      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &pCsr->iCell);
     }
   }else{
     /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array 
@@ -109827,12 +117959,24 @@ static int rtreeFilter(
       if( !pCsr->aConstraint ){
         rc = SQLITE_NOMEM;
       }else{
+        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);
         assert( (idxStr==0 && argc==0) || strlen(idxStr)==argc*2 );
         for(ii=0; ii<argc; ii++){
           RtreeConstraint *p = &pCsr->aConstraint[ii];
           p->op = idxStr[ii*2];
           p->iCoord = idxStr[ii*2+1]-'a';
-          p->rValue = sqlite3_value_double(argv[ii]);
+          if( p->op==RTREE_MATCH ){
+            /* A MATCH operator. The right-hand-side must be a blob that
+            ** can be cast into an RtreeMatchArg object. One created using
+            ** an sqlite3_rtree_geometry_callback() SQL user function.
+            */
+            rc = deserializeGeometry(argv[ii], p);
+            if( rc!=SQLITE_OK ){
+              break;
+            }
+          }else{
+            p->rValue = sqlite3_value_double(argv[ii]);
+          }
         }
       }
     }
@@ -109873,11 +118017,10 @@ static int rtreeFilter(
 **   idxNum     idxStr        Strategy
 **   ------------------------------------------------
 **     1        Unused        Direct lookup by rowid.
-**     2        See below     R-tree query.
-**     3        Unused        Full table scan.
+**     2        See below     R-tree query or full-table scan.
 **   ------------------------------------------------
 **
-** If strategy 1 or 3 is used, then idxStr is not meaningful. If strategy
+** If strategy 1 is used, then idxStr is not meaningful. If strategy
 ** 2 is used, idxStr is formatted to contain 2 bytes for each 
 ** constraint used. The first two bytes of idxStr correspond to 
 ** the constraint in sqlite3_index_info.aConstraintUsage[] with
@@ -109893,6 +118036,7 @@ static int rtreeFilter(
 **      <        0x43 ('C')
 **     >=        0x44 ('D')
 **      >        0x45 ('E')
+**   MATCH       0x46 ('F')
 **   ----------------------
 **
 ** The second of each pair of bytes identifies the coordinate column
@@ -109931,7 +118075,9 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
       return SQLITE_OK;
     }
 
-    if( p->usable && p->iColumn>0 ){
+    if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){
+      int j, opmsk;
+      static const unsigned char compatible[] = { 0, 0, 1, 1, 2, 2 };
       u8 op = 0;
       switch( p->op ){
         case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
@@ -109939,31 +118085,33 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
         case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
         case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
         case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
+        default:
+          assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );
+          op = RTREE_MATCH; 
+          break;
       }
-      if( op ){
-        /* Make sure this particular constraint has not been used before.
-        ** If it has been used before, ignore it.
-        **
-        ** A <= or < can be used if there is a prior >= or >.
-        ** A >= or > can be used if there is a prior < or <=.
-        ** A <= or < is disqualified if there is a prior <=, <, or ==.
-        ** A >= or > is disqualified if there is a prior >=, >, or ==.
-        ** A == is disqualifed if there is any prior constraint.
-        */
-        int j, opmsk;
-        static const unsigned char compatible[] = { 0, 0, 1, 1, 2, 2 };
-        assert( compatible[RTREE_EQ & 7]==0 );
-        assert( compatible[RTREE_LT & 7]==1 );
-        assert( compatible[RTREE_LE & 7]==1 );
-        assert( compatible[RTREE_GT & 7]==2 );
-        assert( compatible[RTREE_GE & 7]==2 );
-        cCol = p->iColumn - 1 + 'a';
-        opmsk = compatible[op & 7];
-        for(j=0; j<iIdx; j+=2){
-          if( zIdxStr[j+1]==cCol && (compatible[zIdxStr[j] & 7] & opmsk)!=0 ){
-            op = 0;
-            break;
-          }
+      assert( op!=0 );
+
+      /* Make sure this particular constraint has not been used before.
+      ** If it has been used before, ignore it.
+      **
+      ** A <= or < can be used if there is a prior >= or >.
+      ** A >= or > can be used if there is a prior < or <=.
+      ** A <= or < is disqualified if there is a prior <=, <, or ==.
+      ** A >= or > is disqualified if there is a prior >=, >, or ==.
+      ** A == is disqualifed if there is any prior constraint.
+      */
+      assert( compatible[RTREE_EQ & 7]==0 );
+      assert( compatible[RTREE_LT & 7]==1 );
+      assert( compatible[RTREE_LE & 7]==1 );
+      assert( compatible[RTREE_GT & 7]==2 );
+      assert( compatible[RTREE_GE & 7]==2 );
+      cCol = p->iColumn - 1 + 'a';
+      opmsk = compatible[op & 7];
+      for(j=0; j<iIdx; j+=2){
+        if( zIdxStr[j+1]==cCol && (compatible[zIdxStr[j] & 7] & opmsk)!=0 ){
+          op = 0;
+          break;
         }
       }
       if( op ){
@@ -110071,7 +118219,12 @@ static float cellOverlap(
   int ii;
   float overlap = 0.0;
   for(ii=0; ii<nCell; ii++){
-    if( ii!=iExclude ){
+#if VARIANT_RSTARTREE_CHOOSESUBTREE
+    if( ii!=iExclude )
+#else
+    assert( iExclude==-1 );
+#endif
+    {
       int jj;
       float o = 1.0;
       for(jj=0; jj<(pRtree->nDim*2); jj+=2){
@@ -110164,22 +118317,31 @@ static int ChooseLeaf(
     ** the smallest area.
     */
     for(iCell=0; iCell<nCell; iCell++){
+      int bBest = 0;
       float growth;
       float area;
       float overlap = 0.0;
       nodeGetCell(pRtree, pNode, iCell, &cell);
       growth = cellGrowth(pRtree, &cell, pCell);
       area = cellArea(pRtree, &cell);
+
 #if VARIANT_RSTARTREE_CHOOSESUBTREE
       if( ii==(pRtree->iDepth-1) ){
         overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell);
       }
-#endif
       if( (iCell==0) 
        || (overlap<fMinOverlap) 
        || (overlap==fMinOverlap && growth<fMinGrowth)
        || (overlap==fMinOverlap && growth==fMinGrowth && area<fMinArea)
       ){
+        bBest = 1;
+      }
+#else
+      if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){
+        bBest = 1;
+      }
+#endif
+      if( bBest ){
         fMinOverlap = overlap;
         fMinGrowth = growth;
         fMinArea = area;
@@ -110202,16 +118364,20 @@ static int ChooseLeaf(
 ** the node pNode. This function updates the bounding box cells in
 ** all ancestor elements.
 */
-static void AdjustTree(
+static int AdjustTree(
   Rtree *pRtree,                    /* Rtree table */
   RtreeNode *pNode,                 /* Adjust ancestry of this node. */
   RtreeCell *pCell                  /* This cell was just inserted */
 ){
   RtreeNode *p = pNode;
   while( p->pParent ){
-    RtreeCell cell;
     RtreeNode *pParent = p->pParent;
-    int iCell = nodeParentIndex(pRtree, p);
+    RtreeCell cell;
+    int iCell;
+
+    if( nodeParentIndex(pRtree, p, &iCell) ){
+      return SQLITE_CORRUPT;
+    }
 
     nodeGetCell(pRtree, pParent, iCell, &cell);
     if( !cellContains(pRtree, &cell, pCell) ){
@@ -110221,6 +118387,7 @@ static void AdjustTree(
  
     p = pParent;
   }
+  return SQLITE_OK;
 }
 
 /*
@@ -110749,14 +118916,14 @@ static int SplitNode(
   nCell++;
 
   if( pNode->iNode==1 ){
-    pRight = nodeNew(pRtree, pNode, 1);
-    pLeft = nodeNew(pRtree, pNode, 1);
+    pRight = nodeNew(pRtree, pNode);
+    pLeft = nodeNew(pRtree, pNode);
     pRtree->iDepth++;
     pNode->isDirty = 1;
     writeInt16(pNode->zData, pRtree->iDepth);
   }else{
     pLeft = pNode;
-    pRight = nodeNew(pRtree, pLeft->pParent, 1);
+    pRight = nodeNew(pRtree, pLeft->pParent);
     nodeReference(pLeft);
   }
 
@@ -110773,8 +118940,12 @@ static int SplitNode(
     goto splitnode_out;
   }
 
-  /* Ensure both child nodes have node numbers assigned to them. */
-  if( (0==pRight->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pRight)))
+  /* Ensure both child nodes have node numbers assigned to them by calling
+  ** nodeWrite(). Node pRight always needs a node number, as it was created
+  ** by nodeNew() above. But node pLeft sometimes already has a node number.
+  ** In this case avoid the all to nodeWrite().
+  */
+  if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))
    || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))
   ){
     goto splitnode_out;
@@ -110790,9 +118961,15 @@ static int SplitNode(
     }
   }else{
     RtreeNode *pParent = pLeft->pParent;
-    int iCell = nodeParentIndex(pRtree, pLeft);
-    nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);
-    AdjustTree(pRtree, pParent, &leftbbox);
+    int iCell;
+    rc = nodeParentIndex(pRtree, pLeft, &iCell);
+    if( rc==SQLITE_OK ){
+      nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);
+      rc = AdjustTree(pRtree, pParent, &leftbbox);
+    }
+    if( rc!=SQLITE_OK ){
+      goto splitnode_out;
+    }
   }
   if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){
     goto splitnode_out;
@@ -110836,20 +119013,43 @@ splitnode_out:
   return rc;
 }
 
+/*
+** If node pLeaf is not the root of the r-tree and its pParent pointer is 
+** still NULL, load all ancestor nodes of pLeaf into memory and populate
+** the pLeaf->pParent chain all the way up to the root node.
+**
+** This operation is required when a row is deleted (or updated - an update
+** is implemented as a delete followed by an insert). SQLite provides the
+** rowid of the row to delete, which can be used to find the leaf on which
+** the entry resides (argument pLeaf). Once the leaf is located, this 
+** function is called to determine its ancestry.
+*/
 static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){
   int rc = SQLITE_OK;
-  if( pLeaf->iNode!=1 && pLeaf->pParent==0 ){
-    sqlite3_bind_int64(pRtree->pReadParent, 1, pLeaf->iNode);
-    if( sqlite3_step(pRtree->pReadParent)==SQLITE_ROW ){
-      i64 iNode = sqlite3_column_int64(pRtree->pReadParent, 0);
-      rc = nodeAcquire(pRtree, iNode, 0, &pLeaf->pParent);
-    }else{
-      rc = SQLITE_ERROR;
-    }
-    sqlite3_reset(pRtree->pReadParent);
-    if( rc==SQLITE_OK ){
-      rc = fixLeafParent(pRtree, pLeaf->pParent);
+  RtreeNode *pChild = pLeaf;
+  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){
+    int rc2 = SQLITE_OK;          /* sqlite3_reset() return code */
+    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);
+    rc = sqlite3_step(pRtree->pReadParent);
+    if( rc==SQLITE_ROW ){
+      RtreeNode *pTest;           /* Used to test for reference loops */
+      i64 iNode;                  /* Node number of parent node */
+
+      /* Before setting pChild->pParent, test that we are not creating a
+      ** loop of references (as we would if, say, pChild==pParent). We don't
+      ** want to do this as it leads to a memory leak when trying to delete
+      ** the referenced counted node structures.
+      */
+      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);
+      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);
+      if( !pTest ){
+        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);
+      }
     }
+    rc = sqlite3_reset(pRtree->pReadParent);
+    if( rc==SQLITE_OK ) rc = rc2;
+    if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT;
+    pChild = pChild->pParent;
   }
   return rc;
 }
@@ -110858,18 +119058,24 @@ static int deleteCell(Rtree *, RtreeNode *, int, int);
 
 static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
   int rc;
+  int rc2;
   RtreeNode *pParent;
   int iCell;
 
   assert( pNode->nRef==1 );
 
   /* Remove the entry in the parent cell. */
-  iCell = nodeParentIndex(pRtree, pNode);
-  pParent = pNode->pParent;
-  pNode->pParent = 0;
-  if( SQLITE_OK!=(rc = deleteCell(pRtree, pParent, iCell, iHeight+1)) 
-   || SQLITE_OK!=(rc = nodeRelease(pRtree, pParent))
-  ){
+  rc = nodeParentIndex(pRtree, pNode, &iCell);
+  if( rc==SQLITE_OK ){
+    pParent = pNode->pParent;
+    pNode->pParent = 0;
+    rc = deleteCell(pRtree, pParent, iCell, iHeight+1);
+  }
+  rc2 = nodeRelease(pRtree, pParent);
+  if( rc==SQLITE_OK ){
+    rc = rc2;
+  }
+  if( rc!=SQLITE_OK ){
     return rc;
   }
 
@@ -110899,8 +119105,9 @@ static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){
   return SQLITE_OK;
 }
 
-static void fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
+static int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
   RtreeNode *pParent = pNode->pParent;
+  int rc = SQLITE_OK; 
   if( pParent ){
     int ii; 
     int nCell = NCELL(pNode);
@@ -110912,10 +119119,13 @@ static void fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
       cellUnion(pRtree, &box, &cell);
     }
     box.iRowid = pNode->iNode;
-    ii = nodeParentIndex(pRtree, pNode);
-    nodeOverwriteCell(pRtree, pParent, &box, ii);
-    fixBoundingBox(pRtree, pParent);
+    rc = nodeParentIndex(pRtree, pNode, &ii);
+    if( rc==SQLITE_OK ){
+      nodeOverwriteCell(pRtree, pParent, &box, ii);
+      rc = fixBoundingBox(pRtree, pParent);
+    }
   }
+  return rc;
 }
 
 /*
@@ -110923,6 +119133,7 @@ static void fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){
 ** cell, adjust the r-tree data structure if required.
 */
 static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
+  RtreeNode *pParent;
   int rc;
 
   if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){
@@ -110939,14 +119150,13 @@ static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
   ** cell in the parent node so that it tightly contains the updated
   ** node.
   */
-  if( pNode->iNode!=1 ){
-    RtreeNode *pParent = pNode->pParent;
-    if( (pParent->iNode!=1 || NCELL(pParent)!=1) 
-     && (NCELL(pNode)<RTREE_MINCELLS(pRtree))
-    ){
+  pParent = pNode->pParent;
+  assert( pParent || pNode->iNode==1 );
+  if( pParent ){
+    if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){
       rc = removeNode(pRtree, pNode, iHeight);
     }else{
-      fixBoundingBox(pRtree, pNode);
+      rc = fixBoundingBox(pRtree, pNode);
     }
   }
 
@@ -111029,7 +119239,7 @@ static int Reinsert(
     }
   }
   if( rc==SQLITE_OK ){
-    fixBoundingBox(pRtree, pNode);
+    rc = fixBoundingBox(pRtree, pNode);
   }
   for(; rc==SQLITE_OK && ii<nCell; ii++){
     /* Find a node to store this cell in. pNode->iNode currently contains
@@ -111083,11 +119293,13 @@ static int rtreeInsertCell(
     rc = SplitNode(pRtree, pNode, pCell, iHeight);
 #endif
   }else{
-    AdjustTree(pRtree, pNode, pCell);
-    if( iHeight==0 ){
-      rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
-    }else{
-      rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
+    rc = AdjustTree(pRtree, pNode, pCell);
+    if( rc==SQLITE_OK ){
+      if( iHeight==0 ){
+        rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);
+      }else{
+        rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);
+      }
     }
   }
   return rc;
@@ -111157,7 +119369,6 @@ static int rtreeUpdate(
   rtreeReference(pRtree);
 
   assert(nData>=1);
-  assert(hashIsEmpty(pRtree));
 
   /* If azData[0] is not an SQL NULL value, it is the rowid of a
   ** record to delete from the r-tree table. The following block does
@@ -111183,8 +119394,10 @@ static int rtreeUpdate(
     /* Delete the cell in question from the leaf node. */
     if( rc==SQLITE_OK ){
       int rc2;
-      iCell = nodeRowidIndex(pRtree, pLeaf, iDelete);
-      rc = deleteCell(pRtree, pLeaf, iCell, 0);
+      rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);
+      if( rc==SQLITE_OK ){
+        rc = deleteCell(pRtree, pLeaf, iCell, 0);
+      }
       rc2 = nodeRelease(pRtree, pLeaf);
       if( rc==SQLITE_OK ){
         rc = rc2;
@@ -111206,19 +119419,20 @@ static int rtreeUpdate(
     ** the root node (the operation that Gutman's paper says to perform 
     ** in this scenario).
     */
-    if( rc==SQLITE_OK && pRtree->iDepth>0 ){
-      if( rc==SQLITE_OK && NCELL(pRoot)==1 ){
-        RtreeNode *pChild;
-        i64 iChild = nodeGetRowid(pRtree, pRoot, 0);
-        rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);
-        if( rc==SQLITE_OK ){
-          rc = removeNode(pRtree, pChild, pRtree->iDepth-1);
-        }
-        if( rc==SQLITE_OK ){
-          pRtree->iDepth--;
-          writeInt16(pRoot->zData, pRtree->iDepth);
-          pRoot->isDirty = 1;
-        }
+    if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){
+      int rc2;
+      RtreeNode *pChild;
+      i64 iChild = nodeGetRowid(pRtree, pRoot, 0);
+      rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);
+      if( rc==SQLITE_OK ){
+        rc = removeNode(pRtree, pChild, pRtree->iDepth-1);
+      }
+      rc2 = nodeRelease(pRtree, pChild);
+      if( rc==SQLITE_OK ) rc = rc2;
+      if( rc==SQLITE_OK ){
+        pRtree->iDepth--;
+        writeInt16(pRoot->zData, pRtree->iDepth);
+        pRoot->isDirty = 1;
       }
     }
 
@@ -111284,6 +119498,7 @@ static int rtreeUpdate(
       }
       rc = sqlite3_reset(pRtree->pReadRowid);
     }
+    *pRowid = cell.iRowid;
 
     if( rc==SQLITE_OK ){
       rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);
@@ -111507,7 +119722,7 @@ static int rtreeInit(
   Rtree *pRtree;
   int nDb;              /* Length of string argv[1] */
   int nName;            /* Length of string argv[2] */
-  int eCoordType = (int)pAux;
+  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);
 
   const char *aErrMsg[] = {
     0,                                                    /* 0 */
@@ -111653,12 +119868,10 @@ static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
 ** function "rtreenode".
 */
 SQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){
-  int rc = SQLITE_OK;
+  const int utf8 = SQLITE_UTF8;
+  int rc;
 
-  if( rc==SQLITE_OK ){
-    int utf8 = SQLITE_UTF8;
-    rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0);
-  }
+  rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0);
   if( rc==SQLITE_OK ){
     int utf8 = SQLITE_UTF8;
     rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0);
@@ -111675,6 +119888,70 @@ SQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){
   return rc;
 }
 
+/*
+** A version of sqlite3_free() that can be used as a callback. This is used
+** in two places - as the destructor for the blob value returned by the
+** invocation of a geometry function, and as the destructor for the geometry
+** functions themselves.
+*/
+static void doSqlite3Free(void *p){
+  sqlite3_free(p);
+}
+
+/*
+** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
+** scalar user function. This C function is the callback used for all such
+** registered SQL functions.
+**
+** The scalar user functions return a blob that is interpreted by r-tree
+** table MATCH operators.
+*/
+static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
+  RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);
+  RtreeMatchArg *pBlob;
+  int nBlob;
+
+  nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(double);
+  pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);
+  if( !pBlob ){
+    sqlite3_result_error_nomem(ctx);
+  }else{
+    int i;
+    pBlob->magic = RTREE_GEOMETRY_MAGIC;
+    pBlob->xGeom = pGeomCtx->xGeom;
+    pBlob->pContext = pGeomCtx->pContext;
+    pBlob->nParam = nArg;
+    for(i=0; i<nArg; i++){
+      pBlob->aParam[i] = sqlite3_value_double(aArg[i]);
+    }
+    sqlite3_result_blob(ctx, pBlob, nBlob, doSqlite3Free);
+  }
+}
+
+/*
+** Register a new geometry function for use with the r-tree MATCH operator.
+*/
+SQLITE_API int sqlite3_rtree_geometry_callback(
+  sqlite3 *db,
+  const char *zGeom,
+  int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *),
+  void *pContext
+){
+  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */
+
+  /* Allocate and populate the context object. */
+  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));
+  if( !pGeomCtx ) return SQLITE_NOMEM;
+  pGeomCtx->xGeom = xGeom;
+  pGeomCtx->pContext = pContext;
+
+  /* Create the new user-function. Register a destructor function to delete
+  ** the context object when it is no longer required.  */
+  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, 
+      (void *)pGeomCtx, geomCallback, 0, 0, doSqlite3Free
+  );
+}
+
 #if !SQLITE_CORE
 SQLITE_API int sqlite3_extension_init(
   sqlite3 *db,
@@ -111701,7 +119978,7 @@ SQLITE_API int sqlite3_extension_init(
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: sqlite3.c 297173 2010-03-30 11:52:25Z iliaa $
+** $Id: sqlite3.c 304571 2010-10-20 19:27:34Z iliaa $
 **
 ** This file implements an integration between the ICU library 
 ** ("International Components for Unicode", an open-source library 
@@ -112202,7 +120479,7 @@ SQLITE_API int sqlite3_extension_init(
 *************************************************************************
 ** This file implements a tokenizer for fts3 based on the ICU library.
 ** 
-** $Id: sqlite3.c 297173 2010-03-30 11:52:25Z iliaa $
+** $Id: sqlite3.c 304571 2010-10-20 19:27:34Z iliaa $
 */
 
 #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
diff --git a/ext/sqlite3/libsqlite/sqlite3.h b/ext/sqlite3/libsqlite/sqlite3.h
index d72fdbd..d78ae39 100644
--- a/ext/sqlite3/libsqlite/sqlite3.h
+++ b/ext/sqlite3/libsqlite/sqlite3.h
@@ -97,7 +97,7 @@ extern "C" {
 **
 ** Since version 3.6.18, SQLite source code has been stored in the
 ** <a href="http://www.fossil-scm.org/">Fossil configuration management
-** system</a>.  ^The SQLITE_SOURCE_ID macro evalutes to
+** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
 ** a string which identifies a particular check-in of SQLite
 ** within its configuration management system.  ^The SQLITE_SOURCE_ID
 ** string contains the date and time of the check-in (UTC) and an SHA1
@@ -107,9 +107,9 @@ extern "C" {
 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
 ** [sqlite_version()] and [sqlite_source_id()].
 */
-#define SQLITE_VERSION        "3.6.23.1"
-#define SQLITE_VERSION_NUMBER 3006023
-#define SQLITE_SOURCE_ID      "2010-03-26 22:28:06 b078b588d617e07886ad156e9f54ade6d823568e"
+#define SQLITE_VERSION        "3.7.3"
+#define SQLITE_VERSION_NUMBER 3007003
+#define SQLITE_SOURCE_ID      "2010-10-08 02:34:02 2677848087c9c090efb17c1893e77d6136a9111d"
 
 /*
 ** CAPI3REF: Run-Time Library Version Numbers
@@ -146,7 +146,6 @@ SQLITE_API const char *sqlite3_libversion(void);
 SQLITE_API const char *sqlite3_sourceid(void);
 SQLITE_API int sqlite3_libversion_number(void);
 
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
 /*
 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
 **
@@ -155,7 +154,7 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** compile time.  ^The SQLITE_ prefix may be omitted from the 
 ** option name passed to sqlite3_compileoption_used().  
 **
-** ^The sqlite3_compileoption_get() function allows interating
+** ^The sqlite3_compileoption_get() function allows iterating
 ** over the list of options that were defined at compile time by
 ** returning the N-th compile time option string.  ^If N is out of range,
 ** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
@@ -163,15 +162,16 @@ SQLITE_API int sqlite3_libversion_number(void);
 ** sqlite3_compileoption_get().
 **
 ** ^Support for the diagnostic functions sqlite3_compileoption_used()
-** and sqlite3_compileoption_get() may be omitted by specifing the 
+** and sqlite3_compileoption_get() may be omitted by specifying the 
 ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
 **
 ** See also: SQL functions [sqlite_compileoption_used()] and
 ** [sqlite_compileoption_get()] and the [compile_options pragma].
 */
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
 SQLITE_API const char *sqlite3_compileoption_get(int N);
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
+#endif
 
 /*
 ** CAPI3REF: Test To See If The Library Is Threadsafe
@@ -268,7 +268,7 @@ typedef sqlite_uint64 sqlite3_uint64;
 **
 ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
 ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
-** successfullly destroyed and all associated resources are deallocated.
+** successfully destroyed and all associated resources are deallocated.
 **
 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
@@ -393,7 +393,7 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */
 #define SQLITE_FULL        13   /* Insertion failed because database is full */
 #define SQLITE_CANTOPEN    14   /* Unable to open the database file */
-#define SQLITE_PROTOCOL    15   /* NOT USED. Database lock protocol error */
+#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
 #define SQLITE_EMPTY       16   /* Database is empty */
 #define SQLITE_SCHEMA      17   /* The database schema changed */
 #define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
@@ -449,7 +449,12 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
 #define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
 #define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
-#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED | (1<<8) )
+#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
+#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
+#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
+#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
+#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
+#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
 
 /*
 ** CAPI3REF: Flags For File Open Operations
@@ -476,11 +481,12 @@ SQLITE_API int sqlite3_exec(
 #define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
 #define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
 #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
+#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
 
 /*
 ** CAPI3REF: Device Characteristics
 **
-** The xDeviceCapabilities method of the [sqlite3_io_methods]
+** The xDeviceCharacteristics method of the [sqlite3_io_methods]
 ** object returns an integer which is a vector of the these
 ** bit values expressing I/O characteristics of the mass storage
 ** device that holds the file that the [sqlite3_io_methods]
@@ -497,17 +503,18 @@ SQLITE_API int sqlite3_exec(
 ** information is written to disk in the same order as calls
 ** to xWrite().
 */
-#define SQLITE_IOCAP_ATOMIC          0x00000001
-#define SQLITE_IOCAP_ATOMIC512       0x00000002
-#define SQLITE_IOCAP_ATOMIC1K        0x00000004
-#define SQLITE_IOCAP_ATOMIC2K        0x00000008
-#define SQLITE_IOCAP_ATOMIC4K        0x00000010
-#define SQLITE_IOCAP_ATOMIC8K        0x00000020
-#define SQLITE_IOCAP_ATOMIC16K       0x00000040
-#define SQLITE_IOCAP_ATOMIC32K       0x00000080
-#define SQLITE_IOCAP_ATOMIC64K       0x00000100
-#define SQLITE_IOCAP_SAFE_APPEND     0x00000200
-#define SQLITE_IOCAP_SEQUENTIAL      0x00000400
+#define SQLITE_IOCAP_ATOMIC                 0x00000001
+#define SQLITE_IOCAP_ATOMIC512              0x00000002
+#define SQLITE_IOCAP_ATOMIC1K               0x00000004
+#define SQLITE_IOCAP_ATOMIC2K               0x00000008
+#define SQLITE_IOCAP_ATOMIC4K               0x00000010
+#define SQLITE_IOCAP_ATOMIC8K               0x00000020
+#define SQLITE_IOCAP_ATOMIC16K              0x00000040
+#define SQLITE_IOCAP_ATOMIC32K              0x00000080
+#define SQLITE_IOCAP_ATOMIC64K              0x00000100
+#define SQLITE_IOCAP_SAFE_APPEND            0x00000200
+#define SQLITE_IOCAP_SEQUENTIAL             0x00000400
+#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800
 
 /*
 ** CAPI3REF: File Locking Levels
@@ -658,6 +665,12 @@ struct sqlite3_io_methods {
   int (*xFileControl)(sqlite3_file*, int op, void *pArg);
   int (*xSectorSize)(sqlite3_file*);
   int (*xDeviceCharacteristics)(sqlite3_file*);
+  /* Methods above are valid for version 1 */
+  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
+  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
+  void (*xShmBarrier)(sqlite3_file*);
+  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
+  /* Methods above are valid for version 2 */
   /* Additional methods may be added in future releases */
 };
 
@@ -675,11 +688,28 @@ struct sqlite3_io_methods {
 ** into an integer that the pArg argument points to. This capability
 ** is used during testing and only needs to be supported when SQLITE_TEST
 ** is defined.
+**
+** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
+** layer a hint of how large the database file will grow to be during the
+** current transaction.  This hint is not guaranteed to be accurate but it
+** is often close.  The underlying VFS might choose to preallocate database
+** file space based on this hint in order to help writes to the database
+** file run faster.
+**
+** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
+** extends and truncates the database file in chunks of a size specified
+** by the user. The fourth argument to [sqlite3_file_control()] should 
+** point to an integer (type int) containing the new chunk-size to use
+** for the nominated database. Allocating database file space in large
+** chunks (say 1MB at a time), may reduce file-system fragmentation and
+** improve performance on some systems.
 */
 #define SQLITE_FCNTL_LOCKSTATE        1
 #define SQLITE_GET_LOCKPROXYFILE      2
 #define SQLITE_SET_LOCKPROXYFILE      3
 #define SQLITE_LAST_ERRNO             4
+#define SQLITE_FCNTL_SIZE_HINT        5
+#define SQLITE_FCNTL_CHUNK_SIZE       6
 
 /*
 ** CAPI3REF: Mutex Handle
@@ -727,15 +757,19 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** The zName field holds the name of the VFS module.  The name must
 ** be unique across all VFS modules.
 **
-** SQLite will guarantee that the zFilename parameter to xOpen
+** ^SQLite guarantees that the zFilename parameter to xOpen
 ** is either a NULL pointer or string obtained
-** from xFullPathname().  SQLite further guarantees that
+** from xFullPathname() with an optional suffix added.
+** ^If a suffix is added to the zFilename parameter, it will
+** consist of a single "-" character followed by no more than
+** 10 alphanumeric and/or "-" characters.
+** ^SQLite further guarantees that
 ** the string will be valid and unchanged until xClose() is
 ** called. Because of the previous sentence,
 ** the [sqlite3_file] can safely store a pointer to the
 ** filename if it needs to remember the filename for some reason.
-** If the zFilename parameter is xOpen is a NULL pointer then xOpen
-** must invent its own temporary name for the file.  Whenever the 
+** If the zFilename parameter to xOpen is a NULL pointer then xOpen
+** must invent its own temporary name for the file.  ^Whenever the 
 ** xFilename parameter is NULL it will also be the case that the
 ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
 **
@@ -746,7 +780,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** If xOpen() opens a file read-only then it sets *pOutFlags to
 ** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
 **
-** SQLite will also add one of the following flags to the xOpen()
+** ^(SQLite will also add one of the following flags to the xOpen()
 ** call, depending on the object being opened:
 **
 ** <ul>
@@ -757,7 +791,8 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** <li>  [SQLITE_OPEN_TRANSIENT_DB]
 ** <li>  [SQLITE_OPEN_SUBJOURNAL]
 ** <li>  [SQLITE_OPEN_MASTER_JOURNAL]
-** </ul>
+** <li>  [SQLITE_OPEN_WAL]
+** </ul>)^
 **
 ** The file I/O implementation can use the object type flags to
 ** change the way it deals with files.  For example, an application
@@ -776,10 +811,11 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** </ul>
 **
 ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
-** deleted when it is closed.  The [SQLITE_OPEN_DELETEONCLOSE]
-** will be set for TEMP  databases, journals and for subjournals.
+** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
+** will be set for TEMP databases and their journals, transient
+** databases, and subjournals.
 **
-** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
+** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
 ** with the [SQLITE_OPEN_CREATE] flag, which are both directly
 ** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
 ** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 
@@ -788,7 +824,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** It is <i>not</i> used to indicate the file should be opened 
 ** for exclusive access.
 **
-** At least szOsFile bytes of memory are allocated by SQLite
+** ^At least szOsFile bytes of memory are allocated by SQLite
 ** to hold the  [sqlite3_file] structure passed as the third
 ** argument to xOpen.  The xOpen method does not have to
 ** allocate the structure; it should just fill it in.  Note that
@@ -798,33 +834,40 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** element will be valid after xOpen returns regardless of the success
 ** or failure of the xOpen call.
 **
-** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
+** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
 ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
 ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
 ** to test whether a file is at least readable.   The file can be a
 ** directory.
 **
-** SQLite will always allocate at least mxPathname+1 bytes for the
+** ^SQLite will always allocate at least mxPathname+1 bytes for the
 ** output buffer xFullPathname.  The exact size of the output buffer
 ** is also passed as a parameter to both  methods. If the output buffer
 ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
 ** handled as a fatal error by SQLite, vfs implementations should endeavor
 ** to prevent this by setting mxPathname to a sufficiently large value.
 **
-** The xRandomness(), xSleep(), and xCurrentTime() interfaces
-** are not strictly a part of the filesystem, but they are
+** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
+** interfaces are not strictly a part of the filesystem, but they are
 ** included in the VFS structure for completeness.
 ** The xRandomness() function attempts to return nBytes bytes
 ** of good-quality randomness into zOut.  The return value is
 ** the actual number of bytes of randomness obtained.
 ** The xSleep() method causes the calling thread to sleep for at
-** least the number of microseconds given.  The xCurrentTime()
-** method returns a Julian Day Number for the current date and time.
-**
+** least the number of microseconds given.  ^The xCurrentTime()
+** method returns a Julian Day Number for the current date and time as
+** a floating point value.
+** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
+** Day Number multipled by 86400000 (the number of milliseconds in 
+** a 24-hour day).  
+** ^SQLite will use the xCurrentTimeInt64() method to get the current
+** date and time if that method is available (if iVersion is 2 or 
+** greater and the function pointer is not NULL) and will fall back
+** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
 */
 typedef struct sqlite3_vfs sqlite3_vfs;
 struct sqlite3_vfs {
-  int iVersion;            /* Structure version number */
+  int iVersion;            /* Structure version number (currently 2) */
   int szOsFile;            /* Size of subclassed sqlite3_file */
   int mxPathname;          /* Maximum file pathname length */
   sqlite3_vfs *pNext;      /* Next registered VFS */
@@ -843,8 +886,16 @@ struct sqlite3_vfs {
   int (*xSleep)(sqlite3_vfs*, int microseconds);
   int (*xCurrentTime)(sqlite3_vfs*, double*);
   int (*xGetLastError)(sqlite3_vfs*, int, char *);
-  /* New fields may be appended in figure versions.  The iVersion
-  ** value will increment whenever this happens. */
+  /*
+  ** The methods above are in version 1 of the sqlite_vfs object
+  ** definition.  Those that follow are added in version 2 or later
+  */
+  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
+  /*
+  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
+  ** New fields may be appended in figure versions.  The iVersion
+  ** value will increment whenever this happens. 
+  */
 };
 
 /*
@@ -856,13 +907,58 @@ struct sqlite3_vfs {
 ** With SQLITE_ACCESS_EXISTS, the xAccess method
 ** simply checks whether the file exists.
 ** With SQLITE_ACCESS_READWRITE, the xAccess method
-** checks whether the file is both readable and writable.
+** checks whether the named directory is both readable and writable
+** (in other words, if files can be added, removed, and renamed within
+** the directory).
+** The SQLITE_ACCESS_READWRITE constant is currently used only by the
+** [temp_store_directory pragma], though this could change in a future
+** release of SQLite.
 ** With SQLITE_ACCESS_READ, the xAccess method
-** checks whether the file is readable.
+** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is
+** currently unused, though it might be used in a future release of
+** SQLite.
 */
 #define SQLITE_ACCESS_EXISTS    0
-#define SQLITE_ACCESS_READWRITE 1
-#define SQLITE_ACCESS_READ      2
+#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */
+#define SQLITE_ACCESS_READ      2   /* Unused */
+
+/*
+** CAPI3REF: Flags for the xShmLock VFS method
+**
+** These integer constants define the various locking operations
+** allowed by the xShmLock method of [sqlite3_io_methods].  The
+** following are the only legal combinations of flags to the
+** xShmLock method:
+**
+** <ul>
+** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
+** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
+** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
+** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
+** </ul>
+**
+** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
+** was given no the corresponding lock.  
+**
+** The xShmLock method can transition between unlocked and SHARED or
+** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
+** and EXCLUSIVE.
+*/
+#define SQLITE_SHM_UNLOCK       1
+#define SQLITE_SHM_LOCK         2
+#define SQLITE_SHM_SHARED       4
+#define SQLITE_SHM_EXCLUSIVE    8
+
+/*
+** CAPI3REF: Maximum xShmLock index
+**
+** The xShmLock method on [sqlite3_io_methods] may use values
+** between 0 and this upper bound as its "offset" argument.
+** The SQLite core will never attempt to acquire or release a
+** lock outside of this range
+*/
+#define SQLITE_SHM_NLOCK        8
+
 
 /*
 ** CAPI3REF: Initialize The SQLite Library
@@ -973,11 +1069,10 @@ SQLITE_API int sqlite3_os_end(void);
 ** ^If the option is unknown or SQLite is unable to set the option
 ** then this routine returns a non-zero [error code].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
+SQLITE_API int sqlite3_config(int, ...);
 
 /*
 ** CAPI3REF: Configure database connections
-** EXPERIMENTAL
 **
 ** The sqlite3_db_config() interface is used to make configuration
 ** changes to a [database connection].  The interface is similar to
@@ -997,11 +1092,10 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
 ** the call is considered successful.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
+SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
 
 /*
 ** CAPI3REF: Memory Allocation Routines
-** EXPERIMENTAL
 **
 ** An instance of this object defines the interface between SQLite
 ** and low-level memory allocation routines.
@@ -1083,7 +1177,6 @@ struct sqlite3_mem_methods {
 
 /*
 ** CAPI3REF: Configuration Options
-** EXPERIMENTAL
 **
 ** These constants are the available integer configuration options that
 ** can be passed as the first argument to the [sqlite3_config()] interface.
@@ -1161,7 +1254,7 @@ struct sqlite3_mem_methods {
 **   <ul>
 **   <li> [sqlite3_memory_used()]
 **   <li> [sqlite3_memory_highwater()]
-**   <li> [sqlite3_soft_heap_limit()]
+**   <li> [sqlite3_soft_heap_limit64()]
 **   <li> [sqlite3_status()]
 **   </ul>)^
 ** ^Memory allocation statistics are enabled by default unless SQLite is
@@ -1175,15 +1268,14 @@ struct sqlite3_mem_methods {
 ** aligned memory buffer from which the scrach allocations will be
 ** drawn, the size of each scratch allocation (sz),
 ** and the maximum number of scratch allocations (N).  The sz
-** argument must be a multiple of 16. The sz parameter should be a few bytes
-** larger than the actual scratch space required due to internal overhead.
+** argument must be a multiple of 16.
 ** The first argument must be a pointer to an 8-byte aligned buffer
 ** of at least sz*N bytes of memory.
-** ^SQLite will use no more than one scratch buffer per thread.  So
-** N should be set to the expected maximum number of threads.  ^SQLite will
-** never require a scratch buffer that is more than 6 times the database
-** page size. ^If SQLite needs needs additional scratch memory beyond 
-** what is provided by this configuration option, then 
+** ^SQLite will use no more than two scratch buffers per thread.  So
+** N should be set to twice the expected maximum number of threads.
+** ^SQLite will never require a scratch buffer that is more than 6
+** times the database page size. ^If SQLite needs needs additional
+** scratch memory beyond what is provided by this configuration option, then 
 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 **
 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
@@ -1203,8 +1295,7 @@ struct sqlite3_mem_methods {
 ** memory needs for the first N pages that it adds to cache.  ^If additional
 ** page cache memory is needed beyond what is provided by this option, then
 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** ^The implementation might use one or more of the N buffers to hold 
-** memory accounting information. The pointer in the first argument must
+** The pointer in the first argument must
 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
 ** will be undefined.</dd>
 **
@@ -1269,6 +1360,24 @@ struct sqlite3_mem_methods {
 ** [sqlite3_pcache_methods] object.  SQLite copies of the current
 ** page cache implementation into that object.)^ </dd>
 **
+** <dt>SQLITE_CONFIG_LOG</dt>
+** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
+** function with a call signature of void(*)(void*,int,const char*), 
+** and a pointer to void. ^If the function pointer is not NULL, it is
+** invoked by [sqlite3_log()] to process each logging event.  ^If the
+** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
+** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
+** passed through as the first parameter to the application-defined logger
+** function whenever that function is invoked.  ^The second parameter to
+** the logger function is a copy of the first parameter to the corresponding
+** [sqlite3_log()] call and is intended to be a [result code] or an
+** [extended result code].  ^The third parameter passed to the logger is
+** log message after formatting via [sqlite3_snprintf()].
+** The SQLite logging interface is not reentrant; the logger function
+** supplied by the application must not invoke any SQLite interface.
+** In a multi-threaded application, the application-defined logger
+** function must be threadsafe. </dd>
+**
 ** </dl>
 */
 #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
@@ -1289,8 +1398,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
 
 /*
-** CAPI3REF: Configuration Options
-** EXPERIMENTAL
+** CAPI3REF: Database Connection Configuration Options
 **
 ** These constants are the available integer configuration options that
 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
@@ -1316,8 +1424,14 @@ struct sqlite3_mem_methods {
 ** or equal to the product of the second and third arguments.  The buffer
 ** must be aligned to an 8-byte boundary.  ^If the second argument to
 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
-** rounded down to the next smaller
-** multiple of 8.  See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
+** rounded down to the next smaller multiple of 8.  ^(The lookaside memory
+** configuration for a database connection can only be changed when that
+** connection is not currently using lookaside memory, or in other words
+** when the "current value" returned by
+** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
+** Any attempt to change the lookaside memory configuration when lookaside
+** memory is in use leaves the configuration unchanged and returns 
+** [SQLITE_BUSY].)^</dd>
 **
 ** </dl>
 */
@@ -1622,6 +1736,9 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 /*
 ** CAPI3REF: Convenience Routines For Running Queries
 **
+** This is a legacy interface that is preserved for backwards compatibility.
+** Use of this interface is not recommended.
+**
 ** Definition: A <b>result table</b> is memory data structure created by the
 ** [sqlite3_get_table()] interface.  A result table records the
 ** complete query results from one or more queries.
@@ -1642,7 +1759,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 ** It is not safe to pass a result table directly to [sqlite3_free()].
 ** A result table should be deallocated using [sqlite3_free_table()].
 **
-** As an example of the result table format, suppose a query result
+** ^(As an example of the result table format, suppose a query result
 ** is as follows:
 **
 ** <blockquote><pre>
@@ -1666,7 +1783,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 **        azResult[5] = "28";
 **        azResult[6] = "Cindy";
 **        azResult[7] = "21";
-** </pre></blockquote>
+** </pre></blockquote>)^
 **
 ** ^The sqlite3_get_table() function evaluates one or more
 ** semicolon-separated SQL statements in the zero-terminated UTF-8
@@ -1674,19 +1791,19 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
 ** pointer given in its 3rd parameter.
 **
 ** After the application has finished with the result from sqlite3_get_table(),
-** it should pass the result table pointer to sqlite3_free_table() in order to
+** it must pass the result table pointer to sqlite3_free_table() in order to
 ** release the memory that was malloced.  Because of the way the
 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
 ** function must not try to call [sqlite3_free()] directly.  Only
 ** [sqlite3_free_table()] is able to release the memory properly and safely.
 **
-** ^(The sqlite3_get_table() interface is implemented as a wrapper around
+** The sqlite3_get_table() interface is implemented as a wrapper around
 ** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access
 ** to any internal data structures of SQLite.  It uses only the public
 ** interface defined here.  As a consequence, errors that occur in the
 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
 ** reflected in subsequent calls to [sqlite3_errcode()] or
-** [sqlite3_errmsg()].)^
+** [sqlite3_errmsg()].
 */
 SQLITE_API int sqlite3_get_table(
   sqlite3 *db,          /* An open database */
@@ -1838,7 +1955,9 @@ SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
 ** is not freed.
 **
 ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
-** is always aligned to at least an 8 byte boundary.
+** is always aligned to at least an 8 byte boundary, or to a
+** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
+** option is used.
 **
 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
@@ -2066,7 +2185,6 @@ SQLITE_API int sqlite3_set_authorizer(
 
 /*
 ** CAPI3REF: Tracing And Profiling Functions
-** EXPERIMENTAL
 **
 ** These routines register callback functions that can be used for
 ** tracing and profiling the execution of SQL statements.
@@ -2082,26 +2200,43 @@ SQLITE_API int sqlite3_set_authorizer(
 ** ^The callback function registered by sqlite3_profile() is invoked
 ** as each SQL statement finishes.  ^The profile callback contains
 ** the original statement text and an estimate of wall-clock time
-** of how long that statement took to run.
-*/
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
+** of how long that statement took to run.  ^The profile callback
+** time is in units of nanoseconds, however the current implementation
+** is only capable of millisecond resolution so the six least significant
+** digits in the time are meaningless.  Future versions of SQLite
+** might provide greater resolution on the profiler callback.  The
+** sqlite3_profile() function is considered experimental and is
+** subject to change in future versions of SQLite.
+*/
+SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
    void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
 
 /*
 ** CAPI3REF: Query Progress Callbacks
 **
-** ^This routine configures a callback function - the
-** progress callback - that is invoked periodically during long
-** running calls to [sqlite3_exec()], [sqlite3_step()] and
-** [sqlite3_get_table()].  An example use for this
+** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
+** function X to be invoked periodically during long running calls to
+** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
+** database connection D.  An example use for this
 ** interface is to keep a GUI updated during a large query.
 **
+** ^The parameter P is passed through as the only parameter to the 
+** callback function X.  ^The parameter N is the number of 
+** [virtual machine instructions] that are evaluated between successive
+** invocations of the callback X.
+**
+** ^Only a single progress handler may be defined at one time per
+** [database connection]; setting a new progress handler cancels the
+** old one.  ^Setting parameter X to NULL disables the progress handler.
+** ^The progress handler is also disabled by setting N to a value less
+** than 1.
+**
 ** ^If the progress callback returns non-zero, the operation is
 ** interrupted.  This feature can be used to implement a
 ** "Cancel" button on a GUI progress dialog box.
 **
-** The progress handler must not do anything that will modify
+** The progress handler callback must not do anything that will modify
 ** the database connection that invoked the progress handler.
 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
 ** database connections for the meaning of "modify" in this paragraph.
@@ -2160,7 +2295,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
 ** combinations shown above or one of the combinations shown above combined
 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
-** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
+** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags,
 ** then the behavior is undefined.
 **
 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
@@ -2285,17 +2420,22 @@ typedef struct sqlite3_stmt sqlite3_stmt;
 ** [database connection] whose limit is to be set or queried.  The
 ** second parameter is one of the [limit categories] that define a
 ** class of constructs to be size limited.  The third parameter is the
-** new limit for that construct.  The function returns the old limit.)^
+** new limit for that construct.)^
 **
 ** ^If the new limit is a negative number, the limit is unchanged.
-** ^(For the limit category of SQLITE_LIMIT_XYZ there is a 
+** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a 
 ** [limits | hard upper bound]
-** set by a compile-time C preprocessor macro named 
-** [limits | SQLITE_MAX_XYZ].
+** set at compile-time by a C preprocessor macro called
+** [limits | SQLITE_MAX_<i>NAME</i>].
 ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
 ** ^Attempts to increase a limit above its hard upper bound are
 ** silently truncated to the hard upper bound.
 **
+** ^Regardless of whether or not the limit was changed, the 
+** [sqlite3_limit()] interface returns the prior value of the limit.
+** ^Hence, to find the current value of a limit without changing it,
+** simply invoke this interface with the third parameter set to -1.
+**
 ** Run-time limits are intended for use in applications that manage
 ** both their own internal database and also databases that are controlled
 ** by untrusted external sources.  An example application might be a
@@ -2324,7 +2464,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** <dl>
 ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
-** <dd>The maximum size of any string or BLOB or table row.<dd>)^
+** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
@@ -2342,7 +2482,9 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 **
 ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
 ** <dd>The maximum number of instructions in a virtual machine program
-** used to implement an SQL statement.</dd>)^
+** used to implement an SQL statement.  This limit is not currently
+** enforced, though that might be added in some future release of
+** SQLite.</dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
 ** <dd>The maximum number of arguments on a function.</dd>)^
@@ -2355,8 +2497,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** [GLOB] operators.</dd>)^
 **
 ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
-** <dd>The maximum number of variables in an SQL statement that can
-** be bound.</dd>)^
+** <dd>The maximum index number of any [parameter] in an SQL statement.)^
 **
 ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
 ** <dd>The maximum depth of recursion for triggers.</dd>)^
@@ -2428,12 +2569,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** <li>
 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
-** statement and try to run it again.  ^If the schema has changed in
-** a way that makes the statement no longer valid, [sqlite3_step()] will still
-** return [SQLITE_SCHEMA].  But unlike the legacy behavior, [SQLITE_SCHEMA] is
-** now a fatal error.  Calling [sqlite3_prepare_v2()] again will not make the
-** error go away.  Note: use [sqlite3_errmsg()] to find the text
-** of the parsing error that results in an [SQLITE_SCHEMA] return.
+** statement and try to run it again.
 ** </li>
 **
 ** <li>
@@ -2446,11 +2582,16 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
 ** </li>
 **
 ** <li>
-** ^If the value of a [parameter | host parameter] in the WHERE clause might
-** change the query plan for a statement, then the statement may be
-** automatically recompiled (as if there had been a schema change) on the first 
-** [sqlite3_step()] call following any change to the 
-** [sqlite3_bind_text | bindings] of the [parameter]. 
+** ^If the specific value bound to [parameter | host parameter] in the 
+** WHERE clause might influence the choice of query plan for a statement,
+** then the statement will be automatically recompiled, as if there had been 
+** a schema change, on the first  [sqlite3_step()] call following any change
+** to the [sqlite3_bind_text | bindings] of that [parameter]. 
+** ^The specific value of WHERE-clause [parameter] might influence the 
+** choice of query plan if the parameter is the left-hand side of a [LIKE]
+** or [GLOB] operator or if the parameter is compared to an indexed column
+** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled.
+** the 
 ** </li>
 ** </ol>
 */
@@ -2517,7 +2658,7 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
 ** then there is no distinction between protected and unprotected
 ** sqlite3_value objects and they can be used interchangeably.  However,
 ** for maximum code portability it is recommended that applications
-** still make the distinction between between protected and unprotected
+** still make the distinction between protected and unprotected
 ** sqlite3_value objects even when not strictly required.
 **
 ** ^The sqlite3_value objects that are passed as parameters into the
@@ -2563,7 +2704,7 @@ typedef struct sqlite3_context sqlite3_context;
 ** </ul>
 **
 ** In the templates above, NNN represents an integer literal,
-** and VVV represents an alphanumeric identifer.)^  ^The values of these
+** and VVV represents an alphanumeric identifier.)^  ^The values of these
 ** parameters (also called "host parameter names" or "SQL parameters")
 ** can be set using the sqlite3_bind_*() routines defined here.
 **
@@ -2712,6 +2853,8 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
 ** ^Return the number of columns in the result set returned by the
 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
 ** statement that does not return data (for example an [UPDATE]).
+**
+** See also: [sqlite3_data_count()]
 */
 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
 
@@ -2877,6 +3020,14 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
 ** be the case that the same database connection is being used by two or
 ** more threads at the same moment in time.
 **
+** For all versions of SQLite up to and including 3.6.23.1, it was required
+** after sqlite3_step() returned anything other than [SQLITE_ROW] that
+** [sqlite3_reset()] be called before any subsequent invocation of
+** sqlite3_step().  Failure to invoke [sqlite3_reset()] in this way would
+** result in an [SQLITE_MISUSE] return from sqlite3_step().  But after
+** version 3.6.23.1, sqlite3_step() began calling [sqlite3_reset()] 
+** automatically in this circumstance rather than returning [SQLITE_MISUSE].  
+**
 ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
 ** API always returns a generic error code, [SQLITE_ERROR], following any
 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call
@@ -2894,8 +3045,14 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*);
 /*
 ** CAPI3REF: Number of columns in a result set
 **
-** ^The sqlite3_data_count(P) the number of columns in the
-** of the result set of [prepared statement] P.
+** ^The sqlite3_data_count(P) interface returns the number of columns in the
+** current row of the result set of [prepared statement] P.
+** ^If prepared statement P does not have results ready to return
+** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
+** interfaces) then sqlite3_data_count(P) returns 0.
+** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
+**
+** See also: [sqlite3_column_count()]
 */
 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 
@@ -2975,18 +3132,26 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** ^If the result is a numeric value then sqlite3_column_bytes() uses
 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
 ** the number of bytes in that string.
-** ^The value returned does not include the zero terminator at the end
-** of the string.  ^For clarity: the value returned is the number of
+** ^If the result is NULL, then sqlite3_column_bytes() returns zero.
+**
+** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
+** routine returns the number of bytes in that BLOB or string.
+** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
+** the string to UTF-16 and then returns the number of bytes.
+** ^If the result is a numeric value then sqlite3_column_bytes16() uses
+** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns
+** the number of bytes in that string.
+** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
+**
+** ^The values returned by [sqlite3_column_bytes()] and 
+** [sqlite3_column_bytes16()] do not include the zero terminators at the end
+** of the string.  ^For clarity: the values returned by
+** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
 ** bytes in the string, not the number of characters.
 **
 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
 ** even empty strings, are always zero terminated.  ^The return
-** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
-** pointer, possibly even a NULL pointer.
-**
-** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
-** but leaves the result in UTF-16 in native byte order instead of UTF-8.
-** ^The zero terminator is not included in this count.
+** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
 **
 ** ^The object returned by [sqlite3_column_value()] is an
 ** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object
@@ -3031,10 +3196,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** used in the table for brevity and because they are familiar to most
 ** C programmers.
 **
-** ^Note that when type conversions occur, pointers returned by prior
+** Note that when type conversions occur, pointers returned by prior
 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
 ** sqlite3_column_text16() may be invalidated.
-** ^(Type conversions and pointer invalidations might occur
+** Type conversions and pointer invalidations might occur
 ** in the following cases:
 **
 ** <ul>
@@ -3047,22 +3212,22 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
 **      sqlite3_column_text() is called.  The content must be converted
 **      to UTF-8.</li>
-** </ul>)^
+** </ul>
 **
 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
 ** not invalidate a prior pointer, though of course the content of the buffer
-** that the prior pointer points to will have been modified.  Other kinds
+** that the prior pointer references will have been modified.  Other kinds
 ** of conversion are done in place when it is possible, but sometimes they
 ** are not possible and in those cases prior pointers are invalidated.
 **
-** ^(The safest and easiest to remember policy is to invoke these routines
+** The safest and easiest to remember policy is to invoke these routines
 ** in one of the following ways:
 **
 ** <ul>
 **  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
 **  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
 **  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
-** </ul>)^
+** </ul>
 **
 ** In other words, you should call sqlite3_column_text(),
 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
@@ -3100,17 +3265,26 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
 ** CAPI3REF: Destroy A Prepared Statement Object
 **
 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
-** ^If the statement was executed successfully or not executed at all, then
-** SQLITE_OK is returned. ^If execution of the statement failed then an
-** [error code] or [extended error code] is returned.
-**
-** ^This routine can be called at any point during the execution of the
-** [prepared statement].  ^If the virtual machine has not
-** completed execution when this routine is called, that is like
-** encountering an error or an [sqlite3_interrupt | interrupt].
-** ^Incomplete updates may be rolled back and transactions canceled,
-** depending on the circumstances, and the
-** [error code] returned will be [SQLITE_ABORT].
+** ^If the most recent evaluation of the statement encountered no errors or
+** or if the statement is never been evaluated, then sqlite3_finalize() returns
+** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then
+** sqlite3_finalize(S) returns the appropriate [error code] or
+** [extended error code].
+**
+** ^The sqlite3_finalize(S) routine can be called at any point during
+** the life cycle of [prepared statement] S:
+** before statement S is ever evaluated, after
+** one or more calls to [sqlite3_reset()], or after any call
+** to [sqlite3_step()] regardless of whether or not the statement has
+** completed execution.
+**
+** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
+**
+** The application must finalize every [prepared statement] in order to avoid
+** resource leaks.  It is a grievous error for the application to try to use
+** a prepared statement after it has been finalized.  Any use of a prepared
+** statement after it has been finalized can result in undefined and
+** undesirable behavior such as segfaults and heap corruption.
 */
 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
 
@@ -3146,23 +3320,25 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** KEYWORDS: {application-defined SQL function}
 ** KEYWORDS: {application-defined SQL functions}
 **
-** ^These two functions (collectively known as "function creation routines")
+** ^These functions (collectively known as "function creation routines")
 ** are used to add SQL functions or aggregates or to redefine the behavior
-** of existing SQL functions or aggregates.  The only difference between the
-** two is that the second parameter, the name of the (scalar) function or
-** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
-** for sqlite3_create_function16().
+** of existing SQL functions or aggregates.  The only differences between
+** these routines are the text encoding expected for
+** the the second parameter (the name of the function being created)
+** and the presence or absence of a destructor callback for
+** the application data pointer.
 **
 ** ^The first parameter is the [database connection] to which the SQL
 ** function is to be added.  ^If an application uses more than one database
 ** connection then application-defined SQL functions must be added
 ** to each database connection separately.
 **
-** The second parameter is the name of the SQL function to be created or
-** redefined.  ^The length of the name is limited to 255 bytes, exclusive of
-** the zero-terminator.  Note that the name length limit is in bytes, not
-** characters.  ^Any attempt to create a function with a longer name
-** will result in [SQLITE_ERROR] being returned.
+** ^The second parameter is the name of the SQL function to be created or
+** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
+** representation, exclusive of the zero-terminator.  ^Note that the name
+** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  
+** ^Any attempt to create a function with a longer name
+** will result in [SQLITE_MISUSE] being returned.
 **
 ** ^The third parameter (nArg)
 ** is the number of arguments that the SQL function or
@@ -3172,10 +3348,10 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** parameter is less than -1 or greater than 127 then the behavior is
 ** undefined.
 **
-** The fourth parameter, eTextRep, specifies what
+** ^The fourth parameter, eTextRep, specifies what
 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
-** its parameters.  Any SQL function implementation should be able to work
-** work with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be
+** its parameters.  Every SQL function implementation must be able to work
+** with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be
 ** more efficient with one encoding than another.  ^An application may
 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
 ** times with the same function but with different values of eTextRep.
@@ -3187,13 +3363,21 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
 ** function can gain access to this pointer using [sqlite3_user_data()].)^
 **
-** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
+** ^The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
 ** pointers to C-language functions that implement the SQL function or
 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
-** callback only; NULL pointers should be passed as the xStep and xFinal
+** callback only; NULL pointers must be passed as the xStep and xFinal
 ** parameters. ^An aggregate SQL function requires an implementation of xStep
-** and xFinal and NULL should be passed for xFunc. ^To delete an existing
-** SQL function or aggregate, pass NULL for all three function callbacks.
+** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
+** SQL function or aggregate, pass NULL poiners for all three function
+** callbacks.
+**
+** ^If the tenth parameter to sqlite3_create_function_v2() is not NULL,
+** then it is invoked when the function is deleted, either by being
+** overloaded or when the database connection closes.
+** ^When the destructure callback of the tenth parameter is invoked, it
+** is passed a single argument which is a copy of the pointer which was
+** the fifth parameter to sqlite3_create_function_v2().
 **
 ** ^It is permitted to register multiple implementations of the same
 ** functions with the same name but with either differing numbers of
@@ -3209,11 +3393,6 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
 ** between UTF8 and UTF16.
 **
 ** ^Built-in functions may be overloaded by new application-defined functions.
-** ^The first application-defined function with a given name overrides all
-** built-in functions in the same [database connection] with the same name.
-** ^Subsequent application-defined functions of the same name only override 
-** prior application-defined functions that are an exact match for the
-** number of parameters and preferred encoding.
 **
 ** ^An application-defined function is permitted to call other
 ** SQLite interfaces.  However, such calls must not
@@ -3240,6 +3419,17 @@ SQLITE_API int sqlite3_create_function16(
   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
   void (*xFinal)(sqlite3_context*)
 );
+SQLITE_API int sqlite3_create_function_v2(
+  sqlite3 *db,
+  const char *zFunctionName,
+  int nArg,
+  int eTextRep,
+  void *pApp,
+  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
+  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
+  void (*xFinal)(sqlite3_context*),
+  void(*xDestroy)(void*)
+);
 
 /*
 ** CAPI3REF: Text Encodings
@@ -3334,7 +3524,7 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
 /*
 ** CAPI3REF: Obtain Aggregate Function Context
 **
-** Implementions of aggregate SQL functions use this
+** Implementations of aggregate SQL functions use this
 ** routine to allocate memory for storing their state.
 **
 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
@@ -3586,46 +3776,70 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
 /*
 ** CAPI3REF: Define New Collating Sequences
 **
-** These functions are used to add new collation sequences to the
-** [database connection] specified as the first argument.
+** ^These functions add, remove, or modify a [collation] associated
+** with the [database connection] specified as the first argument.
 **
-** ^The name of the new collation sequence is specified as a UTF-8 string
+** ^The name of the collation is a UTF-8 string
 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
-** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
-** the name is passed as the second function argument.
-**
-** ^The third argument may be one of the constants [SQLITE_UTF8],
-** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
-** routine expects to be passed pointers to strings encoded using UTF-8,
-** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
-** third argument might also be [SQLITE_UTF16] to indicate that the routine
-** expects pointers to be UTF-16 strings in the native byte order, or the
-** argument can be [SQLITE_UTF16_ALIGNED] if the
-** the routine expects pointers to 16-bit word aligned strings
-** of UTF-16 in the native byte order.
-**
-** A pointer to the user supplied routine must be passed as the fifth
-** argument.  ^If it is NULL, this is the same as deleting the collation
-** sequence (so that SQLite cannot call it anymore).
-** ^Each time the application supplied function is invoked, it is passed
-** as its first parameter a copy of the void* passed as the fourth argument
-** to sqlite3_create_collation() or sqlite3_create_collation16().
-**
-** ^The remaining arguments to the application-supplied routine are two strings,
-** each represented by a (length, data) pair and encoded in the encoding
-** that was passed as the third argument when the collation sequence was
-** registered.  The application defined collation routine should
-** return negative, zero or positive if the first string is less than,
-** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
+** and a UTF-16 string in native byte order for sqlite3_create_collation16().
+** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
+** considered to be the same name.
+**
+** ^(The third argument (eTextRep) must be one of the constants:
+** <ul>
+** <li> [SQLITE_UTF8],
+** <li> [SQLITE_UTF16LE],
+** <li> [SQLITE_UTF16BE],
+** <li> [SQLITE_UTF16], or
+** <li> [SQLITE_UTF16_ALIGNED].
+** </ul>)^
+** ^The eTextRep argument determines the encoding of strings passed
+** to the collating function callback, xCallback.
+** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep
+** force strings to be UTF16 with native byte order.
+** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
+** on an even byte address.
+**
+** ^The fourth argument, pArg, is a application data pointer that is passed
+** through as the first argument to the collating function callback.
+**
+** ^The fifth argument, xCallback, is a pointer to the collating function.
+** ^Multiple collating functions can be registered using the same name but
+** with different eTextRep parameters and SQLite will use whichever
+** function requires the least amount of data transformation.
+** ^If the xCallback argument is NULL then the collating function is
+** deleted.  ^When all collating functions having the same name are deleted,
+** that collation is no longer usable.
+**
+** ^The collating function callback is invoked with a copy of the pArg 
+** application data pointer and with two strings in the encoding specified
+** by the eTextRep argument.  The collating function must return an
+** integer that is negative, zero, or positive
+** if the first string is less than, equal to, or greater than the second,
+** respectively.  A collating function must alway return the same answer
+** given the same inputs.  If two or more collating functions are registered
+** to the same collation name (using different eTextRep values) then all
+** must give an equivalent answer when invoked with equivalent strings.
+** The collating function must obey the following properties for all
+** strings A, B, and C:
+**
+** <ol>
+** <li> If A==B then B==A.
+** <li> If A==B and B==C then A==C.
+** <li> If A<B THEN B>A.
+** <li> If A<B and B<C then A<C.
+** </ol>
+**
+** If a collating function fails any of the above constraints and that
+** collating function is  registered and used, then the behavior of SQLite
+** is undefined.
 **
 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
-** except that it takes an extra argument which is a destructor for
-** the collation.  ^The destructor is called when the collation is
-** destroyed and is passed a copy of the fourth parameter void* pointer
-** of the sqlite3_create_collation_v2().
-** ^Collations are destroyed when they are overridden by later calls to the
-** collation creation functions or when the [database connection] is closed
-** using [sqlite3_close()].
+** with the addition that the xDestroy callback is invoked on pArg when
+** the collating function is deleted.
+** ^Collating functions are deleted when they are overridden by later
+** calls to the collation creation functions or when the
+** [database connection] is closed using [sqlite3_close()].
 **
 ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
 */
@@ -3633,14 +3847,14 @@ SQLITE_API int sqlite3_create_collation(
   sqlite3*, 
   const char *zName, 
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*)
 );
 SQLITE_API int sqlite3_create_collation_v2(
   sqlite3*, 
   const char *zName, 
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*),
   void(*xDestroy)(void*)
 );
@@ -3648,7 +3862,7 @@ SQLITE_API int sqlite3_create_collation16(
   sqlite3*, 
   const void *zName,
   int eTextRep, 
-  void*,
+  void *pArg,
   int(*xCompare)(void*,int,const void*,int,const void*)
 );
 
@@ -3689,7 +3903,7 @@ SQLITE_API int sqlite3_collation_needed16(
   void(*)(void*,sqlite3*,int eTextRep,const void*)
 );
 
-#if SQLITE_HAS_CODEC
+#ifdef SQLITE_HAS_CODEC
 /*
 ** Specify the key for an encrypted database.  This routine should be
 ** called right after sqlite3_open().
@@ -3737,16 +3951,19 @@ SQLITE_API void sqlite3_activate_cerod(
 /*
 ** CAPI3REF: Suspend Execution For A Short Time
 **
-** ^The sqlite3_sleep() function causes the current thread to suspend execution
+** The sqlite3_sleep() function causes the current thread to suspend execution
 ** for at least a number of milliseconds specified in its parameter.
 **
-** ^If the operating system does not support sleep requests with
+** If the operating system does not support sleep requests with
 ** millisecond time resolution, then the time will be rounded up to
-** the nearest second. ^The number of milliseconds of sleep actually
+** the nearest second. The number of milliseconds of sleep actually
 ** requested from the operating system is returned.
 **
 ** ^SQLite implements this interface by calling the xSleep()
-** method of the default [sqlite3_vfs] object.
+** method of the default [sqlite3_vfs] object.  If the xSleep() method
+** of the default VFS is not implemented correctly, or not implemented at
+** all, then the behavior of sqlite3_sleep() may deviate from the description
+** in the previous paragraphs.
 */
 SQLITE_API int sqlite3_sleep(int);
 
@@ -3872,8 +4089,6 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
 ** an error or constraint causes an implicit rollback to occur.
 ** ^The rollback callback is not invoked if a transaction is
 ** automatically rolled back because the database connection is closed.
-** ^The rollback callback is not invoked if a transaction is
-** rolled back because a commit callback returned non-zero.
 **
 ** See also the [sqlite3_update_hook()] interface.
 */
@@ -3970,40 +4185,73 @@ SQLITE_API int sqlite3_enable_shared_cache(int);
 ** pages to improve performance is an example of non-essential memory.
 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
 ** which might be more or less than the amount requested.
+** ^The sqlite3_release_memory() routine is a no-op returning zero
+** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
 */
 SQLITE_API int sqlite3_release_memory(int);
 
 /*
 ** CAPI3REF: Impose A Limit On Heap Size
 **
-** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
-** on the amount of heap memory that may be allocated by SQLite.
-** ^If an internal allocation is requested that would exceed the
-** soft heap limit, [sqlite3_release_memory()] is invoked one or
-** more times to free up some space before the allocation is performed.
+** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
+** soft limit on the amount of heap memory that may be allocated by SQLite.
+** ^SQLite strives to keep heap memory utilization below the soft heap
+** limit by reducing the number of pages held in the page cache
+** as heap memory usages approaches the limit.
+** ^The soft heap limit is "soft" because even though SQLite strives to stay
+** below the limit, it will exceed the limit rather than generate
+** an [SQLITE_NOMEM] error.  In other words, the soft heap limit 
+** is advisory only.
 **
-** ^The limit is called "soft" because if [sqlite3_release_memory()]
-** cannot free sufficient memory to prevent the limit from being exceeded,
-** the memory is allocated anyway and the current operation proceeds.
+** ^The return value from sqlite3_soft_heap_limit64() is the size of
+** the soft heap limit prior to the call.  ^If the argument N is negative
+** then no change is made to the soft heap limit.  Hence, the current
+** size of the soft heap limit can be determined by invoking
+** sqlite3_soft_heap_limit64() with a negative argument.
 **
-** ^A negative or zero value for N means that there is no soft heap limit and
-** [sqlite3_release_memory()] will only be called when memory is exhausted.
-** ^The default value for the soft heap limit is zero.
+** ^If the argument N is zero then the soft heap limit is disabled.
 **
-** ^(SQLite makes a best effort to honor the soft heap limit.
-** But if the soft heap limit cannot be honored, execution will
-** continue without error or notification.)^  This is why the limit is
-** called a "soft" limit.  It is advisory only.
+** ^(The soft heap limit is not enforced in the current implementation
+** if one or more of following conditions are true:
 **
-** Prior to SQLite version 3.5.0, this routine only constrained the memory
-** allocated by a single thread - the same thread in which this routine
-** runs.  Beginning with SQLite version 3.5.0, the soft heap limit is
-** applied to all threads. The value specified for the soft heap limit
-** is an upper bound on the total memory allocation for all threads. In
-** version 3.5.0 there is no mechanism for limiting the heap usage for
-** individual threads.
+** <ul>
+** <li> The soft heap limit is set to zero.
+** <li> Memory accounting is disabled using a combination of the
+**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
+**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
+** <li> An alternative page cache implementation is specifed using
+**      [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
+** <li> The page cache allocates from its own memory pool supplied
+**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
+**      from the heap.
+** </ul>)^
+**
+** Beginning with SQLite version 3.7.3, the soft heap limit is enforced
+** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
+** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
+** the soft heap limit is enforced on every memory allocation.  Without
+** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
+** when memory is allocated by the page cache.  Testing suggests that because
+** the page cache is the predominate memory user in SQLite, most
+** applications will achieve adequate soft heap limit enforcement without
+** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
+**
+** The circumstances under which SQLite will enforce the soft heap limit may
+** changes in future releases of SQLite.
 */
-SQLITE_API void sqlite3_soft_heap_limit(int);
+SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
+
+/*
+** CAPI3REF: Deprecated Soft Heap Limit Interface
+** DEPRECATED
+**
+** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
+** interface.  This routine is provided for historical compatibility
+** only.  All new applications should use the
+** [sqlite3_soft_heap_limit64()] interface rather than this one.
+*/
+SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
+
 
 /*
 ** CAPI3REF: Extract Metadata About A Column Of A Table
@@ -4127,40 +4375,51 @@ SQLITE_API int sqlite3_load_extension(
 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
 
 /*
-** CAPI3REF: Automatically Load An Extensions
+** CAPI3REF: Automatically Load Statically Linked Extensions
 **
-** ^This API can be invoked at program startup in order to register
-** one or more statically linked extensions that will be available
-** to all new [database connections].
+** ^This interface causes the xEntryPoint() function to be invoked for
+** each new [database connection] that is created.  The idea here is that
+** xEntryPoint() is the entry point for a statically linked SQLite extension
+** that is to be automatically loaded into all new database connections.
 **
-** ^(This routine stores a pointer to the extension entry point
-** in an array that is obtained from [sqlite3_malloc()].  That memory
-** is deallocated by [sqlite3_reset_auto_extension()].)^
+** ^(Even though the function prototype shows that xEntryPoint() takes
+** no arguments and returns void, SQLite invokes xEntryPoint() with three
+** arguments and expects and integer result as if the signature of the
+** entry point where as follows:
 **
-** ^This function registers an extension entry point that is
-** automatically invoked whenever a new [database connection]
-** is opened using [sqlite3_open()], [sqlite3_open16()],
-** or [sqlite3_open_v2()].
-** ^Duplicate extensions are detected so calling this routine
-** multiple times with the same extension is harmless.
-** ^Automatic extensions apply across all threads.
+** <blockquote><pre>
+**    int xEntryPoint(
+**      sqlite3 *db,
+**      const char **pzErrMsg,
+**      const struct sqlite3_api_routines *pThunk
+**    );
+** </pre></blockquote>)^
+**
+** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
+** point to an appropriate error message (obtained from [sqlite3_mprintf()])
+** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg
+** is NULL before calling the xEntryPoint().  ^SQLite will invoke
+** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any
+** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],
+** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.
+**
+** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
+** on the list of automatic extensions is a harmless no-op. ^No entry point
+** will be called more than once for each database connection that is opened.
+**
+** See also: [sqlite3_reset_auto_extension()].
 */
 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
 
 /*
 ** CAPI3REF: Reset Automatic Extension Loading
 **
-** ^(This function disables all previously registered automatic
-** extensions. It undoes the effect of all prior
-** [sqlite3_auto_extension()] calls.)^
-**
-** ^This function disables automatic extensions in all threads.
+** ^This interface disables all automatic extensions previously
+** registered using [sqlite3_auto_extension()].
 */
 SQLITE_API void sqlite3_reset_auto_extension(void);
 
 /*
-****** EXPERIMENTAL - subject to change without notice **************
-**
 ** The interface to the virtual-table mechanism is currently considered
 ** to be experimental.  The interface might change in incompatible ways.
 ** If this is a problem for you, do not use the interface at this time.
@@ -4180,7 +4439,6 @@ typedef struct sqlite3_module sqlite3_module;
 /*
 ** CAPI3REF: Virtual Table Object
 ** KEYWORDS: sqlite3_module {virtual table module}
-** EXPERIMENTAL
 **
 ** This structure, sometimes called a a "virtual table module", 
 ** defines the implementation of a [virtual tables].  
@@ -4227,9 +4485,9 @@ struct sqlite3_module {
 /*
 ** CAPI3REF: Virtual Table Indexing Information
 ** KEYWORDS: sqlite3_index_info
-** EXPERIMENTAL
 **
-** The sqlite3_index_info structure and its substructures is used to
+** The sqlite3_index_info structure and its substructures is used as part
+** of the [virtual table] interface to
 ** pass information into and receive the reply from the [xBestIndex]
 ** method of a [virtual table module].  The fields under **Inputs** are the
 ** inputs to xBestIndex and are read-only.  xBestIndex inserts its
@@ -4237,10 +4495,12 @@ struct sqlite3_module {
 **
 ** ^(The aConstraint[] array records WHERE clause constraints of the form:
 **
-** <pre>column OP expr</pre>
+** <blockquote>column OP expr</blockquote>
 **
 ** where OP is =, <, <=, >, or >=.)^  ^(The particular operator is
-** stored in aConstraint[].op.)^  ^(The index of the column is stored in
+** stored in aConstraint[].op using one of the
+** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^
+** ^(The index of the column is stored in
 ** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the
 ** expr on the right-hand side can be evaluated (and thus the constraint
 ** is usable) and false if it cannot.)^
@@ -4300,6 +4560,15 @@ struct sqlite3_index_info {
   int orderByConsumed;       /* True if output is already ordered */
   double estimatedCost;      /* Estimated cost of using this index */
 };
+
+/*
+** CAPI3REF: Virtual Table Constraint Operator Codes
+**
+** These macros defined the allowed values for the
+** [sqlite3_index_info].aConstraint[].op field.  Each value represents
+** an operator that is part of a constraint term in the wHERE clause of
+** a query that uses a [virtual table].
+*/
 #define SQLITE_INDEX_CONSTRAINT_EQ    2
 #define SQLITE_INDEX_CONSTRAINT_GT    4
 #define SQLITE_INDEX_CONSTRAINT_LE    8
@@ -4309,7 +4578,6 @@ struct sqlite3_index_info {
 
 /*
 ** CAPI3REF: Register A Virtual Table Implementation
-** EXPERIMENTAL
 **
 ** ^These routines are used to register a new [virtual table module] name.
 ** ^Module names must be registered before
@@ -4331,13 +4599,13 @@ struct sqlite3_index_info {
 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
 ** destructor.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
+SQLITE_API int sqlite3_create_module(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
   const sqlite3_module *p,   /* Methods for the module */
   void *pClientData          /* Client data for xCreate/xConnect */
 );
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
+SQLITE_API int sqlite3_create_module_v2(
   sqlite3 *db,               /* SQLite connection to register module with */
   const char *zName,         /* Name of the module */
   const sqlite3_module *p,   /* Methods for the module */
@@ -4348,7 +4616,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
 /*
 ** CAPI3REF: Virtual Table Instance Object
 ** KEYWORDS: sqlite3_vtab
-** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass
 ** of this object to describe a particular instance
@@ -4374,7 +4641,6 @@ struct sqlite3_vtab {
 /*
 ** CAPI3REF: Virtual Table Cursor Object
 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
-** EXPERIMENTAL
 **
 ** Every [virtual table module] implementation uses a subclass of the
 ** following structure to describe cursors that point into the
@@ -4396,18 +4662,16 @@ struct sqlite3_vtab_cursor {
 
 /*
 ** CAPI3REF: Declare The Schema Of A Virtual Table
-** EXPERIMENTAL
 **
 ** ^The [xCreate] and [xConnect] methods of a
 ** [virtual table module] call this interface
 ** to declare the format (the names and datatypes of the columns) of
 ** the virtual tables they implement.
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
+SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
 
 /*
 ** CAPI3REF: Overload A Function For A Virtual Table
-** EXPERIMENTAL
 **
 ** ^(Virtual tables can provide alternative implementations of functions
 ** using the [xFindFunction] method of the [virtual table module].  
@@ -4422,7 +4686,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zS
 ** purpose is to be a placeholder function that can be overloaded
 ** by a [virtual table].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
+SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
 
 /*
 ** The interface to the virtual-table mechanism defined above (back up
@@ -4432,8 +4696,6 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const cha
 **
 ** When the virtual-table mechanism stabilizes, we will declare the
 ** interface fixed, support it indefinitely, and remove this comment.
-**
-****** EXPERIMENTAL - subject to change without notice **************
 */
 
 /*
@@ -4776,7 +5038,6 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 
 /*
 ** CAPI3REF: Mutex Methods Object
-** EXPERIMENTAL
 **
 ** An instance of this structure defines the low-level routines
 ** used to allocate and use mutexes.
@@ -4793,7 +5054,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 **
 ** ^The xMutexInit method defined by this structure is invoked as
 ** part of system initialization by the sqlite3_initialize() function.
-** ^The xMutexInit routine is calle by SQLite exactly once for each
+** ^The xMutexInit routine is called by SQLite exactly once for each
 ** effective call to [sqlite3_initialize()].
 **
 ** ^The xMutexEnd method defined by this structure is invoked as
@@ -4826,7 +5087,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
 ** it is passed a NULL pointer).
 **
 ** The xMutexInit() method must be threadsafe.  ^It must be harmless to
-** invoke xMutexInit() mutiple times within the same process and without
+** invoke xMutexInit() multiple times within the same process and without
 ** intervening calls to xMutexEnd().  Second and subsequent calls to
 ** xMutexInit() must be no-ops.
 **
@@ -4989,14 +5250,15 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 #define SQLITE_TESTCTRL_RESERVE                 14
 #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
 #define SQLITE_TESTCTRL_ISKEYWORD               16
-#define SQLITE_TESTCTRL_LAST                    16
+#define SQLITE_TESTCTRL_PGHDRSZ                 17
+#define SQLITE_TESTCTRL_SCRATCHMALLOC           18
+#define SQLITE_TESTCTRL_LAST                    18
 
 /*
 ** CAPI3REF: SQLite Runtime Status
-** EXPERIMENTAL
 **
 ** ^This interface is used to retrieve runtime status information
-** about the preformance of SQLite, and optionally to reset various
+** about the performance of SQLite, and optionally to reset various
 ** highwater marks.  ^The first argument is an integer code for
 ** the specific parameter to measure.  ^(Recognized integer codes
 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
@@ -5009,7 +5271,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 ** ^(Other parameters record only the highwater mark and not the current
 ** value.  For these latter parameters nothing is written into *pCurrent.)^
 **
-** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
+** ^The sqlite3_status() routine returns SQLITE_OK on success and a
 ** non-zero [error code] on failure.
 **
 ** This routine is threadsafe but is not atomic.  This routine can be
@@ -5021,12 +5283,11 @@ SQLITE_API int sqlite3_test_control(int op, ...);
 **
 ** See also: [sqlite3_db_status()]
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
 
 
 /*
 ** CAPI3REF: Status Parameters
-** EXPERIMENTAL
 **
 ** These integer constants designate various run-time status parameters
 ** that can be returned by [sqlite3_status()].
@@ -5049,6 +5310,9 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 ** *pHighwater parameter to [sqlite3_status()] is of interest.  
 ** The value written into the *pCurrent parameter is undefined.</dd>)^
 **
+** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
+** <dd>This parameter records the number of separate memory allocations.</dd>)^
+**
 ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
 ** <dd>This parameter returns the number of pages used out of the
 ** [pagecache memory allocator] that was configured using 
@@ -5057,7 +5321,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 **
 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
 ** <dd>This parameter returns the number of bytes of page cache
-** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
+** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The
 ** returned value includes allocations that overflowed because they
 ** where too large (they were larger than the "sz" parameter to
@@ -5080,7 +5344,7 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 **
 ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
 ** <dd>This parameter returns the number of bytes of scratch memory
-** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
+** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]
 ** buffer and where forced to overflow to [sqlite3_malloc()].  The values
 ** returned include overflows because the requested allocation was too
 ** larger (that is, because the requested allocation was larger than the
@@ -5110,30 +5374,34 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pH
 #define SQLITE_STATUS_PARSER_STACK         6
 #define SQLITE_STATUS_PAGECACHE_SIZE       7
 #define SQLITE_STATUS_SCRATCH_SIZE         8
+#define SQLITE_STATUS_MALLOC_COUNT         9
 
 /*
 ** CAPI3REF: Database Connection Status
-** EXPERIMENTAL
 **
 ** ^This interface is used to retrieve runtime status information 
 ** about a single [database connection].  ^The first argument is the
 ** database connection object to be interrogated.  ^The second argument
-** is the parameter to interrogate.  ^Currently, the only allowed value
-** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
-** Additional options will likely appear in future releases of SQLite.
+** is an integer constant, taken from the set of
+** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that
+** determines the parameter to interrogate.  The set of 
+** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely
+** to grow in future releases of SQLite.
 **
 ** ^The current value of the requested parameter is written into *pCur
 ** and the highest instantaneous value is written into *pHiwtr.  ^If
 ** the resetFlg is true, then the highest instantaneous value is
 ** reset back down to the current value.
 **
+** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
+** non-zero [error code] on failure.
+**
 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
+SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
 
 /*
 ** CAPI3REF: Status Parameters for database connections
-** EXPERIMENTAL
 **
 ** These constants are the available integer "verbs" that can be passed as
 ** the second argument to the [sqlite3_db_status()] interface.
@@ -5148,14 +5416,38 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
 ** <dd>This parameter returns the number of lookaside memory slots currently
 ** checked out.</dd>)^
+**
+** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** memory used by all pager caches associated with the database connection.)^
+** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
+**
+** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** memory used to store the schema for all databases associated
+** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
+** ^The full amount of memory used by the schemas is reported, even if the
+** schema memory is shared with other database connections due to
+** [shared cache mode] being enabled.
+** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
+**
+** ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
+** <dd>This parameter returns the approximate number of of bytes of heap
+** and lookaside memory used by all prepared statements associated with
+** the database connection.)^
+** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
+** </dd>
 ** </dl>
 */
 #define SQLITE_DBSTATUS_LOOKASIDE_USED     0
+#define SQLITE_DBSTATUS_CACHE_USED         1
+#define SQLITE_DBSTATUS_SCHEMA_USED        2
+#define SQLITE_DBSTATUS_STMT_USED          3
+#define SQLITE_DBSTATUS_MAX                3   /* Largest defined DBSTATUS */
 
 
 /*
 ** CAPI3REF: Prepared Statement Status
-** EXPERIMENTAL
 **
 ** ^(Each prepared statement maintains various
 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
@@ -5177,11 +5469,10 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur
 **
 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
 */
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
+SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
 
 /*
 ** CAPI3REF: Status Parameters for prepared statements
-** EXPERIMENTAL
 **
 ** These preprocessor macros define integer codes that name counter
 ** values associated with the [sqlite3_stmt_status()] interface.
@@ -5199,14 +5490,21 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int
 ** A non-zero value in this counter may indicate an opportunity to
 ** improvement performance through careful use of indices.</dd>
 **
+** <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
+** <dd>^This is the number of rows inserted into transient indices that
+** were created automatically in order to help joins run faster.
+** A non-zero value in this counter may indicate an opportunity to
+** improvement performance by adding permanent indices that do not
+** need to be reinitialized each time the statement is run.</dd>
+**
 ** </dl>
 */
 #define SQLITE_STMTSTATUS_FULLSCAN_STEP     1
 #define SQLITE_STMTSTATUS_SORT              2
+#define SQLITE_STMTSTATUS_AUTOINDEX         3
 
 /*
 ** CAPI3REF: Custom Page Cache Object
-** EXPERIMENTAL
 **
 ** The sqlite3_pcache type is opaque.  It is implemented by
 ** the pluggable module.  The SQLite core has no knowledge of
@@ -5221,36 +5519,45 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 /*
 ** CAPI3REF: Application Defined Page Cache.
 ** KEYWORDS: {page cache}
-** EXPERIMENTAL
 **
 ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
 ** register an alternative page cache implementation by passing in an 
-** instance of the sqlite3_pcache_methods structure.)^ The majority of the 
-** heap memory used by SQLite is used by the page cache to cache data read 
-** from, or ready to be written to, the database file. By implementing a 
-** custom page cache using this API, an application can control more 
-** precisely the amount of memory consumed by SQLite, the way in which 
+** instance of the sqlite3_pcache_methods structure.)^
+** In many applications, most of the heap memory allocated by 
+** SQLite is used for the page cache.
+** By implementing a 
+** custom page cache using this API, an application can better control
+** the amount of memory consumed by SQLite, the way in which 
 ** that memory is allocated and released, and the policies used to 
 ** determine exactly which parts of a database file are cached and for 
 ** how long.
 **
+** The alternative page cache mechanism is an
+** extreme measure that is only needed by the most demanding applications.
+** The built-in page cache is recommended for most uses.
+**
 ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
 ** internal buffer by SQLite within the call to [sqlite3_config].  Hence
 ** the application may discard the parameter after the call to
 ** [sqlite3_config()] returns.)^
 **
-** ^The xInit() method is called once for each call to [sqlite3_initialize()]
+** ^(The xInit() method is called once for each effective 
+** call to [sqlite3_initialize()])^
 ** (usually only once during the lifetime of the process). ^(The xInit()
 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
-** ^The xInit() method can set up up global structures and/or any mutexes
+** The intent of the xInit() method is to set up global data structures 
 ** required by the custom page cache implementation. 
+** ^(If the xInit() method is NULL, then the 
+** built-in default page cache is used instead of the application defined
+** page cache.)^
 **
-** ^The xShutdown() method is called from within [sqlite3_shutdown()], 
-** if the application invokes this API. It can be used to clean up 
+** ^The xShutdown() method is called by [sqlite3_shutdown()].
+** It can be used to clean up 
 ** any outstanding resources before process shutdown, if required.
+** ^The xShutdown() method may be NULL.
 **
-** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
-** the xInit method, so the xInit method need not be threadsafe.  ^The
+** ^SQLite automatically serializes calls to the xInit method,
+** so the xInit method need not be threadsafe.  ^The
 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
 ** not need to be threadsafe either.  All other methods must be threadsafe
 ** in multithreaded applications.
@@ -5258,47 +5565,50 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 ** ^SQLite will never invoke xInit() more than once without an intervening
 ** call to xShutdown().
 **
-** ^The xCreate() method is used to construct a new cache instance.  SQLite
-** will typically create one cache instance for each open database file,
+** ^SQLite invokes the xCreate() method to construct a new cache instance.
+** SQLite will typically create one cache instance for each open database file,
 ** though this is not guaranteed. ^The
 ** first parameter, szPage, is the size in bytes of the pages that must
 ** be allocated by the cache.  ^szPage will not be a power of two.  ^szPage
 ** will the page size of the database file that is to be cached plus an
-** increment (here called "R") of about 100 or 200.  ^SQLite will use the
+** increment (here called "R") of about 100 or 200.  SQLite will use the
 ** extra R bytes on each page to store metadata about the underlying
 ** database page on disk.  The value of R depends
 ** on the SQLite version, the target platform, and how SQLite was compiled.
 ** ^R is constant for a particular build of SQLite.  ^The second argument to
 ** xCreate(), bPurgeable, is true if the cache being created will
 ** be used to cache database pages of a file stored on disk, or
-** false if it is used for an in-memory database. ^The cache implementation
+** false if it is used for an in-memory database. The cache implementation
 ** does not have to do anything special based with the value of bPurgeable;
 ** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will
 ** never invoke xUnpin() except to deliberately delete a page.
-** ^In other words, a cache created with bPurgeable set to false will
+** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
+** false will always have the "discard" flag set to true.  
+** ^Hence, a cache created with bPurgeable false will
 ** never contain any unpinned pages.
 **
 ** ^(The xCachesize() method may be called at any time by SQLite to set the
 ** suggested maximum cache-size (number of pages stored by) the cache
 ** instance passed as the first argument. This is the value configured using
-** the SQLite "[PRAGMA cache_size]" command.)^  ^As with the bPurgeable
+** the SQLite "[PRAGMA cache_size]" command.)^  As with the bPurgeable
 ** parameter, the implementation is not required to do anything with this
 ** value; it is advisory only.
 **
-** ^The xPagecount() method should return the number of pages currently
-** stored in the cache.
+** The xPagecount() method must return the number of pages currently
+** stored in the cache, both pinned and unpinned.
 ** 
-** ^The xFetch() method is used to fetch a page and return a pointer to it. 
-** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
-** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
-** mimimum key value is 1. After it has been retrieved using xFetch, the page 
+** The xFetch() method locates a page in the cache and returns a pointer to 
+** the page, or a NULL pointer.
+** A "page", in this context, means a buffer of szPage bytes aligned at an
+** 8-byte boundary. The page to be fetched is determined by the key. ^The
+** mimimum key value is 1.  After it has been retrieved using xFetch, the page 
 ** is considered to be "pinned".
 **
-** ^If the requested page is already in the page cache, then the page cache
+** If the requested page is already in the page cache, then the page cache
 ** implementation must return a pointer to the page buffer with its content
-** intact.  ^(If the requested page is not already in the cache, then the
-** behavior of the cache implementation is determined by the value of the
-** createFlag parameter passed to xFetch, according to the following table:
+** intact.  If the requested page is not already in the cache, then the
+** behavior of the cache implementation should use the value of the createFlag
+** parameter to help it determined what action to take:
 **
 ** <table border=1 width=85% align=center>
 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5307,36 +5617,35 @@ typedef struct sqlite3_pcache sqlite3_pcache;
 **                 Otherwise return NULL.
 ** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return
 **                 NULL if allocating a new page is effectively impossible.
-** </table>)^
+** </table>
 **
-** SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  If
-** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
+** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite
+** will only use a createFlag of 2 after a prior call with a createFlag of 1
+** failed.)^  In between the to xFetch() calls, SQLite may
 ** attempt to unpin one or more cache pages by spilling the content of
-** pinned pages to disk and synching the operating system disk cache. After
-** attempting to unpin pages, the xFetch() method will be invoked again with
-** a createFlag of 2.
+** pinned pages to disk and synching the operating system disk cache.
 **
 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
-** as its second argument. ^(If the third parameter, discard, is non-zero,
-** then the page should be evicted from the cache. In this case SQLite 
-** assumes that the next time the page is retrieved from the cache using
-** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
-** zero, then the page is considered to be unpinned. ^The cache implementation
+** as its second argument.  If the third parameter, discard, is non-zero,
+** then the page must be evicted from the cache.
+** ^If the discard parameter is
+** zero, then the page may be discarded or retained at the discretion of
+** page cache implementation. ^The page cache implementation
 ** may choose to evict unpinned pages at any time.
 **
-** ^(The cache is not required to perform any reference counting. A single 
+** The cache must not perform any reference counting. A single 
 ** call to xUnpin() unpins the page regardless of the number of prior calls 
-** to xFetch().)^
+** to xFetch().
 **
-** ^The xRekey() method is used to change the key value associated with the
-** page passed as the second argument from oldKey to newKey. ^If the cache
-** previously contains an entry associated with newKey, it should be
+** The xRekey() method is used to change the key value associated with the
+** page passed as the second argument. If the cache
+** previously contains an entry associated with newKey, it must be
 ** discarded. ^Any prior cache entry associated with newKey is guaranteed not
 ** to be pinned.
 **
-** ^When SQLite calls the xTruncate() method, the cache must discard all
+** When SQLite calls the xTruncate() method, the cache must discard all
 ** existing cache entries with page numbers (keys) greater than or equal
-** to the value of the iLimit parameter passed to xTruncate(). ^If any
+** to the value of the iLimit parameter passed to xTruncate(). If any
 ** of these pages are pinned, they are implicitly unpinned, meaning that
 ** they can be safely discarded.
 **
@@ -5363,7 +5672,6 @@ struct sqlite3_pcache_methods {
 
 /*
 ** CAPI3REF: Online Backup Object
-** EXPERIMENTAL
 **
 ** The sqlite3_backup object records state information about an ongoing
 ** online backup operation.  ^The sqlite3_backup object is created by
@@ -5376,7 +5684,6 @@ typedef struct sqlite3_backup sqlite3_backup;
 
 /*
 ** CAPI3REF: Online Backup API.
-** EXPERIMENTAL
 **
 ** The backup API copies the content of one database into another.
 ** It is useful either for creating backups of databases or
@@ -5445,10 +5752,14 @@ typedef struct sqlite3_backup sqlite3_backup;
 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
 **
-** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
-** database was opened read-only or if
-** the destination is an in-memory database with a different page size
-** from the source database.
+** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if
+** <ol>
+** <li> the destination database was opened read-only, or
+** <li> the destination database is using write-ahead-log journaling
+** and the destination and source page sizes differ, or
+** <li> The destination database is an in-memory database and the
+** destination and source page sizes differ.
+** </ol>)^
 **
 ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
 ** the [sqlite3_busy_handler | busy-handler function]
@@ -5510,7 +5821,7 @@ typedef struct sqlite3_backup sqlite3_backup;
 **
 ** ^Each call to sqlite3_backup_step() sets two values inside
 ** the [sqlite3_backup] object: the number of pages still to be backed
-** up and the total number of pages in the source databae file.
+** up and the total number of pages in the source database file.
 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
 ** retrieve these two values, respectively.
 **
@@ -5564,7 +5875,6 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 
 /*
 ** CAPI3REF: Unlock Notification
-** EXPERIMENTAL
 **
 ** ^When running in shared-cache mode, a database operation may fail with
 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
@@ -5607,7 +5917,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
 ** blocked connection already has a registered unlock-notify callback,
 ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
 ** called with a NULL pointer as its second argument, then any existing
-** unlock-notify callback is cancelled. ^The blocked connections 
+** unlock-notify callback is canceled. ^The blocked connections 
 ** unlock-notify callback may also be canceled by closing the blocked
 ** connection using [sqlite3_close()].
 **
@@ -5686,23 +5996,21 @@ SQLITE_API int sqlite3_unlock_notify(
 
 /*
 ** CAPI3REF: String Comparison
-** EXPERIMENTAL
 **
 ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
 ** compare the contents of two buffers containing UTF-8 strings in a
-** case-indendent fashion, using the same definition of case independence 
+** case-independent fashion, using the same definition of case independence 
 ** that SQLite uses internally when comparing identifiers.
 */
 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
 
 /*
 ** CAPI3REF: Error Logging Interface
-** EXPERIMENTAL
 **
 ** ^The [sqlite3_log()] interface writes a message into the error log
 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
 ** ^If logging is enabled, the zFormat string and subsequent arguments are
-** passed through to [sqlite3_vmprintf()] to generate the final output string.
+** used with [sqlite3_snprintf()] to generate the final output string.
 **
 ** The sqlite3_log() interface is intended for use by extensions such as
 ** virtual tables, collating functions, and SQL functions.  While there is
@@ -5720,6 +6028,89 @@ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
 
 /*
+** CAPI3REF: Write-Ahead Log Commit Hook
+**
+** ^The [sqlite3_wal_hook()] function is used to register a callback that
+** will be invoked each time a database connection commits data to a
+** [write-ahead log] (i.e. whenever a transaction is committed in
+** [journal_mode | journal_mode=WAL mode]). 
+**
+** ^The callback is invoked by SQLite after the commit has taken place and 
+** the associated write-lock on the database released, so the implementation 
+** may read, write or [checkpoint] the database as required.
+**
+** ^The first parameter passed to the callback function when it is invoked
+** is a copy of the third parameter passed to sqlite3_wal_hook() when
+** registering the callback. ^The second is a copy of the database handle.
+** ^The third parameter is the name of the database that was written to -
+** either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter
+** is the number of pages currently in the write-ahead log file,
+** including those that were just committed.
+**
+** The callback function should normally return [SQLITE_OK].  ^If an error
+** code is returned, that error will propagate back up through the
+** SQLite code base to cause the statement that provoked the callback
+** to report an error, though the commit will have still occurred. If the
+** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value
+** that does not correspond to any valid SQLite error code, the results
+** are undefined.
+**
+** A single database handle may have at most a single write-ahead log callback 
+** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
+** previously registered write-ahead log callback. ^Note that the
+** [sqlite3_wal_autocheckpoint()] interface and the
+** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
+** those overwrite any prior [sqlite3_wal_hook()] settings.
+*/
+SQLITE_API void *sqlite3_wal_hook(
+  sqlite3*, 
+  int(*)(void *,sqlite3*,const char*,int),
+  void*
+);
+
+/*
+** CAPI3REF: Configure an auto-checkpoint
+**
+** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
+** [sqlite3_wal_hook()] that causes any database on [database connection] D
+** to automatically [checkpoint]
+** after committing a transaction if there are N or
+** more frames in the [write-ahead log] file.  ^Passing zero or 
+** a negative value as the nFrame parameter disables automatic
+** checkpoints entirely.
+**
+** ^The callback registered by this function replaces any existing callback
+** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback
+** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism
+** configured by this function.
+**
+** ^The [wal_autocheckpoint pragma] can be used to invoke this interface
+** from SQL.
+**
+** ^Every new [database connection] defaults to having the auto-checkpoint
+** enabled with a threshold of 1000 pages.  The use of this interface
+** is only necessary if the default setting is found to be suboptimal
+** for a particular application.
+*/
+SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
+
+/*
+** CAPI3REF: Checkpoint a database
+**
+** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
+** on [database connection] D to be [checkpointed].  ^If X is NULL or an
+** empty string, then a checkpoint is run on all databases of
+** connection D.  ^If the database connection D is not in
+** [WAL | write-ahead log mode] then this interface is a harmless no-op.
+**
+** ^The [wal_checkpoint pragma] can be used to invoke this interface
+** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the
+** [wal_autocheckpoint pragma] can be used to cause this interface to be
+** run whenever the WAL reaches a certain size threshold.
+*/
+SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
+
+/*
 ** Undo the hack that converts floating point types to integer for
 ** builds on processors without floating point support.
 */
@@ -5732,3 +6123,59 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
 #endif
 #endif
 
+/*
+** 2010 August 30
+**
+** The author disclaims copyright to this source code.  In place of
+** a legal notice, here is a blessing:
+**
+**    May you do good and not evil.
+**    May you find forgiveness for yourself and forgive others.
+**    May you share freely, never taking more than you give.
+**
+*************************************************************************
+*/
+
+#ifndef _SQLITE3RTREE_H_
+#define _SQLITE3RTREE_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
+
+/*
+** Register a geometry callback named zGeom that can be used as part of an
+** R-Tree geometry query as follows:
+**
+**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
+*/
+SQLITE_API int sqlite3_rtree_geometry_callback(
+  sqlite3 *db,
+  const char *zGeom,
+  int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
+  void *pContext
+);
+
+
+/*
+** A pointer to a structure of the following type is passed as the first
+** argument to callbacks registered using rtree_geometry_callback().
+*/
+struct sqlite3_rtree_geometry {
+  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */
+  int nParam;                     /* Size of array aParam[] */
+  double *aParam;                 /* Parameters passed to SQL geom function */
+  void *pUser;                    /* Callback implementation user data */
+  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */
+};
+
+
+#ifdef __cplusplus
+}  /* end of the 'extern "C"' block */
+#endif
+
+#endif  /* ifndef _SQLITE3RTREE_H_ */
+
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 1db73e9..dc8dd8a 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite3.c 300631 2010-06-21 11:06:31Z iliaa $ */
+/* $Id: sqlite3.c 305954 2010-12-03 21:05:44Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -114,6 +114,9 @@ PHP_METHOD(sqlite3, open)
 		zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Already initialised DB Object", 0 TSRMLS_CC);
 	}
 
+	if (strlen(filename) != filename_len) {
+		return;
+	}
 	if (strncmp(filename, ":memory:", 8) != 0) {
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
 			zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC);
@@ -1529,6 +1532,7 @@ PHP_METHOD(sqlite3result, columnName)
 	php_sqlite3_result *result_obj;
 	zval *object = getThis();
 	long column = 0;
+	char *column_name;
 	result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC);
 
 	SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result)
@@ -1536,8 +1540,13 @@ PHP_METHOD(sqlite3result, columnName)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &column) == FAILURE) {
 		return;
 	}
+	column_name = (char*) sqlite3_column_name(result_obj->stmt_obj->stmt, column);
 
-	RETVAL_STRING((char*)sqlite3_column_name(result_obj->stmt_obj->stmt, column), 1);
+	if (column_name == NULL) {
+		RETURN_FALSE;
+	}
+		
+	RETVAL_STRING(column_name, 1);
 }
 /* }}} */
 
diff --git a/ext/sqlite3/tests/bug53463.phpt b/ext/sqlite3/tests/bug53463.phpt
new file mode 100644
index 0000000..c9216e6
--- /dev/null
+++ b/ext/sqlite3/tests/bug53463.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #53463 (sqlite3 columnName() segfaults on bad column_number)
+--FILE--
+<?php
+
+$db = new SQLite3(':memory:');
+
+$db->exec('CREATE TABLE test (whatever INTEGER)');
+$db->exec('INSERT INTO test (whatever) VALUES (1)');
+
+$result = $db->query('SELECT * FROM test');
+while ($row = $result->fetchArray(SQLITE3_NUM)) {
+    var_dump($result->columnName(0));  // string(8) "whatever"
+
+    // Seems returning false will be most appropriate.
+    var_dump($result->columnName(3));  // Segmentation fault
+}
+
+$result->finalize();
+$db->close();
+
+echo "Done\n";
+
+?>
+--EXPECT--
+string(8) "whatever"
+bool(false)
+Done
\ No newline at end of file
diff --git a/ext/sqlite3/tests/sqlite3_15_open_error.phpt b/ext/sqlite3/tests/sqlite3_15_open_error.phpt
index 1fcaca9..49168fd 100644
--- a/ext/sqlite3/tests/sqlite3_15_open_error.phpt
+++ b/ext/sqlite3/tests/sqlite3_15_open_error.phpt
@@ -16,8 +16,8 @@ echo "Done\n";
 unlink($unreadable);
 ?>
 --EXPECTF--
-exception 'Exception' with message 'Unable to open database: %s' in %s/sqlite3_15_open_error.php:%d
+exception 'Exception' with message 'Unable to open database: %s' in %ssqlite3_15_open_error.php:%d
 Stack trace:
-#0 %s/sqlite3_15_open_error.php(%d): SQLite3->__construct('%s')
+#0 %ssqlite3_15_open_error.php(%d): SQLite3->__construct('%s')
 #1 {main}
 Done
diff --git a/ext/standard/array.c b/ext/standard/array.c
index dd3ed25..b477b87 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c 300371 2010-06-11 08:53:31Z dmitry $ */
+/* $Id: array.c 305570 2010-11-19 22:06:44Z felipe $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1389,10 +1389,10 @@ PHP_FUNCTION(extract)
 
 			case EXTR_OVERWRITE:
 				/* GLOBALS protection */
-				if (var_exists && var_name_len == sizeof("GLOBALS") && !strcmp(var_name, "GLOBALS")) {
+				if (var_exists && var_name_len == sizeof("GLOBALS")-1 && !strcmp(var_name, "GLOBALS")) {
 					break;
 				}
-				if (var_exists && var_name_len == sizeof("this")  && !strcmp(var_name, "this") && EG(scope) && EG(scope)->name_length != 0) {
+				if (var_exists && var_name_len == sizeof("this")-1  && !strcmp(var_name, "this") && EG(scope) && EG(scope)->name_length != 0) {
 					break;
 				}
 				ZVAL_STRINGL(&final_name, var_name, var_name_len, 1);
@@ -3557,8 +3557,8 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
 		for (i = 1; i < arr_argc; i++) {
 			Bucket **ptr = ptrs[i];
 			if (behavior == DIFF_NORMAL) {
-				while (*ptr && (0 < (c = diff_data_compare_func(ptrs[0], ptr TSRMLS_CC)))) {
-					ptr++;
+				while (*ptrs[i] && (0 < (c = diff_data_compare_func(ptrs[0], ptrs[i] TSRMLS_CC)))) {
+					ptrs[i]++;
 				}
 			} else if (behavior & DIFF_ASSOC) { /* triggered also when DIFF_KEY */
 				while (*ptr && (0 != (c = diff_key_compare_func(ptrs[0], ptr TSRMLS_CC)))) {
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index dff9055..f0b7a3e 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <jimw at php.net>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: base64.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: base64.c 305780 2010-11-26 21:00:03Z iliaa $ */
 
 #include <string.h>
 
@@ -152,7 +152,7 @@ PHPAPI unsigned char *php_base64_decode_ex(const unsigned char *str, int length,
 	/* run through the whole string, converting as we go */
 	while ((ch = *current++) != '\0' && length-- > 0) {
 		if (ch == base64_pad) {
-			if (*current != '=' && (i % 4) == 1) {
+			if (*current != '=' && ((i % 4) == 1 || (strict && length > 0))) {
 				efree(result);
 				return NULL;
 			}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 690c4a3..f7c82dd 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c 299320 2010-05-13 02:13:30Z felipe $ */
+/* $Id: basic_functions.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -1209,9 +1209,11 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_fstat, 0)
 	ZEND_ARG_INFO(0, fp)
 ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO(arginfo_copy, 0)
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_copy, 0, 0, 2)
 	ZEND_ARG_INFO(0, source_file)
 	ZEND_ARG_INFO(0, destination_file)
+	ZEND_ARG_INFO(0, context)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_fread, 0)
@@ -4671,6 +4673,12 @@ PHP_FUNCTION(error_log)
 		opt_err = erropt;
 	}
 
+	if (opt_err == 3) {
+		if (strlen(opt) != opt_len) {
+			RETURN_FALSE;
+		}
+	}
+
 	if (_php_error_log_ex(opt_err, message, message_len, opt, headers TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
@@ -5159,6 +5167,10 @@ PHP_FUNCTION(highlight_file)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (i) {
 		php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
 	}
@@ -5205,6 +5217,10 @@ PHP_FUNCTION(php_strip_whitespace)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	file_handle.type = ZEND_HANDLE_FILENAME;
 	file_handle.filename = filename;
 	file_handle.free_filename = 0;
@@ -5465,6 +5481,11 @@ PHP_FUNCTION(set_include_path)
 		return;
 	}
 
+	/* No nulls allowed in paths */
+	if (strlen(new_value) != new_value_len) {
+		RETURN_FALSE;
+	}
+
 	old_value = zend_ini_string("include_path", sizeof("include_path"), 0);
 	/* copy to return here, because alter might free it! */
 	if (old_value) {
@@ -5775,6 +5796,10 @@ PHP_FUNCTION(is_uploaded_file)
 		return;
 	}
 
+	if (strlen(path) != path_len) {
+		RETURN_FALSE;
+	}
+
 	if (zend_hash_exists(SG(rfc1867_uploaded_files), path, path_len + 1)) {
 		RETURN_TRUE;
 	} else {
@@ -5815,6 +5840,14 @@ PHP_FUNCTION(move_uploaded_file)
 		RETURN_FALSE;
 	}
 
+	if (strlen(path) != path_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(new_path) != new_path_len) {
+		RETURN_FALSE;
+	}
+
 	VCWD_UNLINK(new_path);
 	if (VCWD_RENAME(path, new_path) == 0) {
 		successful = 1;
@@ -5958,6 +5991,10 @@ PHP_FUNCTION(parse_ini_file)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	/* Set callback function */
 	if (process_sections) {
 		BG(active_ini_file_section) = NULL;
diff --git a/ext/standard/credits.c b/ext/standard/credits.c
index eaf9d54..1e684f0 100644
--- a/ext/standard/credits.c
+++ b/ext/standard/credits.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: credits.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: credits.c 305420 2010-11-16 23:02:00Z felipe $ */
 
 #include "php.h"
 #include "info.h"
@@ -96,7 +96,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */
 		php_info_print_table_colspan_header(2, "PHP Documentation");
 		CREDIT_LINE("Authors", "Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Hannes Magnusson, Georg Richter, Damien Seguy, Jakub Vrana");
 		CREDIT_LINE("Editor", "Philip Olson");
-		CREDIT_LINE("User Note Maintainers", "Friedhelm Betz, Etienne Kneuss, Nuno Lopes, Hannes Magnusson, Felipe Pena, Maciek Sokolewicz");
+		CREDIT_LINE("User Note Maintainers", "Friedhelm Betz, Etienne Kneuss, Nuno Lopes, Hannes Magnusson, Felipe Pena, Maciek Sokolewicz, Daniel P. Brown");
 		CREDIT_LINE("Other Contributors", "Previously active authors, editors and other contributors are listed in the manual.");
 		php_info_print_table_end();
 	}
@@ -104,7 +104,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */
 	if (flag & PHP_CREDITS_QA) {
 		php_info_print_table_start();
 		php_info_print_table_header(1, "PHP Quality Assurance Team");
-		php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen");
+		php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena");
 		php_info_print_table_end();
 	}
 
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index ddf651a..4acd891 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dir.c 300764 2010-06-26 16:03:39Z felipe $ */
+/* $Id: dir.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 /* {{{ includes/startup/misc */
 
@@ -325,6 +325,10 @@ PHP_FUNCTION(chdir)
 		RETURN_FALSE;
 	}
 
+	if (strlen(str) != str_len) {
+		RETURN_FALSE;
+	}
+
 	if ((PG(safe_mode) && !php_checkuid(str, NULL, CHECKUID_CHECK_FILE_AND_DIR)) || php_check_open_basedir(str TSRMLS_CC)) {
 		RETURN_FALSE;
 	}
@@ -436,6 +440,10 @@ PHP_FUNCTION(glob)
 		return;
 	}
 
+	if (strlen(pattern) != pattern_len) {
+		RETURN_FALSE;
+	}
+
 	if (pattern_len >= MAXPATHLEN) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
 		RETURN_FALSE;
@@ -557,6 +565,10 @@ PHP_FUNCTION(scandir)
 		return;
 	}
 
+	if (strlen(dirn) != dirn_len) {
+		RETURN_FALSE;
+	}
+
 	if (dirn_len < 1) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Directory name cannot be empty");
 		RETURN_FALSE;
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 5ed9068..685eb77 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dns.c 293211 2010-01-07 11:02:39Z sebastian $ */
+/* $Id: dns.c 304301 2010-10-11 03:07:03Z cataphract $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -697,7 +697,6 @@ PHP_FUNCTION(dns_get_record)
 	int hostname_len;
 	long type_param = PHP_DNS_ANY;
 	zval *authns = NULL, *addtl = NULL;
-	int addtl_recs = 0;
 	int type_to_fetch;
 #if defined(HAVE_DNS_SEARCH)
 	struct sockaddr_storage from;
@@ -724,7 +723,6 @@ PHP_FUNCTION(dns_get_record)
 	if (addtl) {
 		zval_dtor(addtl);
 		array_init(addtl);
-		addtl_recs = 1;
 	}
 
 	if (type_param & ~PHP_DNS_ALL && type_param != PHP_DNS_ANY) {
@@ -742,7 +740,7 @@ PHP_FUNCTION(dns_get_record)
 	 * - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 )
 	 */
 	for (type = (type_param == PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0);
-		type < (addtl_recs ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
+		type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
 		type++
 	) {
 		first_query = 0;
@@ -858,7 +856,7 @@ PHP_FUNCTION(dns_get_record)
 				}
 			}
 
-			if (addtl_recs && addtl) {
+			if (addtl) {
 				/* Additional records associated with authoritative name servers */
 				while (ar-- > 0 && cp && cp < end) {
 					zval *retval = NULL;
diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c
index bd12c4a..a6e5b0a 100644
--- a/ext/standard/dns_win32.c
+++ b/ext/standard/dns_win32.c
@@ -337,7 +337,6 @@ PHP_FUNCTION(dns_get_record)
 	long type_param = PHP_DNS_ANY;
 	zval *authns = NULL, *addtl = NULL;
 	int type, type_to_fetch, first_query = 1, store_results = 1;
-	int addtl_recs = 0;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzz", &hostname, &hostname_len, &type_param, &authns, &addtl) == FAILURE) {
 		return;
@@ -361,7 +360,7 @@ PHP_FUNCTION(dns_get_record)
 	array_init(return_value);
 
 	for (type = (type_param == PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0);
-		type < (addtl_recs ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
+		type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
 		type++
 	) {
 		DNS_STATUS      status;                 /* Return value of DnsQuery_A() function */
@@ -418,7 +417,7 @@ PHP_FUNCTION(dns_get_record)
 			status = DnsQuery_A(hostname, type_to_fetch, DNS_QUERY_STANDARD, NULL, &pResult, NULL);
 
 			if (status) {
-				if (status == DNS_INFO_NO_RECORDS) {
+				if (status == DNS_INFO_NO_RECORDS || status == DNS_ERROR_RCODE_NAME_ERROR) {
 					continue;
 				} else {
 					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Dns Query failed");
diff --git a/ext/standard/file.c b/ext/standard/file.c
index fc16ab9..d4ccdf2 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.c 298882 2010-05-02 20:11:22Z felipe $ */
+/* $Id: file.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -170,6 +170,7 @@ static void file_globals_dtor(php_file_globals *file_globals_p TSRMLS_DC)
 
 PHP_INI_BEGIN()
 	STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals)
+	PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, NULL)
 	STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
 	STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateLong, auto_detect_line_endings, php_file_globals, file_globals)
 PHP_INI_END()
@@ -385,6 +386,10 @@ PHP_FUNCTION(get_meta_tags)
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	md.stream = php_stream_open_wrapper(filename, "rb",
 			(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS,
 			NULL);
@@ -538,6 +543,10 @@ PHP_FUNCTION(file_get_contents)
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero");
 		RETURN_FALSE;
@@ -558,7 +567,6 @@ PHP_FUNCTION(file_get_contents)
 		RETURN_FALSE;
 	}
 
-	/* uses mmap if possible */
 	if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
 
 		if (PG(magic_quotes_runtime)) {
@@ -595,6 +603,10 @@ PHP_FUNCTION(file_put_contents)
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (Z_TYPE_P(data) == IS_RESOURCE) {
 		php_stream_from_zval(srcstream, &data);
 	}
@@ -739,6 +751,11 @@ PHP_FUNCTION(file)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lr!", &filename, &filename_len, &flags, &zcontext) == FAILURE) {
 		return;
 	}
+
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	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);
 		RETURN_FALSE;
@@ -836,6 +853,14 @@ PHP_FUNCTION(tempnam)
 		return;
 	}
 
+	if (strlen(dir) != dir_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(prefix) != prefix_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) &&(!php_checkuid(dir, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
@@ -894,6 +919,10 @@ PHP_NAMED_FUNCTION(php_if_fopen)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	context = php_stream_context_from_zval(zcontext, 0);
 
 	stream = php_stream_open_wrapper_ex(filename, mode, (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
@@ -1397,6 +1426,10 @@ PHP_FUNCTION(mkdir)
 		RETURN_FALSE;
 	}
 
+	if (strlen(dir) != dir_len) {
+		RETURN_FALSE;
+	}
+
 	context = php_stream_context_from_zval(zcontext, 0);
 
 	RETURN_BOOL(php_stream_mkdir(dir, mode, (recursive ? PHP_STREAM_MKDIR_RECURSIVE : 0) | REPORT_ERRORS, context));
@@ -1416,6 +1449,10 @@ PHP_FUNCTION(rmdir)
 		RETURN_FALSE;
 	}
 
+	if (strlen(dir) != dir_len) {
+		RETURN_FALSE;
+	}
+
 	context = php_stream_context_from_zval(zcontext, 0);
 
 	RETURN_BOOL(php_stream_rmdir(dir, REPORT_ERRORS, context));
@@ -1438,6 +1475,10 @@ PHP_FUNCTION(readfile)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	context = php_stream_context_from_zval(zcontext, 0);
 
 	stream = php_stream_open_wrapper_ex(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
@@ -1511,6 +1552,14 @@ PHP_FUNCTION(rename)
 		RETURN_FALSE;
 	}
 
+	if (strlen(old_name) != old_name_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(new_name) != new_name_len) {
+		RETURN_FALSE;
+	}
+
 	wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0 TSRMLS_CC);
 
 	if (!wrapper || !wrapper->wops) {
@@ -1548,6 +1597,10 @@ PHP_FUNCTION(unlink)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	context = php_stream_context_from_zval(zcontext, 0);
 
 	wrapper = php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC);
@@ -1684,6 +1737,14 @@ PHP_FUNCTION(copy)
 		return;
 	}
 
+	if (strlen(source) != source_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(target) != target_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) &&(!php_checkuid(source, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
@@ -1694,7 +1755,7 @@ PHP_FUNCTION(copy)
 
 	context = php_stream_context_from_zval(zcontext, 0);
 
-	if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) {
+	if (php_copy_file_ctx(source, target, 0, context TSRMLS_CC) == SUCCESS) {
 		RETURN_TRUE;
 	} else {
 		RETURN_FALSE;
@@ -1702,21 +1763,31 @@ PHP_FUNCTION(copy)
 }
 /* }}} */
 
-PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ */
+/* {{{ php_copy_file
+ */
+PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC)
 {
-	return php_copy_file_ex(src, dest, ENFORCE_SAFE_MODE TSRMLS_CC);
+	return php_copy_file_ctx(src, dest, ENFORCE_SAFE_MODE, NULL TSRMLS_CC);
 }
 /* }}} */
 
-/* {{{ php_copy_file
+/* {{{ php_copy_file_ex
  */
 PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC)
 {
+	return php_copy_file_ctx(src, dest, ENFORCE_SAFE_MODE, NULL TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ php_copy_file_ctx
+ */
+PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *context TSRMLS_DC)
+{
 	php_stream *srcstream = NULL, *deststream = NULL;
 	int ret = FAILURE;
 	php_stream_statbuf src_s, dest_s;
 
-	switch (php_stream_stat_path_ex(src, 0, &src_s, NULL)) {
+	switch (php_stream_stat_path_ex(src, 0, &src_s, context)) {
 		case -1:
 			/* non-statable stream */
 			goto safe_to_copy;
@@ -1731,7 +1802,7 @@ PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC)
 		return FAILURE;
 	}
 
-	switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL)) {
+	switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, context)) {
 		case -1:
 			/* non-statable stream */
 			goto safe_to_copy;
@@ -1781,13 +1852,13 @@ no_stat:
 	}
 safe_to_copy:
 
-	srcstream = php_stream_open_wrapper(src, "rb", src_chk | REPORT_ERRORS, NULL);
+	srcstream = php_stream_open_wrapper_ex(src, "rb", src_chk | REPORT_ERRORS, NULL, context);
 
 	if (!srcstream) {
 		return ret;
 	}
 
-	deststream = php_stream_open_wrapper(dest, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+	deststream = php_stream_open_wrapper_ex(dest, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
 
 	if (srcstream && deststream) {
 		ret = php_stream_copy_to_stream_ex(srcstream, deststream, PHP_STREAM_COPY_ALL, NULL);
@@ -2375,6 +2446,10 @@ PHP_FUNCTION(realpath)
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (VCWD_REALPATH(filename, resolved_path_buff)) {
 		if (PG(safe_mode) && (!php_checkuid(resolved_path_buff, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 			RETURN_FALSE;
@@ -2517,6 +2592,14 @@ PHP_FUNCTION(fnmatch)
 		return;
 	}
 
+	if (strlen(pattern) != pattern_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+	
 	if (filename_len >= MAXPATHLEN) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename exceeds the maximum allowed length of %d characters", MAXPATHLEN);
 		RETURN_FALSE;
diff --git a/ext/standard/file.h b/ext/standard/file.h
index 63804b7..8a6b4ed 100644
--- a/ext/standard/file.h
+++ b/ext/standard/file.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: file.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: file.h 305495 2010-11-18 12:10:17Z cataphract $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
@@ -76,6 +76,7 @@ PHPAPI int php_le_stream_context(void);
 PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
 PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC);
 PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC);
+PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *context TSRMLS_DC);
 PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC);
 PHPAPI int php_mkdir(char *dir, 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);
@@ -117,7 +118,7 @@ typedef struct {
 	size_t def_chunk_size;
 	long auto_detect_line_endings;
 	long default_socket_timeout;
-	char *user_agent;
+	char *user_agent; /* for the http wrapper */
 	char *user_stream_current_filename; /* for simple recursion protection */
 	php_stream_context *default_context;
 	HashTable *stream_wrappers;			/* per-request copy of url_stream_wrappers_hash */
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 72aaf98..841c4c7 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filestat.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: filestat.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include "php.h"
 #include "safe_mode.h"
@@ -379,6 +379,10 @@ PHP_FUNCTION(disk_free_space)
 		RETURN_FALSE;
 	}
 
+	if (strlen(path) != path_len) {
+		RETURN_FALSE;
+	}
+
 	if (php_disk_free_space(path, &bytesfree TSRMLS_CC) == SUCCESS) {
 		RETURN_DOUBLE(bytesfree);
 	}
@@ -399,6 +403,10 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (Z_TYPE_P(group) == IS_LONG) {
 		gid = (gid_t)Z_LVAL_P(group);
 	} else if (Z_TYPE_P(group) == IS_STRING) {
@@ -500,6 +508,10 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (Z_TYPE_P(user) == IS_LONG) {
 		uid = (uid_t)Z_LVAL_P(user);
 	} else if (Z_TYPE_P(user) == IS_STRING) {
@@ -607,6 +619,10 @@ PHP_FUNCTION(chmod)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	/* Check the basedir */
 	if (php_check_open_basedir(filename TSRMLS_CC)) {
 		RETURN_FALSE;
@@ -660,6 +676,10 @@ PHP_FUNCTION(touch)
 		return;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	switch (argc) {
 		case 1:
 #ifdef HAVE_UTIME_NULL
@@ -715,8 +735,9 @@ PHP_FUNCTION(touch)
 PHPAPI void php_clear_stat_cache(zend_bool clear_realpath_cache, const char *filename, int filename_len TSRMLS_DC)
 {
 	/* always clear CurrentStatFile and CurrentLStatFile even if filename is not NULL
-	 * as it may contains outdated data (e.g. "nlink" for a directory when deleting a file
+	 * as it may contain outdated data (e.g. "nlink" for a directory when deleting a file
 	 * in this directory, as shown by lstat_stat_variation9.phpt) */
+
 	if (BG(CurrentStatFile)) {
 		efree(BG(CurrentStatFile));
 		BG(CurrentStatFile) = NULL;
@@ -777,6 +798,10 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_length) {
+		RETURN_FALSE;
+	}
+
 	if ((wrapper = php_stream_locate_url_wrapper(filename, &local, 0 TSRMLS_CC)) == &php_plain_files_wrapper) {
 		if (php_check_open_basedir(local TSRMLS_CC)) {
 			RETURN_FALSE;
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 5f5f2a6..f253f8d 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: formatted_print.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: formatted_print.c 305561 2010-11-19 16:36:10Z iliaa $ */
 
 #include <math.h>				/* modf() */
 #include "php.h"
@@ -41,7 +41,7 @@
 #define FLOAT_DIGITS 6
 #define FLOAT_PRECISION 6
 #define MAX_FLOAT_DIGITS 38
-#define MAX_FLOAT_PRECISION 40
+#define MAX_FLOAT_PRECISION 53
 
 #if 0
 /* trick to control varargs functions through cpp */
diff --git a/ext/standard/ftok.c b/ext/standard/ftok.c
index a41c126..13e80a2 100644
--- a/ext/standard/ftok.c
+++ b/ext/standard/ftok.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: ftok.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: ftok.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include "php.h"
 
@@ -39,6 +39,10 @@ PHP_FUNCTION(ftok)
 		return;
 	}
 
+	if (strlen(pathname) != pathname_len) {
+		RETURN_FALSE;
+	}
+
 	if (pathname_len == 0){
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pathname is invalid");
 		RETURN_LONG(-1);
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 6e20d5a..f5885de 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -18,7 +18,7 @@
    |          Sara Golemon <pollita at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: ftp_fopen_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: ftp_fopen_wrapper.c 305495 2010-11-18 12:10:17Z cataphract $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -116,7 +116,6 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, char *path
 	php_stream *stream = NULL, *reuseid = NULL;
 	php_url *resource = NULL;
 	int result, use_ssl, use_ssl_on_data = 0, tmp_len;
-	char *scratch;
 	char tmp_line[512];
 	char *transport;
 	int transport_len;
@@ -250,8 +249,9 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, char *path
 		} else {
 			/* if the user has configured who they are,
 			   send that as the password */
-			if (cfg_get_string("from", &scratch) == SUCCESS) {
-				php_stream_printf(stream TSRMLS_CC, "PASS %s\r\n", scratch);
+			char *from_address = php_ini_string("from", sizeof("from"), 0);
+			if (from_address[0] != '\0') {
+				php_stream_printf(stream TSRMLS_CC, "PASS %s\r\n", from_address);
 			} else {
 				php_stream_write_string(stream, "PASS anonymous\r\n");
 			}
diff --git a/ext/standard/html.c b/ext/standard/html.c
index ef6f960..e5bb013 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: html.c 296121 2010-03-12 16:19:25Z moriyoshi $ */
+/* $Id: html.c 304404 2010-10-14 19:14:06Z cataphract $ */
 
 /*
  * HTML entity resources:
@@ -540,7 +540,7 @@ inline static unsigned int get_next_char(enum entity_charset charset,
 					MB_WRITE(c);
 					this_char = c;
 					pos++;
-				} else if (c < 0xc0) {
+				} else if (c < 0xc2) {
 					MB_FAILURE(pos);
 				} else if (c < 0xe0) {
 					CHECK_LEN(pos, 2);
@@ -572,7 +572,7 @@ inline static unsigned int get_next_char(enum entity_charset charset,
 					MB_WRITE((unsigned char)str[pos + 1]);
 					MB_WRITE((unsigned char)str[pos + 2]);
 					pos += 3;
-				} else if (c < 0xf8) {
+				} else if (c < 0xf5) {
 					CHECK_LEN(pos, 4);
 					if (str[pos + 1] < 0x80 || str[pos + 1] > 0xbf) {
 						MB_FAILURE(pos);
@@ -584,7 +584,7 @@ inline static unsigned int get_next_char(enum entity_charset charset,
 						MB_FAILURE(pos);
 					}
 					this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f);
-					if (this_char < 0x10000) {
+					if (this_char < 0x10000 || this_char > 0x10FFFF) {
 						MB_FAILURE(pos);
 					}
 					MB_WRITE((unsigned char)c);
@@ -867,7 +867,7 @@ det_charset:
 /* }}} */
 
 /* {{{ php_utf32_utf8 */
-size_t php_utf32_utf8(unsigned char *buf, int k)
+size_t php_utf32_utf8(unsigned char *buf, unsigned k)
 {
 	size_t retval = 0;
 
@@ -1020,7 +1020,12 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
 						code = strtol(p + 2, &next, 10);
 					}
 
-					if (next != NULL && *next == ';') {
+					if (code == '\'' && !(quote_style & ENT_HTML_QUOTE_SINGLE) ||
+						code == '"' && !(quote_style & ENT_HTML_QUOTE_DOUBLE)) {
+						invalid_code = 1;
+					}
+
+					if (next != NULL && *next == ';' && !invalid_code) {
 						switch (charset) {
 							case cs_utf_8:
 								q += php_utf32_utf8(q, code);
@@ -1032,11 +1037,7 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
 								if ((code >= 0x80 && code < 0xa0) || code > 0xff) {
 									invalid_code = 1;
 								} else {
-									if (code == 39 || !quote_style) {
-										invalid_code = 1;
-									} else {
-										*(q++) = code;
-									}
+									*(q++) = code;
 								}
 								break;
 
@@ -1407,54 +1408,86 @@ PHP_FUNCTION(htmlentities)
 }
 /* }}} */
 
-/* {{{ proto array get_html_translation_table([int table [, int quote_style]])
+/* {{{ proto array get_html_translation_table([int table [, int quote_style [, string charset_hint]]])
    Returns the internal translation table used by htmlspecialchars and htmlentities */
 PHP_FUNCTION(get_html_translation_table)
 {
 	long which = HTML_SPECIALCHARS, quote_style = ENT_COMPAT;
-	int i, j;
-	char ind[2];
-	enum entity_charset charset = determine_charset(NULL TSRMLS_CC);
+	unsigned int i;
+	int j;
+	unsigned char ind[5]; /* max # of 8-bit code units (4; for UTF-8) + 1 for \0 */
+	void *dummy;
+	char *charset_hint = NULL;
+	int charset_hint_len;
+	enum entity_charset charset;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &which, &quote_style) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls",
+			&which, &quote_style, &charset_hint, &charset_hint_len) == FAILURE) {
 		return;
 	}
 
-	array_init(return_value);
+	charset = determine_charset(charset_hint TSRMLS_CC);
 
-	ind[1] = 0;
+	array_init(return_value);
 
 	switch (which) {
-		case HTML_ENTITIES:
-			for (j=0; entity_map[j].charset != cs_terminator; j++) {
-				if (entity_map[j].charset != charset)
+	case HTML_ENTITIES:
+		for (j = 0; entity_map[j].charset != cs_terminator; j++) {
+			if (entity_map[j].charset != charset)
+				continue;
+			for (i = 0; i <= entity_map[j].endchar - entity_map[j].basechar; i++) {
+				char buffer[16];
+				unsigned k;
+				size_t written;
+
+				if (entity_map[j].table[i] == NULL)
 					continue;
-				for (i = 0; i <= entity_map[j].endchar - entity_map[j].basechar; i++) {
-					char buffer[16];
+					
+				k = i + entity_map[j].basechar;
 
-					if (entity_map[j].table[i] == NULL)
-						continue;
-					/* what about wide chars here ?? */
-					ind[0] = i + entity_map[j].basechar;
-					snprintf(buffer, sizeof(buffer), "&%s;", entity_map[j].table[i]);
-					add_assoc_string(return_value, ind, buffer, 1);
+				switch (charset) {
+				case cs_utf_8:
+					written = php_utf32_utf8(ind, k);
+					ind[written] = '\0';
+					break;
+				case cs_big5:
+				case cs_gb2312:
+				case cs_big5hkscs:
+				case cs_sjis:
+					/* we have no mappings for these, but if we had... */
+					/* break through */
+				default: /* one byte */
+					written = 1;
+					ind[0] = (unsigned char)k;
+					ind[1] = '\0';
+					break;
+				}
 
+				snprintf(buffer, sizeof(buffer), "&%s;", entity_map[j].table[i]);
+				if (zend_hash_find(Z_ARRVAL_P(return_value), (const char*)ind, written+1, &dummy) == FAILURE) {
+					/* in case of the single quote, which is repeated, the first one wins,
+						* so don't replace the existint mapping */
+					add_assoc_string(return_value, (const char*)ind, buffer, 1);
 				}
 			}
-			/* break thru */
-
-		case HTML_SPECIALCHARS:
-			for (j = 0; basic_entities[j].charcode != 0; j++) {
+		}
+		/* break thru */
 
-				if (basic_entities[j].flags && (quote_style & basic_entities[j].flags) == 0)
-					continue;
+	case HTML_SPECIALCHARS:
+		add_assoc_stringl(return_value, "&", "&", sizeof("&") - 1, 1);
+		for (j = 0; basic_entities[j].charcode != 0; j++) {
+			if (basic_entities[j].flags && (quote_style & basic_entities[j].flags) == 0)
+				continue;
 				
-				ind[0] = (unsigned char)basic_entities[j].charcode;
-				add_assoc_stringl(return_value, ind, basic_entities[j].entity, basic_entities[j].entitylen, 1);
+			ind[0] = (unsigned char)basic_entities[j].charcode;
+			ind[1] = '\0';
+			if (zend_hash_find(Z_ARRVAL_P(return_value), (const char*)ind, 2, &dummy) == FAILURE) {
+				add_assoc_stringl(return_value, ind, basic_entities[j].entity,
+					basic_entities[j].entitylen, 1);
 			}
-			add_assoc_stringl(return_value, "&", "&", sizeof("&") - 1, 1);
+		}
 
-			break;
+		break;
 	}
 }
 /* }}} */
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 09de024..69b8bfa 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -19,7 +19,7 @@
    |          Sara Golemon <pollita at php.net>                              |
    +----------------------------------------------------------------------+
  */
-/* $Id: http_fopen_wrapper.c 293998 2010-01-25 16:28:13Z jani $ */ 
+/* $Id: http_fopen_wrapper.c 305495 2010-11-18 12:10:17Z cataphract $ */ 
 
 #include "php.h"
 #include "php_globals.h"
@@ -111,6 +111,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 	char *user_headers = NULL;
 	int header_init = ((flags & HTTP_WRAPPER_HEADER_INIT) != 0);
 	int redirected = ((flags & HTTP_WRAPPER_REDIRECTED) != 0);
+	int follow_location = 1;
 	php_stream_filter *transfer_encoding = NULL;
 
 	tmp_line[0] = '\0';
@@ -213,7 +214,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
  	 		char header_line[HTTP_HEADER_BLOCK_SIZE];
 
 			/* get response header */
-			while (php_stream_gets(stream, header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL)	{
+			while (php_stream_gets(stream, header_line, HTTP_HEADER_BLOCK_SIZE-1) != NULL) {
 				if (header_line[0] == '\n' ||
 				    header_line[0] == '\r' ||
 				    header_line[0] == '\0') {
@@ -233,7 +234,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 		}
 	}
 
-	if (stream == NULL)	
+	if (stream == NULL)
 		goto out;
 
 	/* avoid buffering issues while reading header */
@@ -309,7 +310,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 		}
 
 		/* query string */
-		if (resource->query)	{
+		if (resource->query) {
 			strlcat(scratch, "?", scratch_len);
 			strlcat(scratch, resource->query, scratch_len);
 		}
@@ -442,15 +443,18 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 	}
 
 	/* if the user has configured who they are, send a From: line */
-	if (((have_header & HTTP_HEADER_FROM) == 0) && cfg_get_string("from", &tmp) == SUCCESS)	{
-		if (snprintf(scratch, scratch_len, "From: %s\r\n", tmp) > 0)
-			php_stream_write(stream, scratch, strlen(scratch));
+	{
+		char *from_address = php_ini_string("from", sizeof("from"), 0);
+		if (((have_header & HTTP_HEADER_FROM) == 0) && from_address[0] != '\0') {
+			if (snprintf(scratch, scratch_len, "From: %s\r\n", from_address) > 0)
+				php_stream_write(stream, scratch, strlen(scratch));
+		}
 	}
 
 	/* Send Host: header so name-based virtual hosts work */
 	if ((have_header & HTTP_HEADER_HOST) == 0) {
 		if ((use_ssl && resource->port != 443 && resource->port != 0) || 
-			(!use_ssl && resource->port != 80 && resource->port != 0))	{
+			(!use_ssl && resource->port != 80 && resource->port != 0)) {
 			if (snprintf(scratch, scratch_len, "Host: %s:%i\r\n", resource->host, resource->port) > 0)
 				php_stream_write(stream, scratch, strlen(scratch));
 		} else {
@@ -628,6 +632,11 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 			http_header_line[http_header_line_length] = '\0';
 
 			if (!strncasecmp(http_header_line, "Location: ", 10)) {
+				if (context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) {
+					SEPARATE_ZVAL(tmpzval);
+					convert_to_long_ex(tmpzval);
+					follow_location = Z_LVAL_PP(tmpzval);
+				}
 				strlcpy(location, http_header_line + 10, sizeof(location));
 			} else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) {
 				php_stream_notify_info(context, PHP_STREAM_NOTIFY_MIME_TYPE_IS, http_header_line + 14, 0);
@@ -670,9 +679,9 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 			break;
 		}
 	}
-	
-	if (!reqok || location[0] != '\0') {
-		if (((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) && redirect_max <= 1) {
+
+	if (!reqok || (location[0] != '\0' && follow_location)) {
+		if (!follow_location || (((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) && redirect_max <= 1)) {
 			goto out;
 		}
 
@@ -685,7 +694,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 		php_stream_close(stream);
 		stream = NULL;
 
-		if (location[0] != '\0')	{
+		if (location[0] != '\0') {
 
 			char new_path[HTTP_HEADER_BLOCK_SIZE];
 			char loc_path[HTTP_HEADER_BLOCK_SIZE];
@@ -697,7 +706,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 							strncasecmp(location, "ftps://", sizeof("ftps://")-1))) 
 			{
 				if (*location != '/') {
-					if (*(location+1) != '\0' && resource->path) {		
+					if (*(location+1) != '\0' && resource->path) {
 						char *s = strrchr(resource->path, '/');
 						if (!s) {
 							s = resource->path;
@@ -736,20 +745,20 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
 				goto out;
 			}
 
-#define CHECK_FOR_CNTRL_CHARS(val) {	\
-	if (val) {	\
-		unsigned char *s, *e;	\
-		int l;	\
-		l = php_url_decode(val, strlen(val));	\
-		s = (unsigned char*)val; e = s + l;	\
-		while (s < e) {	\
-			if (iscntrl(*s)) {	\
-				php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect URL! %s", new_path);	\
-				goto out;	\
-			}	\
-			s++;	\
-		}	\
-	}	\
+#define CHECK_FOR_CNTRL_CHARS(val) { \
+	if (val) { \
+		unsigned char *s, *e; \
+		int l; \
+		l = php_url_decode(val, strlen(val)); \
+		s = (unsigned char*)val; e = s + l; \
+		while (s < e) { \
+			if (iscntrl(*s)) { \
+				php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect URL! %s", new_path); \
+				goto out; \
+			} \
+			s++; \
+		} \
+	} \
 }
 			/* check for control characters in login, password & path */
 			if (strncasecmp(new_path, "http://", sizeof("http://") - 1) || strncasecmp(new_path, "https://", sizeof("https://") - 1)) {
@@ -839,7 +848,7 @@ static php_stream_wrapper_ops http_stream_wops = {
 	NULL  /* rmdir */
 };
 
-PHPAPI php_stream_wrapper php_stream_http_wrapper =	{
+PHPAPI php_stream_wrapper php_stream_http_wrapper = {
 	&http_stream_wops,
 	NULL,
 	1 /* is_url */
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index b5c0b25..5c11a42 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: iptc.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: iptc.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 /*
  * Functions to parse & compse IPTC data.
@@ -190,6 +190,10 @@ PHP_FUNCTION(iptcembed)
 		return;
 	}
 
+	if (strlen(jpeg_file) != jpeg_file_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) && (!php_checkuid(jpeg_file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
 		RETURN_FALSE;
 	}
diff --git a/ext/standard/link.c b/ext/standard/link.c
index ac45b4b..cb152ef 100644
--- a/ext/standard/link.c
+++ b/ext/standard/link.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: link.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: link.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #include "php.h"
 #include "php_filestat.h"
@@ -64,6 +64,10 @@ PHP_FUNCTION(readlink)
 		return;
 	}
 
+	if (strlen(link) != link_len) {
+		RETURN_FALSE;
+	}
+
 	if (PG(safe_mode) && !php_checkuid(link, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
 		RETURN_FALSE;
 	}
@@ -72,7 +76,7 @@ PHP_FUNCTION(readlink)
 		RETURN_FALSE;
 	}
 
-	ret = readlink(link, buff, MAXPATHLEN-1);
+	ret = php_sys_readlink(link, buff, MAXPATHLEN-1);
 
 	if (ret == -1) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
@@ -123,6 +127,14 @@ PHP_FUNCTION(symlink)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
 		return;
 	}
+
+	if (strlen(topath) != topath_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(frompath) != frompath_len) {
+		RETURN_FALSE;
+	}
 	
 	if (!expand_filepath(frompath, source_p TSRMLS_CC)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
@@ -188,6 +200,14 @@ PHP_FUNCTION(link)
 		return;
 	}
 
+	if (strlen(topath) != topath_len) {
+		RETURN_FALSE;
+	}
+
+	if (strlen(frompath) != frompath_len) {
+		RETURN_FALSE;
+	}
+
 	if (!expand_filepath(frompath, source_p TSRMLS_CC) || !expand_filepath(topath, dest_p TSRMLS_CC)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
 		RETURN_FALSE;
diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c
index f7f5803..faf256c 100644
--- a/ext/standard/link_win32.c
+++ b/ext/standard/link_win32.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: link_win32.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: link_win32.c 303500 2010-09-18 14:54:40Z pajoye $ */
 #ifdef PHP_WIN32
 
 #include "php.h"
@@ -45,47 +45,19 @@
 
 /*
 TODO:
-- Create php_readlink, php_link and php_symlink in win32/link.c
+- Create php_readlink (done), php_link and php_symlink in win32/link.c
 - Expose them (PHPAPI) so extensions developers can use them
 - define link/readlink/symlink to their php_ equivalent and use them in ext/standart/link.c
 - this file is then useless and we have a portable link API
 */
 
-#ifndef VOLUME_NAME_NT
-#define VOLUME_NAME_NT 0x2
-#endif
-
-#ifndef VOLUME_NAME_DOS
-#define VOLUME_NAME_DOS 0x0
-#endif
-
 /* {{{ proto string readlink(string filename)
    Return the target of a symbolic link */
 PHP_FUNCTION(readlink)
 {
-	HINSTANCE kernel32;
 	char *link;
 	int link_len;
-	TCHAR Path[MAXPATHLEN];
-	char path_resolved[MAXPATHLEN];
-	HANDLE hFile;
-	DWORD dwRet;
-
-	typedef BOOL (WINAPI *gfpnh_func)(HANDLE, LPTSTR, DWORD, DWORD);
-	gfpnh_func pGetFinalPathNameByHandle;
-
-	kernel32 = LoadLibrary("kernel32.dll");
-
-	if (kernel32) {
-		pGetFinalPathNameByHandle = (gfpnh_func)GetProcAddress(kernel32, "GetFinalPathNameByHandleA");
-		if (pGetFinalPathNameByHandle == NULL) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't call GetFinalPathNameByHandleA");
-			RETURN_FALSE;
-		}
-	} else {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't call get a handle on kernel32.dll");
-		RETURN_FALSE;
-	}
+	char target[MAXPATHLEN];
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
 		return;
@@ -94,42 +66,11 @@ PHP_FUNCTION(readlink)
 	if (OPENBASEDIR_CHECKPATH(link)) {
 		RETURN_FALSE;
 	}
-	if (!expand_filepath(link, path_resolved TSRMLS_CC)) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory");
-		RETURN_FALSE;
-	}
-	hFile = CreateFile(path_resolved,                  // file to open
-				 GENERIC_READ,          // open for reading
-				 FILE_SHARE_READ,       // share for reading
-				 NULL,                  // default security
-				 OPEN_EXISTING,         // existing file only
-				 FILE_FLAG_BACKUP_SEMANTICS, // normal file
-				 NULL);                 // no attr. template
-
-	if( hFile == INVALID_HANDLE_VALUE) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not open file (error %d)", GetLastError());
-			RETURN_FALSE;
-	}
-
-	dwRet = pGetFinalPathNameByHandle(hFile, Path, MAXPATHLEN, VOLUME_NAME_DOS);
-	if(dwRet >= MAXPATHLEN) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't resolve the full path, the path exceeds the MAX_PATH_LEN (%d) limit", MAXPATHLEN);
-		RETURN_FALSE;
-	}
-
-	CloseHandle(hFile);
 
-	/* Append NULL to the end of the string */
-	Path[dwRet] = '\0';
-
-	if(dwRet > 4) {
-		/* Skip first 4 characters if they are "\??\" */
-		if(Path[0] == '\\' && Path[1] == '\\' && Path[2] == '?' && Path[3] ==  '\\') {
-			RETURN_STRING(Path + 4, 1);
-		}
-	} else {
-		RETURN_STRING(Path, 1);
+	if (php_sys_readlink(link, target, MAXPATHLEN) == -1) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "readlink failed to read the symbolic link (%s), error %d)", link, GetLastError());
 	}
+	RETURN_STRING(target, 1);
 }
 /* }}} */
 
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 8a3949e..2376730 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: math.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: math.c 301991 2010-08-08 15:45:02Z iliaa $ */
 
 #include "php.h"
 #include "php_math.h"
@@ -29,6 +29,8 @@
 #include <float.h>
 #include <stdlib.h>
 
+#include "basic_functions.h"
+
 /* {{{ php_intlog10abs
    Returns floor(log10(fabs(val))), uses fast binary search */
 static inline int php_intlog10abs(double value) {
@@ -127,7 +129,11 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
 	double tmp_value;
 	int precision_places;
 
-	precision_places = 14 - php_intlog10abs(value);
+	if ((precision_places = php_intlog10abs(value)) > 0) {
+		precision_places = 14 - php_intlog10abs(value);
+	} else {
+		precision_places = 14;
+	}
 
 	f1 = php_intpow10(abs(places));
 
@@ -690,7 +696,11 @@ PHP_FUNCTION(log)
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "base must be greater than 0");				
 		RETURN_FALSE;
 	}
-	RETURN_DOUBLE(log(num) / log(base));
+	if (base == 1) {
+		RETURN_DOUBLE(php_get_nan());
+	} else {
+		RETURN_DOUBLE(log(num) / log(base));
+	}
 }
 /* }}} */
 
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index afb5071..1aeea77 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -15,7 +15,7 @@
    | Author: Wez Furlong <wez at thebrainroom.com>                           |
    +----------------------------------------------------------------------+
  */
-/* $Id: proc_open.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: proc_open.c 303163 2010-09-08 08:34:57Z pajoye $ */
 
 #if 0 && (defined(__linux__) || defined(sun) || defined(__IRIX__))
 # define _BSD_SOURCE 		/* linux wants this when XOPEN mode is on */
@@ -88,13 +88,13 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
 	HashPosition pos;
 
 	memset(&env, 0, sizeof(env));
-	
+
 	if (!environment) {
 		return env;
 	}
-	
+
 	cnt = zend_hash_num_elements(Z_ARRVAL_P(environment));
-	
+
 	if (cnt < 1) {
 #ifndef PHP_WIN32
 		env.envarray = (char **) pecalloc(1, sizeof(char *), is_persistent);
@@ -112,15 +112,15 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
 	for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
 			zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
 			zend_hash_move_forward_ex(target_hash, &pos)) {
-		
+
 		convert_to_string_ex(element);
 		el_len = Z_STRLEN_PP(element);
 		if (el_len == 0) {
 			continue;
 		}
-		
+
 		sizeenv += el_len+1;
-		
+
 		switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) {
 			case HASH_KEY_IS_STRING:
 				if (string_length == 0) {
@@ -139,14 +139,14 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
 	for (zend_hash_internal_pointer_reset_ex(target_hash, &pos);
 			zend_hash_get_current_data_ex(target_hash, (void **) &element, &pos) == SUCCESS;
 			zend_hash_move_forward_ex(target_hash, &pos)) {
-		
+
 		convert_to_string_ex(element);
 		el_len = Z_STRLEN_PP(element);
-		
+
 		if (el_len == 0) {
 			continue;
 		}
-		
+
 		data = Z_STRVAL_PP(element);
 		switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, &pos)) {
 			case HASH_KEY_IS_STRING:
@@ -185,7 +185,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
 				memcpy(p, string_key, string_length);
 				strcat(p, "=");
 				strcat(p, data);
-				
+
 #ifndef PHP_WIN32
 				*ep = p;
 				++ep;
@@ -203,10 +203,10 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent
 			case HASH_KEY_NON_EXISTANT:
 				break;
 		}
-	}	
+	}
+
+	assert((uint)(p - env.envp) <= sizeenv);
 
-	assert(p - env.envp <= sizeenv);
-	
 	zend_hash_internal_pointer_reset_ex(target_hash, &pos);
 
 	return env;
@@ -246,20 +246,19 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 			proc->pipes[i] = 0;
 		}
 	}
-	
+
 #ifdef PHP_WIN32
-	
 	WaitForSingleObject(proc->childHandle, INFINITE);
 	GetExitCodeProcess(proc->childHandle, &wstatus);
 	FG(pclose_ret) = wstatus;
 	CloseHandle(proc->childHandle);
-	
+
 #elif HAVE_SYS_WAIT_H
-	
+
 	do {
 		wait_pid = waitpid(proc->child, &wstatus, 0);
 	} while (wait_pid == -1 && errno == EINTR);
-	
+
 	if (wait_pid == -1) {
 		FG(pclose_ret) = -1;
 	} else {
@@ -267,14 +266,13 @@ static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 			wstatus = WEXITSTATUS(wstatus);
 		FG(pclose_ret) = wstatus;
 	}
-	
+
 #else
 	FG(pclose_ret) = -1;
 #endif
 	_php_free_envp(proc->env, proc->is_persistent);
 	pefree(proc->command, proc->is_persistent);
 	pefree(proc, proc->is_persistent);
-	
 }
 /* }}} */
 
@@ -340,13 +338,13 @@ PHP_FUNCTION(proc_terminate)
 	zval *zproc;
 	struct php_process_handle *proc;
 	long sig_no = SIGTERM;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zproc, &sig_no) == FAILURE) {
 		RETURN_FALSE;
 	}
 
 	ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
-	
+
 #ifdef PHP_WIN32
 	if (TerminateProcess(proc->childHandle, 255)) {
 		RETURN_TRUE;
@@ -369,13 +367,13 @@ PHP_FUNCTION(proc_close)
 {
 	zval *zproc;
 	struct php_process_handle *proc;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zproc) == FAILURE) {
 		RETURN_FALSE;
 	}
 
 	ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1, "process", le_proc_open);
-	
+
 	zend_list_delete(Z_LVAL_P(zproc));
 	RETURN_LONG(FG(pclose_ret));
 }
@@ -395,7 +393,7 @@ PHP_FUNCTION(proc_get_status)
 #endif
 	int running = 1, signaled = 0, stopped = 0;
 	int exitcode = -1, termsig = 0, stopsig = 0;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zproc) == FAILURE) {
 		RETURN_FALSE;
 	}
@@ -406,19 +404,19 @@ PHP_FUNCTION(proc_get_status)
 
 	add_assoc_string(return_value, "command", proc->command, 1);
 	add_assoc_long(return_value, "pid", (long) proc->child);
-	
+
 #ifdef PHP_WIN32
-	
+
 	GetExitCodeProcess(proc->childHandle, &wstatus);
 
 	running = wstatus == STILL_ACTIVE;
 	exitcode = running ? -1 : wstatus;
-	
+
 #elif HAVE_SYS_WAIT_H
-	
+
 	errno = 0;
 	wait_pid = waitpid(proc->child, &wstatus, WNOHANG|WUNTRACED);
-	
+
 	if (wait_pid == proc->child) {
 		if (WIFEXITED(wstatus)) {
 			running = 0;
@@ -461,7 +459,7 @@ PHP_FUNCTION(proc_get_status)
 static inline HANDLE dup_handle(HANDLE src, BOOL inherit, BOOL closeorig)
 {
 	HANDLE copy, self = GetCurrentProcess();
-	
+
 	if (!DuplicateHandle(self, src, self, &copy, 0, inherit, DUPLICATE_SAME_ACCESS |
 				(closeorig ? DUPLICATE_CLOSE_SOURCE : 0)))
 		return NULL;
@@ -553,16 +551,16 @@ PHP_FUNCTION(proc_open)
 			    Z_LVAL_PP(item)) {
 				suppress_errors = 1;
 			}
-		}	
+		}
 		if (SUCCESS == zend_hash_find(Z_ARRVAL_P(other_options), "bypass_shell", sizeof("bypass_shell"), (void**)&item)) {
 			if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) &&
 			    Z_LVAL_PP(item)) {
 				bypass_shell = 1;
 			}
-		}	
+		}
 	}
 #endif
-	
+
 	command_len = strlen(command);
 
 	if (environment) {
@@ -580,7 +578,7 @@ PHP_FUNCTION(proc_open)
 	security.bInheritHandle = TRUE;
 	security.lpSecurityDescriptor = NULL;
 #endif
-	
+
 	/* walk the descriptor spec and set up files/pipes */
 	zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(descriptorspec), &pos);
 	while (zend_hash_get_current_data_ex(Z_ARRVAL_P(descriptorspec), (void **)&descitem, &pos) == SUCCESS) {
@@ -754,14 +752,24 @@ PHP_FUNCTION(proc_open)
 	}
 
 #ifdef PHP_WIN32
+	if (cwd == NULL) {
+		char cur_cwd[MAXPATHLEN];
+		char *getcwd_result;
+		getcwd_result = VCWD_GETCWD(cur_cwd, MAXPATHLEN);
+		if (!getcwd_result) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get current directory");
+			goto exit_fail;
+		}
+	}
+
 	memset(&si, 0, sizeof(si));
 	si.cb = sizeof(si);
 	si.dwFlags = STARTF_USESTDHANDLES;
-	
+
 	si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
 	si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
 	si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-	
+
 	/* redirect stdin/stdout/stderr if requested */
 	for (i = 0; i < ndesc; i++) {
 		switch(descriptors[i].index) {
@@ -777,13 +785,13 @@ PHP_FUNCTION(proc_open)
 		}
 	}
 
-	
+
 	memset(&pi, 0, sizeof(pi));
-	
+
 	if (suppress_errors) {
 		old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
 	}
-	
+
 	dwCreateFlags = NORMAL_PRIORITY_CLASS;
 	if(strcmp(sapi_module.name, "cli") != 0) {
 		dwCreateFlags |= CREATE_NO_WINDOW;
@@ -795,14 +803,14 @@ PHP_FUNCTION(proc_open)
 		spprintf(&command_with_cmd, 0, "%s /c %s", GetVersion() < 0x80000000 ? COMSPEC_NT : COMSPEC_9X, command);
 
 		newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, dwCreateFlags, env.envp, cwd, &si, &pi);
-		
+
 		efree(command_with_cmd);
 	}
 
 	if (suppress_errors) {
 		SetErrorMode(old_error_mode);
 	}
-	
+
 	if (FALSE == newprocok) {
 		DWORD dw = GetLastError();
 
@@ -887,7 +895,7 @@ PHP_FUNCTION(proc_open)
 			tcsetpgrp(0, my_pid);
 		}
 #endif
-		
+
 		/* close those descriptors that we just opened for the parent stuff,
 		 * dup new descriptors into required descriptors and close the original
 		 * cruft */
@@ -909,11 +917,11 @@ PHP_FUNCTION(proc_open)
 			close(slave_pty);
 		}
 #endif
-		
+
 		if (cwd) {
 			chdir(cwd);
 		}
-		
+
 		if (env.envarray) {
 			execle("/bin/sh", "sh", "-c", command, NULL, env.envarray);
 		} else {
@@ -1007,7 +1015,7 @@ PHP_FUNCTION(proc_open)
 
 					/* nasty hack; don't copy it */
 					stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
-					
+
 					MAKE_STD_ZVAL(retfp);
 					php_stream_to_zval(stream, retfp);
 					add_index_zval(pipes, descriptors[i].index, retfp);
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index 7f0fae0..056b2a4 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: quot_print.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: quot_print.c 305759 2010-11-25 21:38:06Z iliaa $ */
 
 #include <stdlib.h>
 
@@ -68,7 +68,7 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len
 		 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 64, 64, 64, 64, 64, 64,
 		64, 10, 11, 12, 13, 14, 15, 64, 64, 64, 64, 64, 64, 64, 64, 64,
 		64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-		64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+		64, 10, 11, 12, 13, 14, 15, 64, 64, 64, 64, 64, 64, 64, 64, 64,
 		64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
 		64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
 		64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index db5523a..7660ada 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -23,7 +23,7 @@
    |                     Shawn Cokus <Cokus at math.washington.edu>          |
    +----------------------------------------------------------------------+
  */
-/* $Id: rand.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: rand.c 305754 2010-11-25 16:44:20Z cataphract $ */
 
 #include <stdlib.h>
 
@@ -315,8 +315,14 @@ PHP_FUNCTION(mt_rand)
 	long number;
 	int  argc = ZEND_NUM_ARGS();
 
-	if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE)
-		return;
+	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);
+			RETURN_FALSE;
+		}
+	}
 
 	if (!BG(mt_rand_is_seeded)) {
 		php_mt_srand(GENERATE_SEED() TSRMLS_CC);
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 6285a33..049af57 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: streamsfuncs.c 297895 2010-04-12 13:10:05Z pajoye $ */
+/* $Id: streamsfuncs.c 304384 2010-10-14 03:15:15Z cataphract $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -116,9 +116,13 @@ PHP_FUNCTION(stream_socket_client)
 
 	/* prepare the timeout value for use */
 	conv = (php_timeout_ull) (timeout * 1000000.0);
+#ifdef PHP_WIN32
+	tv.tv_sec = (long)(conv / 1000000);
+	tv.tv_usec =(long)(conv % 1000000);
+#else
 	tv.tv_sec = conv / 1000000;
 	tv.tv_usec = conv % 1000000;
-
+#endif
 	if (zerrno)	{
 		zval_dtor(zerrno);
 		ZVAL_LONG(zerrno, 0);
@@ -258,9 +262,13 @@ PHP_FUNCTION(stream_socket_accept)
 
 	/* prepare the timeout value for use */
 	conv = (php_timeout_ull) (timeout * 1000000.0);
+#ifdef PHP_WIN32
+	tv.tv_sec = (long)(conv / 1000000);
+	tv.tv_usec = (long)(conv % 1000000);
+#else
 	tv.tv_sec = conv / 1000000;
 	tv.tv_usec = conv % 1000000;
-
+#endif
 	if (zpeername) {
 		zval_dtor(zpeername);
 		ZVAL_NULL(zpeername);
@@ -407,7 +415,7 @@ PHP_FUNCTION(stream_get_contents)
 {
 	php_stream *stream;
 	zval *zsrc;
-	long maxlen = PHP_STREAM_COPY_ALL, pos = 0;
+	long maxlen = PHP_STREAM_COPY_ALL, pos = -1L;
 	int len, newlen;
 	char *contents = NULL;
 
@@ -417,9 +425,19 @@ PHP_FUNCTION(stream_get_contents)
 
 	php_stream_from_zval(stream, &zsrc);
 
-	if ((pos > 0 || (pos == 0 && ZEND_NUM_ARGS() > 2)) && php_stream_seek(stream, pos, SEEK_SET) < 0) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
-		RETURN_FALSE;
+	if (pos >= 0) {
+		int seek_res = 0;
+		if (pos > stream->position) {
+			/* use SEEK_CUR to allow emulation in streams that don't support seeking */
+			seek_res = php_stream_seek(stream, pos - stream->position, SEEK_CUR);
+		} else if (pos < stream->position)  {
+			seek_res = php_stream_seek(stream, pos, SEEK_SET);
+		}
+
+		if (seek_res != 0) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
+			RETURN_FALSE;
+		}
 	}
 
 	len = php_stream_copy_to_mem(stream, &contents, maxlen, 0);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 3187310..6c6f35a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c 300105 2010-06-02 19:26:10Z rasmus $ */
+/* $Id: string.c 305418 2010-11-16 22:16:44Z felipe $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -1873,7 +1873,7 @@ PHP_FUNCTION(strrpos)
 		p = haystack + offset;
 		e = haystack + haystack_len - needle_len;
 	} else {
-		if (-offset > haystack_len || offset < -INT_MAX) {
+		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;
 		}
@@ -1951,7 +1951,7 @@ PHP_FUNCTION(strripos)
 			e = haystack + haystack_len - 1;
 		} else {
 			p = haystack;
-			if (-offset > haystack_len || offset < -INT_MAX) {
+			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;
 			}
@@ -1983,7 +1983,7 @@ PHP_FUNCTION(strripos)
 		p = haystack_dup + offset;
 		e = haystack_dup + haystack_len - needle_len;
 	} else {
-		if (-offset > haystack_len || offset < -INT_MAX) {
+		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");
@@ -2571,7 +2571,7 @@ static void php_lcfirst(char *str)
 }
 /* }}} */
 
-/* {{{ proto string ucfirst(string str)
+/* {{{ proto string lcfirst(string str)
    Make a string's first character lowercase */
 PHP_FUNCTION(lcfirst)
 {
@@ -4211,9 +4211,8 @@ int php_tag_find(char *tag, int len, char *set) {
 				if (!isspace((int)c)) {
 					if (state == 0) {
 						state=1;
-						if (c != '/')
-							*(n++) = c;
-					} else {
+					}
+					if (c != '/') {
 						*(n++) = c;
 					}
 				} else {
@@ -4861,7 +4860,7 @@ PHP_FUNCTION(str_pad)
 	long pad_length;			/* Length to pad to */
 	
 	/* Helper variables */
-	int	   num_pad_chars;		/* Number of padding characters (total - input size) */
+	size_t	   num_pad_chars;		/* Number of padding characters (total - input size) */
 	char  *result = NULL;		/* Resulting string */
 	int	   result_len = 0;		/* Length of the resulting string */
 	char  *pad_str_val = " ";	/* Pointer to padding string */
@@ -4874,11 +4873,9 @@ PHP_FUNCTION(str_pad)
 		return;
 	}
 
-	num_pad_chars = pad_length - input_len;
-
 	/* If resulting string turns out to be shorter than input string,
 	   we simply copy the input and return. */
-	if (pad_length <= 0 || num_pad_chars <= 0) {
+	if (pad_length <= 0 || (pad_length - input_len) <= 0) {
 		RETURN_STRINGL(input, input_len, 1);
 	}
 
@@ -4892,6 +4889,11 @@ PHP_FUNCTION(str_pad)
 		return;
 	}
 
+	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 = (char *)emalloc(input_len + num_pad_chars + 1);
 
 	/* We need to figure out the left/right padding lengths. */
diff --git a/ext/standard/tests/array/bug52534.phpt b/ext/standard/tests/array/bug52534.phpt
new file mode 100644
index 0000000..dfff3fd
--- /dev/null
+++ b/ext/standard/tests/array/bug52534.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #52534 (var_export array with negative key)
+--FILE--
+<?php
+
+$aArray = array ( -1 => 'Hello');
+
+var_export($aArray);
+
+?>
+--EXPECT--
+array (
+  -1 => 'Hello',
+)
diff --git a/ext/standard/tests/array/extract_safety.phpt b/ext/standard/tests/array/extract_safety.phpt
new file mode 100644
index 0000000..d5d0763
--- /dev/null
+++ b/ext/standard/tests/array/extract_safety.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test extract() for overwrite of GLOBALS
+--FILE--
+<?php
+$str = "John";
+debug_zval_dump($GLOBALS["str"]);
+
+/* Extracting Global Variables */
+$splat = array("foo" => "bar");
+var_dump(extract(array("GLOBALS" => $splat, EXTR_OVERWRITE)));
+
+unset ($splat);
+
+debug_zval_dump($GLOBALS["str"]);
+
+echo "\nDone";
+?>
+
+--EXPECTF--
+string(4) "John" refcount(2)
+int(0)
+string(4) "John" refcount(2)
+
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/assert/assert02.phpt b/ext/standard/tests/assert/assert02.phpt
index 8f986d5..723eeb9 100644
--- a/ext/standard/tests/assert/assert02.phpt
+++ b/ext/standard/tests/assert/assert02.phpt
@@ -4,7 +4,7 @@ catch assert() errors
 assert.active=1
 assert.warning=1
 assert.callback=
-assert.bbail=0
+assert.bail=0
 assert.quiet_eval=0
 --FILE--
 <?php
diff --git a/ext/standard/tests/file/bug52820.phpt b/ext/standard/tests/file/bug52820.phpt
new file mode 100644
index 0000000..b398cc4
--- /dev/null
+++ b/ext/standard/tests/file/bug52820.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)
+--SKIPIF--
+<?php
+/* unfortunately no standard function does a cast to FILE*, so we need
+ * curl to test this */
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+$handle=curl_init('http://127.0.0.1:37349/');
+curl_setopt($handle, CURLOPT_VERBOSE, true);
+curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
+if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
+    die("skip fopencookie not supported on this platform");
+--FILE--
+<?php
+function do_stuff($url) {
+    $handle=curl_init('http://127.0.0.1:37349/');
+    curl_setopt($handle, CURLOPT_VERBOSE, true);
+    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
+    curl_exec($handle);
+    echo "About to rewind!\n";
+    rewind($o);
+    echo stream_get_contents($o);
+    return $o;
+}
+
+echo "temp stream (close after):\n";
+fclose(do_stuff("php://temp"));
+
+echo "\nmemory stream (close after):\n";
+fclose(do_stuff("php://memory"));
+
+echo "\nDone.\n";
+--EXPECT--
+temp stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+*   Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+memory stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349 (#0)
+*   Trying 127.0.0.1... * Connection refused
+* couldn't connect to host
+* Closing connection #0
+
+Done.
diff --git a/ext/standard/tests/file/bug53241.phpt b/ext/standard/tests/file/bug53241.phpt
new file mode 100644
index 0000000..685bf14
--- /dev/null
+++ b/ext/standard/tests/file/bug53241.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #53241 (stream casting that relies on fdopen/fopencookie fails with 'xb' mode)
+--SKIPIF--
+<?php
+/* unfortunately no standard function does a cast to FILE*, so we need
+ * curl to test this */
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+--FILE--
+<?php
+$fn = __DIR__ . "/test.tmp";
+ at unlink($fn);
+$fh = fopen($fn, 'xb');
+$ch = curl_init('http://www.yahoo.com/');
+var_dump(curl_setopt($ch, CURLOPT_FILE, $fh));
+echo "Done.\n";
+--CLEAN--
+<?php
+$fn = __DIR__ . "/test.tmp";
+ at unlink($fn);
+?>
+--EXPECT--
+bool(true)
+Done.
diff --git a/ext/standard/tests/file/copy_variation12.phpt b/ext/standard/tests/file/copy_variation12.phpt
index 34667ba..7f96fd0 100644
--- a/ext/standard/tests/file/copy_variation12.phpt
+++ b/ext/standard/tests/file/copy_variation12.phpt
@@ -41,11 +41,11 @@ rmdir(dirname(__FILE__)."/copy_variation12");
 --EXPECTF--
 *** Test copy() function: Trying to create a copy of an existing dir ***
 
-Warning: copy(): The first argument to copy() function cannot be a directory in %s/copy_variation12.php on line %d
+Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation12.php on line %d
 bool(false)
 bool(false)
 int(%d)
 
-Warning: filesize(): stat failed for %s/copy_copy_variation12 in %s/copy_variation12.php on line %d
+Warning: filesize(): stat failed for %scopy_copy_variation12 in %scopy_variation12.php on line %d
 bool(false)
 *** Done ***
diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt
index 48386743f325e3cfedaa7712443a6af249aa9593..32756c1ede19ac8fb5e1029e4cd549b1bf42c199 100644
GIT binary patch
delta 51
zcmZ3d@>yxZ<c+rzm>82bTQfi7n4BXhH<_PLmnAJRr+BhGUo3Z0etwPyh?lCl*@yQL
F3jp%@5;6b)

delta 78
zcmV-U0I~n`BCaHmlPgzAP9iA^ARuIEWhf$ZYiV#GL~kH&Z*(AXb#5SUZXj1_Ze(wF
kb0R4_3bA&50<-i2<_MGe2+RQhlO7R5lL!hcv!D#q1Rf_E<^TWy

diff --git a/ext/standard/tests/file/disk_free_space_variation.phpt b/ext/standard/tests/file/disk_free_space_variation.phpt
index c180998..178f857 100644
--- a/ext/standard/tests/file/disk_free_space_variation.phpt
+++ b/ext/standard/tests/file/disk_free_space_variation.phpt
@@ -105,19 +105,19 @@ float(%d)
 float(%d)
 
 -- Iteration 9 --
-float(%d)
-float(%d)
+bool(false)
+bool(false)
 
 -- Iteration 10 --
-float(%d)
-float(%d)
+bool(false)
+bool(false)
 
 -- Iteration 11 --
-float(%d)
-float(%d)
+bool(false)
+bool(false)
 
 -- Iteration 12 --
-float(%d)
-float(%d)
+bool(false)
+bool(false)
 
 --- Done ---
diff --git a/ext/standard/tests/file/file_get_contents_variation8-win32.phpt b/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
index 43d742a..c0074ff 100644
--- a/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
+++ b/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
@@ -76,8 +76,6 @@ Warning: file_get_contents( ): failed to open stream: Permission denied in %s on
 bool(false)
 
 -- Filename: \0 --
-
-Warning: file_get_contents(): Filename cannot be empty in %s on line %d
 bool(false)
 
 -- Filename: array() --
diff --git a/ext/standard/tests/file/file_get_contents_variation8.phpt b/ext/standard/tests/file/file_get_contents_variation8.phpt
index dca75a0..84621e1 100644
--- a/ext/standard/tests/file/file_get_contents_variation8.phpt
+++ b/ext/standard/tests/file/file_get_contents_variation8.phpt
@@ -68,8 +68,6 @@ bool(false)
 Warning: file_get_contents( ): failed to open stream: No such file or directory in %s on line %d
 bool(false)
 -- Iteration 6 --
-
-Warning: file_get_contents(): Filename cannot be empty in %s on line %d
 bool(false)
 -- Iteration 7 --
 
diff --git a/ext/standard/tests/file/file_put_contents_variation8.phpt b/ext/standard/tests/file/file_put_contents_variation8.phpt
index 1e27e71334165f687b4bf263cfd56e934dbce78d..c35ace47b2c0037484e7d90885bd0876d29a7e9f 100644
GIT binary patch
delta 20
ccmew-xJ7WoU$)5?*d-_Xvhi)sW1qkX0A3phxBvhE

delta 18
acmdlY_)l=dU$)5!Y)Om^o5k4YF#-Tc0tQn6

diff --git a/ext/standard/tests/file/filegroup_variation3.phpt b/ext/standard/tests/file/filegroup_variation3.phpt
index dd875a0..c41f383 100644
--- a/ext/standard/tests/file/filegroup_variation3.phpt
+++ b/ext/standard/tests/file/filegroup_variation3.phpt
@@ -74,8 +74,8 @@ bool(false)
 Warning: filegroup(): stat failed for %s/filegroup_variation3/filegroup*.tmp in %s on line %d
 bool(false)
 - Iteration 7 -
-int(%d)
+bool(false)
 - Iteration 8 -
-int(%d)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation3.phpt b/ext/standard/tests/file/fileinode_variation3.phpt
index c81b573..23cf3c7 100644
--- a/ext/standard/tests/file/fileinode_variation3.phpt
+++ b/ext/standard/tests/file/fileinode_variation3.phpt
@@ -75,8 +75,8 @@ bool(false)
 Warning: fileinode(): stat failed for %s/fileinode_variation3/fileinode*.tmp in %s on line %d
 bool(false)
 - Iteration 7 -
-int(%d)
+bool(false)
 - Iteration 8 -
-int(%d)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/fileowner_variation3.phpt b/ext/standard/tests/file/fileowner_variation3.phpt
index 2a322b6..b2691e9 100644
--- a/ext/standard/tests/file/fileowner_variation3.phpt
+++ b/ext/standard/tests/file/fileowner_variation3.phpt
@@ -75,8 +75,8 @@ bool(false)
 Warning: fileowner(): stat failed for %s/fileowner_variation3/fileowner*.tmp in %s on line %d
 bool(false)
 - Iteration 7 -
-int(%d)
+bool(false)
 - Iteration 8 -
-int(%d)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/fileperms_variation3.phpt b/ext/standard/tests/file/fileperms_variation3.phpt
index 38101e3..1e7396a 100644
--- a/ext/standard/tests/file/fileperms_variation3.phpt
+++ b/ext/standard/tests/file/fileperms_variation3.phpt
@@ -74,8 +74,8 @@ bool(false)
 Warning: fileperms(): stat failed for %s/fileperms_variation3/fileperms*.tmp in %s on line %d
 bool(false)
 - Iteration 7 -
-int(%d)
+bool(false)
 - Iteration 8 -
-int(%d)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/fnmatch_variation.phpt b/ext/standard/tests/file/fnmatch_variation.phpt
index e65bdd0..13afebb 100644
--- a/ext/standard/tests/file/fnmatch_variation.phpt
+++ b/ext/standard/tests/file/fnmatch_variation.phpt
@@ -259,21 +259,21 @@ bool(true)
 --- With Strings ---
 -- Iteration 0 --
 bool(true)
-bool(true)
+bool(false)
 bool(true)
 bool(false)
 bool(false)
 bool(true)
 -- Iteration 1 --
-bool(true)
-bool(true)
-bool(true)
 bool(false)
 bool(false)
-bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
 -- Iteration 2 --
 bool(true)
-bool(true)
+bool(false)
 bool(true)
 bool(false)
 bool(false)
@@ -282,7 +282,7 @@ bool(true)
 bool(false)
 bool(false)
 bool(false)
-bool(true)
+bool(false)
 bool(false)
 bool(false)
 -- Iteration 4 --
@@ -294,7 +294,7 @@ bool(true)
 bool(false)
 -- Iteration 5 --
 bool(true)
-bool(true)
+bool(false)
 bool(true)
 bool(false)
 bool(false)
@@ -397,28 +397,28 @@ bool(true)
 bool(true)
 bool(true)
 bool(true)
-bool(true)
+bool(false)
 bool(false)
 bool(false)
 -- Iteration 1 --
 bool(true)
 bool(true)
 bool(true)
-bool(true)
+bool(false)
 bool(false)
 bool(false)
 -- Iteration 2 --
 bool(true)
 bool(true)
 bool(true)
-bool(true)
+bool(false)
 bool(false)
 bool(false)
 -- Iteration 3 --
-bool(true)
-bool(true)
-bool(true)
-bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
 bool(false)
 bool(false)
 -- Iteration 4 --
diff --git a/ext/standard/tests/file/glob_variation.phpt b/ext/standard/tests/file/glob_variation.phpt
index 52c0dc8..64d3d8a 100755
--- a/ext/standard/tests/file/glob_variation.phpt
+++ b/ext/standard/tests/file/glob_variation.phpt
@@ -325,20 +325,12 @@ array(0) {
 }
 
 -- Iteration 8 --
-array(0) {
-}
-array(0) {
-}
-array(0) {
-}
-array(1) {
-  [0]=>
-  string(%d) "%s/glob_variation/WONDER5"
-}
-array(0) {
-}
-array(0) {
-}
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
 
 -- Iteration 9 --
 array(0) {
@@ -441,8 +433,7 @@ array(1) {
 array(0) {
 }
 -- Iteration 8 --
-array(0) {
-}
+bool(false)
 -- Iteration 9 --
 array(0) {
 }
diff --git a/ext/standard/tests/file/is_dir_variation4.phpt b/ext/standard/tests/file/is_dir_variation4.phpt
index a68fe0b..b83d185 100644
--- a/ext/standard/tests/file/is_dir_variation4.phpt
+++ b/ext/standard/tests/file/is_dir_variation4.phpt
@@ -77,9 +77,9 @@ bool(true)
 bool(false)
 
 -- Iteration 9 --
-bool(true)
+bool(false)
 
 -- Iteration 10 --
-bool(true)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/is_executable_variation1.phpt b/ext/standard/tests/file/is_executable_variation1.phpt
index 9969911..bc826b9 100644
--- a/ext/standard/tests/file/is_executable_variation1.phpt
+++ b/ext/standard/tests/file/is_executable_variation1.phpt
@@ -76,9 +76,9 @@ bool(false)
 -- Iteration 5 --
 bool(false)
 -- Iteration 6 --
-bool(true)
+bool(false)
 -- Iteration 7 --
-bool(true)
+bool(false)
 -- Iteration 8 --
 bool(false)
 -- Iteration 9 --
diff --git a/ext/standard/tests/file/is_file_variation4.phpt b/ext/standard/tests/file/is_file_variation4.phpt
index 55aeedf..fbdf438 100644
--- a/ext/standard/tests/file/is_file_variation4.phpt
+++ b/ext/standard/tests/file/is_file_variation4.phpt
@@ -67,8 +67,8 @@ bool(false)
 - Iteration 6 -
 bool(false)
 - Iteration 7 -
-bool(true)
+bool(false)
 - Iteration 8 -
-bool(true)
+bool(false)
 
 *** Done ***
diff --git a/ext/standard/tests/file/is_readable_variation1.phpt b/ext/standard/tests/file/is_readable_variation1.phpt
index a131032..7493574 100644
--- a/ext/standard/tests/file/is_readable_variation1.phpt
+++ b/ext/standard/tests/file/is_readable_variation1.phpt
@@ -87,11 +87,11 @@ bool(false)
 -- Iteration 6 --
 bool(false)
 -- Iteration 7 --
-bool(true)
+bool(false)
 -- Iteration 8 --
-bool(true)
+bool(false)
 -- Iteration 9 --
-bool(true)
+bool(false)
 -- Iteration 10 --
 bool(true)
 -- Iteration 11 --
diff --git a/ext/standard/tests/file/is_writable_variation1.phpt b/ext/standard/tests/file/is_writable_variation1.phpt
index bf3e7e1..1f3cbf5 100644
--- a/ext/standard/tests/file/is_writable_variation1.phpt
+++ b/ext/standard/tests/file/is_writable_variation1.phpt
@@ -96,14 +96,14 @@ bool(false)
 bool(false)
 bool(false)
 -- Iteration 7 --
-bool(true)
-bool(true)
+bool(false)
+bool(false)
 -- Iteration 8 --
-bool(true)
-bool(true)
+bool(false)
+bool(false)
 -- Iteration 9 --
-bool(true)
-bool(true)
+bool(false)
+bool(false)
 -- Iteration 10 --
 bool(true)
 bool(true)
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
index e7c41c4..101e890 100644
--- a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
+++ b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
@@ -64,8 +64,8 @@ Warning: rmdir(%s/mkdir_variation2/): %s on line %d
 bool(false)
 
 *** Testing mkdir() and rmdir() for binary safe functionality ***
-bool(true)
-bool(true)
+bool(false)
+bool(false)
 
 *** Testing mkdir() with miscelleneous input ***
 bool(true)
diff --git a/ext/standard/tests/file/readfile_variation10-win32.phpt b/ext/standard/tests/file/readfile_variation10-win32.phpt
index 6453b98..1624194 100644
--- a/ext/standard/tests/file/readfile_variation10-win32.phpt
+++ b/ext/standard/tests/file/readfile_variation10-win32.phpt
@@ -37,7 +37,7 @@ $names_arr = array(
 
 foreach($names_arr as $key => $value) {
       echo "\n-- Filename: $key --\n";
-      readfile($value);
+      var_dump(readfile($value));
 };
 
 ?>
@@ -48,40 +48,48 @@ foreach($names_arr as $key => $value) {
 -- Filename: -1 --
 
 Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
 
 -- Filename: TRUE --
 
 Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
 
 -- Filename: FALSE --
 
 Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
 
 -- Filename: NULL --
 
 Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
 
 -- Filename: "" --
 
 Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
 
 -- Filename: " " --
 
 Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
+bool(false)
 
 -- Filename: \0 --
-
-Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
 
 -- Filename: array() --
 
 Warning: readfile() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
 
 -- Filename: /no/such/file/dir --
 
 Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+bool(false)
 
 -- Filename: php/php --
 
 Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
+bool(false)
 ===Done===
\ No newline at end of file
diff --git a/ext/standard/tests/file/readfile_variation10.phpt b/ext/standard/tests/file/readfile_variation10.phpt
index a48150aee0fcf1240a7f47b7939c317043ae037f..2caa2de1d259b0012f6f5722b441a25666b1f9b8 100644
GIT binary patch
delta 216
zcmeyxyPa=?3bRC6Vo`ibX>Nf=QEFmJT4qkFhDu&yZmQ;FBj(lIN%{FX8fl3+#X$ZY
z=1>%VBTEoTd}Y>96(sYxbafR<Qj1G6^U at X6xsW6#pJdHOG1!<b7KPu>7Au9Mo{LLM
POH08eKQC1Q$lwA1(T_+Z

delta 94
zcmdna_ltLf3Nv3(YGO)SW=^VxN?u}a>SP<{)ssInhfLnU5(vjxtRcL*x(X$!#U+_}
q=?dx$lUO7sm$T?je$1LRIg%}A@<Fy3J}xaSEd`hSyi^4sg9`vL;2zZg

diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt
index a86025889d31bedfad6b7214ff98c1a4cd9dcd62..2cd9dbdd949d456a4e7093b3e0993f45f1c71046 100644
GIT binary patch
delta 25
gcmaDYcUN`;4>u22Qht7pMp|M{ajNF#W!y)Z0e1xn6#xJL

delta 26
icmcaB`&w=T4>u#j<b9lGlN~tyC*S5!*{s36l^Fnh^a#HI

diff --git a/ext/standard/tests/file/rename_variation13.phpt b/ext/standard/tests/file/rename_variation13.phpt
index 24697d5..2c35198 100644
--- a/ext/standard/tests/file/rename_variation13.phpt
+++ b/ext/standard/tests/file/rename_variation13.phpt
@@ -98,11 +98,7 @@ bool(true)
 Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
 bool(false)
 -- testing '%s' --
-
-Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
 bool(false)
-
-Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
 bool(false)
 -- testing 'Array' --
 
diff --git a/ext/standard/tests/file/stream_rfc2397_006.phpt b/ext/standard/tests/file/stream_rfc2397_006.phpt
index dab6cd5..b1b3111 100755
--- a/ext/standard/tests/file/stream_rfc2397_006.phpt
+++ b/ext/standard/tests/file/stream_rfc2397_006.phpt
@@ -21,8 +21,8 @@ foreach($streams as $stream)
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
-string(0) ""
-string(6) "foobar"
+bool(false)
+bool(false)
 string(13) "foobar foobar"
 
 Warning: file_get_contents(data:;base64,#Zm9vYmFyIGZvb2Jhc=): failed to open stream: rfc2397: unable to decode in %sstream_rfc2397_006.php on line %d
diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt
index fb457cb..a51a10a 100644
--- a/ext/standard/tests/file/tempnam_variation3-win32.phpt
+++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt
@@ -31,8 +31,8 @@ $names_arr = array(
 	NULL,
 	"",
 	" ",
-	"\0",
 	/* Invalid args */ 
+	"\0",
 	array(),
 
 	/* Valid args*/ 
@@ -102,7 +102,8 @@ OK
 Failed, not created in the correct directory %s vs %s
 0
 -- Iteration 6 --
-OK
+Failed, not created in the correct directory %s vs %s
+0
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
index 69ab16c..4a0e861 100644
--- a/ext/standard/tests/file/tempnam_variation3.phpt
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
@@ -100,9 +100,9 @@ File name is => %s/%s
 File permissions are => 100600
 File created in => directory specified
 -- Iteration 6 --
-File name is => %s/%s
-File permissions are => 100600
-File created in => directory specified
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt
index 34e352a..8ea839e 100644
--- a/ext/standard/tests/file/tempnam_variation7-win32.phpt
+++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt
@@ -89,9 +89,9 @@ File name is => %s%et%s
 File permissions are => 100666
 File created in => temp dir
 -- Iteration 6 --
-File name is => %s%et%s
-File permissions are => 100666
-File created in => temp dir
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
diff --git a/ext/standard/tests/file/tempnam_variation7.phpt b/ext/standard/tests/file/tempnam_variation7.phpt
index 18d074d..16f94f0 100644
--- a/ext/standard/tests/file/tempnam_variation7.phpt
+++ b/ext/standard/tests/file/tempnam_variation7.phpt
@@ -94,9 +94,9 @@ File name is => %s%etempnam_variation3.tmp%s
 File permissions are => 100600
 File created in => temp dir
 -- Iteration 6 --
-File name is => %s%etempnam_variation3.tmp%s
-File permissions are => 100600
-File created in => temp dir
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
 -- Iteration 7 --
 
 Warning: tempnam() expects parameter 1 to be string, array given in %s on line %d
diff --git a/ext/standard/tests/general_functions/bug44394_2.phpt b/ext/standard/tests/general_functions/bug44394_2.phpt
index 161483e..3ca5397 100644
--- a/ext/standard/tests/general_functions/bug44394_2.phpt
+++ b/ext/standard/tests/general_functions/bug44394_2.phpt
@@ -4,6 +4,7 @@ Bug #44394 (Last two bytes missing from output) with session.use_trans_id
 <?php if (!extension_loaded("session")) print "skip"; ?>
 --INI--
 session.name=PHPSESSID
+session.use_only_cookies=0
 --FILE--
 <?php
 
diff --git a/ext/standard/tests/general_functions/bug46587.phpt b/ext/standard/tests/general_functions/bug46587.phpt
new file mode 100644
index 0000000..becbde9
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug46587.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #46587 (mt_rand() does not check that max is greater than min).
+--FILE--
+<?php
+
+var_dump(mt_rand(3,8));
+var_dump(mt_rand(8,3));
+
+echo "Done.\n";
+?>
+--EXPECTF--
+int(%d)
+
+Warning: mt_rand(): max(3) is smaller than min(8) in %s on line %d
+bool(false)
+Done.
diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
index 31bcb80..f679a41 100644
--- a/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
+++ b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt
@@ -1,20 +1,20 @@
---TEST--
-Test function get_cfg_var() by calling deprecated option
---CREDITS--
-Francesco Fullone ff at ideato.it
-#PHPTestFest Cesena Italia on 2009-06-20
---INI--
-register_globals=1
---SKIPIF--
-<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or greater"); ?>
---FILE--
-<?php
-echo "*** Test by calling method or function with deprecated option ***\n";
-var_dump(get_cfg_var( 'register_globals' ) );
-
-?>
---EXPECTF--
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in %s on line 0
-*** Test by calling method or function with deprecated option ***
-string(1) "1"
-
+--TEST--
+Test function get_cfg_var() by calling deprecated option
+--CREDITS--
+Francesco Fullone ff at ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--INI--
+register_globals=1
+--SKIPIF--
+<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or greater"); ?>
+--FILE--
+<?php
+echo "*** Test by calling method or function with deprecated option ***\n";
+var_dump(get_cfg_var( 'register_globals' ) );
+
+?>
+--EXPECTF--
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in %s on line 0
+*** Test by calling method or function with deprecated option ***
+string(1) "1"
+
diff --git a/ext/standard/tests/general_functions/putenv_error1.phpt b/ext/standard/tests/general_functions/putenv_error1.phpt
index c4b49f3..0fd0640 100644
--- a/ext/standard/tests/general_functions/putenv_error1.phpt
+++ b/ext/standard/tests/general_functions/putenv_error1.phpt
@@ -16,7 +16,7 @@ print ($set ? 'it worked' : 'boo') . "\n";
 ?>
 ==DONE==
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Warning: putenv(): Safe Mode warning: Cannot set environment variable 'FOO' - it's not in the allowed list in %s on line %d
 
diff --git a/ext/standard/tests/general_functions/putenv_error2.phpt b/ext/standard/tests/general_functions/putenv_error2.phpt
index 456a7ab..b8f306c 100644
--- a/ext/standard/tests/general_functions/putenv_error2.phpt
+++ b/ext/standard/tests/general_functions/putenv_error2.phpt
@@ -12,7 +12,7 @@ putenv('BAZ=bop');
 ?>
 ==DONE==
 --EXPECTF--
-Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0
 
 Warning: putenv(): Safe Mode warning: Cannot override protected environment variable 'FOO' in %s on line %d
 
diff --git a/ext/standard/tests/http/bug53198.phpt b/ext/standard/tests/http/bug53198.phpt
new file mode 100644
index 0000000..fe26bc9
--- /dev/null
+++ b/ext/standard/tests/http/bug53198.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Bug #53198 (From: header cannot be changed with ini_set)
+--SKIPIF--
+<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
+--INI--
+from=teste at teste.pt
+--FILE--
+<?php
+require 'server.inc';
+
+function do_test() {
+
+	$responses = array(
+		"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
+	);
+
+	$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
+
+	foreach($responses as $r) {
+
+		$fd = fopen('http://127.0.0.1:12342/', 'rb', false);
+
+		fseek($output, 0, SEEK_SET);
+		var_dump(stream_get_contents($output));
+		fseek($output, 0, SEEK_SET);
+	}
+
+	http_server_kill($pid);
+
+}
+
+echo "-- Test: leave default --\n";
+
+do_test();
+
+echo "-- Test: after ini_set --\n";
+
+ini_set('from', 'junk at junk.com');
+
+do_test();
+
+?>
+--EXPECT--
+-- Test: leave default --
+string(63) "GET / HTTP/1.0
+From: teste at teste.pt
+Host: 127.0.0.1:12342
+
+"
+-- Test: after ini_set --
+string(62) "GET / HTTP/1.0
+From: junk at junk.com
+Host: 127.0.0.1:12342
+
+"
+
diff --git a/ext/standard/tests/math/log_variation2.phpt b/ext/standard/tests/math/log_variation2.phpt
index 00b3b31..327e7c5 100644
--- a/ext/standard/tests/math/log_variation2.phpt
+++ b/ext/standard/tests/math/log_variation2.phpt
@@ -94,7 +94,7 @@ Warning: log(): base must be greater than 0 in %s on line %d
 bool(false)
 
 -- Iteration 2 --
-float(INF)
+float(NAN)
 
 -- Iteration 3 --
 float(0.12145441273706)
@@ -135,7 +135,7 @@ Warning: log(): base must be greater than 0 in %s on line %d
 bool(false)
 
 -- Iteration 13 --
-float(INF)
+float(NAN)
 
 -- Iteration 14 --
 
@@ -143,7 +143,7 @@ Warning: log(): base must be greater than 0 in %s on line %d
 bool(false)
 
 -- Iteration 15 --
-float(INF)
+float(NAN)
 
 -- Iteration 16 --
 
diff --git a/ext/standard/tests/misc/syslog_vars_variation1.phpt b/ext/standard/tests/misc/syslog_vars_variation1.phpt
index ae53a57..0237830 100644
--- a/ext/standard/tests/misc/syslog_vars_variation1.phpt
+++ b/ext/standard/tests/misc/syslog_vars_variation1.phpt
@@ -7,5 +7,5 @@ define_syslog_variables=On
 var_dump(isset($LOG_ERR));
 ?>
 --EXPECTF--
-Warning: Directive 'define_syslog_variables' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'define_syslog_variables' is deprecated in PHP 5.3 and greater in Unknown on line 0
 bool(true)
diff --git a/ext/standard/tests/streams/bug46024.phpt b/ext/standard/tests/streams/bug46024.phpt
index 34407cd..3f2a5f8 100644
--- a/ext/standard/tests/streams/bug46024.phpt
+++ b/ext/standard/tests/streams/bug46024.phpt
@@ -1,7 +1,7 @@
 --TEST--
 Bug #46024 stream_select() doesn't return the correct number
 --SKIPIF--
-<?php if (!getenv('TEST_PHP_EXECUTABLE')) die("TEST_PHP_EXECUTABLE not defined"); ?>
+<?php if (!getenv('TEST_PHP_EXECUTABLE')) die("skip TEST_PHP_EXECUTABLE not defined"); ?>
 --FILE--
 <?php
 $php = getenv('TEST_PHP_EXECUTABLE'); 
diff --git a/ext/standard/tests/strings/bug47168.phpt b/ext/standard/tests/strings/bug47168.phpt
new file mode 100644
index 0000000..4cca362
--- /dev/null
+++ b/ext/standard/tests/strings/bug47168.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #47168 (printf of floating point variable prints maximum of 40 decimal places)
+--FILE--
+<?php
+
+$dyadic = 0.00000000000045474735088646411895751953125;
+var_dump(printf ("%1.41f\n",unserialize(serialize($dyadic))));
+
+?>
+--EXPECT--
+0.00000000000045474735088646411895751953125
+int(44)
diff --git a/ext/standard/tests/strings/bug49785.phpt b/ext/standard/tests/strings/bug49785.phpt
index fa42dac..3c38afd 100644
--- a/ext/standard/tests/strings/bug49785.phpt
+++ b/ext/standard/tests/strings/bug49785.phpt
@@ -156,7 +156,7 @@ string(0) ""
 string(0) ""
 string(0) ""
 string(8) "f0908080"
-string(8) "f7bfbfbf"
+string(0) ""
 string(0) ""
 string(0) ""
 string(0) ""
diff --git a/ext/standard/tests/strings/bug53021.phpt b/ext/standard/tests/strings/bug53021.phpt
new file mode 100644
index 0000000..4a8fbe4
--- /dev/null
+++ b/ext/standard/tests/strings/bug53021.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Bug #53021 (Failure to convert numeric entities with ENT_NOQUOTES and ISO-8859-1)
+--FILE--
+<?php
+var_dump(unpack("H*",html_entity_decode("é", ENT_QUOTES, "ISO-8859-1")));
+echo "double quotes variations:", "\n";
+echo html_entity_decode(""", ENT_NOQUOTES, 'UTF-8'), "\n";
+echo html_entity_decode(""", ENT_NOQUOTES, 'UTF-8'), "\n";
+echo html_entity_decode(""", ENT_QUOTES, 'UTF-8'), "\n";
+echo html_entity_decode(""", ENT_QUOTES, 'UTF-8'), "\n";
+echo html_entity_decode(""", ENT_COMPAT, 'UTF-8'), "\n";
+echo html_entity_decode(""", ENT_COMPAT, 'UTF-8'), "\n";
+
+echo "\nsingle quotes variations:", "\n";
+echo html_entity_decode("'", ENT_NOQUOTES, 'UTF-8'), "\n";
+echo html_entity_decode("'", ENT_QUOTES, 'UTF-8'), "\n";
+echo html_entity_decode("'", ENT_COMPAT, 'UTF-8'), "\n";
+--EXPECT--
+array(1) {
+  [1]=>
+  string(2) "e9"
+}
+double quotes variations:
+"
+"
+"
+"
+"
+"
+
+single quotes variations:
+'
+'
+'
diff --git a/ext/standard/tests/strings/bug53319.phpt b/ext/standard/tests/strings/bug53319.phpt
new file mode 100644
index 0000000..0bcc06d
--- /dev/null
+++ b/ext/standard/tests/strings/bug53319.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #53319 (Strip_tags() may strip '<br />' incorrectly)
+--FILE--
+<?php
+
+$str = '<br /><br  />USD<input type="text"/><br/>CDN<br><input type="text" />';
+var_dump(strip_tags($str, '<input>'));
+var_dump(strip_tags($str, '<br><input>') === $str);
+var_dump(strip_tags($str));
+var_dump(strip_tags('<a/b>', '<a>'));
+
+?>
+--EXPECTF--
+string(47) "USD<input type="text"/>CDN<input type="text" />"
+bool(true)
+string(6) "USDCDN"
+string(0) ""
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic1-win32.phpt b/ext/standard/tests/strings/get_html_translation_table_basic1-win32.phpt
deleted file mode 100644
index 700b8e3..0000000
--- a/ext/standard/tests/strings/get_html_translation_table_basic1-win32.phpt
+++ /dev/null
@@ -1,269 +0,0 @@
---TEST--
-Test get_html_translation_table() function : basic functionality - with default args
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) != "WIN"){  
-  die('skip only for Windows');
-}
-
-if( !setlocale(LC_ALL, "English_United States.1252") ) {
-  die('skip failed to set locale settings to "English_United States.1252"');
-}
-?>
---FILE--
-<?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
- * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
- * Source code: ext/standard/html.c
-*/
-
-/* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
-
-//set locale
-setlocale(LC_ALL, "English_United States.1252"); 
-
-echo "*** Testing get_html_translation_table() : basic functionality ***\n";
-
-// Calling get_html_translation_table() with default arguments
-echo "-- with default arguments --\n";
-var_dump( get_html_translation_table() );
-
-// Calling get_html_translation_table() with all possible optional arguments
-echo "-- with table = HTML_ENTITIES --\n";
-$table = HTML_ENTITIES;
-var_dump( get_html_translation_table($table) );
-
-echo "-- with table = HTML_SPECIALCHARS --\n";
-$table = HTML_SPECIALCHARS; 
-var_dump( get_html_translation_table($table) );
-
-echo "Done\n";
-?>
---EXPECTF--
-*** Testing get_html_translation_table() : basic functionality ***
--- with default arguments --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_ENTITIES --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_SPECIALCHARS --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic1.phpt b/ext/standard/tests/strings/get_html_translation_table_basic1.phpt
index a3dd507..0adafa3 100644
--- a/ext/standard/tests/strings/get_html_translation_table_basic1.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_basic1.phpt
@@ -1,269 +1,545 @@
 --TEST--
 Test get_html_translation_table() function : basic functionality - with default args
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) == 'WIN'){  
-  die('skip Not for Windows');
-}
-
-if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
-  die('skip failed to set locale settings to "en-US.UTF-8"');
-}
-?>
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
 
 /* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
 
-//set locale to en_US.UTF-8
-setlocale(LC_ALL, "en_US.UTF-8"); 
 
 echo "*** Testing get_html_translation_table() : basic functionality ***\n";
 
-// Calling get_html_translation_table() with default arguments
-echo "-- with default arguments --\n";
-var_dump( get_html_translation_table() );
-
-// Calling get_html_translation_table() with all possible optional arguments
 echo "-- with table = HTML_ENTITIES --\n";
 $table = HTML_ENTITIES;
-var_dump( get_html_translation_table($table) );
+var_dump( get_html_translation_table($table, ENT_COMPAT, "UTF-8") );
 
 echo "-- with table = HTML_SPECIALCHARS --\n";
 $table = HTML_SPECIALCHARS; 
-var_dump( get_html_translation_table($table) );
+var_dump( get_html_translation_table($table, ENT_COMPAT, "UTF-8") );
 
 echo "Done\n";
 ?>
 --EXPECTF--
 *** Testing get_html_translation_table() : basic functionality ***
--- with default arguments --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
 -- with table = HTML_ENTITIES --
-array(100) {
-  [" "]=>
+array(252) {
+  [" "]=>
   string(6) " "
-  ["¡"]=>
+  ["¡"]=>
   string(7) "¡"
-  ["¢"]=>
+  ["¢"]=>
   string(6) "¢"
-  ["£"]=>
+  ["£"]=>
   string(7) "£"
-  ["¤"]=>
+  ["¤"]=>
   string(8) "¤"
-  ["¥"]=>
+  ["Â¥"]=>
   string(5) "¥"
-  ["¦"]=>
+  ["¦"]=>
   string(8) "¦"
-  ["§"]=>
+  ["§"]=>
   string(6) "§"
-  ["¨"]=>
+  ["¨"]=>
   string(5) "¨"
-  ["©"]=>
+  ["©"]=>
   string(6) "©"
-  ["ª"]=>
+  ["ª"]=>
   string(6) "ª"
-  ["«"]=>
+  ["«"]=>
   string(7) "«"
-  ["¬"]=>
+  ["¬"]=>
   string(5) "¬"
-  ["­"]=>
+  ["­"]=>
   string(5) "­"
-  ["®"]=>
+  ["®"]=>
   string(5) "®"
-  ["¯"]=>
+  ["¯"]=>
   string(6) "¯"
-  ["°"]=>
+  ["°"]=>
   string(5) "°"
-  ["±"]=>
+  ["±"]=>
   string(8) "±"
-  ["²"]=>
+  ["²"]=>
   string(6) "&sup2;"
-  ["³"]=>
+  ["³"]=>
   string(6) "&sup3;"
-  ["´"]=>
+  ["´"]=>
   string(7) "´"
-  ["µ"]=>
+  ["µ"]=>
   string(7) "µ"
-  ["¶"]=>
+  ["¶"]=>
   string(6) "¶"
-  ["·"]=>
+  ["·"]=>
   string(8) "·"
-  ["¸"]=>
+  ["¸"]=>
   string(7) "¸"
-  ["¹"]=>
+  ["¹"]=>
   string(6) "&sup1;"
-  ["º"]=>
+  ["º"]=>
   string(6) "º"
-  ["»"]=>
+  ["»"]=>
   string(7) "»"
-  ["¼"]=>
+  ["¼"]=>
   string(8) "&frac14;"
-  ["½"]=>
+  ["½"]=>
   string(8) "&frac12;"
-  ["¾"]=>
+  ["¾"]=>
   string(8) "&frac34;"
-  ["¿"]=>
+  ["¿"]=>
   string(8) "¿"
-  ["À"]=>
+  ["À"]=>
   string(8) "À"
-  ["Á"]=>
+  ["Á"]=>
   string(8) "Á"
-  ["Â"]=>
+  ["Â"]=>
   string(7) "Â"
-  ["Ã"]=>
+  ["Ã"]=>
   string(8) "Ã"
-  ["Ä"]=>
+  ["Ä"]=>
   string(6) "Ä"
-  ["Å"]=>
+  ["Ã…"]=>
   string(7) "Å"
-  ["Æ"]=>
+  ["Æ"]=>
   string(7) "Æ"
-  ["Ç"]=>
+  ["Ç"]=>
   string(8) "Ç"
-  ["È"]=>
+  ["È"]=>
   string(8) "È"
-  ["É"]=>
+  ["É"]=>
   string(8) "É"
-  ["Ê"]=>
+  ["Ê"]=>
   string(7) "Ê"
-  ["Ë"]=>
+  ["Ë"]=>
   string(6) "Ë"
-  ["Ì"]=>
+  ["Ì"]=>
   string(8) "Ì"
-  ["Í"]=>
+  ["Í"]=>
   string(8) "Í"
-  ["Î"]=>
+  ["ÃŽ"]=>
   string(7) "Î"
-  ["Ï"]=>
+  ["Ï"]=>
   string(6) "Ï"
-  ["Ð"]=>
+  ["Ð"]=>
   string(5) "Ð"
-  ["Ñ"]=>
+  ["Ñ"]=>
   string(8) "Ñ"
-  ["Ò"]=>
+  ["Ã’"]=>
   string(8) "Ò"
-  ["Ó"]=>
+  ["Ó"]=>
   string(8) "Ó"
-  ["Ô"]=>
+  ["Ô"]=>
   string(7) "Ô"
-  ["Õ"]=>
+  ["Õ"]=>
   string(8) "Õ"
-  ["Ö"]=>
+  ["Ö"]=>
   string(6) "Ö"
-  ["×"]=>
+  ["×"]=>
   string(7) "×"
-  ["Ø"]=>
+  ["Ø"]=>
   string(8) "Ø"
-  ["Ù"]=>
+  ["Ù"]=>
   string(8) "Ù"
-  ["Ú"]=>
+  ["Ú"]=>
   string(8) "Ú"
-  ["Û"]=>
+  ["Û"]=>
   string(7) "Û"
-  ["Ü"]=>
+  ["Ü"]=>
   string(6) "Ü"
-  ["Ý"]=>
+  ["Ý"]=>
   string(8) "Ý"
-  ["Þ"]=>
+  ["Þ"]=>
   string(7) "Þ"
-  ["ß"]=>
+  ["ß"]=>
   string(7) "ß"
-  ["à"]=>
+  ["à"]=>
   string(8) "à"
-  ["á"]=>
+  ["á"]=>
   string(8) "á"
-  ["â"]=>
+  ["â"]=>
   string(7) "â"
-  ["ã"]=>
+  ["ã"]=>
   string(8) "ã"
-  ["ä"]=>
+  ["ä"]=>
   string(6) "ä"
-  ["å"]=>
+  ["Ã¥"]=>
   string(7) "å"
-  ["æ"]=>
+  ["æ"]=>
   string(7) "æ"
-  ["ç"]=>
+  ["ç"]=>
   string(8) "ç"
-  ["è"]=>
+  ["è"]=>
   string(8) "è"
-  ["é"]=>
+  ["é"]=>
   string(8) "é"
-  ["ê"]=>
+  ["ê"]=>
   string(7) "ê"
-  ["ë"]=>
+  ["ë"]=>
   string(6) "ë"
-  ["ì"]=>
+  ["ì"]=>
   string(8) "ì"
-  ["í"]=>
+  ["í"]=>
   string(8) "í"
-  ["î"]=>
+  ["î"]=>
   string(7) "î"
-  ["ï"]=>
+  ["ï"]=>
   string(6) "ï"
-  ["ð"]=>
+  ["ð"]=>
   string(5) "ð"
-  ["ñ"]=>
+  ["ñ"]=>
   string(8) "ñ"
-  ["ò"]=>
+  ["ò"]=>
   string(8) "ò"
-  ["ó"]=>
+  ["ó"]=>
   string(8) "ó"
-  ["ô"]=>
+  ["ô"]=>
   string(7) "ô"
-  ["õ"]=>
+  ["õ"]=>
   string(8) "õ"
-  ["ö"]=>
+  ["ö"]=>
   string(6) "ö"
-  ["÷"]=>
+  ["÷"]=>
   string(8) "÷"
-  ["ø"]=>
+  ["ø"]=>
   string(8) "ø"
-  ["ù"]=>
+  ["ù"]=>
   string(8) "ù"
-  ["ú"]=>
+  ["ú"]=>
   string(8) "ú"
-  ["û"]=>
+  ["û"]=>
   string(7) "û"
-  ["ü"]=>
+  ["ü"]=>
   string(6) "ü"
-  ["ý"]=>
+  ["ý"]=>
   string(8) "ý"
-  ["þ"]=>
+  ["þ"]=>
   string(7) "þ"
-  ["ÿ"]=>
+  ["ÿ"]=>
   string(6) "ÿ"
+  ["Å’"]=>
+  string(7) "Œ"
+  ["Å“"]=>
+  string(7) "œ"
+  ["Å "]=>
+  string(8) "Š"
+  ["Å¡"]=>
+  string(8) "š"
+  ["Ÿ"]=>
+  string(6) "Ÿ"
+  ["Æ’"]=>
+  string(6) "ƒ"
+  ["ˆ"]=>
+  string(6) "ˆ"
+  ["˜"]=>
+  string(7) "˜"
+  ["Α"]=>
+  string(7) "Α"
+  ["Î’"]=>
+  string(6) "Β"
+  ["Γ"]=>
+  string(7) "Γ"
+  ["Δ"]=>
+  string(7) "Δ"
+  ["Ε"]=>
+  string(9) "Ε"
+  ["Ζ"]=>
+  string(6) "Ζ"
+  ["Η"]=>
+  string(5) "Η"
+  ["Θ"]=>
+  string(7) "Θ"
+  ["Ι"]=>
+  string(6) "Ι"
+  ["Κ"]=>
+  string(7) "Κ"
+  ["Λ"]=>
+  string(8) "Λ"
+  ["Μ"]=>
+  string(4) "Μ"
+  ["Ν"]=>
+  string(4) "Ν"
+  ["Ξ"]=>
+  string(4) "Ξ"
+  ["Ο"]=>
+  string(9) "Ο"
+  ["Π"]=>
+  string(4) "Π"
+  ["Ρ"]=>
+  string(5) "Ρ"
+  ["Σ"]=>
+  string(7) "Σ"
+  ["Τ"]=>
+  string(5) "Τ"
+  ["Î¥"]=>
+  string(9) "Υ"
+  ["Φ"]=>
+  string(5) "Φ"
+  ["Χ"]=>
+  string(5) "Χ"
+  ["Ψ"]=>
+  string(5) "Ψ"
+  ["Ω"]=>
+  string(7) "Ω"
+  ["α"]=>
+  string(7) "α"
+  ["β"]=>
+  string(6) "β"
+  ["γ"]=>
+  string(7) "γ"
+  ["δ"]=>
+  string(7) "δ"
+  ["ε"]=>
+  string(9) "ε"
+  ["ζ"]=>
+  string(6) "ζ"
+  ["η"]=>
+  string(5) "η"
+  ["θ"]=>
+  string(7) "θ"
+  ["ι"]=>
+  string(6) "ι"
+  ["κ"]=>
+  string(7) "κ"
+  ["λ"]=>
+  string(8) "λ"
+  ["μ"]=>
+  string(4) "μ"
+  ["ν"]=>
+  string(4) "ν"
+  ["ξ"]=>
+  string(4) "ξ"
+  ["ο"]=>
+  string(9) "ο"
+  ["Ï€"]=>
+  string(4) "π"
+  ["ρ"]=>
+  string(5) "ρ"
+  ["Ï‚"]=>
+  string(8) "ς"
+  ["σ"]=>
+  string(7) "σ"
+  ["Ï„"]=>
+  string(5) "τ"
+  ["Ï…"]=>
+  string(9) "υ"
+  ["φ"]=>
+  string(5) "φ"
+  ["χ"]=>
+  string(5) "χ"
+  ["ψ"]=>
+  string(5) "ψ"
+  ["ω"]=>
+  string(7) "ω"
+  ["Ï‘"]=>
+  string(10) "ϑ"
+  ["Ï’"]=>
+  string(7) "ϒ"
+  ["Ï–"]=>
+  string(5) "ϖ"
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(8) " "
+  ["‌"]=>
+  string(6) "‌"
+  ["‍"]=>
+  string(5) "‍"
+  ["‎"]=>
+  string(5) "‎"
+  ["‏"]=>
+  string(5) "‏"
+  ["–"]=>
+  string(7) "–"
+  ["—"]=>
+  string(7) "—"
+  ["‘"]=>
+  string(7) "‘"
+  ["’"]=>
+  string(7) "’"
+  ["‚"]=>
+  string(7) "‚"
+  ["“"]=>
+  string(7) "“"
+  ["”"]=>
+  string(7) "”"
+  ["„"]=>
+  string(7) "„"
+  ["†"]=>
+  string(8) "†"
+  ["‡"]=>
+  string(8) "‡"
+  ["•"]=>
+  string(6) "•"
+  ["…"]=>
+  string(8) "…"
+  ["‰"]=>
+  string(8) "‰"
+  ["′"]=>
+  string(7) "′"
+  ["″"]=>
+  string(7) "″"
+  ["‹"]=>
+  string(8) "‹"
+  ["›"]=>
+  string(8) "›"
+  ["‾"]=>
+  string(7) "‾"
+  ["⁄"]=>
+  string(7) "⁄"
+  ["€"]=>
+  string(6) "€"
+  ["â„‘"]=>
+  string(7) "ℑ"
+  ["℘"]=>
+  string(8) "℘"
+  ["ℜ"]=>
+  string(6) "ℜ"
+  ["â„¢"]=>
+  string(7) "™"
+  ["ℵ"]=>
+  string(9) "ℵ"
+  ["←"]=>
+  string(6) "←"
+  ["↑"]=>
+  string(6) "↑"
+  ["→"]=>
+  string(6) "→"
+  ["↓"]=>
+  string(6) "↓"
+  ["↔"]=>
+  string(6) "↔"
+  ["↵"]=>
+  string(7) "↵"
+  ["⇐"]=>
+  string(6) "⇐"
+  ["⇑"]=>
+  string(6) "⇑"
+  ["⇒"]=>
+  string(6) "⇒"
+  ["⇓"]=>
+  string(6) "⇓"
+  ["⇔"]=>
+  string(6) "⇔"
+  ["∀"]=>
+  string(8) "∀"
+  ["∂"]=>
+  string(6) "∂"
+  ["∃"]=>
+  string(7) "∃"
+  ["∅"]=>
+  string(7) "∅"
+  ["∇"]=>
+  string(7) "∇"
+  ["∈"]=>
+  string(6) "∈"
+  ["∉"]=>
+  string(7) "∉"
+  ["∋"]=>
+  string(4) "∋"
+  ["∏"]=>
+  string(6) "∏"
+  ["∑"]=>
+  string(5) "∑"
+  ["−"]=>
+  string(7) "−"
+  ["∗"]=>
+  string(8) "∗"
+  ["√"]=>
+  string(7) "√"
+  ["∝"]=>
+  string(6) "∝"
+  ["∞"]=>
+  string(7) "∞"
+  ["∠"]=>
+  string(5) "∠"
+  ["∧"]=>
+  string(5) "∧"
+  ["∨"]=>
+  string(4) "∨"
+  ["∩"]=>
+  string(5) "∩"
+  ["∪"]=>
+  string(5) "∪"
+  ["∫"]=>
+  string(5) "∫"
+  ["∴"]=>
+  string(8) "&there4;"
+  ["∼"]=>
+  string(5) "∼"
+  ["≅"]=>
+  string(6) "≅"
+  ["≈"]=>
+  string(7) "≈"
+  ["≠"]=>
+  string(4) "≠"
+  ["≡"]=>
+  string(7) "≡"
+  ["≤"]=>
+  string(4) "≤"
+  ["≥"]=>
+  string(4) "≥"
+  ["⊂"]=>
+  string(5) "⊂"
+  ["⊃"]=>
+  string(5) "⊃"
+  ["⊄"]=>
+  string(6) "⊄"
+  ["⊆"]=>
+  string(6) "⊆"
+  ["⊇"]=>
+  string(6) "⊇"
+  ["⊕"]=>
+  string(7) "⊕"
+  ["⊗"]=>
+  string(8) "⊗"
+  ["⊥"]=>
+  string(6) "⊥"
+  ["â‹…"]=>
+  string(6) "⋅"
+  ["⌈"]=>
+  string(7) "⌈"
+  ["⌉"]=>
+  string(7) "⌉"
+  ["⌊"]=>
+  string(8) "⌊"
+  ["⌋"]=>
+  string(8) "⌋"
+  ["〈"]=>
+  string(6) "⟨"
+  ["〉"]=>
+  string(6) "⟩"
+  ["â—Š"]=>
+  string(5) "◊"
+  ["â™ "]=>
+  string(8) "♠"
+  ["♣"]=>
+  string(7) "♣"
+  ["♥"]=>
+  string(8) "♥"
+  ["♦"]=>
+  string(7) "♦"
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- with table = HTML_SPECIALCHARS --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic2-win32.phpt b/ext/standard/tests/strings/get_html_translation_table_basic2-win32.phpt
deleted file mode 100644
index 1b1a53a..0000000
--- a/ext/standard/tests/strings/get_html_translation_table_basic2-win32.phpt
+++ /dev/null
@@ -1,673 +0,0 @@
---TEST--
-Test get_html_translation_table() function : basic functionality - table as HTML_ENTITIES & diff quote_style
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) != "WIN"){  
-  die('skip only for Windows');
-}
-
-if( !setlocale(LC_ALL, "English_United States.1252") ) {
-  die('skip failed to set locale settings to "English_United States.1252"');
-}
-
-?>
---FILE--
-<?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
- * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
- * Source code: ext/standard/html.c
-*/
-
-/* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
-
-//set locale 
-setlocale(LC_ALL, "English_United States.1252");
-
-
-echo "*** Testing get_html_translation_table() : basic functionality ***\n";
-
-// Calling get_html_translation_table() with default arguments
-echo "-- with default arguments --\n";
-var_dump( get_html_translation_table() );
-
-// Calling get_html_translation_table() with all arguments
-// $table as HTML_ENTITIES and different quote style
-echo "-- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --\n";
-$table = HTML_ENTITIES;
-$quote_style = ENT_COMPAT;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-echo "-- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --\n";
-$quote_style = ENT_QUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-echo "-- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --\n";
-$quote_style = ENT_NOQUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-
-echo "Done\n";
-?>
---EXPECTF--
-*** Testing get_html_translation_table() : basic functionality ***
--- with default arguments --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --
-array(101) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["'"]=>
-  string(5) "'"
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --
-array(99) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic2.phpt b/ext/standard/tests/strings/get_html_translation_table_basic2.phpt
index 3e04638..8d27e15 100644
--- a/ext/standard/tests/strings/get_html_translation_table_basic2.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_basic2.phpt
@@ -1,18 +1,8 @@
 --TEST--
 Test get_html_translation_table() function : basic functionality - table as HTML_ENTITIES & diff quote_style
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) == "WIN"){  
-  die('skip Not for Windows');
-}
-
-if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
-  die('skip failed to set locale settings to "en-US.UTF-8"');
-}
-?>
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
@@ -25,648 +15,1545 @@ setlocale(LC_ALL, "en_US.UTF-8");
 
 echo "*** Testing get_html_translation_table() : basic functionality ***\n";
 
-// Calling get_html_translation_table() with default arguments
-echo "-- with default arguments --\n";
-var_dump( get_html_translation_table() );
-
 // Calling get_html_translation_table() with all arguments
 // $table as HTML_ENTITIES and different quote style
 echo "-- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --\n";
 $table = HTML_ENTITIES;
 $quote_style = ENT_COMPAT;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
 echo "-- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --\n";
 $quote_style = ENT_QUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
 echo "-- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --\n";
 $quote_style = ENT_NOQUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
 
 echo "Done\n";
 ?>
 --EXPECTF--
 *** Testing get_html_translation_table() : basic functionality ***
--- with default arguments --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
 -- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --
-array(100) {
-  [" "]=>
+array(252) {
+  [" "]=>
   string(6) " "
-  ["¡"]=>
+  ["¡"]=>
   string(7) "¡"
-  ["¢"]=>
+  ["¢"]=>
   string(6) "¢"
-  ["£"]=>
+  ["£"]=>
   string(7) "£"
-  ["¤"]=>
+  ["¤"]=>
   string(8) "¤"
-  ["¥"]=>
+  ["Â¥"]=>
   string(5) "¥"
-  ["¦"]=>
+  ["¦"]=>
   string(8) "¦"
-  ["§"]=>
+  ["§"]=>
   string(6) "§"
-  ["¨"]=>
+  ["¨"]=>
   string(5) "¨"
-  ["©"]=>
+  ["©"]=>
   string(6) "©"
-  ["ª"]=>
+  ["ª"]=>
   string(6) "ª"
-  ["«"]=>
+  ["«"]=>
   string(7) "«"
-  ["¬"]=>
+  ["¬"]=>
   string(5) "¬"
-  ["­"]=>
+  ["­"]=>
   string(5) "­"
-  ["®"]=>
+  ["®"]=>
   string(5) "®"
-  ["¯"]=>
+  ["¯"]=>
   string(6) "¯"
-  ["°"]=>
+  ["°"]=>
   string(5) "°"
-  ["±"]=>
+  ["±"]=>
   string(8) "±"
-  ["²"]=>
+  ["²"]=>
   string(6) "&sup2;"
-  ["³"]=>
+  ["³"]=>
   string(6) "&sup3;"
-  ["´"]=>
+  ["´"]=>
   string(7) "´"
-  ["µ"]=>
+  ["µ"]=>
   string(7) "µ"
-  ["¶"]=>
+  ["¶"]=>
   string(6) "¶"
-  ["·"]=>
+  ["·"]=>
   string(8) "·"
-  ["¸"]=>
+  ["¸"]=>
   string(7) "¸"
-  ["¹"]=>
+  ["¹"]=>
   string(6) "&sup1;"
-  ["º"]=>
+  ["º"]=>
   string(6) "º"
-  ["»"]=>
+  ["»"]=>
   string(7) "»"
-  ["¼"]=>
+  ["¼"]=>
   string(8) "&frac14;"
-  ["½"]=>
+  ["½"]=>
   string(8) "&frac12;"
-  ["¾"]=>
+  ["¾"]=>
   string(8) "&frac34;"
-  ["¿"]=>
+  ["¿"]=>
   string(8) "¿"
-  ["À"]=>
+  ["À"]=>
   string(8) "À"
-  ["Á"]=>
+  ["Á"]=>
   string(8) "Á"
-  ["Â"]=>
+  ["Â"]=>
   string(7) "Â"
-  ["Ã"]=>
+  ["Ã"]=>
   string(8) "Ã"
-  ["Ä"]=>
+  ["Ä"]=>
   string(6) "Ä"
-  ["Å"]=>
+  ["Ã…"]=>
   string(7) "Å"
-  ["Æ"]=>
+  ["Æ"]=>
   string(7) "Æ"
-  ["Ç"]=>
+  ["Ç"]=>
   string(8) "Ç"
-  ["È"]=>
+  ["È"]=>
   string(8) "È"
-  ["É"]=>
+  ["É"]=>
   string(8) "É"
-  ["Ê"]=>
+  ["Ê"]=>
   string(7) "Ê"
-  ["Ë"]=>
+  ["Ë"]=>
   string(6) "Ë"
-  ["Ì"]=>
+  ["Ì"]=>
   string(8) "Ì"
-  ["Í"]=>
+  ["Í"]=>
   string(8) "Í"
-  ["Î"]=>
+  ["ÃŽ"]=>
   string(7) "Î"
-  ["Ï"]=>
+  ["Ï"]=>
   string(6) "Ï"
-  ["Ð"]=>
+  ["Ð"]=>
   string(5) "Ð"
-  ["Ñ"]=>
+  ["Ñ"]=>
   string(8) "Ñ"
-  ["Ò"]=>
+  ["Ã’"]=>
   string(8) "Ò"
-  ["Ó"]=>
+  ["Ó"]=>
   string(8) "Ó"
-  ["Ô"]=>
+  ["Ô"]=>
   string(7) "Ô"
-  ["Õ"]=>
+  ["Õ"]=>
   string(8) "Õ"
-  ["Ö"]=>
+  ["Ö"]=>
   string(6) "Ö"
-  ["×"]=>
+  ["×"]=>
   string(7) "×"
-  ["Ø"]=>
+  ["Ø"]=>
   string(8) "Ø"
-  ["Ù"]=>
+  ["Ù"]=>
   string(8) "Ù"
-  ["Ú"]=>
+  ["Ú"]=>
   string(8) "Ú"
-  ["Û"]=>
+  ["Û"]=>
   string(7) "Û"
-  ["Ü"]=>
+  ["Ü"]=>
   string(6) "Ü"
-  ["Ý"]=>
+  ["Ý"]=>
   string(8) "Ý"
-  ["Þ"]=>
+  ["Þ"]=>
   string(7) "Þ"
-  ["ß"]=>
+  ["ß"]=>
   string(7) "ß"
-  ["à"]=>
+  ["à"]=>
   string(8) "à"
-  ["á"]=>
+  ["á"]=>
   string(8) "á"
-  ["â"]=>
+  ["â"]=>
   string(7) "â"
-  ["ã"]=>
+  ["ã"]=>
   string(8) "ã"
-  ["ä"]=>
+  ["ä"]=>
   string(6) "ä"
-  ["å"]=>
+  ["Ã¥"]=>
   string(7) "å"
-  ["æ"]=>
+  ["æ"]=>
   string(7) "æ"
-  ["ç"]=>
+  ["ç"]=>
   string(8) "ç"
-  ["è"]=>
+  ["è"]=>
   string(8) "è"
-  ["é"]=>
+  ["é"]=>
   string(8) "é"
-  ["ê"]=>
+  ["ê"]=>
   string(7) "ê"
-  ["ë"]=>
+  ["ë"]=>
   string(6) "ë"
-  ["ì"]=>
+  ["ì"]=>
   string(8) "ì"
-  ["í"]=>
+  ["í"]=>
   string(8) "í"
-  ["î"]=>
+  ["î"]=>
   string(7) "î"
-  ["ï"]=>
+  ["ï"]=>
   string(6) "ï"
-  ["ð"]=>
+  ["ð"]=>
   string(5) "ð"
-  ["ñ"]=>
+  ["ñ"]=>
   string(8) "ñ"
-  ["ò"]=>
+  ["ò"]=>
   string(8) "ò"
-  ["ó"]=>
+  ["ó"]=>
   string(8) "ó"
-  ["ô"]=>
+  ["ô"]=>
   string(7) "ô"
-  ["õ"]=>
+  ["õ"]=>
   string(8) "õ"
-  ["ö"]=>
+  ["ö"]=>
   string(6) "ö"
-  ["÷"]=>
+  ["÷"]=>
   string(8) "÷"
-  ["ø"]=>
+  ["ø"]=>
   string(8) "ø"
-  ["ù"]=>
+  ["ù"]=>
   string(8) "ù"
-  ["ú"]=>
+  ["ú"]=>
   string(8) "ú"
-  ["û"]=>
+  ["û"]=>
   string(7) "û"
-  ["ü"]=>
+  ["ü"]=>
   string(6) "ü"
-  ["ý"]=>
+  ["ý"]=>
   string(8) "ý"
-  ["þ"]=>
+  ["þ"]=>
   string(7) "þ"
-  ["ÿ"]=>
+  ["ÿ"]=>
   string(6) "ÿ"
+  ["Å’"]=>
+  string(7) "Œ"
+  ["Å“"]=>
+  string(7) "œ"
+  ["Å "]=>
+  string(8) "Š"
+  ["Å¡"]=>
+  string(8) "š"
+  ["Ÿ"]=>
+  string(6) "Ÿ"
+  ["Æ’"]=>
+  string(6) "ƒ"
+  ["ˆ"]=>
+  string(6) "ˆ"
+  ["˜"]=>
+  string(7) "˜"
+  ["Α"]=>
+  string(7) "Α"
+  ["Î’"]=>
+  string(6) "Β"
+  ["Γ"]=>
+  string(7) "Γ"
+  ["Δ"]=>
+  string(7) "Δ"
+  ["Ε"]=>
+  string(9) "Ε"
+  ["Ζ"]=>
+  string(6) "Ζ"
+  ["Η"]=>
+  string(5) "Η"
+  ["Θ"]=>
+  string(7) "Θ"
+  ["Ι"]=>
+  string(6) "Ι"
+  ["Κ"]=>
+  string(7) "Κ"
+  ["Λ"]=>
+  string(8) "Λ"
+  ["Μ"]=>
+  string(4) "Μ"
+  ["Ν"]=>
+  string(4) "Ν"
+  ["Ξ"]=>
+  string(4) "Ξ"
+  ["Ο"]=>
+  string(9) "Ο"
+  ["Π"]=>
+  string(4) "Π"
+  ["Ρ"]=>
+  string(5) "Ρ"
+  ["Σ"]=>
+  string(7) "Σ"
+  ["Τ"]=>
+  string(5) "Τ"
+  ["Î¥"]=>
+  string(9) "Υ"
+  ["Φ"]=>
+  string(5) "Φ"
+  ["Χ"]=>
+  string(5) "Χ"
+  ["Ψ"]=>
+  string(5) "Ψ"
+  ["Ω"]=>
+  string(7) "Ω"
+  ["α"]=>
+  string(7) "α"
+  ["β"]=>
+  string(6) "β"
+  ["γ"]=>
+  string(7) "γ"
+  ["δ"]=>
+  string(7) "δ"
+  ["ε"]=>
+  string(9) "ε"
+  ["ζ"]=>
+  string(6) "ζ"
+  ["η"]=>
+  string(5) "η"
+  ["θ"]=>
+  string(7) "θ"
+  ["ι"]=>
+  string(6) "ι"
+  ["κ"]=>
+  string(7) "κ"
+  ["λ"]=>
+  string(8) "λ"
+  ["μ"]=>
+  string(4) "μ"
+  ["ν"]=>
+  string(4) "ν"
+  ["ξ"]=>
+  string(4) "ξ"
+  ["ο"]=>
+  string(9) "ο"
+  ["Ï€"]=>
+  string(4) "π"
+  ["ρ"]=>
+  string(5) "ρ"
+  ["Ï‚"]=>
+  string(8) "ς"
+  ["σ"]=>
+  string(7) "σ"
+  ["Ï„"]=>
+  string(5) "τ"
+  ["Ï…"]=>
+  string(9) "υ"
+  ["φ"]=>
+  string(5) "φ"
+  ["χ"]=>
+  string(5) "χ"
+  ["ψ"]=>
+  string(5) "ψ"
+  ["ω"]=>
+  string(7) "ω"
+  ["Ï‘"]=>
+  string(10) "ϑ"
+  ["Ï’"]=>
+  string(7) "ϒ"
+  ["Ï–"]=>
+  string(5) "ϖ"
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(8) " "
+  ["‌"]=>
+  string(6) "‌"
+  ["‍"]=>
+  string(5) "‍"
+  ["‎"]=>
+  string(5) "‎"
+  ["‏"]=>
+  string(5) "‏"
+  ["–"]=>
+  string(7) "–"
+  ["—"]=>
+  string(7) "—"
+  ["‘"]=>
+  string(7) "‘"
+  ["’"]=>
+  string(7) "’"
+  ["‚"]=>
+  string(7) "‚"
+  ["“"]=>
+  string(7) "“"
+  ["”"]=>
+  string(7) "”"
+  ["„"]=>
+  string(7) "„"
+  ["†"]=>
+  string(8) "†"
+  ["‡"]=>
+  string(8) "‡"
+  ["•"]=>
+  string(6) "•"
+  ["…"]=>
+  string(8) "…"
+  ["‰"]=>
+  string(8) "‰"
+  ["′"]=>
+  string(7) "′"
+  ["″"]=>
+  string(7) "″"
+  ["‹"]=>
+  string(8) "‹"
+  ["›"]=>
+  string(8) "›"
+  ["‾"]=>
+  string(7) "‾"
+  ["⁄"]=>
+  string(7) "⁄"
+  ["€"]=>
+  string(6) "€"
+  ["â„‘"]=>
+  string(7) "ℑ"
+  ["℘"]=>
+  string(8) "℘"
+  ["ℜ"]=>
+  string(6) "ℜ"
+  ["â„¢"]=>
+  string(7) "™"
+  ["ℵ"]=>
+  string(9) "ℵ"
+  ["←"]=>
+  string(6) "←"
+  ["↑"]=>
+  string(6) "↑"
+  ["→"]=>
+  string(6) "→"
+  ["↓"]=>
+  string(6) "↓"
+  ["↔"]=>
+  string(6) "↔"
+  ["↵"]=>
+  string(7) "↵"
+  ["⇐"]=>
+  string(6) "⇐"
+  ["⇑"]=>
+  string(6) "⇑"
+  ["⇒"]=>
+  string(6) "⇒"
+  ["⇓"]=>
+  string(6) "⇓"
+  ["⇔"]=>
+  string(6) "⇔"
+  ["∀"]=>
+  string(8) "∀"
+  ["∂"]=>
+  string(6) "∂"
+  ["∃"]=>
+  string(7) "∃"
+  ["∅"]=>
+  string(7) "∅"
+  ["∇"]=>
+  string(7) "∇"
+  ["∈"]=>
+  string(6) "∈"
+  ["∉"]=>
+  string(7) "∉"
+  ["∋"]=>
+  string(4) "∋"
+  ["∏"]=>
+  string(6) "∏"
+  ["∑"]=>
+  string(5) "∑"
+  ["−"]=>
+  string(7) "−"
+  ["∗"]=>
+  string(8) "∗"
+  ["√"]=>
+  string(7) "√"
+  ["∝"]=>
+  string(6) "∝"
+  ["∞"]=>
+  string(7) "∞"
+  ["∠"]=>
+  string(5) "∠"
+  ["∧"]=>
+  string(5) "∧"
+  ["∨"]=>
+  string(4) "∨"
+  ["∩"]=>
+  string(5) "∩"
+  ["∪"]=>
+  string(5) "∪"
+  ["∫"]=>
+  string(5) "∫"
+  ["∴"]=>
+  string(8) "&there4;"
+  ["∼"]=>
+  string(5) "∼"
+  ["≅"]=>
+  string(6) "≅"
+  ["≈"]=>
+  string(7) "≈"
+  ["≠"]=>
+  string(4) "≠"
+  ["≡"]=>
+  string(7) "≡"
+  ["≤"]=>
+  string(4) "≤"
+  ["≥"]=>
+  string(4) "≥"
+  ["⊂"]=>
+  string(5) "⊂"
+  ["⊃"]=>
+  string(5) "⊃"
+  ["⊄"]=>
+  string(6) "⊄"
+  ["⊆"]=>
+  string(6) "⊆"
+  ["⊇"]=>
+  string(6) "⊇"
+  ["⊕"]=>
+  string(7) "⊕"
+  ["⊗"]=>
+  string(8) "⊗"
+  ["⊥"]=>
+  string(6) "⊥"
+  ["â‹…"]=>
+  string(6) "⋅"
+  ["⌈"]=>
+  string(7) "⌈"
+  ["⌉"]=>
+  string(7) "⌉"
+  ["⌊"]=>
+  string(8) "⌊"
+  ["⌋"]=>
+  string(8) "⌋"
+  ["〈"]=>
+  string(6) "⟨"
+  ["〉"]=>
+  string(6) "⟩"
+  ["â—Š"]=>
+  string(5) "◊"
+  ["â™ "]=>
+  string(8) "♠"
+  ["♣"]=>
+  string(7) "♣"
+  ["♥"]=>
+  string(8) "♥"
+  ["♦"]=>
+  string(7) "♦"
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --
-array(101) {
-  [" "]=>
+array(253) {
+  [" "]=>
   string(6) " "
-  ["¡"]=>
+  ["¡"]=>
   string(7) "¡"
-  ["¢"]=>
+  ["¢"]=>
   string(6) "¢"
-  ["£"]=>
+  ["£"]=>
   string(7) "£"
-  ["¤"]=>
+  ["¤"]=>
   string(8) "¤"
-  ["¥"]=>
+  ["Â¥"]=>
   string(5) "¥"
-  ["¦"]=>
+  ["¦"]=>
   string(8) "¦"
-  ["§"]=>
+  ["§"]=>
   string(6) "§"
-  ["¨"]=>
+  ["¨"]=>
   string(5) "¨"
-  ["©"]=>
+  ["©"]=>
   string(6) "©"
-  ["ª"]=>
+  ["ª"]=>
   string(6) "ª"
-  ["«"]=>
+  ["«"]=>
   string(7) "«"
-  ["¬"]=>
+  ["¬"]=>
   string(5) "¬"
-  ["­"]=>
+  ["­"]=>
   string(5) "­"
-  ["®"]=>
+  ["®"]=>
   string(5) "®"
-  ["¯"]=>
+  ["¯"]=>
   string(6) "¯"
-  ["°"]=>
+  ["°"]=>
   string(5) "°"
-  ["±"]=>
+  ["±"]=>
   string(8) "±"
-  ["²"]=>
+  ["²"]=>
   string(6) "&sup2;"
-  ["³"]=>
+  ["³"]=>
   string(6) "&sup3;"
-  ["´"]=>
+  ["´"]=>
   string(7) "´"
-  ["µ"]=>
+  ["µ"]=>
   string(7) "µ"
-  ["¶"]=>
+  ["¶"]=>
   string(6) "¶"
-  ["·"]=>
+  ["·"]=>
   string(8) "·"
-  ["¸"]=>
+  ["¸"]=>
   string(7) "¸"
-  ["¹"]=>
+  ["¹"]=>
   string(6) "&sup1;"
-  ["º"]=>
+  ["º"]=>
   string(6) "º"
-  ["»"]=>
+  ["»"]=>
   string(7) "»"
-  ["¼"]=>
+  ["¼"]=>
   string(8) "&frac14;"
-  ["½"]=>
+  ["½"]=>
   string(8) "&frac12;"
-  ["¾"]=>
+  ["¾"]=>
   string(8) "&frac34;"
-  ["¿"]=>
+  ["¿"]=>
   string(8) "¿"
-  ["À"]=>
+  ["À"]=>
   string(8) "À"
-  ["Á"]=>
+  ["Á"]=>
   string(8) "Á"
-  ["Â"]=>
+  ["Â"]=>
   string(7) "Â"
-  ["Ã"]=>
+  ["Ã"]=>
   string(8) "Ã"
-  ["Ä"]=>
+  ["Ä"]=>
   string(6) "Ä"
-  ["Å"]=>
+  ["Ã…"]=>
   string(7) "Å"
-  ["Æ"]=>
+  ["Æ"]=>
   string(7) "Æ"
-  ["Ç"]=>
+  ["Ç"]=>
   string(8) "Ç"
-  ["È"]=>
+  ["È"]=>
   string(8) "È"
-  ["É"]=>
+  ["É"]=>
   string(8) "É"
-  ["Ê"]=>
+  ["Ê"]=>
   string(7) "Ê"
-  ["Ë"]=>
+  ["Ë"]=>
   string(6) "Ë"
-  ["Ì"]=>
+  ["Ì"]=>
   string(8) "Ì"
-  ["Í"]=>
+  ["Í"]=>
   string(8) "Í"
-  ["Î"]=>
+  ["ÃŽ"]=>
   string(7) "Î"
-  ["Ï"]=>
+  ["Ï"]=>
   string(6) "Ï"
-  ["Ð"]=>
+  ["Ð"]=>
   string(5) "Ð"
-  ["Ñ"]=>
+  ["Ñ"]=>
   string(8) "Ñ"
-  ["Ò"]=>
+  ["Ã’"]=>
   string(8) "Ò"
-  ["Ó"]=>
+  ["Ó"]=>
   string(8) "Ó"
-  ["Ô"]=>
+  ["Ô"]=>
   string(7) "Ô"
-  ["Õ"]=>
+  ["Õ"]=>
   string(8) "Õ"
-  ["Ö"]=>
+  ["Ö"]=>
   string(6) "Ö"
-  ["×"]=>
+  ["×"]=>
   string(7) "×"
-  ["Ø"]=>
+  ["Ø"]=>
   string(8) "Ø"
-  ["Ù"]=>
+  ["Ù"]=>
   string(8) "Ù"
-  ["Ú"]=>
+  ["Ú"]=>
   string(8) "Ú"
-  ["Û"]=>
+  ["Û"]=>
   string(7) "Û"
-  ["Ü"]=>
+  ["Ü"]=>
   string(6) "Ü"
-  ["Ý"]=>
+  ["Ý"]=>
   string(8) "Ý"
-  ["Þ"]=>
+  ["Þ"]=>
   string(7) "Þ"
-  ["ß"]=>
+  ["ß"]=>
   string(7) "ß"
-  ["à"]=>
+  ["à"]=>
   string(8) "à"
-  ["á"]=>
+  ["á"]=>
   string(8) "á"
-  ["â"]=>
+  ["â"]=>
   string(7) "â"
-  ["ã"]=>
+  ["ã"]=>
   string(8) "ã"
-  ["ä"]=>
+  ["ä"]=>
   string(6) "ä"
-  ["å"]=>
+  ["Ã¥"]=>
   string(7) "å"
-  ["æ"]=>
+  ["æ"]=>
   string(7) "æ"
-  ["ç"]=>
+  ["ç"]=>
   string(8) "ç"
-  ["è"]=>
+  ["è"]=>
   string(8) "è"
-  ["é"]=>
+  ["é"]=>
   string(8) "é"
-  ["ê"]=>
+  ["ê"]=>
   string(7) "ê"
-  ["ë"]=>
+  ["ë"]=>
   string(6) "ë"
-  ["ì"]=>
+  ["ì"]=>
   string(8) "ì"
-  ["í"]=>
+  ["í"]=>
   string(8) "í"
-  ["î"]=>
+  ["î"]=>
   string(7) "î"
-  ["ï"]=>
+  ["ï"]=>
   string(6) "ï"
-  ["ð"]=>
+  ["ð"]=>
   string(5) "ð"
-  ["ñ"]=>
+  ["ñ"]=>
   string(8) "ñ"
-  ["ò"]=>
+  ["ò"]=>
   string(8) "ò"
-  ["ó"]=>
+  ["ó"]=>
   string(8) "ó"
-  ["ô"]=>
+  ["ô"]=>
   string(7) "ô"
-  ["õ"]=>
+  ["õ"]=>
   string(8) "õ"
-  ["ö"]=>
+  ["ö"]=>
   string(6) "ö"
-  ["÷"]=>
+  ["÷"]=>
   string(8) "÷"
-  ["ø"]=>
+  ["ø"]=>
   string(8) "ø"
-  ["ù"]=>
+  ["ù"]=>
   string(8) "ù"
-  ["ú"]=>
+  ["ú"]=>
   string(8) "ú"
-  ["û"]=>
+  ["û"]=>
   string(7) "û"
-  ["ü"]=>
+  ["ü"]=>
   string(6) "ü"
-  ["ý"]=>
+  ["ý"]=>
   string(8) "ý"
-  ["þ"]=>
+  ["þ"]=>
   string(7) "þ"
-  ["ÿ"]=>
+  ["ÿ"]=>
   string(6) "ÿ"
+  ["Å’"]=>
+  string(7) "Œ"
+  ["Å“"]=>
+  string(7) "œ"
+  ["Å "]=>
+  string(8) "Š"
+  ["Å¡"]=>
+  string(8) "š"
+  ["Ÿ"]=>
+  string(6) "Ÿ"
+  ["Æ’"]=>
+  string(6) "ƒ"
+  ["ˆ"]=>
+  string(6) "ˆ"
+  ["˜"]=>
+  string(7) "˜"
+  ["Α"]=>
+  string(7) "Α"
+  ["Î’"]=>
+  string(6) "Β"
+  ["Γ"]=>
+  string(7) "Γ"
+  ["Δ"]=>
+  string(7) "Δ"
+  ["Ε"]=>
+  string(9) "Ε"
+  ["Ζ"]=>
+  string(6) "Ζ"
+  ["Η"]=>
+  string(5) "Η"
+  ["Θ"]=>
+  string(7) "Θ"
+  ["Ι"]=>
+  string(6) "Ι"
+  ["Κ"]=>
+  string(7) "Κ"
+  ["Λ"]=>
+  string(8) "Λ"
+  ["Μ"]=>
+  string(4) "Μ"
+  ["Ν"]=>
+  string(4) "Ν"
+  ["Ξ"]=>
+  string(4) "Ξ"
+  ["Ο"]=>
+  string(9) "Ο"
+  ["Π"]=>
+  string(4) "Π"
+  ["Ρ"]=>
+  string(5) "Ρ"
+  ["Σ"]=>
+  string(7) "Σ"
+  ["Τ"]=>
+  string(5) "Τ"
+  ["Î¥"]=>
+  string(9) "Υ"
+  ["Φ"]=>
+  string(5) "Φ"
+  ["Χ"]=>
+  string(5) "Χ"
+  ["Ψ"]=>
+  string(5) "Ψ"
+  ["Ω"]=>
+  string(7) "Ω"
+  ["α"]=>
+  string(7) "α"
+  ["β"]=>
+  string(6) "β"
+  ["γ"]=>
+  string(7) "γ"
+  ["δ"]=>
+  string(7) "δ"
+  ["ε"]=>
+  string(9) "ε"
+  ["ζ"]=>
+  string(6) "ζ"
+  ["η"]=>
+  string(5) "η"
+  ["θ"]=>
+  string(7) "θ"
+  ["ι"]=>
+  string(6) "ι"
+  ["κ"]=>
+  string(7) "κ"
+  ["λ"]=>
+  string(8) "λ"
+  ["μ"]=>
+  string(4) "μ"
+  ["ν"]=>
+  string(4) "ν"
+  ["ξ"]=>
+  string(4) "ξ"
+  ["ο"]=>
+  string(9) "ο"
+  ["Ï€"]=>
+  string(4) "π"
+  ["ρ"]=>
+  string(5) "ρ"
+  ["Ï‚"]=>
+  string(8) "ς"
+  ["σ"]=>
+  string(7) "σ"
+  ["Ï„"]=>
+  string(5) "τ"
+  ["Ï…"]=>
+  string(9) "υ"
+  ["φ"]=>
+  string(5) "φ"
+  ["χ"]=>
+  string(5) "χ"
+  ["ψ"]=>
+  string(5) "ψ"
+  ["ω"]=>
+  string(7) "ω"
+  ["Ï‘"]=>
+  string(10) "ϑ"
+  ["Ï’"]=>
+  string(7) "ϒ"
+  ["Ï–"]=>
+  string(5) "ϖ"
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(8) " "
+  ["‌"]=>
+  string(6) "‌"
+  ["‍"]=>
+  string(5) "‍"
+  ["‎"]=>
+  string(5) "‎"
+  ["‏"]=>
+  string(5) "‏"
+  ["–"]=>
+  string(7) "–"
+  ["—"]=>
+  string(7) "—"
+  ["‘"]=>
+  string(7) "‘"
+  ["’"]=>
+  string(7) "’"
+  ["‚"]=>
+  string(7) "‚"
+  ["“"]=>
+  string(7) "“"
+  ["”"]=>
+  string(7) "”"
+  ["„"]=>
+  string(7) "„"
+  ["†"]=>
+  string(8) "†"
+  ["‡"]=>
+  string(8) "‡"
+  ["•"]=>
+  string(6) "•"
+  ["…"]=>
+  string(8) "…"
+  ["‰"]=>
+  string(8) "‰"
+  ["′"]=>
+  string(7) "′"
+  ["″"]=>
+  string(7) "″"
+  ["‹"]=>
+  string(8) "‹"
+  ["›"]=>
+  string(8) "›"
+  ["‾"]=>
+  string(7) "‾"
+  ["⁄"]=>
+  string(7) "⁄"
+  ["€"]=>
+  string(6) "€"
+  ["â„‘"]=>
+  string(7) "ℑ"
+  ["℘"]=>
+  string(8) "℘"
+  ["ℜ"]=>
+  string(6) "ℜ"
+  ["â„¢"]=>
+  string(7) "™"
+  ["ℵ"]=>
+  string(9) "ℵ"
+  ["←"]=>
+  string(6) "←"
+  ["↑"]=>
+  string(6) "↑"
+  ["→"]=>
+  string(6) "→"
+  ["↓"]=>
+  string(6) "↓"
+  ["↔"]=>
+  string(6) "↔"
+  ["↵"]=>
+  string(7) "↵"
+  ["⇐"]=>
+  string(6) "⇐"
+  ["⇑"]=>
+  string(6) "⇑"
+  ["⇒"]=>
+  string(6) "⇒"
+  ["⇓"]=>
+  string(6) "⇓"
+  ["⇔"]=>
+  string(6) "⇔"
+  ["∀"]=>
+  string(8) "∀"
+  ["∂"]=>
+  string(6) "∂"
+  ["∃"]=>
+  string(7) "∃"
+  ["∅"]=>
+  string(7) "∅"
+  ["∇"]=>
+  string(7) "∇"
+  ["∈"]=>
+  string(6) "∈"
+  ["∉"]=>
+  string(7) "∉"
+  ["∋"]=>
+  string(4) "∋"
+  ["∏"]=>
+  string(6) "∏"
+  ["∑"]=>
+  string(5) "∑"
+  ["−"]=>
+  string(7) "−"
+  ["∗"]=>
+  string(8) "∗"
+  ["√"]=>
+  string(7) "√"
+  ["∝"]=>
+  string(6) "∝"
+  ["∞"]=>
+  string(7) "∞"
+  ["∠"]=>
+  string(5) "∠"
+  ["∧"]=>
+  string(5) "∧"
+  ["∨"]=>
+  string(4) "∨"
+  ["∩"]=>
+  string(5) "∩"
+  ["∪"]=>
+  string(5) "∪"
+  ["∫"]=>
+  string(5) "∫"
+  ["∴"]=>
+  string(8) "&there4;"
+  ["∼"]=>
+  string(5) "∼"
+  ["≅"]=>
+  string(6) "≅"
+  ["≈"]=>
+  string(7) "≈"
+  ["≠"]=>
+  string(4) "≠"
+  ["≡"]=>
+  string(7) "≡"
+  ["≤"]=>
+  string(4) "≤"
+  ["≥"]=>
+  string(4) "≥"
+  ["⊂"]=>
+  string(5) "⊂"
+  ["⊃"]=>
+  string(5) "⊃"
+  ["⊄"]=>
+  string(6) "⊄"
+  ["⊆"]=>
+  string(6) "⊆"
+  ["⊇"]=>
+  string(6) "⊇"
+  ["⊕"]=>
+  string(7) "⊕"
+  ["⊗"]=>
+  string(8) "⊗"
+  ["⊥"]=>
+  string(6) "⊥"
+  ["â‹…"]=>
+  string(6) "⋅"
+  ["⌈"]=>
+  string(7) "⌈"
+  ["⌉"]=>
+  string(7) "⌉"
+  ["⌊"]=>
+  string(8) "⌊"
+  ["⌋"]=>
+  string(8) "⌋"
+  ["〈"]=>
+  string(6) "⟨"
+  ["〉"]=>
+  string(6) "⟩"
+  ["â—Š"]=>
+  string(5) "◊"
+  ["â™ "]=>
+  string(8) "♠"
+  ["♣"]=>
+  string(7) "♣"
+  ["♥"]=>
+  string(8) "♥"
+  ["♦"]=>
+  string(7) "♦"
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["'"]=>
-  string(5) "'"
+  string(6) "'"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --
-array(99) {
-  [" "]=>
+array(251) {
+  [" "]=>
   string(6) " "
-  ["¡"]=>
+  ["¡"]=>
   string(7) "¡"
-  ["¢"]=>
+  ["¢"]=>
   string(6) "¢"
-  ["£"]=>
+  ["£"]=>
   string(7) "£"
-  ["¤"]=>
+  ["¤"]=>
   string(8) "¤"
-  ["¥"]=>
+  ["Â¥"]=>
   string(5) "¥"
-  ["¦"]=>
+  ["¦"]=>
   string(8) "¦"
-  ["§"]=>
+  ["§"]=>
   string(6) "§"
-  ["¨"]=>
+  ["¨"]=>
   string(5) "¨"
-  ["©"]=>
+  ["©"]=>
   string(6) "©"
-  ["ª"]=>
+  ["ª"]=>
   string(6) "ª"
-  ["«"]=>
+  ["«"]=>
   string(7) "«"
-  ["¬"]=>
+  ["¬"]=>
   string(5) "¬"
-  ["­"]=>
+  ["­"]=>
   string(5) "­"
-  ["®"]=>
+  ["®"]=>
   string(5) "®"
-  ["¯"]=>
+  ["¯"]=>
   string(6) "¯"
-  ["°"]=>
+  ["°"]=>
   string(5) "°"
-  ["±"]=>
+  ["±"]=>
   string(8) "±"
-  ["²"]=>
+  ["²"]=>
   string(6) "&sup2;"
-  ["³"]=>
+  ["³"]=>
   string(6) "&sup3;"
-  ["´"]=>
+  ["´"]=>
   string(7) "´"
-  ["µ"]=>
+  ["µ"]=>
   string(7) "µ"
-  ["¶"]=>
+  ["¶"]=>
   string(6) "¶"
-  ["·"]=>
+  ["·"]=>
   string(8) "·"
-  ["¸"]=>
+  ["¸"]=>
   string(7) "¸"
-  ["¹"]=>
+  ["¹"]=>
   string(6) "&sup1;"
-  ["º"]=>
+  ["º"]=>
   string(6) "º"
-  ["»"]=>
+  ["»"]=>
   string(7) "»"
-  ["¼"]=>
+  ["¼"]=>
   string(8) "&frac14;"
-  ["½"]=>
+  ["½"]=>
   string(8) "&frac12;"
-  ["¾"]=>
+  ["¾"]=>
   string(8) "&frac34;"
-  ["¿"]=>
+  ["¿"]=>
   string(8) "¿"
-  ["À"]=>
+  ["À"]=>
   string(8) "À"
-  ["Á"]=>
+  ["Á"]=>
   string(8) "Á"
-  ["Â"]=>
+  ["Â"]=>
   string(7) "Â"
-  ["Ã"]=>
+  ["Ã"]=>
   string(8) "Ã"
-  ["Ä"]=>
+  ["Ä"]=>
   string(6) "Ä"
-  ["Å"]=>
+  ["Ã…"]=>
   string(7) "Å"
-  ["Æ"]=>
+  ["Æ"]=>
   string(7) "Æ"
-  ["Ç"]=>
+  ["Ç"]=>
   string(8) "Ç"
-  ["È"]=>
+  ["È"]=>
   string(8) "È"
-  ["É"]=>
+  ["É"]=>
   string(8) "É"
-  ["Ê"]=>
+  ["Ê"]=>
   string(7) "Ê"
-  ["Ë"]=>
+  ["Ë"]=>
   string(6) "Ë"
-  ["Ì"]=>
+  ["Ì"]=>
   string(8) "Ì"
-  ["Í"]=>
+  ["Í"]=>
   string(8) "Í"
-  ["Î"]=>
+  ["ÃŽ"]=>
   string(7) "Î"
-  ["Ï"]=>
+  ["Ï"]=>
   string(6) "Ï"
-  ["Ð"]=>
+  ["Ð"]=>
   string(5) "Ð"
-  ["Ñ"]=>
+  ["Ñ"]=>
   string(8) "Ñ"
-  ["Ò"]=>
+  ["Ã’"]=>
   string(8) "Ò"
-  ["Ó"]=>
+  ["Ó"]=>
   string(8) "Ó"
-  ["Ô"]=>
+  ["Ô"]=>
   string(7) "Ô"
-  ["Õ"]=>
+  ["Õ"]=>
   string(8) "Õ"
-  ["Ö"]=>
+  ["Ö"]=>
   string(6) "Ö"
-  ["×"]=>
+  ["×"]=>
   string(7) "×"
-  ["Ø"]=>
+  ["Ø"]=>
   string(8) "Ø"
-  ["Ù"]=>
+  ["Ù"]=>
   string(8) "Ù"
-  ["Ú"]=>
+  ["Ú"]=>
   string(8) "Ú"
-  ["Û"]=>
+  ["Û"]=>
   string(7) "Û"
-  ["Ü"]=>
+  ["Ü"]=>
   string(6) "Ü"
-  ["Ý"]=>
+  ["Ý"]=>
   string(8) "Ý"
-  ["Þ"]=>
+  ["Þ"]=>
   string(7) "Þ"
-  ["ß"]=>
+  ["ß"]=>
   string(7) "ß"
-  ["à"]=>
+  ["à"]=>
   string(8) "à"
-  ["á"]=>
+  ["á"]=>
   string(8) "á"
-  ["â"]=>
+  ["â"]=>
   string(7) "â"
-  ["ã"]=>
+  ["ã"]=>
   string(8) "ã"
-  ["ä"]=>
+  ["ä"]=>
   string(6) "ä"
-  ["å"]=>
+  ["Ã¥"]=>
   string(7) "å"
-  ["æ"]=>
+  ["æ"]=>
   string(7) "æ"
-  ["ç"]=>
+  ["ç"]=>
   string(8) "ç"
-  ["è"]=>
+  ["è"]=>
   string(8) "è"
-  ["é"]=>
+  ["é"]=>
   string(8) "é"
-  ["ê"]=>
+  ["ê"]=>
   string(7) "ê"
-  ["ë"]=>
+  ["ë"]=>
   string(6) "ë"
-  ["ì"]=>
+  ["ì"]=>
   string(8) "ì"
-  ["í"]=>
+  ["í"]=>
   string(8) "í"
-  ["î"]=>
+  ["î"]=>
   string(7) "î"
-  ["ï"]=>
+  ["ï"]=>
   string(6) "ï"
-  ["ð"]=>
+  ["ð"]=>
   string(5) "ð"
-  ["ñ"]=>
+  ["ñ"]=>
   string(8) "ñ"
-  ["ò"]=>
+  ["ò"]=>
   string(8) "ò"
-  ["ó"]=>
+  ["ó"]=>
   string(8) "ó"
-  ["ô"]=>
+  ["ô"]=>
   string(7) "ô"
-  ["õ"]=>
+  ["õ"]=>
   string(8) "õ"
-  ["ö"]=>
+  ["ö"]=>
   string(6) "ö"
-  ["÷"]=>
+  ["÷"]=>
   string(8) "÷"
-  ["ø"]=>
+  ["ø"]=>
   string(8) "ø"
-  ["ù"]=>
+  ["ù"]=>
   string(8) "ù"
-  ["ú"]=>
+  ["ú"]=>
   string(8) "ú"
-  ["û"]=>
+  ["û"]=>
   string(7) "û"
-  ["ü"]=>
+  ["ü"]=>
   string(6) "ü"
-  ["ý"]=>
+  ["ý"]=>
   string(8) "ý"
-  ["þ"]=>
+  ["þ"]=>
   string(7) "þ"
-  ["ÿ"]=>
+  ["ÿ"]=>
   string(6) "ÿ"
+  ["Å’"]=>
+  string(7) "Œ"
+  ["Å“"]=>
+  string(7) "œ"
+  ["Å "]=>
+  string(8) "Š"
+  ["Å¡"]=>
+  string(8) "š"
+  ["Ÿ"]=>
+  string(6) "Ÿ"
+  ["Æ’"]=>
+  string(6) "ƒ"
+  ["ˆ"]=>
+  string(6) "ˆ"
+  ["˜"]=>
+  string(7) "˜"
+  ["Α"]=>
+  string(7) "Α"
+  ["Î’"]=>
+  string(6) "Β"
+  ["Γ"]=>
+  string(7) "Γ"
+  ["Δ"]=>
+  string(7) "Δ"
+  ["Ε"]=>
+  string(9) "Ε"
+  ["Ζ"]=>
+  string(6) "Ζ"
+  ["Η"]=>
+  string(5) "Η"
+  ["Θ"]=>
+  string(7) "Θ"
+  ["Ι"]=>
+  string(6) "Ι"
+  ["Κ"]=>
+  string(7) "Κ"
+  ["Λ"]=>
+  string(8) "Λ"
+  ["Μ"]=>
+  string(4) "Μ"
+  ["Ν"]=>
+  string(4) "Ν"
+  ["Ξ"]=>
+  string(4) "Ξ"
+  ["Ο"]=>
+  string(9) "Ο"
+  ["Π"]=>
+  string(4) "Π"
+  ["Ρ"]=>
+  string(5) "Ρ"
+  ["Σ"]=>
+  string(7) "Σ"
+  ["Τ"]=>
+  string(5) "Τ"
+  ["Î¥"]=>
+  string(9) "Υ"
+  ["Φ"]=>
+  string(5) "Φ"
+  ["Χ"]=>
+  string(5) "Χ"
+  ["Ψ"]=>
+  string(5) "Ψ"
+  ["Ω"]=>
+  string(7) "Ω"
+  ["α"]=>
+  string(7) "α"
+  ["β"]=>
+  string(6) "β"
+  ["γ"]=>
+  string(7) "γ"
+  ["δ"]=>
+  string(7) "δ"
+  ["ε"]=>
+  string(9) "ε"
+  ["ζ"]=>
+  string(6) "ζ"
+  ["η"]=>
+  string(5) "η"
+  ["θ"]=>
+  string(7) "θ"
+  ["ι"]=>
+  string(6) "ι"
+  ["κ"]=>
+  string(7) "κ"
+  ["λ"]=>
+  string(8) "λ"
+  ["μ"]=>
+  string(4) "μ"
+  ["ν"]=>
+  string(4) "ν"
+  ["ξ"]=>
+  string(4) "ξ"
+  ["ο"]=>
+  string(9) "ο"
+  ["Ï€"]=>
+  string(4) "π"
+  ["ρ"]=>
+  string(5) "ρ"
+  ["Ï‚"]=>
+  string(8) "ς"
+  ["σ"]=>
+  string(7) "σ"
+  ["Ï„"]=>
+  string(5) "τ"
+  ["Ï…"]=>
+  string(9) "υ"
+  ["φ"]=>
+  string(5) "φ"
+  ["χ"]=>
+  string(5) "χ"
+  ["ψ"]=>
+  string(5) "ψ"
+  ["ω"]=>
+  string(7) "ω"
+  ["Ï‘"]=>
+  string(10) "ϑ"
+  ["Ï’"]=>
+  string(7) "ϒ"
+  ["Ï–"]=>
+  string(5) "ϖ"
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(6) " "
+  [" "]=>
+  string(8) " "
+  ["‌"]=>
+  string(6) "‌"
+  ["‍"]=>
+  string(5) "‍"
+  ["‎"]=>
+  string(5) "‎"
+  ["‏"]=>
+  string(5) "‏"
+  ["–"]=>
+  string(7) "–"
+  ["—"]=>
+  string(7) "—"
+  ["‘"]=>
+  string(7) "‘"
+  ["’"]=>
+  string(7) "’"
+  ["‚"]=>
+  string(7) "‚"
+  ["“"]=>
+  string(7) "“"
+  ["”"]=>
+  string(7) "”"
+  ["„"]=>
+  string(7) "„"
+  ["†"]=>
+  string(8) "†"
+  ["‡"]=>
+  string(8) "‡"
+  ["•"]=>
+  string(6) "•"
+  ["…"]=>
+  string(8) "…"
+  ["‰"]=>
+  string(8) "‰"
+  ["′"]=>
+  string(7) "′"
+  ["″"]=>
+  string(7) "″"
+  ["‹"]=>
+  string(8) "‹"
+  ["›"]=>
+  string(8) "›"
+  ["‾"]=>
+  string(7) "‾"
+  ["⁄"]=>
+  string(7) "⁄"
+  ["€"]=>
+  string(6) "€"
+  ["â„‘"]=>
+  string(7) "ℑ"
+  ["℘"]=>
+  string(8) "℘"
+  ["ℜ"]=>
+  string(6) "ℜ"
+  ["â„¢"]=>
+  string(7) "™"
+  ["ℵ"]=>
+  string(9) "ℵ"
+  ["←"]=>
+  string(6) "←"
+  ["↑"]=>
+  string(6) "↑"
+  ["→"]=>
+  string(6) "→"
+  ["↓"]=>
+  string(6) "↓"
+  ["↔"]=>
+  string(6) "↔"
+  ["↵"]=>
+  string(7) "↵"
+  ["⇐"]=>
+  string(6) "⇐"
+  ["⇑"]=>
+  string(6) "⇑"
+  ["⇒"]=>
+  string(6) "⇒"
+  ["⇓"]=>
+  string(6) "⇓"
+  ["⇔"]=>
+  string(6) "⇔"
+  ["∀"]=>
+  string(8) "∀"
+  ["∂"]=>
+  string(6) "∂"
+  ["∃"]=>
+  string(7) "∃"
+  ["∅"]=>
+  string(7) "∅"
+  ["∇"]=>
+  string(7) "∇"
+  ["∈"]=>
+  string(6) "∈"
+  ["∉"]=>
+  string(7) "∉"
+  ["∋"]=>
+  string(4) "∋"
+  ["∏"]=>
+  string(6) "∏"
+  ["∑"]=>
+  string(5) "∑"
+  ["−"]=>
+  string(7) "−"
+  ["∗"]=>
+  string(8) "∗"
+  ["√"]=>
+  string(7) "√"
+  ["∝"]=>
+  string(6) "∝"
+  ["∞"]=>
+  string(7) "∞"
+  ["∠"]=>
+  string(5) "∠"
+  ["∧"]=>
+  string(5) "∧"
+  ["∨"]=>
+  string(4) "∨"
+  ["∩"]=>
+  string(5) "∩"
+  ["∪"]=>
+  string(5) "∪"
+  ["∫"]=>
+  string(5) "∫"
+  ["∴"]=>
+  string(8) "&there4;"
+  ["∼"]=>
+  string(5) "∼"
+  ["≅"]=>
+  string(6) "≅"
+  ["≈"]=>
+  string(7) "≈"
+  ["≠"]=>
+  string(4) "≠"
+  ["≡"]=>
+  string(7) "≡"
+  ["≤"]=>
+  string(4) "≤"
+  ["≥"]=>
+  string(4) "≥"
+  ["⊂"]=>
+  string(5) "⊂"
+  ["⊃"]=>
+  string(5) "⊃"
+  ["⊄"]=>
+  string(6) "⊄"
+  ["⊆"]=>
+  string(6) "⊆"
+  ["⊇"]=>
+  string(6) "⊇"
+  ["⊕"]=>
+  string(7) "⊕"
+  ["⊗"]=>
+  string(8) "⊗"
+  ["⊥"]=>
+  string(6) "⊥"
+  ["â‹…"]=>
+  string(6) "⋅"
+  ["⌈"]=>
+  string(7) "⌈"
+  ["⌉"]=>
+  string(7) "⌉"
+  ["⌊"]=>
+  string(8) "⌊"
+  ["⌋"]=>
+  string(8) "⌋"
+  ["〈"]=>
+  string(6) "⟨"
+  ["〉"]=>
+  string(6) "⟩"
+  ["â—Š"]=>
+  string(5) "◊"
+  ["â™ "]=>
+  string(8) "♠"
+  ["♣"]=>
+  string(7) "♣"
+  ["♥"]=>
+  string(8) "♥"
+  ["♦"]=>
+  string(7) "♦"
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic3-win32.phpt b/ext/standard/tests/strings/get_html_translation_table_basic3-win32.phpt
deleted file mode 100644
index f3fb8b4..0000000
--- a/ext/standard/tests/strings/get_html_translation_table_basic3-win32.phpt
+++ /dev/null
@@ -1,79 +0,0 @@
---TEST--
-Test get_html_translation_table() function : basic functionality - table as HTML_SPECIALCHARS
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) != "WIN"){  
-  die('skip only for Windows');
-}
-
-if( !setlocale(LC_ALL, "English_United States.1252") ) {
-  die('skip failed to set locale settings to "English_United States.1252"');
-}
-
-?>
---FILE--
-<?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
- * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
- * Source code: ext/standard/html.c
-*/
-
-/* test get_html_translation_table() when $table argument is specified as HTML_SPECIALCHARS */
-
-//set locale 
-setlocale(LC_ALL, "English_United States.1252");
-
-echo "*** Testing get_html_translation_table() : basic functionality ***\n";
-
-// $table as HTML_SEPCIALCHARS and different quote style
-echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --\n";
-$table = HTML_SPECIALCHARS;
-$quote_style = ENT_COMPAT;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --\n";
-$quote_style = ENT_QUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --\n";
-$quote_style = ENT_NOQUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
-
-echo "Done\n";
-?>
---EXPECTF--
-*** Testing get_html_translation_table() : basic functionality ***
--- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --
-array(5) {
-  ["""]=>
-  string(6) """
-  ["'"]=>
-  string(5) "'"
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic3.phpt b/ext/standard/tests/strings/get_html_translation_table_basic3.phpt
index 58394eb..e7c66b5 100644
--- a/ext/standard/tests/strings/get_html_translation_table_basic3.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_basic3.phpt
@@ -1,42 +1,29 @@
 --TEST--
 Test get_html_translation_table() function : basic functionality - table as HTML_SPECIALCHARS
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) == "WIN"){  
-  die('skip Not for Windows');
-}
-
-if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
-  die('skip failed to set locale settings to "en-US.UTF-8"');
-}
-?>
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
 
 /* test get_html_translation_table() when $table argument is specified as HTML_SPECIALCHARS */
 
-//set locale to en_US.UTF-8
-setlocale(LC_ALL, "en_US.UTF-8");
-
 echo "*** Testing get_html_translation_table() : basic functionality ***\n";
 
 // $table as HTML_SEPCIALCHARS and different quote style
 echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --\n";
 $table = HTML_SPECIALCHARS;
 $quote_style = ENT_COMPAT;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
-echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --\n";
+echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --\n";
 $quote_style = ENT_QUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
-echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --\n";
+echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --\n";
 $quote_style = ENT_NOQUOTES;
-var_dump( get_html_translation_table($table, $quote_style) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
 
 echo "Done\n";
 ?>
@@ -44,35 +31,35 @@ echo "Done\n";
 *** Testing get_html_translation_table() : basic functionality ***
 -- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
--- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --
+-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --
 array(5) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["'"]=>
-  string(5) "'"
+  string(6) "'"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
--- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --
+-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_basic4.phpt b/ext/standard/tests/strings/get_html_translation_table_basic4.phpt
new file mode 100644
index 0000000..938fff4
--- /dev/null
+++ b/ext/standard/tests/strings/get_html_translation_table_basic4.phpt
@@ -0,0 +1,289 @@
+--TEST--
+Test get_html_translation_table() function : basic functionality - charset WINDOWS-1252
+--FILE--
+<?php
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
+ * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
+ * Source code: ext/standard/html.c
+*/
+
+
+echo "*** Testing get_html_translation_table() : basic functionality/Windows-1252 ***\n";
+
+echo "-- with table = HTML_ENTITIES --\n";
+$table = HTML_ENTITIES;
+var_dump( get_html_translation_table($table, ENT_COMPAT, "WINDOWS-1252") );
+
+echo "-- with table = HTML_SPECIALCHARS --\n";
+$table = HTML_SPECIALCHARS; 
+var_dump( get_html_translation_table($table, ENT_COMPAT, "WINDOWS-1252") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing get_html_translation_table() : basic functionality/Windows-1252 ***
+-- with table = HTML_ENTITIES --
+array(125) {
+  ["€"]=>
+  string(6) "€"
+  ["‚"]=>
+  string(7) "‚"
+  ["ƒ"]=>
+  string(6) "ƒ"
+  ["„"]=>
+  string(7) "„"
+  ["…"]=>
+  string(8) "…"
+  ["†"]=>
+  string(8) "†"
+  ["‡"]=>
+  string(8) "‡"
+  ["ˆ"]=>
+  string(6) "ˆ"
+  ["‰"]=>
+  string(8) "‰"
+  ["Š"]=>
+  string(8) "Š"
+  ["‹"]=>
+  string(8) "‹"
+  ["Œ"]=>
+  string(7) "Œ"
+  ["‘"]=>
+  string(7) "‘"
+  ["’"]=>
+  string(7) "’"
+  ["“"]=>
+  string(7) "“"
+  ["”"]=>
+  string(7) "”"
+  ["•"]=>
+  string(6) "•"
+  ["–"]=>
+  string(7) "–"
+  ["—"]=>
+  string(7) "—"
+  ["˜"]=>
+  string(7) "˜"
+  ["™"]=>
+  string(7) "™"
+  ["š"]=>
+  string(8) "š"
+  ["›"]=>
+  string(8) "›"
+  ["œ"]=>
+  string(7) "œ"
+  ["Ÿ"]=>
+  string(6) "Ÿ"
+  [" "]=>
+  string(6) " "
+  ["¡"]=>
+  string(7) "¡"
+  ["¢"]=>
+  string(6) "¢"
+  ["£"]=>
+  string(7) "£"
+  ["¤"]=>
+  string(8) "¤"
+  ["¥"]=>
+  string(5) "¥"
+  ["¦"]=>
+  string(8) "¦"
+  ["§"]=>
+  string(6) "§"
+  ["¨"]=>
+  string(5) "¨"
+  ["©"]=>
+  string(6) "©"
+  ["ª"]=>
+  string(6) "ª"
+  ["«"]=>
+  string(7) "«"
+  ["¬"]=>
+  string(5) "¬"
+  ["­"]=>
+  string(5) "­"
+  ["®"]=>
+  string(5) "®"
+  ["¯"]=>
+  string(6) "¯"
+  ["°"]=>
+  string(5) "°"
+  ["±"]=>
+  string(8) "±"
+  ["²"]=>
+  string(6) "&sup2;"
+  ["³"]=>
+  string(6) "&sup3;"
+  ["´"]=>
+  string(7) "´"
+  ["µ"]=>
+  string(7) "µ"
+  ["¶"]=>
+  string(6) "¶"
+  ["·"]=>
+  string(8) "·"
+  ["¸"]=>
+  string(7) "¸"
+  ["¹"]=>
+  string(6) "&sup1;"
+  ["º"]=>
+  string(6) "º"
+  ["»"]=>
+  string(7) "»"
+  ["¼"]=>
+  string(8) "&frac14;"
+  ["½"]=>
+  string(8) "&frac12;"
+  ["¾"]=>
+  string(8) "&frac34;"
+  ["¿"]=>
+  string(8) "¿"
+  ["À"]=>
+  string(8) "À"
+  ["Á"]=>
+  string(8) "Á"
+  ["Â"]=>
+  string(7) "Â"
+  ["Ã"]=>
+  string(8) "Ã"
+  ["Ä"]=>
+  string(6) "Ä"
+  ["Å"]=>
+  string(7) "Å"
+  ["Æ"]=>
+  string(7) "Æ"
+  ["Ç"]=>
+  string(8) "Ç"
+  ["È"]=>
+  string(8) "È"
+  ["É"]=>
+  string(8) "É"
+  ["Ê"]=>
+  string(7) "Ê"
+  ["Ë"]=>
+  string(6) "Ë"
+  ["Ì"]=>
+  string(8) "Ì"
+  ["Í"]=>
+  string(8) "Í"
+  ["Î"]=>
+  string(7) "Î"
+  ["Ï"]=>
+  string(6) "Ï"
+  ["Ð"]=>
+  string(5) "Ð"
+  ["Ñ"]=>
+  string(8) "Ñ"
+  ["Ò"]=>
+  string(8) "Ò"
+  ["Ó"]=>
+  string(8) "Ó"
+  ["Ô"]=>
+  string(7) "Ô"
+  ["Õ"]=>
+  string(8) "Õ"
+  ["Ö"]=>
+  string(6) "Ö"
+  ["×"]=>
+  string(7) "×"
+  ["Ø"]=>
+  string(8) "Ø"
+  ["Ù"]=>
+  string(8) "Ù"
+  ["Ú"]=>
+  string(8) "Ú"
+  ["Û"]=>
+  string(7) "Û"
+  ["Ü"]=>
+  string(6) "Ü"
+  ["Ý"]=>
+  string(8) "Ý"
+  ["Þ"]=>
+  string(7) "Þ"
+  ["ß"]=>
+  string(7) "ß"
+  ["à"]=>
+  string(8) "à"
+  ["á"]=>
+  string(8) "á"
+  ["â"]=>
+  string(7) "â"
+  ["ã"]=>
+  string(8) "ã"
+  ["ä"]=>
+  string(6) "ä"
+  ["å"]=>
+  string(7) "å"
+  ["æ"]=>
+  string(7) "æ"
+  ["ç"]=>
+  string(8) "ç"
+  ["è"]=>
+  string(8) "è"
+  ["é"]=>
+  string(8) "é"
+  ["ê"]=>
+  string(7) "ê"
+  ["ë"]=>
+  string(6) "ë"
+  ["ì"]=>
+  string(8) "ì"
+  ["í"]=>
+  string(8) "í"
+  ["î"]=>
+  string(7) "î"
+  ["ï"]=>
+  string(6) "ï"
+  ["ð"]=>
+  string(5) "ð"
+  ["ñ"]=>
+  string(8) "ñ"
+  ["ò"]=>
+  string(8) "ò"
+  ["ó"]=>
+  string(8) "ó"
+  ["ô"]=>
+  string(7) "ô"
+  ["õ"]=>
+  string(8) "õ"
+  ["ö"]=>
+  string(6) "ö"
+  ["÷"]=>
+  string(8) "÷"
+  ["ø"]=>
+  string(8) "ø"
+  ["ù"]=>
+  string(8) "ù"
+  ["ú"]=>
+  string(8) "ú"
+  ["û"]=>
+  string(7) "û"
+  ["ü"]=>
+  string(6) "ü"
+  ["ý"]=>
+  string(8) "ý"
+  ["þ"]=>
+  string(7) "þ"
+  ["ÿ"]=>
+  string(6) "ÿ"
+  ["&"]=>
+  string(5) "&"
+  ["""]=>
+  string(6) """
+  ["<"]=>
+  string(4) "<"
+  [">"]=>
+  string(4) ">"
+}
+-- with table = HTML_SPECIALCHARS --
+array(4) {
+  ["&"]=>
+  string(5) "&"
+  ["""]=>
+  string(6) """
+  ["<"]=>
+  string(4) "<"
+  [">"]=>
+  string(4) ">"
+}
+Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_error.phpt b/ext/standard/tests/strings/get_html_translation_table_error.phpt
index 5f18714..149adbc 100644
--- a/ext/standard/tests/strings/get_html_translation_table_error.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_error.phpt
@@ -2,7 +2,7 @@
 Test get_html_translation_table() function : error conditions 
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
@@ -15,7 +15,7 @@ $table = HTML_ENTITIES;
 $quote_style = ENT_COMPAT;
 $extra_arg = 10;
 
-var_dump( get_html_translation_table($table, $quote_style, $extra_arg) );
+var_dump( get_html_translation_table($table, $quote_style, "UTF-8", $extra_arg) );
 
 echo "Done\n";
 ?>
@@ -24,6 +24,6 @@ echo "Done\n";
 
 -- Testing get_html_translation_table() function with more than expected no. of arguments --
 
-Warning: get_html_translation_table() expects at most 2 parameters, 3 given in %s on line %d
+Warning: get_html_translation_table() expects at most 3 parameters, 4 given in %s on line %d
 NULL
 Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_variation1-win32.phpt b/ext/standard/tests/strings/get_html_translation_table_variation1-win32.phpt
deleted file mode 100644
index 2217efb..0000000
--- a/ext/standard/tests/strings/get_html_translation_table_variation1-win32.phpt
+++ /dev/null
@@ -1,1117 +0,0 @@
---TEST--
-Test get_html_translation_table() function : usage variations - unexpected table values
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) != "WIN"){  
-  die('skip only for Windows');
-}
-
-if( !setlocale(LC_ALL, "English_United States.1252") ) {
-  die('skip failed to set locale settings to "English_United States.1252"');
-}
-
-?>
---FILE--
-<?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
- * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
- * Source code: ext/standard/html.c
-*/
-
-/*
- * test get_html_translation_table() with unexpected value for argument $table 
-*/
-
-//set locale
-setlocale(LC_ALL, "English_United States.1252"); 
-
-echo "*** Testing get_html_translation_table() : usage variations ***\n";
-// initialize all required variables
-$quote_style = ENT_COMPAT;
-
-// get an unset variable
-$unset_var = 10;
-unset($unset_var);
-
-// a resource variable 
-$fp = fopen(__FILE__, "r");
-
-// array with different values
-$values =  array (
-
-  // array values
-  array(),
-  array(0),
-  array(1),
-  array(1, 2),
-  array('color' => 'red', 'item' => 'pen'),
-
-  // boolean values
-  true,
-  false,
-  TRUE,
-  FALSE,
-
-  // string values
-  "string",
-  'string',
-
-  // objects
-  new stdclass(),
-
-  // empty string
-  "",
-  '',
-
-  // null vlaues
-  NULL,
-  null,
-
-  // resource var
-  $fp,
-
-  // undefined variable
-  @$undefined_var,
-
-  // unset variable
-  @$unset_var
-);
-
-
-// loop through each element of the array and check the working of get_html_translation_table()
-// when $table arugment is supplied with different values
-echo "\n--- Testing get_html_translation_table() by supplying different values for 'table' argument ---\n";
-$counter = 1;
-for($index = 0; $index < count($values); $index ++) {
-  echo "-- Iteration $counter --\n";
-  $table = $values [$index];
-
-  var_dump( get_html_translation_table($table) );
-  var_dump( get_html_translation_table($table, $quote_style) );
-
-  $counter ++;
-}
-
-// close resource
-fclose($fp);
-
-echo "Done\n";
-?>
---EXPECTF--
-*** Testing get_html_translation_table() : usage variations ***
-
---- Testing get_html_translation_table() by supplying different values for 'table' argument ---
--- Iteration 1 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
--- Iteration 2 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
--- Iteration 3 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
--- Iteration 4 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
--- Iteration 5 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
-NULL
--- Iteration 6 --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 7 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 8 --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 9 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 10 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
--- Iteration 11 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
--- Iteration 12 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %s
-NULL
--- Iteration 13 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
--- Iteration 14 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
-NULL
--- Iteration 15 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 16 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 17 --
-
-Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %s
-NULL
-
-Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %s
-NULL
--- Iteration 18 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 19 --
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_variation1.phpt b/ext/standard/tests/strings/get_html_translation_table_variation1.phpt
index 7bf919e..edae95a 100644
--- a/ext/standard/tests/strings/get_html_translation_table_variation1.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_variation1.phpt
@@ -1,18 +1,8 @@
 --TEST--
 Test get_html_translation_table() function : usage variations - unexpected table values
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) == "WIN"){  
-  die('skip Not for Windows');
-}
-
-if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
-  die('skip failed to set locale settings to "en-US.UTF-8"');
-}
-?>
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
@@ -21,9 +11,6 @@ if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
  * test get_html_translation_table() with unexpected value for argument $table 
 */
 
-//set locale to en_US.UTF-8
-setlocale(LC_ALL, "en_US.UTF-8");
-
 echo "*** Testing get_html_translation_table() : usage variations ***\n";
 // initialize all required variables
 $quote_style = ENT_COMPAT;
@@ -85,8 +72,17 @@ for($index = 0; $index < count($values); $index ++) {
   echo "-- Iteration $counter --\n";
   $table = $values [$index];
 
-  var_dump( get_html_translation_table($table) );
-  var_dump( get_html_translation_table($table, $quote_style) );
+  $v = get_html_translation_table($table, ENT_COMPAT, "UTF-8");
+  if (is_array($v) && count($v) > 100)
+    var_dump(count($v));
+   else
+    var_dump($v);
+   
+  $v = get_html_translation_table($table, $quote_style, "UTF-8");
+  if (is_array($v) && count($v) > 100)
+    var_dump(count($v));
+   else
+    var_dump($v);
 
   $counter ++;
 }
@@ -102,1015 +98,211 @@ echo "Done\n";
 --- Testing get_html_translation_table() by supplying different values for 'table' argument ---
 -- Iteration 1 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 -- Iteration 2 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 -- Iteration 3 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 -- Iteration 4 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 -- Iteration 5 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, array given in %s on line %d
 NULL
 -- Iteration 6 --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
+int(252)
+int(252)
+-- Iteration 7 --
+array(4) {
   ["&"]=>
   string(5) "&"
-}
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
--- Iteration 7 --
 array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
   ["&"]=>
   string(5) "&"
-}
-array(4) {
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 8 --
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
+int(252)
+int(252)
+-- Iteration 9 --
+array(4) {
   ["&"]=>
   string(5) "&"
-}
-array(100) {
-  [" "]=>
-  string(6) " "
-  ["¡"]=>
-  string(7) "¡"
-  ["¢"]=>
-  string(6) "¢"
-  ["£"]=>
-  string(7) "£"
-  ["¤"]=>
-  string(8) "¤"
-  ["¥"]=>
-  string(5) "¥"
-  ["¦"]=>
-  string(8) "¦"
-  ["§"]=>
-  string(6) "§"
-  ["¨"]=>
-  string(5) "¨"
-  ["©"]=>
-  string(6) "©"
-  ["ª"]=>
-  string(6) "ª"
-  ["«"]=>
-  string(7) "«"
-  ["¬"]=>
-  string(5) "¬"
-  ["­"]=>
-  string(5) "­"
-  ["®"]=>
-  string(5) "®"
-  ["¯"]=>
-  string(6) "¯"
-  ["°"]=>
-  string(5) "°"
-  ["±"]=>
-  string(8) "±"
-  ["²"]=>
-  string(6) "&sup2;"
-  ["³"]=>
-  string(6) "&sup3;"
-  ["´"]=>
-  string(7) "´"
-  ["µ"]=>
-  string(7) "µ"
-  ["¶"]=>
-  string(6) "¶"
-  ["·"]=>
-  string(8) "·"
-  ["¸"]=>
-  string(7) "¸"
-  ["¹"]=>
-  string(6) "&sup1;"
-  ["º"]=>
-  string(6) "º"
-  ["»"]=>
-  string(7) "»"
-  ["¼"]=>
-  string(8) "&frac14;"
-  ["½"]=>
-  string(8) "&frac12;"
-  ["¾"]=>
-  string(8) "&frac34;"
-  ["¿"]=>
-  string(8) "¿"
-  ["À"]=>
-  string(8) "À"
-  ["Á"]=>
-  string(8) "Á"
-  ["Â"]=>
-  string(7) "Â"
-  ["Ã"]=>
-  string(8) "Ã"
-  ["Ä"]=>
-  string(6) "Ä"
-  ["Å"]=>
-  string(7) "Å"
-  ["Æ"]=>
-  string(7) "Æ"
-  ["Ç"]=>
-  string(8) "Ç"
-  ["È"]=>
-  string(8) "È"
-  ["É"]=>
-  string(8) "É"
-  ["Ê"]=>
-  string(7) "Ê"
-  ["Ë"]=>
-  string(6) "Ë"
-  ["Ì"]=>
-  string(8) "Ì"
-  ["Í"]=>
-  string(8) "Í"
-  ["Î"]=>
-  string(7) "Î"
-  ["Ï"]=>
-  string(6) "Ï"
-  ["Ð"]=>
-  string(5) "Ð"
-  ["Ñ"]=>
-  string(8) "Ñ"
-  ["Ò"]=>
-  string(8) "Ò"
-  ["Ó"]=>
-  string(8) "Ó"
-  ["Ô"]=>
-  string(7) "Ô"
-  ["Õ"]=>
-  string(8) "Õ"
-  ["Ö"]=>
-  string(6) "Ö"
-  ["×"]=>
-  string(7) "×"
-  ["Ø"]=>
-  string(8) "Ø"
-  ["Ù"]=>
-  string(8) "Ù"
-  ["Ú"]=>
-  string(8) "Ú"
-  ["Û"]=>
-  string(7) "Û"
-  ["Ü"]=>
-  string(6) "Ü"
-  ["Ý"]=>
-  string(8) "Ý"
-  ["Þ"]=>
-  string(7) "Þ"
-  ["ß"]=>
-  string(7) "ß"
-  ["à"]=>
-  string(8) "à"
-  ["á"]=>
-  string(8) "á"
-  ["â"]=>
-  string(7) "â"
-  ["ã"]=>
-  string(8) "ã"
-  ["ä"]=>
-  string(6) "ä"
-  ["å"]=>
-  string(7) "å"
-  ["æ"]=>
-  string(7) "æ"
-  ["ç"]=>
-  string(8) "ç"
-  ["è"]=>
-  string(8) "è"
-  ["é"]=>
-  string(8) "é"
-  ["ê"]=>
-  string(7) "ê"
-  ["ë"]=>
-  string(6) "ë"
-  ["ì"]=>
-  string(8) "ì"
-  ["í"]=>
-  string(8) "í"
-  ["î"]=>
-  string(7) "î"
-  ["ï"]=>
-  string(6) "ï"
-  ["ð"]=>
-  string(5) "ð"
-  ["ñ"]=>
-  string(8) "ñ"
-  ["ò"]=>
-  string(8) "ò"
-  ["ó"]=>
-  string(8) "ó"
-  ["ô"]=>
-  string(7) "ô"
-  ["õ"]=>
-  string(8) "õ"
-  ["ö"]=>
-  string(6) "ö"
-  ["÷"]=>
-  string(8) "÷"
-  ["ø"]=>
-  string(8) "ø"
-  ["ù"]=>
-  string(8) "ù"
-  ["ú"]=>
-  string(8) "ú"
-  ["û"]=>
-  string(7) "û"
-  ["ü"]=>
-  string(6) "ü"
-  ["ý"]=>
-  string(8) "ý"
-  ["þ"]=>
-  string(7) "þ"
-  ["ÿ"]=>
-  string(6) "ÿ"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
--- Iteration 9 --
 array(4) {
-  ["""]=>
-  string(6) """
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
   ["&"]=>
   string(5) "&"
-}
-array(4) {
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 10 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 -- Iteration 11 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 -- Iteration 12 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, object given in %s on line %d
 NULL
 -- Iteration 13 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 -- Iteration 14 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, string given in %s on line %d
 NULL
 -- Iteration 15 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 16 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 17 --
 
-Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
 NULL
 
-Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %s
+Warning: get_html_translation_table() expects parameter 1 to be long, resource given in %s on line %d
 NULL
 -- Iteration 18 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 19 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["""]=>
   string(6) """
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_variation2-win32.phpt b/ext/standard/tests/strings/get_html_translation_table_variation2-win32.phpt
deleted file mode 100644
index 109a40c..0000000
--- a/ext/standard/tests/strings/get_html_translation_table_variation2-win32.phpt
+++ /dev/null
@@ -1,220 +0,0 @@
---TEST--
-Test get_html_translation_table() function : usage variations - unexpected quote_style values
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) != "WIN"){  
-  die('skip only for Windows');
-}
-
-if( !setlocale(LC_ALL, "English_United States.1252") ) {
-  die('skip failed to set locale settings to "English_United States.1252"');
-}
-
-?>
---FILE--
-<?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
- * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
- * Source code: ext/standard/html.c
-*/
-
-/*
- * test get_html_translation_table() with unexpteced value for argument $quote_style
-*/
-
-//set locale
-setlocale(LC_ALL, "English_United States.1252"); 
-
-echo "*** Testing get_html_translation_table() : usage variations ***\n";
-// initialize all required variables
-$table = HTML_SPECIALCHARS;
-
-// get an unset variable
-$unset_var = 10;
-unset($unset_var);
-
-// a resource var
-$fp = fopen(__FILE__, "r");
-
-// array with different values
-$values =  array (
-
-  // array values
-  array(),
-  array(0),
-  array(1),
-  array(1, 2),
-  array('color' => 'red', 'item' => 'pen'),
-
-  // boolean values
-  true,
-  false,
-  TRUE,
-  FALSE,
-
-  // string values
-  "string",
-  'string',
-
-  // objects
-  new stdclass(),
-
-  // empty string
-  "",
-  '',
-
-  // null vlaues
-  NULL,
-  null,
-
-  // resource var
-  $fp, 
-
-  // undefined variable
-  @$undefined_var,
-
-  // unset variable
-  @$unset_var
-);
-
-
-// loop through each element of the array and check the working of get_html_translation_table()
-// when $quote_style arugment is supplied with different values
-echo "\n--- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---\n";
-$counter = 1;
-for($index = 0; $index < count($values); $index ++) {
-  echo "-- Iteration $counter --\n";
-  $quote_style = $values [$index];
-
-  var_dump( get_html_translation_table($table, $quote_style) );
-
-  $counter ++;
-}
-
-echo "Done\n";
-?>
---EXPECTF--
-*** Testing get_html_translation_table() : usage variations ***
-
---- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---
--- Iteration 1 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
-NULL
--- Iteration 2 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
-NULL
--- Iteration 3 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
-NULL
--- Iteration 4 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
-NULL
--- Iteration 5 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
-NULL
--- Iteration 6 --
-array(4) {
-  ["'"]=>
-  string(5) "'"
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 7 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 8 --
-array(4) {
-  ["'"]=>
-  string(5) "'"
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 9 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 10 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
-NULL
--- Iteration 11 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
-NULL
--- Iteration 12 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, object given in %s on line %s
-NULL
--- Iteration 13 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
-NULL
--- Iteration 14 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
-NULL
--- Iteration 15 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 16 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 17 --
-
-Warning: get_html_translation_table() expects parameter 2 to be long, resource given in %s on line %s
-NULL
--- Iteration 18 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
--- Iteration 19 --
-array(3) {
-  ["<"]=>
-  string(4) "<"
-  [">"]=>
-  string(4) ">"
-  ["&"]=>
-  string(5) "&"
-}
-Done
diff --git a/ext/standard/tests/strings/get_html_translation_table_variation2.phpt b/ext/standard/tests/strings/get_html_translation_table_variation2.phpt
index cc055f3..b792a55 100644
--- a/ext/standard/tests/strings/get_html_translation_table_variation2.phpt
+++ b/ext/standard/tests/strings/get_html_translation_table_variation2.phpt
@@ -1,18 +1,8 @@
 --TEST--
 Test get_html_translation_table() function : usage variations - unexpected quote_style values
---SKIPIF--
-<?php
-if( substr(PHP_OS, 0, 3) == "WIN"){  
-  die('skip Not for Windows');
-}
-
-if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
-  die('skip failed to set locale settings to "en-US.UTF-8"');
-}
-?>
 --FILE--
 <?php
-/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style]] )
+/* Prototype  : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
  * Description: Returns the internal translation table used by htmlspecialchars and htmlentities
  * Source code: ext/standard/html.c
 */
@@ -118,43 +108,43 @@ Warning: get_html_translation_table() expects parameter 2 to be long, array give
 NULL
 -- Iteration 6 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["'"]=>
-  string(5) "'"
+  string(6) "'"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 7 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 8 --
 array(4) {
+  ["&"]=>
+  string(5) "&"
   ["'"]=>
-  string(5) "'"
+  string(6) "'"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 9 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 10 --
 
@@ -178,21 +168,21 @@ Warning: get_html_translation_table() expects parameter 2 to be long, string giv
 NULL
 -- Iteration 15 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 16 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 17 --
 
@@ -200,20 +190,20 @@ Warning: get_html_translation_table() expects parameter 2 to be long, resource g
 NULL
 -- Iteration 18 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 -- Iteration 19 --
 array(3) {
+  ["&"]=>
+  string(5) "&"
   ["<"]=>
   string(4) "<"
   [">"]=>
   string(4) ">"
-  ["&"]=>
-  string(5) "&"
 }
 Done
diff --git a/ext/standard/tests/strings/htmlentities-utf-2.phpt b/ext/standard/tests/strings/htmlentities-utf-2.phpt
index c5f4ac4..d515dc0 100755
--- a/ext/standard/tests/strings/htmlentities-utf-2.phpt
+++ b/ext/standard/tests/strings/htmlentities-utf-2.phpt
@@ -50,8 +50,8 @@ foreach($strings as $string) {
 %unicode|string%(16) "266561637574653b"
 %unicode|string%(2) "79"
 %unicode|string%(2) "79"
-%unicode|string%(8) "f7bfbfbf"
-%unicode|string%(8) "f7bfbfbf"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
diff --git a/ext/standard/tests/strings/htmlentities-utf-3.phpt b/ext/standard/tests/strings/htmlentities-utf-3.phpt
new file mode 100644
index 0000000..c28917b
--- /dev/null
+++ b/ext/standard/tests/strings/htmlentities-utf-3.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Test get_next_char(), used by htmlentities()/htmlspecialchars(): validity of UTF-8 sequences
+--FILE--
+<?php
+
+/* conformance to Unicode 5.2, section 3.9, D92 */
+
+$val_ranges = array(
+	array(array(0x00, 0x7F)),
+	array(array(0xC2, 0xDF), array(0x80, 0xBF)),
+	array(array(0xE0, 0xE0), array(0xA0, 0xBF), array(0x80, 0xBF)),
+	array(array(0xE1, 0xEC), array(0x80, 0xBF), array(0x80, 0xBF)),
+	array(array(0xED, 0xED), array(0x80, 0x9F), array(0x80, 0xBF)),
+	array(array(0xEE, 0xEF), array(0x80, 0xBF), array(0x80, 0xBF)),
+	array(array(0xF0, 0xF0), array(0x90, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)),
+	array(array(0xF1, 0xF3), array(0x80, 0xBF), array(0x80, 0xBF), array(0x80, 0xBF)),
+	array(array(0xF4, 0xF4), array(0x80, 0x8F), array(0x80, 0xBF), array(0x80, 0xBF)),
+);
+
+function is_valid($seq) {
+	global $val_ranges;
+	$b = ord($seq[0]);
+	foreach ($val_ranges as $l) {
+		if ($b >= $l[0][0] && $b <= $l[0][1]) {
+			if (count($l) != strlen($seq)) {
+				return false;
+			}
+			for ($n = 1; $n < strlen($seq); $n++) {
+				if (ord($seq[$n]) < $l[$n][0] || ord($seq[$n]) > $l[$n][1]) {
+					return false;
+				}
+			}
+			return true;
+		}
+	}
+	return false;
+}
+
+function concordance($s) {
+	$vhe = strlen(htmlspecialchars($s, ENT_QUOTES, "UTF-8")) > 0;
+	$v = is_valid($s);
+	return ($vhe === $v);
+}
+
+for ($b1 = 0xC0; $b1 < 0xE0; $b1++) {
+	for ($b2 = 0x80; $b2 < 0xBF; $b2++) {
+		$s = chr($b1).chr($b2);
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+	}
+}
+
+
+for ($b1 = 0xE0; $b1 < 0xEF; $b1++) {
+	for ($b2 = 0x80; $b2 < 0xBF; $b2++) {
+		$s = chr($b1).chr($b2)."\x80";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+		$s = chr($b1).chr($b2)."\xBF";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+	}
+}
+
+for ($b1 = 0xF0; $b1 < 0xFF; $b1++) {
+	for ($b2 = 0x80; $b2 < 0xBF; $b2++) {
+		$s = chr($b1).chr($b2)."\x80\x80";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+		$s = chr($b1).chr($b2)."\xBF\x80";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+		$s = chr($b1).chr($b2)."\x80\xBF";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+		$s = chr($b1).chr($b2)."\xBF\xBF";
+		if (!concordance($s))
+			echo "Discordance for ".bin2hex($s),"\n";
+	}
+}
+echo "Done.\n";
+--EXPECT--
+Done.
diff --git a/ext/standard/tests/strings/htmlentities-utf.phpt b/ext/standard/tests/strings/htmlentities-utf.phpt
index 1daafc6..6a66e4d 100755
--- a/ext/standard/tests/strings/htmlentities-utf.phpt
+++ b/ext/standard/tests/strings/htmlentities-utf.phpt
@@ -50,8 +50,8 @@ foreach($strings as $string) {
 %unicode|string%(16) "266561637574653b"
 %unicode|string%(0) ""
 %unicode|string%(0) ""
-%unicode|string%(8) "f7bfbfbf"
-%unicode|string%(8) "f7bfbfbf"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
 %unicode|string%(0) ""
diff --git a/ext/standard/tests/strings/htmlentities17.phpt b/ext/standard/tests/strings/htmlentities17.phpt
index b203e7c..d9e67a9 100644
--- a/ext/standard/tests/strings/htmlentities17.phpt
+++ b/ext/standard/tests/strings/htmlentities17.phpt
@@ -3,7 +3,6 @@ htmlentities() / html_entity_decode() #8592 - #9002 table test
 --FILE--
 <?php
 $tests = array(
-	array(8768, '≀', "e28980"),
 	array(8853, '⊕',  "e28a95"),
 	array(8855, '⊗', "e28a97"),
 	array(8869, '⊥',   "e28aa5"),
@@ -26,7 +25,6 @@ foreach ($tests as $test) {
 }
 ?>
 --EXPECT--
-string(8) "≀"
 string(7) "⊕"
 string(8) "⊗"
 string(6) "⊥"
@@ -37,7 +35,6 @@ string(8) "⌊"
 string(8) "⌋"
 string(6) "⟨"
 string(6) "⟩"
-string(6) "e28980"
 string(6) "e28a95"
 string(6) "e28a97"
 string(6) "e28aa5"
diff --git a/ext/standard/tests/strings/parse_str_basic3.phpt b/ext/standard/tests/strings/parse_str_basic3.phpt
index 0cc7616..06e6143 100644
--- a/ext/standard/tests/strings/parse_str_basic3.phpt
+++ b/ext/standard/tests/strings/parse_str_basic3.phpt
@@ -91,7 +91,7 @@ var_dump($res);
 ?>
 ===DONE===
 --EXPECTF--
-Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
 *** Testing parse_str() : basic functionality ***
 
 Test string with array values
diff --git a/ext/standard/tests/url/bug52327.phpt b/ext/standard/tests/url/bug52327.phpt
new file mode 100644
index 0000000..fb2e0fa
--- /dev/null
+++ b/ext/standard/tests/url/bug52327.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52327 (base64_decode() improper handling of leading padding)
+--FILE--
+<?php
+var_dump(
+	base64_decode('=VGhl=ICc9=JyBz=eW1i=b2xz=IGFy=ZW4n=dCBh=bGxv=d2Vk=IHdo=ZXJl=IGkg=cHV0=IHRo=ZW0g=by5P'),
+	base64_decode('=VGhl=ICc9=JyBz=eW1i=b2xz=IGFy=ZW4n=dCBh=bGxv=d2Vk=IHdo=ZXJl=IGkg=cHV0=IHRo=ZW0g=by5P', true)
+);
+?>
+--EXPECT--
+string(51) "The '=' symbols aren't allowed where i put them o.O"
+bool(false)
diff --git a/ext/standard/tests/url/bug53248.phpt b/ext/standard/tests/url/bug53248.phpt
new file mode 100644
index 0000000..5e31c51
--- /dev/null
+++ b/ext/standard/tests/url/bug53248.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #53248 (rawurlencode RFC 3986 EBCDIC support)
+--FILE--
+<?php
+
+var_dump(rawurlencode('A1_-.~'));
+var_dump(rawurldecode('%41%31%5F%2D%2E%7E'));
+
+?>
+--EXPECTF--
+string(6) "A1_-.~"
+string(6) "A1_-.~"
\ No newline at end of file
diff --git a/ext/standard/url.c b/ext/standard/url.c
index dc94655..63e302d 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <jimw at php.net>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: url.c 300501 2010-06-16 18:56:24Z pajoye $ */
+/* $Id: url.c 305159 2010-11-07 12:59:22Z felipe $ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -585,7 +585,7 @@ PHPAPI char *php_raw_url_encode(char const *s, int len, int *new_length)
 			str[y++] = hexchars[(unsigned char) s[x] >> 4];
 			str[y] = hexchars[(unsigned char) s[x] & 15];
 #else /*CHARSET_EBCDIC*/
-		if (!isalnum(str[y]) && strchr("_-.", str[y]) != NULL) {
+		if (!isalnum(str[y]) && strchr("_-.~", str[y]) != NULL) {
 			str[y++] = '%';
 			str[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4];
 			str[y] = hexchars[os_toascii[(unsigned char) s[x]] & 15];
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 90e9250..e71e594 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: var.c 301144 2010-07-09 21:19:27Z scottmac $ */
+/* $Id: var.c 303330 2010-09-13 20:14:18Z kalle $ */
 
 /* {{{ includes
 */
@@ -284,9 +284,13 @@ PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
 			return;
 		}
 		ce = Z_OBJCE_PP(struc);
-		Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
-		php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
-		efree(class_name);
+		if (Z_OBJ_HANDLER_PP(struc, get_class_name)) {
+			Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
+			php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
+			efree(class_name);
+		} else {
+			php_printf("%sobject(unknown class)#%d (%d) refcount(%u){\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
+		}
 		zval_element_dump_func = zval_object_property_dump;
 head_done:
 		if (myht) {
@@ -353,7 +357,7 @@ static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list a
 
 	if (hash_key->nKeyLength == 0) { /* numeric key */
 		buffer_append_spaces(buf, level+1);
-		smart_str_append_long(buf, hash_key->h);
+		smart_str_append_long(buf, (long) hash_key->h);
 		smart_str_appendl(buf, " => ", 4);
 	} else { /* string key */
 		char *key, *tmp_str;
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 8c0d867..b88cab0 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Jun 25 15:36:31 2010 */
+/* Generated by re2c 0.13.5 on Fri Aug  6 19:14:17 2010 */
 /*
   +----------------------------------------------------------------------+
   | PHP Version 5                                                        |
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.c 300843 2010-06-29 00:58:31Z stas $ */
+/* $Id: var_unserializer.c 301949 2010-08-06 22:23:10Z felipe $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
@@ -210,7 +210,7 @@ static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
 	while (1) {
 		cursor = (char)*p;
 		if (cursor >= '0' && cursor <= '9') {
-			result = result * 10 + cursor - '0';
+			result = result * 10 + (size_t)(cursor - (unsigned char)'0');
 		} else {
 			break;
 		}
diff --git a/ext/standard/var_unserializer.c.orig b/ext/standard/var_unserializer.c.orig
index ad474c0..586eedb 100644
--- a/ext/standard/var_unserializer.c.orig
+++ b/ext/standard/var_unserializer.c.orig
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Jun 25 15:36:31 2010 */
+/* Generated by re2c 0.13.5 on Fri Aug  6 19:14:17 2010 */
 #line 1 "ext/standard/var_unserializer.re"
 /*
   +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.c 300843 2010-06-29 00:58:31Z stas $ */
+/* $Id: var_unserializer.c 301949 2010-08-06 22:23:10Z felipe $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
@@ -212,7 +212,7 @@ static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
 	while (1) {
 		cursor = (char)*p;
 		if (cursor >= '0' && cursor <= '9') {
-			result = result * 10 + cursor - '0';
+			result = result * 10 + (size_t)(cursor - (unsigned char)'0');
 		} else {
 			break;
 		}
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 3312bee..5d4a379 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: var_unserializer.re 300843 2010-06-29 00:58:31Z stas $ */
+/* $Id: var_unserializer.re 301935 2010-08-06 18:20:41Z rasmus $ */
 
 #include "php.h"
 #include "ext/standard/php_var.h"
@@ -216,7 +216,7 @@ static inline long parse_iv2(const unsigned char *p, const unsigned char **q)
 	while (1) {
 		cursor = (char)*p;
 		if (cursor >= '0' && cursor <= '9') {
-			result = result * 10 + cursor - '0';
+			result = result * 10 + (size_t)(cursor - (unsigned char)'0');
 		} else {
 			break;
 		}
diff --git a/ext/sybase_ct/config.m4 b/ext/sybase_ct/config.m4
index aba6f47..f335c4c 100644
--- a/ext/sybase_ct/config.m4
+++ b/ext/sybase_ct/config.m4
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4 301036 2010-07-07 10:15:24Z thekid $
+dnl $Id: config.m4 302918 2010-08-31 12:28:30Z thekid $
 dnl
 
 PHP_ARG_WITH(sybase-ct, for Sybase-CT support,
@@ -34,7 +34,7 @@ if test "$PHP_SYBASE_CT" != "no"; then
   if test -f $SYBASE_CT_INCDIR/tds.h || test -f $SYBASE_CT_INCDIR/tds_sysdep_public.h; then
     PHP_ADD_LIBRARY(ct,, SYBASE_CT_SHARED_LIBADD)
     SYBASE_CT_LIBS="-L$SYBASE_CT_LIBDIR -lct"
-  elif test -f $SYBASE_CT_INCDIR/libsybct64; then
+  elif test -f $SYBASE_CT_INCDIR/libsybct64.so; then
     PHP_ADD_LIBRARY(sybcs64,, SYBASE_CT_SHARED_LIBADD)
     PHP_ADD_LIBRARY(sybct64,, SYBASE_CT_SHARED_LIBADD)
     PHP_ADD_LIBRARY(sybcomn64,, SYBASE_CT_SHARED_LIBADD)
@@ -57,7 +57,7 @@ if test "$PHP_SYBASE_CT" != "no"; then
   
     PHP_CHECK_LIBRARY(insck64, insck__getVdate, [PHP_ADD_LIBRARY(insck64,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
     PHP_CHECK_LIBRARY(insck64, bsd_tcp,         [PHP_ADD_LIBRARY(insck64,, SYBASE_CT_SHARED_LIBADD)],[],[-L$SYBASE_CT_LIBDIR])
-  elif test -f $SYBASE_CT_INCDIR/libsybct; then
+  elif test -f $SYBASE_CT_INCDIR/libsybct.so; then
     PHP_ADD_LIBRARY(sybcs,, SYBASE_CT_SHARED_LIBADD)
     PHP_ADD_LIBRARY(sybct,, SYBASE_CT_SHARED_LIBADD)
     PHP_ADD_LIBRARY(sybcomn,, SYBASE_CT_SHARED_LIBADD)
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index 9b04934..a2747fc 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sysvmsg.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: sysvmsg.c 303429 2010-09-16 19:15:26Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -145,7 +145,7 @@ PHP_MINFO_FUNCTION(sysvmsg)
 {
 	php_info_print_table_start();
 	php_info_print_table_row(2, "sysvmsg support", "enabled");
-	php_info_print_table_row(2, "Revision", "$Revision: 293036 $");
+	php_info_print_table_row(2, "Revision", "$Revision: 303429 $");
 	php_info_print_table_end();
 }
 /* }}} */
@@ -157,18 +157,18 @@ PHP_FUNCTION(msg_set_queue)
 	zval *queue, *data;
 	sysvmsg_queue_t *mq = NULL;
 	struct msqid_ds stat;
-			
+
 	RETVAL_FALSE;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &queue, &data) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
 	if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
 		zval **item;
-		
+
 		/* now pull out members of data and set them in the stat buffer */
 		if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.uid", sizeof("msg_perm.uid"), (void **) &item) == SUCCESS) {
 			convert_to_long_ex(item);
@@ -200,18 +200,18 @@ PHP_FUNCTION(msg_stat_queue)
 	zval *queue;
 	sysvmsg_queue_t *mq = NULL;
 	struct msqid_ds stat;
-	
+
 	RETVAL_FALSE;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
 	if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
 		array_init(return_value);
-		
+
 		add_assoc_long(return_value, "msg_perm.uid", stat.msg_perm.uid);
 		add_assoc_long(return_value, "msg_perm.gid", stat.msg_perm.gid);
 		add_assoc_long(return_value, "msg_perm.mode", stat.msg_perm.mode);
@@ -253,7 +253,7 @@ PHP_FUNCTION(msg_get_queue)
 	long key;
 	long perms = 0666;
 	sysvmsg_queue_t *mq;
-	
+
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &key, &perms) == FAILURE)	{
 		return;
 	}
@@ -271,7 +271,7 @@ PHP_FUNCTION(msg_get_queue)
 			RETURN_FALSE;
 		}
 	}
-	RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg));	
+	RETVAL_RESOURCE(zend_list_insert(mq, le_sysvmsg));
 }
 /* }}} */
 
@@ -285,7 +285,7 @@ PHP_FUNCTION(msg_remove_queue)
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
 	if (msgctl(mq->id, IPC_RMID, NULL) == 0) {
@@ -307,10 +307,10 @@ PHP_FUNCTION(msg_receive)
 	sysvmsg_queue_t *mq = NULL;
 	struct php_msgbuf *messagebuffer = NULL; /* buffer to transmit */
 	int result;
-	
+
 	RETVAL_FALSE;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlzlz|blz", 
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlzlz|blz",
 				&queue, &desiredmsgtype, &out_msgtype, &maxsize,
 				&out_message, &do_unserialize, &flags, &zerrcode) == FAILURE) {
 		return;
@@ -337,23 +337,23 @@ PHP_FUNCTION(msg_receive)
 			realflags |= IPC_NOWAIT;
 		}
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
 	messagebuffer = (struct php_msgbuf *) safe_emalloc(maxsize, 1, sizeof(struct php_msgbuf));
 
 	result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags);
-		
+
 	zval_dtor(out_msgtype);
-	zval_dtor(out_message);	
+	zval_dtor(out_message);
 	ZVAL_LONG(out_msgtype, 0);
 	ZVAL_FALSE(out_message);
-	
+
 	if (zerrcode) {
 		zval_dtor(zerrcode);
 		ZVAL_LONG(zerrcode, 0);
 	}
-	
+
 	if (result >= 0) {
 		/* got it! */
 		ZVAL_LONG(out_msgtype, messagebuffer->mtype);
@@ -395,14 +395,14 @@ PHP_FUNCTION(msg_send)
 	struct php_msgbuf * messagebuffer = NULL; /* buffer to transmit */
 	int result;
 	int message_len = 0;
-	
+
 	RETVAL_FALSE;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz|bbz",
 				&queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE) {
 		return;
 	}
-	
+
 	ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t*, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
 	if (do_serialize) {
@@ -412,7 +412,7 @@ PHP_FUNCTION(msg_send)
 		PHP_VAR_SERIALIZE_INIT(var_hash);
 		php_var_serialize(&msg_var, &message, &var_hash TSRMLS_CC);
 		PHP_VAR_SERIALIZE_DESTROY(var_hash);
-		
+
 		/* NB: php_msgbuf is 1 char bigger than a long, so there is no need to
 		 * allocate the extra byte. */
 		messagebuffer = safe_emalloc(msg_var.len, 1, sizeof(struct php_msgbuf));
@@ -448,12 +448,12 @@ PHP_FUNCTION(msg_send)
 			efree(p);
 		}
 	}
-	
+
 	/* set the message type */
 	messagebuffer->mtype = msgtype;
 
 	result = msgsnd(mq->id, messagebuffer, message_len, blocking ? 0 : IPC_NOWAIT);
-	
+
 	efree(messagebuffer);
 
 	if (result == -1) {
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 2c75589..c4a79a6 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: tidy.c 296107 2010-03-12 10:28:59Z jani $ */
+/* $Id: tidy.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -567,6 +567,9 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
 	}
 	
 	if (is_file) {
+		if (strlen(arg1) != arg1_len) {
+			RETURN_FALSE;
+		}
 		if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) {
 			RETURN_FALSE;
 		}
@@ -1085,7 +1088,7 @@ static PHP_MINFO_FUNCTION(tidy)
 	php_info_print_table_start();
 	php_info_print_table_header(2, "Tidy support", "enabled");
 	php_info_print_table_row(2, "libTidy Release", (char *)tidyReleaseDate());
-	php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c 296107 2010-03-12 10:28:59Z jani $)");
+	php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c 305507 2010-11-18 15:22:22Z pajoye $)");
 	php_info_print_table_end();
 
 	DISPLAY_INI_ENTRIES();
@@ -1221,6 +1224,9 @@ static PHP_FUNCTION(tidy_parse_file)
 		RETURN_FALSE;
 	}
 
+	if (strlen(inputfile) != input_len) {
+		RETURN_FALSE;
+	}
 	tidy_instanciate(tidy_ce_doc, return_value TSRMLS_CC);
 	obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
 
@@ -1534,10 +1540,13 @@ static TIDY_DOC_METHOD(__construct)
 							  &options, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}
-	
+
 	obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
 	
 	if (inputfile) {
+		if (strlen(inputfile) != input_len) {
+			RETURN_FALSE;
+		}
 		if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory %s", inputfile, (use_include_path) ? "(Using include path)" : "");
 			return;
@@ -1568,7 +1577,10 @@ static TIDY_DOC_METHOD(parseFile)
 							  &options, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}
-	
+
+	if (strlen(inputfile) != input_len) {
+		RETURN_FALSE;
+	}
 	if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory %s", inputfile, (use_include_path) ? "(Using include path)" : "");
 		RETURN_FALSE;
diff --git a/ext/wddx/tests/bug52468.phpt b/ext/wddx/tests/bug52468.phpt
new file mode 100644
index 0000000..151c236
--- /dev/null
+++ b/ext/wddx/tests/bug52468.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #52468 (wddx_deserialize corrupts integer field value when left empty)
+--FILE--
+<?php
+
+$message = "<wddxPacket version='1.0'><header><comment>my_command</comment></header><data><struct><var name='handle'><number></number></var></struct></data></wddxPacket>";
+
+print_r(wddx_deserialize($message));
+print_r(wddx_deserialize($message));
+
+?>
+--EXPECT--
+Array
+(
+    [handle] => 0
+)
+Array
+(
+    [handle] => 0
+)
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 507a423..cacf36e 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: wddx.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: wddx.c 301765 2010-08-01 17:34:09Z felipe $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -785,6 +785,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
 		ALLOC_ZVAL(ent.data);
 		INIT_PZVAL(ent.data);
 		Z_TYPE_P(ent.data) = IS_LONG;
+		Z_LVAL_P(ent.data) = 0;
 		wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
 	} else if (!strcmp(name, EL_BOOLEAN)) {
 		int i;
diff --git a/ext/xml/tests/bug49687.phpt b/ext/xml/tests/bug49687.phpt
new file mode 100644
index 0000000..3ff19ce
--- /dev/null
+++ b/ext/xml/tests/bug49687.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #49687 Several utf8_decode deficiencies and vulnerabilities
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('xml')) die ("skip xml extension not available");
+?>
+--FILE--
+<?php
+
+$tests = array(
+    "\x41\xC2\x3E\x42",
+    "\xE3\x80\x22",
+    "\x41\x98\xBA\x42\xE2\x98\x43\xE2\x98\xBA\xE2\x98",
+);
+foreach ($tests as $t) {
+    echo bin2hex(utf8_decode($t)), "\n";
+}
+echo "Done.\n";
+--EXPECT--
+413f3e42
+3f22
+413f3f423f433f3f
+Done.
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index 7ca7099..936710a 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: xml.c 293146 2010-01-05 13:03:40Z pierrick $ */
+/* $Id: xml.c 304959 2010-10-27 18:13:25Z cataphract $ */
 
 #define IS_EXT_MODULE
 
@@ -659,10 +659,111 @@ PHPAPI char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char
 }
 /* }}} */
 
+/* copied from trunk's implementation of get_next_char in ext/standard/html.c */
+#define MB_FAILURE(pos, advance) do { \
+	*cursor = pos + (advance); \
+	*status = FAILURE; \
+	return 0; \
+} while (0)
+
+#define CHECK_LEN(pos, chars_need) ((str_len - (pos)) >= (chars_need))
+#define utf8_lead(c)  ((c) < 0x80 || ((c) >= 0xC2 && (c) <= 0xF4))
+#define utf8_trail(c) ((c) >= 0x80 && (c) <= 0xBF)
+
+/* {{{ php_next_utf8_char
+ */
+static inline unsigned int php_next_utf8_char(
+		const unsigned char *str,
+		size_t str_len,
+		size_t *cursor,
+		int *status)
+{
+	size_t pos = *cursor;
+	unsigned int this_char = 0;
+	unsigned char c;
+
+	*status = SUCCESS;
+
+	if (!CHECK_LEN(pos, 1))
+		MB_FAILURE(pos, 1);
+
+	/* We'll follow strategy 2. from section 3.6.1 of UTR #36:
+		* "In a reported illegal byte sequence, do not include any
+		*  non-initial byte that encodes a valid character or is a leading
+		*  byte for a valid sequence.» */
+	c = str[pos];
+	if (c < 0x80) {
+		this_char = c;
+		pos++;
+	} else if (c < 0xc2) {
+		MB_FAILURE(pos, 1);
+	} else if (c < 0xe0) {
+		if (!CHECK_LEN(pos, 2))
+			MB_FAILURE(pos, 1);
+
+		if (!utf8_trail(str[pos + 1])) {
+			MB_FAILURE(pos, utf8_lead(str[pos + 1]) ? 1 : 2);
+		}
+		this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f);
+		if (this_char < 0x80) { /* non-shortest form */
+			MB_FAILURE(pos, 2);
+		}
+		pos += 2;
+	} else if (c < 0xf0) {
+		size_t avail = str_len - pos;
+
+		if (avail < 3 ||
+				!utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2])) {
+			if (avail < 2 || utf8_lead(str[pos + 1]))
+				MB_FAILURE(pos, 1);
+			else if (avail < 3 || utf8_lead(str[pos + 2]))
+				MB_FAILURE(pos, 2);
+			else
+				MB_FAILURE(pos, 3);
+		}
+
+		this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f);
+		if (this_char < 0x800) { /* non-shortest form */
+			MB_FAILURE(pos, 3);
+		} else if (this_char >= 0xd800 && this_char <= 0xdfff) { /* surrogate */
+			MB_FAILURE(pos, 3);
+		}
+		pos += 3;
+	} else if (c < 0xf5) {
+		size_t avail = str_len - pos;
+
+		if (avail < 4 ||
+				!utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2]) ||
+				!utf8_trail(str[pos + 3])) {
+			if (avail < 2 || utf8_lead(str[pos + 1]))
+				MB_FAILURE(pos, 1);
+			else if (avail < 3 || utf8_lead(str[pos + 2]))
+				MB_FAILURE(pos, 2);
+			else if (avail < 4 || utf8_lead(str[pos + 3]))
+				MB_FAILURE(pos, 3);
+			else
+				MB_FAILURE(pos, 4);
+		}
+				
+		this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f);
+		if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */
+			MB_FAILURE(pos, 4);
+		}
+		pos += 4;
+	} else {
+		MB_FAILURE(pos, 1);
+	}
+	
+	*cursor = pos;
+	return this_char;
+}
+/* }}} */
+
+
 /* {{{ xml_utf8_decode */
 PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
 {
-	int pos = len;
+	size_t pos = 0;
 	char *newbuf = emalloc(len + 1);
 	unsigned int c;
 	char (*decoder)(unsigned short) = NULL;
@@ -681,36 +782,15 @@ PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_
 		newbuf[*newlen] = '\0';
 		return newbuf;
 	}
-	while (pos > 0) {
-		c = (unsigned char)(*s);
-		if (c >= 0xf0) { /* four bytes encoded, 21 bits */
-			if(pos-4 >= 0) {
-				c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6) | (s[3]&63);
-			} else {
-				c = '?';	
-			}
-			s += 4;
-			pos -= 4;
-		} else if (c >= 0xe0) { /* three bytes encoded, 16 bits */
-			if(pos-3 >= 0) {
-				c = ((s[0]&63)<<12) | ((s[1]&63)<<6) | (s[2]&63);
-			} else {
-				c = '?';
-			}
-			s += 3;
-			pos -= 3;
-		} else if (c >= 0xc0) { /* two bytes encoded, 11 bits */
-			if(pos-2 >= 0) {
-				c = ((s[0]&63)<<6) | (s[1]&63);
-			} else {
-				c = '?';
-			}
-			s += 2;
-			pos -= 2;
-		} else {
-			s++;
-			pos--;
+
+	while (pos < (size_t)len) {
+		int status = FAILURE;
+		c = php_next_utf8_char((const unsigned char*)s, (size_t) len, &pos, &status);
+
+		if (status == FAILURE || c > 0xFFU) {
+			c = '?';
 		}
+
 		newbuf[*newlen] = decoder ? decoder(c) : c;
 		++*newlen;
 	}
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c
index e6d7e53..531c8d3 100644
--- a/ext/xsl/xsltprocessor.c
+++ b/ext/xsl/xsltprocessor.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: xsltprocessor.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: xsltprocessor.c 305507 2010-11-18 15:22:22Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -642,6 +642,9 @@ PHP_FUNCTION(xsl_xsltprocessor_transform_to_uri)
 
 	ret = -1;
 	if (newdocp) {
+		if (strlen(uri) != uri_len) {
+			RETURN_FALSE;
+		}
 		ret = xsltSaveResultToFilename(uri, newdocp, sheetp, 0);
 		xmlFreeDoc(newdocp);
 	}
@@ -845,7 +848,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_profiling)
 		if (intern->profiling) {
 			efree(intern->profiling);
 		}
-		if (filename != NULL) {
+		if (filename != NULL && strlen(filename) == filename_len) {
 			intern->profiling = estrndup(filename,filename_len);
 		} else {
 			intern->profiling = NULL;
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 2e1d69e..de35143 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_zip.c 300470 2010-06-15 18:48:33Z pajoye $ */
+/* $Id: php_zip.c 305848 2010-11-30 11:04:06Z pajoye $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -162,6 +162,9 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
 	 */
 	virtual_file_ex(&new_state, file, NULL, CWD_EXPAND);
 	path_cleaned =  php_zip_make_relative_path(new_state.cwd, new_state.cwd_length);
+	if(!path_cleaned) {
+		return 0;
+	}
 	path_cleaned_len = strlen(path_cleaned);
 
 	if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
@@ -1148,6 +1151,10 @@ static PHP_NAMED_FUNCTION(zif_zip_open)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (ZIP_OPENBASEDIR_CHECKPATH(filename)) {
 		RETURN_FALSE;
 	}
@@ -1437,6 +1444,10 @@ static ZIPARCHIVE_METHOD(open)
 		RETURN_FALSE;
 	}
 
+	if (strlen(filename) != filename_len) {
+		RETURN_FALSE;
+	}
+
 	if (ZIP_OPENBASEDIR_CHECKPATH(filename)) {
 		RETURN_FALSE;
 	}
@@ -1649,7 +1660,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: %i, %i given)", 
+						php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entry name too long (max: %d, %ld given)", 
 						MAXPATHLEN - 1, (add_path_len + file_stripped_len));
 						zval_dtor(return_value);
 						RETURN_FALSE;
@@ -1961,6 +1972,9 @@ static ZIPARCHIVE_METHOD(getArchiveComment)
 	}
 
 	comment = zip_get_archive_comment(intern, &comment_len, (int)flags);
+	if(comment==NULL) {
+		RETURN_FALSE;
+	}
 	RETURN_STRINGL((char *)comment, (long)comment_len, 1);
 }
 /* }}} */
@@ -2360,12 +2374,16 @@ static ZIPARCHIVE_METHOD(extractTo)
 		RETURN_FALSE;
 	}
 
-    if (php_stream_stat_path(pathto, &ssb) < 0) {
-        ret = php_stream_mkdir(pathto, 0777,  PHP_STREAM_MKDIR_RECURSIVE, NULL);
-        if (!ret) {
-            RETURN_FALSE;
-        }
-    }
+	if (strlen(pathto) != pathto_len) {
+		RETURN_FALSE;
+	}
+
+	if (php_stream_stat_path(pathto, &ssb) < 0) {
+		ret = php_stream_mkdir(pathto, 0777,  PHP_STREAM_MKDIR_RECURSIVE, NULL);
+		if (!ret) {
+			RETURN_FALSE;
+		}
+	}
 
 	ZIP_FROM_OBJECT(intern, this);
 	if (zval_files && (Z_TYPE_P(zval_files) != IS_NULL)) {
@@ -2446,6 +2464,9 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &len, &flags) == FAILURE) {
 			return;
 		}
+		if (strlen(filename) != filename_len) {
+			return;
+		}
 		PHP_ZIP_STAT_PATH(intern, filename, filename_len, flags, sb);
 	} else {
 		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|ll", &index, &len, &flags) == FAILURE) {
@@ -2779,7 +2800,7 @@ static PHP_MINFO_FUNCTION(zip)
 	php_info_print_table_start();
 
 	php_info_print_table_row(2, "Zip", "enabled");
-	php_info_print_table_row(2, "Extension Version","$Id: php_zip.c 300470 2010-06-15 18:48:33Z pajoye $");
+	php_info_print_table_row(2, "Extension Version","$Id: php_zip.c 305848 2010-11-30 11:04:06Z pajoye $");
 	php_info_print_table_row(2, "Zip version", PHP_ZIP_VERSION_STRING);
 	php_info_print_table_row(2, "Libzip version", "0.9.0");
 
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c
index c40b834..ef05b95 100644
--- a/ext/zip/zip_stream.c
+++ b/ext/zip/zip_stream.c
@@ -1,4 +1,4 @@
-/* $Id: zip_stream.c 298626 2010-04-26 23:55:03Z kalle $ */
+/* $Id: zip_stream.c 305467 2010-11-17 17:55:18Z pierrick $ */
 #ifdef HAVE_CONFIG_H
 #   include "config.h"
 #endif
@@ -30,7 +30,7 @@ struct php_zip_stream_data_t {
 /* {{{ php_zip_ops_read */
 static size_t php_zip_ops_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
 {
-	int n = 0;
+	size_t n = 0;
 	STREAM_DATA_FROM_STREAM();
 
 	if (self->za && self->zf) {
@@ -95,13 +95,90 @@ static int php_zip_ops_flush(php_stream *stream TSRMLS_DC)
 }
 /* }}} */
 
+static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
+{
+	struct zip_stat sb;
+	const char *path = stream->orig_path;
+	int path_len = strlen(stream->orig_path);
+	char *file_basename;
+	size_t file_basename_len;
+	char file_dirname[MAXPATHLEN];
+	struct zip *za;
+	char *fragment;
+	int fragment_len;
+	int err;
+
+	fragment = strchr(path, '#');
+	if (!fragment) {
+		return -1;
+	}
+
+
+	if (strncasecmp("zip://", path, 6) == 0) {
+		path += 6;
+	}
+
+	fragment_len = strlen(fragment);
+
+	if (fragment_len < 1) {
+		return -1;
+	}
+	path_len = strlen(path);
+	if (path_len >= MAXPATHLEN) {
+		return -1;
+	}
+
+	memcpy(file_dirname, path, path_len - fragment_len);
+	file_dirname[path_len - fragment_len] = '\0';
+
+	php_basename((char *)path, path_len - fragment_len, NULL, 0, &file_basename, &file_basename_len TSRMLS_CC);
+	fragment++;
+
+	if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
+		efree(file_basename);
+		return -1;
+	}
+
+	za = zip_open(file_dirname, ZIP_CREATE, &err);
+	if (za) {
+		memset(ssb, 0, sizeof(php_stream_statbuf));
+		if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
+			efree(file_basename);
+			return -1;
+		}
+		zip_close(za);
+
+		if (path[path_len-1] != '/') {
+			ssb->sb.st_size = sb.size;
+			ssb->sb.st_mode |= S_IFREG; /* regular file */
+		} else {
+			ssb->sb.st_size = 0;
+			ssb->sb.st_mode |= S_IFDIR; /* regular directory */
+		}
+
+		ssb->sb.st_mtime = sb.mtime;
+		ssb->sb.st_atime = sb.mtime;
+		ssb->sb.st_ctime = sb.mtime;
+		ssb->sb.st_nlink = 1;
+		ssb->sb.st_rdev = -1;
+#ifndef PHP_WIN32
+		ssb->sb.st_blksize = -1;
+		ssb->sb.st_blocks = -1;
+#endif
+		ssb->sb.st_ino = -1;
+	}
+	efree(file_basename);
+	return 0;
+}
+/* }}} */
+
 php_stream_ops php_stream_zipio_ops = {
 	php_zip_ops_write, php_zip_ops_read,
 	php_zip_ops_close, php_zip_ops_flush,
 	"zip",
 	NULL, /* seek */
 	NULL, /* cast */
-	NULL, /* stat */
+	php_zip_ops_stat, /* stat */
 	NULL  /* set_option */
 };
 
diff --git a/ext/zlib/tests/bug_52944.phpt b/ext/zlib/tests/bug_52944.phpt
new file mode 100644
index 0000000..8503711
--- /dev/null
+++ b/ext/zlib/tests/bug_52944.phpt
@@ -0,0 +1,157 @@
+--TEST--
+Bug #52944 (segfault with zlib filter and corrupted data)
+--SKIPIF--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+$data =
+'U3XuBFLaJfQAWt4cqi8u8ugXxyDcPTZy8VicbJr50gGTEh0dmo+d8O4uBCTuAf3dHbbDYTieluscWXkKlavfKdMkZZRP3GpTApbb'.
+'mQONJCgdbpPHat6iGOoq34vIGCLKFuD8qiA4ti5AL7bArvDtd7i+5tvn49j1L3bwroIsk1iPS5leATIwp1iwk+VdPLzu7tsexYBf'.
+'giLx7WtQI779GtQIKD1QI4AT1Ihvf0I1Iu1u1Ca+7Vs3TtfqiCXvrm99EuJy/ix5z1VD8atW9sUyvmu/pQn8KU5lZvHUqC5xzgow'.
+'0e8m/e5n5fLH2EPhBn4CA3n0p02/E/hVlAgxNIczOk7H7shAHSyUQ7PIwicPE/xNw7Nq4F+aHj2CowlZQKvhr2+fGIhA1QsSG6SD'.
+'y3MBWfRsWxpYq08oqfievkq2Du7uwO99DGhG4GQrIODp67QfRFEFnrUQWD1qV2R44JVHoEjwt5c6ASus4MdOAtA+2OZAHLLOA9O6'.
+'4kgGY4wOggODnQMWrk6fnTn4s4E/GG/QqEPiOiY+PWvij9MDz+0qM8WlyB6rGiGdVcVbChvQJhcjos7ShfrFxU017nBgsMHx2OON'.
+'NV7mx3AovW/veYYnlUfNlF1TNysBvNPrs5V6ClWzREIaxqSGPIK+EoQEeqBvCarbQHOQnolOl/jMrmXPMBWbIDRkzJPVo3kCD3Us'.
+'NRXjK+Ad8/fMLPiqY7+CulD4Vc/pga9nIEdhGDsx1qvT4Aw9rpW6rGtv5tqvcnMLWCNgtbu7BZ25GYiGMwiStZFNs0jY+uxVFrcG'.
+'rOVt+PaYWLhRRxt3rOCm2E/BUUA75CBa7wmWkSkXFyV7bsA/9NU5TPSC8jU9p/fSqS0u9l44323oNb1h6KfYl1mvAYIzNUX0Csfp'.
+'pozkYa12FecgDSsD86KHnATUwz8uzu3jbL5Bkb9UyUtMjL30feyC0oVBYY/DcR8DYdAnbI1FcItMFuAcIkNLx7498TGqFlN49v/K'.
+'5TdaEbZPfKhWMwvZw5SKGjMvAGm6xBrEIRtYsmfRcY0NfA5ogzyuzS2nO9sCMcVkMlxTpc03vuJcSkv9T4aZkYktzv5j3FUIf9Eu'.
+'EVuPX9ZM2dBAEEEAmEzVXRcbdmMfGoEF0hn+ufCvjZoGXMbSLKGXRkIhYEcJFHzrGphvw7M/YAd1MT/q4b1weBHE7+N+ge1EyDGK'.
+'vT/q0GzHs65w1UpMcFyhKRUsLtZfOj1gG3MMrfijvnyV7gJ6DOJTfsQwogzOuESkGzr2vt7AB5ltDDDgs1YBLCP2Hs4ep/INGvDn'.
+'0gS4x7TeREJvQoEvnXoNF2AxzeJZadBG9nsfE1DhTWy/BU0CvZ/t/8VxK1No7y8OsiarJz7+Z4eP7zN0XqDFE2fBdgcLzaFdGau4'.
+'eCY+NT0bWZiQ9RJ8xXipdAO0oplw23O6CXo1DvAcC7C0VnHjT9+dnveSDURCDL+J058ivgw1MKpyUank1fTE7eD+MYNOtKepW3EM'.
+'5BaeogscRezzQwX74AjxOVQW7QYa4BPofdJVOrFAYE2dq42rbINe19qxXjuXQquNl2liaVckfFge4ywTvwxcfNuyttEveIsC5Efh'.
+'t/0A5I1okwDIHgrUs3fN2x3Q79uewcOW4/dgcJII2THNt84OUqH5dlnqMzEPzLrjLQi4S+MtVgp6vWcf+ZBE33o8admzR8jNW06P'.
+'QldnMQigV9BkjL7s2W0fRg+kbGLKAf78yTVnjHqLJv5Qjv0IeEDy4yPGq0JBW+BDvsVZShTCaCWReUxyexvGUy8LRxw72zipLkfM'.
+'a5oI2gU7/g1j8VDFlbFspQbEOJs7RdSJJDjP95E1IHKcjuHLG4xcDeh/dWXyLkXf/JFL2QJcW2nE5NXi4hT+b7e6jjOGiqHNMbWT'.
+'sLVBvw1MQLgf8dt69bepfRWCHfyDIx4Z+RYGUv6AqwxbGGD5A8YzzGY9+71nbKlzi0glZwx/ABx/NvCnUYMEyJXuvXns4PsG/jQ6'.
+'9kcfPq8j/DqmrZ9xXXoYSLidm1i1f/LA7BI807Pf4oZPYI19F9WRQRAtZJMeRRzCn8DnwMM9PzepeCNEb883OvT9HP0ovLO8UkY9'.
+'/oSSaM+n4dt20Kigx0lBgiPHgQFn4nAVc8ufSMdg4i0Z5mg0oDjD7s0saDFcEhehwEJntB2onT2hGTAXAx8MKgAVNU21E8wQNYXQ'.
+'NFf40yNVQga+Z0+xrAmk7oMUQWOfM/2ZTX758olZiaMm33pQ/X1BtvOrMAnHeJiBSheFXMKD94DNU2mkmsvE3AGrJtVcB2n/4inK'.
+'jwAZCUviQzNQgOMJojl7IF8e6YyJidrAa1HrParr/hwJifakm3TB5m8GqSGxuFhz2Nv4I4tpcyMhr4FeaN2ikWvSsZuGlgZCVWHF'.
+'Np2AKxTgEbXkY+6FyRivfDWrEnEbI0h5C9WhRdKUIws1Ah6PXb/LjqrO8bUMac6wX7iXoKV/qlgtU/vKMP8GXcQaGMxdF4PtMdNP'.
+'ZfKg8U56sg92RdJk2/hHYYCN5zp4Y3bwxvRIDt4rezRJujhIQWXMspk1tCIWF4Fj37holt/deS/w2ZSTfD2cxMJZPbDZ0OYnSf04'.
+'AG019g+HdEw8gKmvDnh0/LSRPjWAIn4zfc2aeSUXcBYeU1jd2I1B897dKS8OKHsMHdJLqeNoVE7kY6f05tQBMfvYtSMfCsHh2TKu'.
+'LJozmKY8Pt2g/m3wGcJKGzaKCYCjQaYqLY9ja5xckLecwnjndoKrMLh2ChaskC6FQQLdYmK3k6T6hmzudB5gliE9wbMKq0ZO2+Kd'.
+'frgGaU2bFYOwh4YbGc/Zhj9Itfsuumm46+8WuYgSemdNDMUOrLF9bIiF1SvIcfVibPsEfwXwEgRSrs4IkLhpCoDTFzjumlOAIgv7'.
+'dHqWGtnCI+BW4UFq1KaFKnGAPM8tcjzFDns13W1tFBMMjlEFXCANwEPGsKQoHiwupo+2BNgoJzXw8Jci0Ug780lYtzhDwyI4bF6x'.
+'tqUz//T3J/sNHcfVGwcG5Bv26+FhQ7/TQV2+UfYjXUmH+PYKvF9nYOAfXIFs05MF0GZuD+I1bxzCPYYAjX94gfYEikCDHljmHIQW'.
+'UdBAG97qgZKGn3X8eYo/z/DnOf58iz/fnZmpI6Hv5tHsjoPB/VhMZvm0zJxnI7sKbVamF/wDJ7XXkHRLpV/PHnqUZUHNI1FjPSox'.
+'M2fsNKtw7xDv3pBTh3Jpx8SUjDoe7Ssr/t9s7tgDz8hKkEz5kxsXB26mjTbLQ5gd0ryBQfK6DbLuACweipYkhxgdULB45bjEIYlj'.
+'hFzVsQOI9LI/eo5Cvzx90cFAgZLOlXo0DtD6ybmilDPD+Gr6DgT5PLw4dFw+wKZQgkwvoxcfLGV8/5ybY+ZeR4R9OdUvJqZS+MKc'.
+'s5i2khnoq5qlU1GEomn7cvac2y5zlAvJ5ekoBXEmmg4vFCRqJWfSDU8FLZagAgvcApwcX4zNnW+3KWE2YAQKUg1bPxdm05UZpCod'.
+'QOJfTouMHbo2uDhDcozKx1ymCZKK+RG2g1QRLvx2xHWCOiqI77EHF3INCaEsyzUz/VZsDo99btQVL3dOHTSHKdSbBiP8BunIxD/Q'.
+'kVOlT56ZzWmO6pBwBb6UZL5nVh1s0o0rPqys8GkNel/5BI5a7+5OBVgHLswDjCWAKA3QjzMQmuDJdZ4xFcc9XYlZf0GhqxmZKhXj'.
+'oLpb2QyUXsI4reNzqEBAwoCl1JXT28ixWewzk2fHsDUVeVTikTHNoQn+mMMZ1hXzRpybchWrwo89E5V7YBNqMbVKXjKa6zlzsufk'.
+'3oVshy4QS3Y9MPPSWuvCHpWGY1C0GsnGl0s+DtMkVYZBwZokYHiw02MjvySnMDkpMz/PzY/0ifyikqkgDvhBfOcL9CYY5bY/jvvi'.
+'0e1jIum7gPac24Oohaeixwlae4FNHGYihuxDmm5vHR6cHB3une9vHv+I6Kpgjt/uvj65F2Jzj7/nJomR+3jKD6fL8tO4vMaEMSSt'.
+'qrMG7I40BA458LMgpdHs7Nht3v3l2z5ZEqYieUvZsMg270hz7W51oW03NT86wygOKgqXRQeupQr6efBYaiBLDapLDYqlHoHOLpfY'.
+'qSwxB0tklaW15xDWlV1D20regqPt5Dtm5Dke7kiQcFviiCUS7AXYS7cA2w+BHXaH7agAmLjOQgbZqYZUqpmk1dxKpxmK9WQGSt0H'.
+'tjq2g344KEC+ySAZGy7LRpNxAezay+C2g3Hgj2kvUAFqoja5MwdSacnEzeM8wUWYAs5xJc4CpIJznOLcA4HSfxO2K+iz7YrmdOaB'.
+'KRi38xiPg/gqiPcL00gA5qRdfRQMonEwH7CeQ1iCXiiAr9E5dNU8uy2bgflDPygWVwCEMo/p9PojsEkKROm6WR8f8ynS1cxwojAD'.
+'jRQ2cAtQu3n2J8DNod+NioAjtzyoUCoWbckOnmzmqVBbfJpZGTAoAO62yjDtAsw+nXxWhusU4A4OyzDdAswxnY5WhgsLcCdBXFFi'.
+'zwOBkGtnVf0vvIyHN30/mgzHlVNpbyXQT7yZsAJIHB+AgBetQjGvMKaPji3BZ4IZFGF+FFXpFz+8UVjqSMR0HIrT5ApW8FTg2PQr'.
+'WzH1ZIgLNqVkSKexLqj0RCSMcioojOCFcTzVeEOD2wkEAs3RijgN/f3mSv15vfb06fOVNfCAFfDC1BXYlzONN8hBk/Dy861WFgiz'.
+'FTu4UpY7BrK5NYLExKnrzT8sbLXEUduODm2ntdo0ydwaoRviC0h6wcXqqjsHP0XD4LDdBhLTgfxi/+BjB6wzgabNaPCkCblpNb/L'.
+'TsD1Ujg2IA2xB/Gxo97KwLDXeJxC7rDERTxU6g8L+fMa9UVcRTdKhzZulFIaImUU3gR9SjGZSNdxCO3VX4SDjoYrmEvixGc8xnIM'.
+'OmQV/myETn396fPaYsepLd44a/oy1HIrhuroi7hsL1bTAZsMLaI1/ewLhyylRig7BACCp2sA/vMR4VrSvChuAeMt1Za061Bf1lt4'.
+'xn19SesG8IItxrfVlzrWHSh57Cyl9ZYnVcd2iLVONibfrj99Wlsc1RaHSwU+gazbGSuF2ymnhHhiG/FKmmiGx8vO0qJfxxPt+bm1'.
+'9FtJ/ocFaPR1oWuXFrtLy7l+xZJOHKiCJKfYO/AteCBvnSpiZgB/WDCMcNcJT9IjZZdWl0xgMgwBMRDtSe5w9nDXNBsiBwcvCDYP'.
+'Tx474dsSLJOgvSS7tqqWZkqqOIN7y3QXDAefl3TZ33pN14gWjl7XNaYBPa6+pPPxxTWEssfwnjy3NTVS+fQNEPbR7aPVJ397sLm/'.
+'g+79uzgYgL6xewnen4LX8y39ccRp50nXBfqdAxmXTDx3lm/aePRodRVd2+NBkr6TPIvpvhdHWyIl8GyJvmU4z9n6A1TsJSriFYEe'.
+'JV1QzJTyIRzKq0i5gEczU+JhJLJq8hrcaoz0NUMploYeyf80BMphPoc+HITjuQj/wBcYprUYdUHmnUOX4iWyg9F4KgjyCLjiG0Mn'.
+'lAwjIlZNnI42sFtGfRc4YPX072or35+tdiy8GEEex//Y0epreM/K43uRCCbkqs2rVu56xQ4OHfUi5KUYJWnzXgx4g5+x9Pk///rv'.
+'Pv+3z//l8z/8+u9+/ftf/8Pnf9A+/wsk/QWS/vHzP//695//n8//7dd//+t/+PXvNUj6LwD7f37+i4apn/9vzPT5L3iJKfSxpNGj'.
+'XIAtd3OJwHGAK3Z0h6mat9RfeB+KobfChDSJbvHtsxlwG1p+jqd6S9glunATWm8pkAyOCu2H48MDQ1/FbJgLhsdIt7ja8N9t+vRo'.
+'KRkkshqNuqUpX9ROW2rIKudSRVdaSq5eAmOkgCketpYaWk40p19nVnbdQnZHKh63mnGGXqKnnhvQFQRlvtnMk1VC434eKMBGc0PS'.
+'4q/nv3sZMC0vz0PiKhNZoeiCbsh4JJuN19AMEj4nNt/gL6ov1U6prag/ixClmCIeXVRaf+G91JdFzZb1F6veS9ytlGsBISD2RE5C'.
+'ZquEqJACxfboSg+WPksKkUGR0uhRlYrEC0QkqMw+E+RWeG0mcK+uziGlvHj3OBoEJ9AF+THMglcIXxvUwygGnXjuTabn3ni+lhi5'.
+'U1x4ovt++cphHs5hykdYxjt3ihJfliQ0Efym/5dKiW8TSs7duSWibvv5o1JglBm5go8kknDYRjTAKrdLYPbCmP35I85OLq/VQMD3'.
+'g/aYk/BpNje/2vklGSmyfZNdt+NFrem8upMeqqrfEoxpUEHTJbpiZskDBrhYMudUSOUkZctDnrj4T8MfSIHfNCQ5r9Yjr0dVo2nw'.
+'aOTAe0pPpJS2oq3Xak0BgXQCwkMbmE9NNgQNc3XNXFl7/gzhkHuQBMIkSOnPxhHK3cwa4jSQt9oSIYLeKKEmvixbGmwEqV0Lv1mn'.
+'Uk2ZFuUKZR06D28GMVNIV7BfwuRdOCTqzUPDHVVZh6wP77dfcoBzjQ++SwrZiyuFOKX4wtubgeJgHNpBu43n2OijST8BZ1HHy3HH'.
+'4ComjXVtZmnPcMsFtvkR3oZId/6xAau939V2KG+i1e1v7bX5NyF/r22+P3l7eHRsj28gUfg2fMPuJOSQUjzQ/OFrkQ34Wdnb3do5'.
+'ON5BZJxDXpZswE/ua3p9cnaJoigc+C2xszt+V9/vrorGrOavKWTyJHd3hjqB0JLpzq04d6mhExF0K3GvguzyhY7V5SgRHCptvETn'.
+'RVfefNWmEyzaRve0ffbYceiGQZy5wuUoPfBtvHfB7QQ2eJUAYXUwQjYZT/vBKb5TBIEFuhOg/roCccBwCfPKNqksEAA4ZZiV1bY6'.
+'vMbtOPo46uBh+3iActsOE0NvAJO2giEGSOPI0Rs6cm168HVnZoEJ98pNgn44LNaftmRa7WZyHdK5TxhYcesDrI7rSQ3cJchXXlHa'.
+'AAqCojHZfqZ+8KLxOBrgh7pIlpemhg7iXO2mNzXIguqyIBQWeqOdLwmYaQzjC5PzJRG7Y3qxoDYdwgkFkeQSjb+9abStaSMEmvKK'.
+'74cY9XCsUJbo2hYLXzBKkaL2JFwRbLdyzTkwVFyqnxR4RieROrdUZKNtw8gK4g8kOcmOtrjR8stbFrj8SW+D7YktIa4Qb3SMLJZo'.
+'LL1ohVcg81w8PauiOhrxp6O3o+F4Be8obNRrtb9peq5/0aGNXQ0KEeKaNtlhbuA+lObAjTvhsFFrjsCUAwe9UdNfvliF0tBplkeL'.
+'yxbyUXZUw1GUhLTvzHRwKyNYSL6OgdSkBeTHhg42Nd16rM/weLv5HzkWWR6ETCXQEibNoiQH7oExwmOhdqEWoVXHTUW4W5Y2ic34'.
+'YiqRi/inKltXZOvKbMW6lhpmQQ0aoYUYG13rEx2NIKE+rdDECHRRqqDmN48Q1RhRDdrKJWcbMHooT9C0/n35UXrSH0LgwHa6Z6dN'.
+'EoXWnETDMxkAgx/lQNfp3t3dzujODxiekCpBLnD9fjIMxw7Jr/fwZPSI3JgIY/tlDbLjYfvi/Ul7mZ4wfFu9AcodhgMYgeQ8NJSt'.
+'lKFFRbAUlftaL4DHJIy+cdEwehu9BolR5tFODlJsrAU4vn9dmmUYBUntKcTpXeJueXyInBabseI43Ei4zjS4dDx2i2b1RFEjKIpv'.
+'ANfxCKcR0gNN+Rkd4cdy2byNMBiYXaQ0caMrXClHJjW66EmlrzM+2xXIfzNGN+F2ZmU2rRBxP4XB9UZVIrroeNcXyJjWMdbc4Bsc'.
+'kBYNPvtzEiOH0EfeNUfFY2VTf45TuC1cWfyseoBp+ox3c/8b1DZfnaoKK+2RtZVKmjadD9Tt04PTGPRzxmmLi5iyuBins6D6fvRJ'.
+'py1/uVRxKaP4wGj6lNWI7QGtPqzSlO5qCFxkPC4lLi4+LogrRMISCz4afVuKlceptAVEWXImhAFVih4lzh0InzvWyHekLlcR5+0l'.
+'HsOAheABymIw4olaVsfKb18UtGmpHqUcEeoIqAQ41cWg0M8wnutBmBHrgSo4ayQ6l/o+hbiPXyVQNdeiYKVrN0aj/pS5DnQhMShd'.
+'+DTDACDlMicgjDyqH22LxUX8BSN2iJfG+GC3OQ6fTbmBHxp8AgcKcAw5CZy20FPVeR/n8hqh3ZrENOuwkT028JRxs9mFkda+Qc9w'.
+'o9YQvdN1nHTn/0a3QQDJKAhayWn37O5OebfPxeATyh3cALffR0MB+KkF+uV1qg3QKOOamuVva/xtrerbOn+DP0L2nqLVB7zVtXpn'.
+'M6jMMBUV56g8G5SET9Y5Gqv8jk/W+bkQkJTEz9a57HVOlW/WudLR/ElJsAQm5auSYLFCVXUhaELlMJTU8zjtnG2oL0Q/Zp/bQTDu'.
+'Rq1GxxL3GjfaqEattAO7liQ2GKEmqSdQxkiBwpbhlBGBbkBf9TXPcfJ4B2PVSPrR9d0wigdu/67tJmNz1bTH4KbkcpuZoUDCleg/'.
+'ZwjQUMwpT2q0Cu1nyC12N9BlsagT/82ahKX/Tk0i14maJNjwv1+jisMq9zUNH1RTQQR4UdQP3KFeJIng/d+JKtLnRLqkQzE3ckK0'.
+'IqW9mQ0XW7X6VPSnt4CnAb4pZT0Tmj8d57hpzlIH919ZGKMql6cqCixSlRjzijSkhmw/VjtgcbFtflFdBGOV6qKUTapnZg2ieNRV'.
+'ZwG6oKx7VTLqATp3BS0b4AoQhjPAzq54oa15NqIKzOEhS3gDOd+FbXO24qAZbdPq8tWBZIaf6nSLwAivq/sbfAALIDM+enimCgXy'.
+'SzPrwiTnwjklI+k1usjQS9ZF3rOA5xR/5v9uoaEFZbDr+4rMoXzaHthK+ZQjtJbySSfRSCb44i/48jiTwslK/clcYMU7DkZ4jFfm'.
+'5fBskI0WW+A42Ch8jsdOAKlBPxjglRfwNGw5nkF/zRl/EBNReChY3PEMffmU71Nxb4z0YpXUhoSsYB8+YQwgIFZEMSRflrMXtDOt'.
+'tWfPTAv+fjG+eoavruKr/0Z8axm+NRXfWg6f3Jts6eayburY3amN5hnisBg6v7IDNkheCNMldJjK9rrjrGfBd2QOOqtA1F+MX6BO'.
+'p7j2fFu31mcmvFpflPSLuQqGTYB7fCXi07SxbUkYJWWtlLJOKWeVtVk2Nhq/2Pxobpi//E2uFl//dW51eWhhhc0na/azZ1Yuda0y'.
+'dV2kyqr/0Th1V9qbK6+JQmsz86H3B0n3vES65yXSPTcryzfnvzxQ7HJ12cvVFVgu1gI60P3FqFma+H8FyTXXVubm0mvDT1uQHA4A'.
+'MH9D9Fl2oA0IC+mSdJqt6LaDN5hP4q3jY/pAYwDcRfAI8Y9SiI4ewRCcEjoHoovCrTVFm4EP1Ws7JcE545N7uk5XzC4dQO7sABFU'.
+'lhzbd+teTtzGaQ2HK/47s9xPkzhonK49VdK8IOxQGrzjvzWQQV4fzWLICf/Dt0nAL5whjq6HjdP682fW0zX4/5nlT91hrpyWG19k'.
+'uerr33OShIOELLETB1PEBkn8L00OGLhGlcC0i657EQLsdwD33Tp8+ZbT8Y6j4RiaioiV8iK8r1Ug+u4ZwltPRZYIeoCaDVWuP01L'.
+'iGIfzExA9GzdegYNqj3l9DhoSewCMnH7A/AiTtfWoSIAWl9b4w9XIVgdY4B++h1dvFBHPeR3k9Dl0gQVO1G/xQlr9WeINGvw2nf4'.
+'Dpo27ESN02+fUZMgRTSfem+9htU+s/qoF5nU9W/XAddz/CbSmd5ra0+znqF0UVT9KXxY/w4QPc0+QF9AnS3xT6SPwuGFoNV3a1b9'.
+'+3WRPg0wSlk0A/+tEaZBILkBapJ2jtL4gRtHSDxqKgIN3aupYJa1784s6jj+LKiR66/nhFip1Pdr0FVQqdEkHvUDiZdQpd2RJVFn'.
+'cm0ATRL2r4IYAL5fs8S/MwuG2DhQ2oWVLjYW8irjOA/M07VJOOzYPTDmhigOxDu9NtMJOplu3baCdkOHl+BwMv7TBLf/E2huWQjs'.
+'0oKRSZlPU+yA5EwBnFmIcHeI+O5D1APFv+qE5pPucpvziErcl2klzWV0V9ZMmXN3eF9eEISUaXXNfFHPyl9de9KlwlPckGIYKytd'.
+'gX2lrhSwNfFC/8vak2vRl+RDwboaQnGUt55v1nwE97ZLbRk3rLvirHEJKuGAavH4S9tV7Kv7c64Um/aku1Iv9dkcHA80rqLj0vY9'.
+'ybPGnybh8CtaWGjjw3kLTSz34HwkDzbynl4s9eRxcUG33B1kg/tRAoWGT9gif7cLhZvLPaXRDyESeGDwl/Go7X64QtiitE4CzRPA'.
+'mR96Ozej6B48QH/woTbaDVGvUXRtgEytYa9it5hK074AVQiolnuAzFhR0K0APqxYsW/nIkQPj3y7dNmNU7LmQymz+QxQbIpoiMoL'.
+'xfqh5MpxxFYY+w8NUO7Ky3hs1FfkMFDJjxLoATSSHySSdDgUBNk8NNVEULhDYO6mNVOpkC+bR0e+m3bwZPu8DMWFzoE8Sr7n1O1v'.
+'a/Vn3zX5Op9ak6fqB7SMXOpEI1x1+qbj1JWeHPC5/3g6e/9JzV6nzn5BVXM9vEQEJy4G8hDG1afZeje+GqK73+2a/ICK1RisdtNF'.
+'W2hZkSPCFaiBmQ1FI3zSX+mB6sqQrV7kmf9/fDrkqIA8Hz5IgeVBfsD+KxABGNcBvptDBgPo8KRuPzN/N2JgTdSRUrOfPflrGGQe'.
+'cb8QBXT0M5XKr9CTKwz0i3SoAw3TnUoYxSHILStxQcq4hyoOisNbJ7orocrFfy12kk89VteyhOWyYP9txQhR1suLsguUU10qDyjo'.
+'GMAMa89MUzZO6YKLnI6vAMeaqiL+FTjp/v3aeiW11CUFKQ8y/krXqhGwSt/5GKWgNl8Y9dU1+9tnpmoHfWs/e772DM0SREe8TAxv'.
+'rM2FxZZi8wQANK+GD4Xs6fc5CNbstRyG79cVHPOyPC/k+e6pyIUhdxkX3EuM7gvUWUXPyFZ7BnM8WRNUpoGS9vXcboEMK6GapScy'.
+'4qK0wQGSvHltdbULPjH5xQ18z0Jb6GQ/uRyQAuU2dKpT+5eTYBIUA2MCx+UVdKvlqJPpdMEzzomXptejkeuH46l+JoRmVgURxGgE'.
+'lmeL1VFaF7+7E+uGTT52PftKE+zw+Y9t+O/773UR6RNwAFaxbDwzKC3LvcKCWnhKkQjO4ly3hTY0+Cxmq4Cs4c+4Om3ntvipQ8v6'.
+'YMeJtcHbti0a7dRmQRpJ0bZuiaR8Zkq2Auylq/kWd34ja7Bwyv0IN3+Pi2uNSpGBCESeZU0W8ajcagFNdKV7JPhCR3uQhIG4Y5qW'.
+'EZSNLKE3wQ2c7bCPgZakYbw0MsC8zZ7nLSHarYB5SIZOFBh1XgjzOw5//v9XKLNoVJpjO8DdHkkDXx7JLvOhv+xeIsKe54xcER3+'.
+'deO2JcetGDLlUdi6dxS2lVFIIel3d8/Sc1zSwJTscXWt4VZEmKyuNUWQshwqKyszuu4oF6eMq2Q0pKXwsGq4hCcGbisdUrfie6MO'.
+'8tkqDhuz2XbaK2tpdJcPhpv/ot30Mfa6AkmtEsmXFjbLN+xL8auhVS25m+Brh5oMlv29G1WI+/raOrUEL+rtGz3fzkwyYHcqb6qQ'.
+'ONp5c76/c8w3/eI6He2zEKl4uK++2e9r7TDotxItBhxxGLR0BWQNQN65SXIdxQDRioZLY43C4FSgdQTqo77VXJyRJqmQ8LEcGki+'.
+'QaJCPwXovagTDrUw0cLhldsPc0U+g+87AzfsF77/YeH1zs52RXNkclV7wpjbk8Ksqdiv42jYYdx/WHh3dPh6d2+nogDlC5UxlyAq'.
+'IBb0+uSd1pdNpcIsbV2ju3i1QQj8MxkUs61XZrO1owADcP0xSF7KL2v9anP7/Hhn82jrraN/jCaa72KNwIJuaa5GO2w0jtzVrsNx'.
+'F2Q5COWpNnJjdwDaME7sF178Ev+9A2WXaC9cjY4HXFrlg71xG+rSSyDqi1X3paWNI4GaqNwPRDXev9s7hHq8PjzaP9/df+Poq8lq'.
+'OOisnuPdyKvBcJV1pd0J25xh5/z4ZPPk/fGrzaPz7Z3Xm+/3Tk52fj7hfX6OtnQc9ANqazvqY1C9top7u9Vcx5s/7ZxneSjXm2Cs'.
+'4emFVbAnh4d7J7vvOIuApRZQjqSY5Wjn9VER/VHQBhp1IUMyroIvFiHhZTHlXFCx3YM3spxH1HL3Co1X2y7CnhyebO4hmxwLeAA+'.
+'icau6IiGxhk2f9j8+fzD5m5a8ew/yLAVDYdAWChBgT7eOdiuhD4G9YqcQ3szZY32j9+c7xwdaVpllp04jmIt8v0JDLzHWY7jo5/O'.
+'63MKweN/xIWFZFfEgR91huEneAH6jUCWBoIY2OeHP84p+jWRGa3UlpZM6E709qTfnyq1qM4rCNMBtTvpk+pNHucKXKvOsykHwf2F'.
+'YtPXKhGcgJgEBu9HuDqkBRnpgHYamAGYiqKUC2lF13SYNJq3eezr1dhxSasNpL12k+EvIBSkCaz2y+bJyRyKgP0KWghjo/OFPeW9'.
+'uI8eKZ0HYmoydKn1odcPNKV+rw/3tneOKvuLhnaSgR4cahI3IT+Ism8fd45z3z4GSa6L1ufzBPfOkpA7b452t2G04mEU5ziacuBH'.
+'Ad5BwvRm9AT+ZufkfG/34McidilvEokcgc7fH+1V1gXSGSdBvT3Z36uConRAmiiwIFff71dSEKzKKJ4M0goIWXrOcuLdztH5u803'.
+'Owxer2Ut2t59t4d0LQ3GLvMic9xtbaataLf1mRa1tdu12VIZwfnJuz0FQf40AC314VGApJfg2OPoPW6v4dAL3qzOx5PUzeUlTewT'.
+'hiFQKn+WVeCE5Ofbww/nr48O9/Mt0NpxNGgsVQGfHKrNHYf9fhnu/at9VXziWEDzTIHb2X938rFIP+JYaqoC+WoHOm+nAAqQeJKS'.
+'Arb5+gT6CqAeKTDY6JpKdLALzk92T1SmJcDP/8fnv3z+p8///Ot/0j7/4+f/S/v8v37+y6//y+d/+PxPGnz63z//Z+3zvwDEv3z+'.
+'r5//UUW3t31UwofoOPs/ahneYq79j/l8kGt/Who3W4d77/cPzunglxyZYJCVwd4d7f60ebKj0CgOr1x/WoY83v1zHuExKIsy2HaG'.
+'TYzAEcpP7KI50Gsq9HYlWElmoIipaMzO0e7htiqNp6MKsP0dcL+3c3wx1TjevaLZOSGAbDnAY2+q6HNSpE9VU7YO3x+cHH1UlSCg'.
+'i6e/udG7B1uHWVcD2O4QdE4F4Kv3H4/zFXQrOWd7r8Dp231VBh1+OEC7syjEtoWirADNCWcA3UutRaEXjk9guJYE7RHPA1VVEI9K'.
+'rSg7qOo/suXUVo/B4kiq6Pj6MFc+nog5D1/90SOqIc45zS20XmOwTW+S3Ae1RlBvaQ5hPtQ6QW0Jc6I/1eKHSn+uVlLzprQnvwy+'.
+'uXWye3igcjgf4FQCPNpXB3eKujy0918dwuPh+3evPqqKO44mI6hGCfTVx+1NhTUBtOVOkwqwDzs7P6pdeR0EF1Vw+8Aeb48zuEE0'.
+'HHcF4NbbzaMTAVnidDQupcVXAV+SL6T3QKmGUnKo0PeNtyJcJmYknHYV9Seyu/KVBlbND09w2LMhX0KdQqeo54GTt5PCp67OPPD1'.
+'2naefOs1Les5FbK+XyA09UgFgY929nNwozi4CqMJOO7VGZ4XEXfdfntlCl50GXbtYwF2TUNAWV0m7u7xu73Nj+cgy/ePC/0M4nyg'.
+'GM7bO3sFES37I8ABKizJzVcABuLq9S546WoW5LY40KbRBFwY8XDtDsfo7bcIA3ohibCLN6rQCcH5RSjFpLqWpD7+XLRgO23tnMvZ'.
+'BcR9H+IJq3fiESmZWBbnilDlCKPe2X5QJA==';
+$fp = fopen('data://text/plain;base64,' . $data, 'r');
+stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
+var_dump(fread($fp,1));
+var_dump(fread($fp,1));
+fclose($fp);
+echo "Done.\n";
+--EXPECT--
+string(0) ""
+string(0) ""
+Done.
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 56fdc0e..0192909 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zlib_filter.c 296107 2010-03-12 10:28:59Z jani $ */
+/* $Id: zlib_filter.c 303878 2010-09-29 18:58:58Z cataphract $ */
 
 #include "php.h"
 #include "php_zlib.h"
@@ -102,6 +102,9 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
 			} else if (status != Z_OK) {
 				/* Something bad happened */
 				php_stream_bucket_delref(bucket TSRMLS_CC);
+				/* reset these because despite the error the filter may be used again */
+				data->strm.next_in = data->inbuf;
+				data->strm.avail_in = 0;
 				return PSFS_ERR_FATAL;
 			}
 			desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */
diff --git a/ext/zlib/zlib_fopen_wrapper.c b/ext/zlib/zlib_fopen_wrapper.c
index 0866076..5253964 100644
--- a/ext/zlib/zlib_fopen_wrapper.c
+++ b/ext/zlib/zlib_fopen_wrapper.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: zlib_fopen_wrapper.c 296107 2010-03-12 10:28:59Z jani $ */
+/* $Id: zlib_fopen_wrapper.c 303772 2010-09-26 20:46:54Z pajoye $ */
 
 #define _GNU_SOURCE
 
@@ -128,7 +128,7 @@ php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mod
 		path += 5;
 	}
 	
-	innerstream = php_stream_open_wrapper(path, mode, STREAM_MUST_SEEK | options | STREAM_WILL_CAST, opened_path);
+	innerstream = php_stream_open_wrapper_ex(path, mode, STREAM_MUST_SEEK | options | STREAM_WILL_CAST, opened_path, context);
 	
 	if (innerstream) {
 		int fd;
diff --git a/main/SAPI.c b/main/SAPI.c
index 1fd6ffd..1681a41 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: SAPI.c 296362 2010-03-18 22:37:25Z andrei $ */
+/* $Id: SAPI.c 305481 2010-11-18 04:09:02Z cataphract $ */
 
 #include <ctype.h>
 #include <sys/stat.h>
@@ -194,7 +194,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
 	int read_bytes;
 	int allocated_bytes=SAPI_POST_BLOCK_SIZE+1;
 
-	if (SG(request_info).content_length > SG(post_max_size)) {
+	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",
 					SG(request_info).content_length, SG(post_max_size));
 		return;
@@ -207,7 +207,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
 			break;
 		}
 		SG(read_post_bytes) += read_bytes;
-		if (SG(read_post_bytes) > SG(post_max_size)) {
+		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));
 			break;
 		}
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 015be97..d171ea9 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: fopen_wrappers.c 298277 2010-04-21 22:22:31Z felipe $ */
+/* $Id: fopen_wrappers.c 305698 2010-11-23 22:14:54Z pajoye $ */
 
 /* {{{ includes
  */
@@ -173,21 +173,27 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
 	memcpy(path_tmp, resolved_name, path_len + 1); /* safe */
 
 	while (VCWD_REALPATH(path_tmp, resolved_name) == NULL) {
-#ifdef HAVE_SYMLINK
-		if (nesting_level == 0) {
-			int ret;
-			char buf[MAXPATHLEN];
-
-			ret = readlink(path_tmp, buf, MAXPATHLEN - 1);
-			if (ret < 0) {
-				/* not a broken symlink, move along.. */
-			} else {
-				/* put the real path into the path buffer */
-				memcpy(path_tmp, buf, ret);
-				path_tmp[ret] = '\0';
+#if defined(PHP_WIN32) || defined(HAVE_SYMLINK)
+#if defined(PHP_WIN32)
+		if (EG(windows_version_info).dwMajorVersion > 5) {
+#endif
+			if (nesting_level == 0) {
+				int ret;
+				char buf[MAXPATHLEN];
+
+				ret = php_sys_readlink(path_tmp, buf, MAXPATHLEN - 1);
+				if (ret < 0) {
+					/* not a broken symlink, move along.. */
+				} else {
+					/* put the real path into the path buffer */
+					memcpy(path_tmp, buf, ret);
+					path_tmp[ret] = '\0';
+				}
 			}
+#if defined(PHP_WIN32)
 		}
 #endif
+#endif
 
 #if defined(PHP_WIN32) || defined(NETWARE)
 		path_file = strrchr(path_tmp, DEFAULT_SLASH);
@@ -228,6 +234,9 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
 				resolved_basedir[resolved_basedir_len] = PHP_DIR_SEPARATOR;
 				resolved_basedir[++resolved_basedir_len] = '\0';
 			}
+		} else {
+				resolved_basedir[resolved_basedir_len++] = PHP_DIR_SEPARATOR;
+				resolved_basedir[resolved_basedir_len] = '\0';
 		}
 
 		resolved_name_len = strlen(resolved_name);
@@ -244,8 +253,13 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
 #else
 		if (strncmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {
 #endif
-			/* File is in the right directory */
-			return 0;
+			if (resolved_name_len > resolved_basedir_len &&
+				resolved_name[resolved_basedir_len - 1] != PHP_DIR_SEPARATOR) {
+				return -1;
+			} else {
+				/* File is in the right directory */
+				return 0;
+			}
 		} else {
 			/* /openbasedir/ and /openbasedir are the same directory */
 			if (resolved_basedir_len == (resolved_name_len + 1) && resolved_basedir[resolved_basedir_len - 1] == PHP_DIR_SEPARATOR) {
@@ -281,6 +295,14 @@ PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
 		char *ptr;
 		char *end;
 
+		/* Check if the path is too long so we can give a more useful error
+		* message. */
+		if (strlen(path) > (MAXPATHLEN - 1)) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "File name is longer than the maximum allowed path length on this platform (%d): %s", MAXPATHLEN, path);
+			errno = EINVAL;
+			return -1;
+		}
+
 		pathbuf = estrdup(PG(open_basedir));
 
 		ptr = pathbuf;
@@ -519,6 +541,10 @@ PHPAPI char *php_resolve_path(const char *filename, int filename_length, const c
 		return NULL;
 	}
 
+	if (strlen(filename) != filename_length) {
+		return NULL;
+	}
+
 	/* Don't resolve paths which contain protocol (except of file://) */
 	for (p = filename; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++);
 	if ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/')) {
diff --git a/main/main.c b/main/main.c
index 45751ad..4b52195 100644
--- a/main/main.c
+++ b/main/main.c
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c 296107 2010-03-12 10:28:59Z jani $ */
+/* $Id: main.c 305266 2010-11-11 01:43:53Z kalle $ */
 
 /* {{{ includes
  */
@@ -1944,6 +1944,11 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 	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_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
+#ifdef ZEND_MULTIBYTE
+	REGISTER_MAIN_LONG_CONSTANT("ZEND_MULTIBYTE", 1, CONST_PERSISTENT | CONST_CS);
+#else
+	REGISTER_MAIN_LONG_CONSTANT("ZEND_MULTIBYTE", 0, CONST_PERSISTENT | CONST_CS);
+#endif
 
 #ifdef PHP_WIN32
 	REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR",      EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS);
@@ -2076,14 +2081,14 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 
 		while (*p) {
 			if (cfg_get_long((char*)*p, &val) == SUCCESS && val) {
-				zend_error(E_WARNING, "Directive '%s' is deprecated in PHP 5.3 and greater", *p);
+				zend_error(E_DEPRECATED, "Directive '%s' is deprecated in PHP 5.3 and greater", *p);
 			}
 			++p;
 		}
 
 		/* This is not too nice, but since its the only one theres no need for extra stuff here */
 		if (cfg_get_long("zend.ze1_compatibility_mode", &val) == SUCCESS && val) {
-			zend_error(E_ERROR, "zend.ze1_compatibility_mode is no longer supported in PHP 5.3 and greater");
+			zend_error(E_CORE_ERROR, "zend.ze1_compatibility_mode is no longer supported in PHP 5.3 and greater");
 		}
 	}
 	
diff --git a/main/network.c b/main/network.c
index 542c7cf..4e2ce7c 100644
--- a/main/network.c
+++ b/main/network.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: network.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: network.c 303958 2010-10-02 18:32:20Z cataphract $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -125,7 +125,7 @@ static const char *php_gai_strerror(int code)
                 {EAI_MEMORY, "Memory allocation failure"},
 #  ifdef EAI_NODATA
                 {EAI_NODATA, "No address associated with hostname"},
-#  endif    
+#  endif
                 {EAI_NONAME, "Name or service not known"},
                 {EAI_SERVICE, "Servname not supported for ai_socktype"},
                 {EAI_SOCKTYPE, "ai_socktype not supported"},
@@ -139,7 +139,7 @@ static const char *php_gai_strerror(int code)
                         return (char *)values[i].msg;
                 }
         }
-        
+
         return "Unknown error";
 }
 /* }}} */
@@ -182,10 +182,10 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
 	}
 #if HAVE_GETADDRINFO
 	memset(&hints, '\0', sizeof(hints));
-		
+
 	hints.ai_family = AF_INET; /* default to regular inet (see below) */
 	hints.ai_socktype = socktype;
-		
+
 # if HAVE_IPV6
 	/* probe for a working IPv6 stack; even if detected as having v6 at compile
 	 * time, at runtime some stacks are slow to resolve or have other issues
@@ -206,7 +206,7 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
 	}
 	hints.ai_family = ipv6_borked ? AF_INET : AF_UNSPEC;
 # endif
-		
+
 	if ((n = getaddrinfo(host, NULL, &hints, &res))) {
 		if (error_string) {
 			spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
@@ -228,17 +228,17 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
 	sai = res;
 	for (n = 1; (sai = sai->ai_next) != NULL; n++)
 		;
-	
+
 	*sal = safe_emalloc((n + 1), sizeof(*sal), 0);
 	sai = res;
 	sap = *sal;
-	
+
 	do {
 		*sap = emalloc(sai->ai_addrlen);
 		memcpy(*sap, sai->ai_addr, sai->ai_addrlen);
 		sap++;
 	} while ((sai = sai->ai_next) != NULL);
-	
+
 	freeaddrinfo(res);
 #else
 	if (!inet_aton(host, &in)) {
@@ -313,7 +313,7 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
 	int ret = 0;
 
 	SET_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
-	
+
 	if ((n = connect(sockfd, addr, addrlen)) != 0) {
 		error = php_socket_errno();
 
@@ -337,8 +337,18 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
 	if (n == 0) {
 		goto ok;
 	}
-
+# ifdef PHP_WIN32
+	/* The documentation for connect() says in case of non-blocking connections
+	 * the select function reports success in the writefds set and failure in
+	 * the exceptfds set. Indeed, using PHP_POLLREADABLE results in select
+	 * failing only due to the timeout and not immediately as would be
+	 * expected when a connection is actively refused. This way,
+	 * php_pollfd_for will return a mask with POLLOUT if the connection
+	 * is successful and with POLLPRI otherwise. */
+	if ((n = php_pollfd_for(sockfd, POLLOUT|POLLPRI, timeout)) == 0) {
+#else
 	if ((n = php_pollfd_for(sockfd, PHP_POLLREADABLE|POLLOUT, timeout)) == 0) {
+#endif
 		error = PHP_TIMEOUT_ERROR_VALUE;
 	}
 
@@ -366,9 +376,11 @@ ok:
 		*error_code = error;
 	}
 
-	if (error && error_string) {
-		*error_string = php_socket_strerror(error, NULL, 0);
+	if (error) {
 		ret = -1;
+		if (error_string) {
+			*error_string = php_socket_strerror(error, NULL, 0);
+		}
 	}
 	return ret;
 #else
@@ -447,14 +459,14 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
 
 		if (sa) {
 			/* attempt to bind */
-		
+
 #ifdef SO_REUSEADDR
 			{
 				int val = 1;
 				setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(val));
 			}
 #endif
-			
+
 			n = bind(sock, sa, socklen);
 
 			if (n != SOCK_CONN_ERR) {
@@ -474,13 +486,13 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
 	if (error_string) {
 		*error_string = php_socket_strerror(err, NULL, 0);
 	}
-	
+
 bound:
 
 	php_network_freeaddresses(psal);
-	
+
 	return sock;
-	
+
 }
 /* }}} */
 
@@ -598,7 +610,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
 				/* generally not thread safe, but it *is* thread safe under win32 */
 				buf = inet_ntoa(((struct sockaddr_in*)sa)->sin_addr);
 				if (buf) {
-					*textaddrlen = spprintf(textaddr, 0, "%s:%d", 
+					*textaddrlen = spprintf(textaddr, 0, "%s:%d",
 						buf, ntohs(((struct sockaddr_in*)sa)->sin_port));
 				}
 
@@ -608,7 +620,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
 			case AF_INET6:
 				buf = (char*)inet_ntop(sa->sa_family, &((struct sockaddr_in6*)sa)->sin6_addr, (char *)&abuf, sizeof(abuf));
 				if (buf) {
-					*textaddrlen = spprintf(textaddr, 0, "%s:%d", 
+					*textaddrlen = spprintf(textaddr, 0, "%s:%d",
 						buf, ntohs(((struct sockaddr_in6*)sa)->sin6_port));
 				}
 
@@ -639,7 +651,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
 	}
 }
 
-PHPAPI int php_network_get_peer_name(php_socket_t sock, 
+PHPAPI int php_network_get_peer_name(php_socket_t sock,
 		char **textaddr, long *textaddrlen,
 		struct sockaddr **addr,
 		socklen_t *addrlen
@@ -648,7 +660,7 @@ PHPAPI int php_network_get_peer_name(php_socket_t sock,
 	php_sockaddr_storage sa;
 	socklen_t sl = sizeof(sa);
 	memset(&sa, 0, sizeof(sa));
-	
+
 	if (getpeername(sock, (struct sockaddr*)&sa, &sl) == 0) {
 		php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl,
 				textaddr, textaddrlen,
@@ -659,7 +671,7 @@ PHPAPI int php_network_get_peer_name(php_socket_t sock,
 	return -1;
 }
 
-PHPAPI int php_network_get_sock_name(php_socket_t sock, 
+PHPAPI int php_network_get_sock_name(php_socket_t sock,
 		char **textaddr, long *textaddrlen,
 		struct sockaddr **addr,
 		socklen_t *addrlen
@@ -668,7 +680,7 @@ PHPAPI int php_network_get_sock_name(php_socket_t sock,
 	php_sockaddr_storage sa;
 	socklen_t sl = sizeof(sa);
 	memset(&sa, 0, sizeof(sa));
-	
+
 	if (getsockname(sock, (struct sockaddr*)&sa, &sl) == 0) {
 		php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl,
 				textaddr, textaddrlen,
@@ -703,7 +715,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
 	int error = 0, n;
 	php_sockaddr_storage sa;
 	socklen_t sl;
-		
+
 	n = php_pollfd_for(srvsock, PHP_POLLREADABLE, timeout);
 
 	if (n == 0) {
@@ -724,18 +736,18 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
 			error = php_socket_errno();
 		}
 	}
-	
+
 	if (error_code) {
 		*error_code = error;
 	}
 	if (error_string) {
 		*error_string = php_socket_strerror(error, NULL, 0);
 	}
-	
+
 	return clisock;
 }
 /* }}} */
-	
+
 
 
 /* Connect to a remote host using an interruptible connect with optional timeout.
@@ -747,7 +759,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
 /* {{{ php_network_connect_socket_to_host */
 php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
 		int socktype, int asynchronous, struct timeval *timeout, char **error_string,
-		int *error_code, char *bindto, unsigned short bindport 
+		int *error_code, char *bindto, unsigned short bindport
 		TSRMLS_DC)
 {
 	int num_addrs, n, fatal = 0;
@@ -825,7 +837,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
 
 					local_address = (struct sockaddr*)in4;
 					local_address_len = sizeof(struct sockaddr_in);
-				
+
 					in4->sin_family = sa->sa_family;
 					in4->sin_port = htons(bindport);
 					if (!inet_aton(bindto, &in4->sin_addr)) {
@@ -840,7 +852,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
 
 					local_address = (struct sockaddr*)in6;
 					local_address_len = sizeof(struct sockaddr_in6);
-				
+
 					in6->sin6_family = sa->sa_family;
 					in6->sin6_port = htons(bindport);
 					if (inet_pton(AF_INET6, bindto, &in6->sin6_addr) < 1) {
@@ -862,7 +874,7 @@ skip_bind:
 				efree(*error_string);
 				*error_string = NULL;
 			}
-			
+
 			n = php_network_connect_socket(sock, sa, socklen, asynchronous,
 					timeout ? &working_timeout : NULL,
 					error_string, error_code);
@@ -907,7 +919,7 @@ skip_bind:
 connected:
 
 	php_network_freeaddresses(psal);
-	
+
 	return sock;
 }
 /* }}} */
@@ -984,7 +996,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
 	int free_it = 1;
 
 	if (!FormatMessage(
-				FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+				FORMAT_MESSAGE_ALLOCATE_BUFFER |
 				FORMAT_MESSAGE_FROM_SYSTEM |
 				FORMAT_MESSAGE_IGNORE_INSERTS,
 				NULL,
@@ -1065,7 +1077,7 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC)
 	flags = !block;
 	if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) {
 		char *error_string;
-		
+
 		error_string = php_socket_strerror(WSAGetLastError(), NULL, 0);
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error_string);
 		efree(error_string);
diff --git a/main/output.c b/main/output.c
index f7b1e0c..681e4ce 100644
--- a/main/output.c
+++ b/main/output.c
@@ -1,4 +1,4 @@
-/* 
+/*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
    +----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: output.c 296107 2010-03-12 10:28:59Z jani $ */
+/* $Id: output.c 305950 2010-12-03 16:04:24Z jani $ */
 
 #include "php.h"
 #include "ext/standard/head.h"
@@ -61,7 +61,7 @@ PHPAPI int php_default_output_func(const char *str, uint str_len TSRMLS_DC)
 /* {{{ php_output_init_globals */
 static void php_output_init_globals(php_output_globals *output_globals_p TSRMLS_DC)
 {
- 	OG(php_body_write) = php_default_output_func;
+	OG(php_body_write) = php_default_output_func;
 	OG(php_header_write) = php_default_output_func;
 	OG(implicit_flush) = 0;
 	OG(output_start_filename) = NULL;
@@ -69,22 +69,20 @@ static void php_output_init_globals(php_output_globals *output_globals_p TSRMLS_
 }
 /* }}} */
 
-
 /* {{{ php_output_startup
-   Start output layer */
+ * Start output layer */
 PHPAPI void php_output_startup(void)
 {
 #ifdef ZTS
 	ts_allocate_id(&output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
-#else 
+#else
 	php_output_init_globals(&output_globals TSRMLS_CC);
 #endif
 }
 /* }}} */
 
-
 /* {{{ php_output_activate
-   Initilize output global for activation */
+ * Initilize output global for activation */
 PHPAPI void php_output_activate(TSRMLS_D)
 {
 	OG(php_body_write) = php_ub_body_write;
@@ -97,15 +95,6 @@ PHPAPI void php_output_activate(TSRMLS_D)
 }
 /* }}} */
 
-
-/* {{{ php_output_set_status
-   Toggle output status.  Do NOT use in application code, only in SAPIs where appropriate. */
-PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC)
-{
-	OG(disable_output) = !status;
-}
-/* }}} */
-
 /* {{{ php_output_register_constants */
 void php_output_register_constants(TSRMLS_D)
 {
@@ -115,12 +104,19 @@ void php_output_register_constants(TSRMLS_D)
 }
 /* }}} */
 
+/* {{{ php_output_set_status
+ * Toggle output status.  Do NOT use in application code, only in SAPIs where appropriate. */
+PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC)
+{
+	OG(disable_output) = !status;
+}
+/* }}} */
 
 /* {{{ php_body_write
  * Write body part */
 PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC)
 {
-	return OG(php_body_write)(str, str_length TSRMLS_CC);	
+	return OG(php_body_write)(str, str_length TSRMLS_CC);
 }
 /* }}} */
 
@@ -219,7 +215,7 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS
 	 fclose(fp);
  }
 #endif
-	
+
 	if (OG(active_ob_buffer).internal_output_handler) {
 		final_buffer = OG(active_ob_buffer).internal_output_handler_buffer;
 		final_buffer_length = OG(active_ob_buffer).internal_output_handler_buffer_size;
@@ -343,7 +339,7 @@ PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC)
  */
 PHPAPI void php_start_implicit_flush(TSRMLS_D)
 {
-	OG(implicit_flush)=1;
+	OG(implicit_flush) = 1;
 }
 /* }}} */
 
@@ -351,7 +347,23 @@ PHPAPI void php_start_implicit_flush(TSRMLS_D)
  */
 PHPAPI void php_end_implicit_flush(TSRMLS_D)
 {
-	OG(implicit_flush)=0;
+	OG(implicit_flush) = 0;
+}
+/* }}} */
+
+/* {{{ char *php_get_output_start_filename(TSRMLS_D)
+ *  Return filename start output something */
+PHPAPI char *php_get_output_start_filename(TSRMLS_D)
+{
+	return OG(output_start_filename);
+}
+/* }}} */
+
+/* {{{ char *php_get_output_start_lineno(TSRMLS_D)
+ * Return line number start output something */
+PHPAPI int php_get_output_start_lineno(TSRMLS_D)
+{
+	return OG(output_start_lineno);
 }
 /* }}} */
 
@@ -359,7 +371,7 @@ PHPAPI void php_end_implicit_flush(TSRMLS_D)
  */
 PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size, char *handler_name, zend_bool erase TSRMLS_DC)
 {
-	if (OG(ob_nesting_level)==0 || OG(active_ob_buffer).internal_output_handler || strcmp(OG(active_ob_buffer).handler_name, OB_DEFAULT_HANDLER_NAME)) {
+	if (OG(ob_nesting_level) == 0 || OG(active_ob_buffer).internal_output_handler || strcmp(OG(active_ob_buffer).handler_name, OB_DEFAULT_HANDLER_NAME)) {
 		php_start_ob_buffer(NULL, buffer_size, erase TSRMLS_CC);
 	}
 
@@ -398,8 +410,7 @@ static inline void php_ob_allocate(uint text_length TSRMLS_DC)
 /* }}} */
 
 /* {{{ php_ob_init_conflict
- * Returns 1 if handler_set is already used and generates error message
- */
+ * Returns 1 if handler_set is already used and generates error message */
 PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC)
 {
 	if (php_ob_handler_used(handler_set TSRMLS_CC)) {
@@ -419,7 +430,7 @@ static int php_ob_init_named(uint initial_size, uint block_size, char *handler_n
 	if (output_handler && !zend_is_callable(output_handler, 0, NULL TSRMLS_CC)) {
 		return FAILURE;
 	}
-	
+
 	tmp_buf.block_size = block_size;
 	tmp_buf.size = initial_size;
 	tmp_buf.buffer = (char *) emalloc(initial_size+1);
@@ -452,8 +463,7 @@ static int php_ob_init_named(uint initial_size, uint block_size, char *handler_n
 /* }}} */
 
 /* {{{ php_ob_handler_from_string
- * Create zval output handler from string 
- */
+ * Create zval output handler from string */
 static zval* php_ob_handler_from_string(const char *handler_name, int len TSRMLS_DC)
 {
 	zval *output_handler;
@@ -544,36 +554,16 @@ static int php_ob_init(uint initial_size, uint block_size, zval *output_handler,
 
 /* {{{ php_ob_list_each
  */
-static int php_ob_list_each(php_ob_buffer *ob_buffer, zval *ob_handler_array) 
+static int php_ob_list_each(php_ob_buffer *ob_buffer, zval *ob_handler_array)
 {
 	add_next_index_string(ob_handler_array, ob_buffer->handler_name, 1);
 	return 0;
 }
 /* }}} */
 
-/* {{{ proto false|array ob_list_handlers()
- *  List all output_buffers in an array 
- */
-PHP_FUNCTION(ob_list_handlers)
-{
-	if (zend_parse_parameters_none() == FAILURE) {
-		return;
-	}
-	
-	array_init(return_value);
-	if (OG(ob_nesting_level)) {
-		if (OG(ob_nesting_level)>1) {
-			zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_ob_list_each, return_value);
-		}
-		php_ob_list_each(&OG(active_ob_buffer), return_value);
-	}
-}
-/* }}} */
-
 /* {{{ php_ob_used_each
- *  Sets handler_name to NULL is found
- */
-static int php_ob_handler_used_each(php_ob_buffer *ob_buffer, char **handler_name) 
+   Sets handler_name to NULL is found */
+static int php_ob_handler_used_each(php_ob_buffer *ob_buffer, char **handler_name)
 {
 	if (!strcmp(ob_buffer->handler_name, *handler_name)) {
 		*handler_name = NULL;
@@ -584,8 +574,7 @@ static int php_ob_handler_used_each(php_ob_buffer *ob_buffer, char **handler_nam
 /* }}} */
 
 /* {{{ php_ob_used
- * returns 1 if given handler_name is used as output_handler
- */
+   returns 1 if given handler_name is used as output_handler */
 PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC)
 {
 	char *tmp = handler_name;
@@ -616,10 +605,10 @@ static inline void php_ob_append(const char *text, uint text_length TSRMLS_DC)
 	memcpy(target, text, text_length);
 	target[text_length]=0;
 
- 	/* If implicit_flush is On or chunked buffering, send contents to next buffer and return. */
+	/* If implicit_flush is On or chunked buffering, send contents to next buffer and return. */
 	if (OG(active_ob_buffer).chunk_size
 		&& OG(active_ob_buffer).text_length >= OG(active_ob_buffer).chunk_size) {
-		
+
 		php_end_ob_buffer(1, 1 TSRMLS_CC);
 		return;
 	}
@@ -646,7 +635,6 @@ static inline void php_ob_prepend(const char *text, uint text_length)
 }
 #endif
 
-
 /* {{{ php_ob_get_buffer
  * Return the current output buffer */
 PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC)
@@ -675,7 +663,6 @@ PHPAPI int php_ob_get_length(zval *p TSRMLS_DC)
  * Wrapper functions - implementation
  */
 
-
 /* buffered output function */
 static int php_b_body_write(const char *str, uint str_length TSRMLS_DC)
 {
@@ -691,7 +678,7 @@ PHPAPI int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_D
 
 	if (OG(disable_output)) {
 		return 0;
-	}		
+	}
 
 	result = OG(php_header_write)(str, str_length TSRMLS_CC);
 
@@ -733,26 +720,56 @@ PHPAPI int php_ub_body_write(const char *str, uint str_length TSRMLS_DC)
 }
 /* }}} */
 
+/* {{{ int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result)
+ */
+static int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result)
+{
+	zval *elem;
+
+	MAKE_STD_ZVAL(elem);
+	array_init(elem);
+
+	add_assoc_long(elem, "chunk_size", ob_buffer->chunk_size);
+	if (!ob_buffer->chunk_size) {
+		add_assoc_long(elem, "size", ob_buffer->size);
+		add_assoc_long(elem, "block_size", ob_buffer->block_size);
+	}
+	if (ob_buffer->internal_output_handler) {
+		add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_INTERNAL);
+		add_assoc_long(elem, "buffer_size", ob_buffer->internal_output_handler_buffer_size);
+	} else {
+		add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_USER);
+	}
+	add_assoc_long(elem, "status", ob_buffer->status);
+	add_assoc_string(elem, "name", ob_buffer->handler_name, 1);
+	add_assoc_bool(elem, "del", ob_buffer->erase);
+	add_next_index_zval(result, elem);
+
+	return SUCCESS;
+}
+/* }}} */
+
 /*
- * HEAD support
+ * USERLAND (nearly 1:1 of old output.c)
  */
 
-/* {{{ proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
+/* {{{ proto bool ob_start([string|array user_function [, int chunk_size [, bool erase]]])
    Turn on Output Buffering (specifying an optional output handler). */
 PHP_FUNCTION(ob_start)
 {
-	zval *output_handler=NULL;
-	long chunk_size=0;
-	zend_bool erase=1;
+	zval *output_handler = NULL;
+	long chunk_size = 0;
+	zend_bool erase = 1;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zlb", &output_handler, &chunk_size, &erase) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/lb", &output_handler, &chunk_size, &erase) == FAILURE) {
 		return;
 	}
 
-	if (chunk_size < 0)
+	if (chunk_size < 0) {
 		chunk_size = 0;
+	}
 
-	if (php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC)==FAILURE) {
+	if (php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
 	RETURN_TRUE;
@@ -768,21 +785,20 @@ PHP_FUNCTION(ob_flush)
 	}
 
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer. No buffer to flush");
 		RETURN_FALSE;
 	}
-	
+
 	if (!OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer %s", OG(active_ob_buffer).handler_name);
 		RETURN_FALSE;
 	}
-	
+
 	php_end_ob_buffer(1, 1 TSRMLS_CC);
 	RETURN_TRUE;
 }
 /* }}} */
 
-
 /* {{{ proto bool ob_clean(void)
    Clean (delete) the current output buffer */
 PHP_FUNCTION(ob_clean)
@@ -790,17 +806,17 @@ PHP_FUNCTION(ob_clean)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-	
+
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete");
 		RETURN_FALSE;
 	}
 
 	if (!OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s", OG(active_ob_buffer).handler_name);
 		RETURN_FALSE;
 	}
-	
+
 	php_end_ob_buffer(0, 1 TSRMLS_CC);
 	RETURN_TRUE;
 }
@@ -813,16 +829,17 @@ PHP_FUNCTION(ob_end_flush)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-	
+
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
 		RETURN_FALSE;
 	}
+
 	if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s", OG(active_ob_buffer).handler_name);
 		RETURN_FALSE;
 	}
-	
+
 	php_end_ob_buffer(1, 0 TSRMLS_CC);
 	RETURN_TRUE;
 }
@@ -835,16 +852,17 @@ PHP_FUNCTION(ob_end_clean)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-		
+
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete");
 		RETURN_FALSE;
 	}
+
 	if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s", OG(active_ob_buffer).handler_name);
 		RETURN_FALSE;
 	}
-	
+
 	php_end_ob_buffer(0, 0 TSRMLS_CC);
 	RETURN_TRUE;
 }
@@ -858,22 +876,22 @@ PHP_FUNCTION(ob_get_flush)
 		return;
 	}
 
-	/* get contents */
-	if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+	if (php_ob_get_buffer(return_value TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
-	/* error checks */
+
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
 		zval_dtor(return_value);
 		RETURN_FALSE;
 	}
+
 	if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s", OG(active_ob_buffer).handler_name);
 		zval_dtor(return_value);
 		RETURN_FALSE;
 	}
-	/* flush */
+
 	php_end_ob_buffer(1, 0 TSRMLS_CC);
 }
 /* }}} */
@@ -885,22 +903,22 @@ PHP_FUNCTION(ob_get_clean)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-	/* get contents */
-	if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+
+	if (php_ob_get_buffer(return_value TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
-	/* error checks */
+
 	if (!OG(ob_nesting_level)) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete");
 		zval_dtor(return_value);
 		RETURN_FALSE;
 	}
 	if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
-		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+		php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s", OG(active_ob_buffer).handler_name);
 		zval_dtor(return_value);
 		RETURN_FALSE;
 	}
-	/* delete buffer */
+
 	php_end_ob_buffer(0, 0 TSRMLS_CC);
 }
 /* }}} */
@@ -912,8 +930,8 @@ PHP_FUNCTION(ob_get_contents)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-		
-	if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+
+	if (php_ob_get_buffer(return_value TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
 }
@@ -926,8 +944,8 @@ PHP_FUNCTION(ob_get_level)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-		
-	RETURN_LONG (OG(ob_nesting_level));
+
+	RETURN_LONG(OG(ob_nesting_level));
 }
 /* }}} */
 
@@ -938,63 +956,52 @@ PHP_FUNCTION(ob_get_length)
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
-		
-	if (php_ob_get_length(return_value TSRMLS_CC)==FAILURE) {
+
+	if (php_ob_get_length(return_value TSRMLS_CC) == FAILURE) {
 		RETURN_FALSE;
 	}
 }
 /* }}} */
 
-/* {{{ int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result) */
-static int php_ob_buffer_status(php_ob_buffer *ob_buffer, zval *result) 
+/* {{{ proto false|array ob_list_handlers()
+   List all output_buffers in an array */
+PHP_FUNCTION(ob_list_handlers)
 {
-	zval *elem;
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
 
-	MAKE_STD_ZVAL(elem);
-	array_init(elem);
+	array_init(return_value);
 
-	add_assoc_long(elem, "chunk_size", ob_buffer->chunk_size);
-	if (!ob_buffer->chunk_size) {
-		add_assoc_long(elem, "size", ob_buffer->size);
-		add_assoc_long(elem, "block_size", ob_buffer->block_size);
-	}
-	if (ob_buffer->internal_output_handler) {
-		add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_INTERNAL);
-		add_assoc_long(elem, "buffer_size", ob_buffer->internal_output_handler_buffer_size);
-	}
-	else {
-		add_assoc_long(elem, "type", PHP_OUTPUT_HANDLER_USER);
+	if (OG(ob_nesting_level)) {
+		if (OG(ob_nesting_level) > 1) {
+			zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_ob_list_each, return_value);
+		}
+		php_ob_list_each(&OG(active_ob_buffer), return_value);
 	}
-	add_assoc_long(elem, "status", ob_buffer->status);
-	add_assoc_string(elem, "name", ob_buffer->handler_name, 1);
-	add_assoc_bool(elem, "del", ob_buffer->erase);
-	add_next_index_zval(result, elem);
-
-	return SUCCESS;
 }
 /* }}} */
 
-
 /* {{{ proto false|array ob_get_status([bool full_status])
    Return the status of the active or all output buffers */
 PHP_FUNCTION(ob_get_status)
 {
 	zend_bool full_status = 0;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &full_status) == FAILURE ) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &full_status) == FAILURE) {
 		return;
 	}
 
 	array_init(return_value);
 
 	if (full_status) {
-		if (OG(ob_nesting_level)>1) {
+		if (OG(ob_nesting_level) > 1) {
 			zend_stack_apply_with_argument(&OG(ob_buffers), ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *elem, void *))php_ob_buffer_status, return_value);
 		}
-		if (OG(ob_nesting_level)>0 && php_ob_buffer_status(&OG(active_ob_buffer), return_value)==FAILURE) {
+		if (OG(ob_nesting_level) > 0 && php_ob_buffer_status(&OG(active_ob_buffer), return_value) == FAILURE) {
 			RETURN_FALSE;
 		}
-	} else if (OG(ob_nesting_level)>0) {
+	} else if (OG(ob_nesting_level) > 0) {
 		add_assoc_long(return_value, "level", OG(ob_nesting_level));
 		if (OG(active_ob_buffer).internal_output_handler) {
 			add_assoc_long(return_value, "type", PHP_OUTPUT_HANDLER_INTERNAL);
@@ -1008,7 +1015,6 @@ PHP_FUNCTION(ob_get_status)
 }
 /* }}} */
 
-
 /* {{{ proto void ob_implicit_flush([int flag])
    Turn implicit flush on/off and is equivalent to calling flush() after every output call */
 PHP_FUNCTION(ob_implicit_flush)
@@ -1027,25 +1033,6 @@ PHP_FUNCTION(ob_implicit_flush)
 }
 /* }}} */
 
-
-/* {{{ char *php_get_output_start_filename(TSRMLS_D)
-   Return filename start output something */
-PHPAPI char *php_get_output_start_filename(TSRMLS_D)
-{
-	return OG(output_start_filename);
-}
-/* }}} */
-
-
-/* {{{ char *php_get_output_start_lineno(TSRMLS_D)
-   Return line number start output something */
-PHPAPI int php_get_output_start_lineno(TSRMLS_D)
-{
-	return OG(output_start_lineno);
-}
-/* }}} */
-
-
 /* {{{ proto bool output_reset_rewrite_vars(void)
    Reset(clear) URL rewriter values */
 PHP_FUNCTION(output_reset_rewrite_vars)
@@ -1058,7 +1045,6 @@ PHP_FUNCTION(output_reset_rewrite_vars)
 }
 /* }}} */
 
-
 /* {{{ proto bool output_add_rewrite_var(string name, string value)
    Add URL rewriter values */
 PHP_FUNCTION(output_add_rewrite_var)
diff --git a/main/php_config.h.in b/main/php_config.h.in
index d62d836..ff2e503 100644
--- a/main/php_config.h.in
+++ b/main/php_config.h.in
@@ -467,6 +467,9 @@
 /* Define if you have the setpriority function.  */
 #undef HAVE_SETPRIORITY
 
+/* Define if you have the setproctitle function.  */
+#undef HAVE_SETPROCTITLE
+
 /* Define if you have the setsid function.  */
 #undef HAVE_SETSID
 
@@ -953,9 +956,6 @@
 /* Whether you have a Continuity Server */
 #undef HAVE_CONTINUITY
 
-/* define if libevent is available */
-#undef HAVE_LIBEVENT
-
 /* do we have prctl? */
 #undef HAVE_PRCTL
 
@@ -974,8 +974,14 @@
 /* /proc/pid/mem interface */
 #undef PROC_MEM_FILE
 
-/* fpm version */
-#undef PHP_FPM_VERSION
+/* Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o. */
+#undef HAVE_BUILTIN_ATOMIC
+
+/* do we have TCP_INFO? */
+#undef HAVE_LQ_TCP_INFO
+
+/* do we have SO_LISTENQxxx? */
+#undef HAVE_LQ_SO_LISTENQ
 
 /* fpm user name */
 #undef PHP_FPM_USER
@@ -1173,9 +1179,6 @@
 #undef HAVE_NANOSLEEP
 
 /*   */
-#undef HAVE_NANOSLEEP
-
-/*   */
 #undef HAVE_LIBRT
 
 /* Define if you have the getaddrinfo function */
diff --git a/main/php_ini.c b/main/php_ini.c
index 13ed8a5..ff7adaf 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ini.c 300272 2010-06-08 12:54:11Z tony2001 $ */
+/* $Id: php_ini.c 303199 2010-09-09 05:11:05Z aharvey $ */
 
 #include "php.h"
 #include "ext/standard/info.h"
@@ -201,6 +201,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
 /* Reset / free active_ini_sectin global */
 #define RESET_ACTIVE_INI_HASH() do { \
 	active_ini_hash = NULL;          \
+	is_special_section = 0;          \
 } while (0)
 /* }}} */
 
@@ -398,13 +399,39 @@ int php_init_config(TSRMLS_D)
 		static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
 #ifdef PHP_WIN32
 		char *reg_location;
+		char phprc_path[MAXPATHLEN];
 #endif
 
 		env_location = getenv("PHPRC");
+
+#ifdef PHP_WIN32
+		if (!env_location) {
+			char dummybuf;
+			int size;
+
+			SetLastError(0);
+
+			/*If the given bugger is not large enough to hold the data, the return value is 
+			the buffer size,  in characters, required to hold the string and its terminating 
+			null character. We use this return value to alloc the final buffer. */
+			size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
+			if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+				/* The environment variable doesn't exist. */
+				env_location = "";
+			} else {
+				if (size == 0) {
+					env_location = "";
+				} else {
+					size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
+					env_location = phprc_path;
+				}
+			}
+		}
+#else
 		if (!env_location) {
 			env_location = "";
 		}
-
+#endif
 		/*
 		 * Prepare search path
 		 */
@@ -628,9 +655,6 @@ int php_init_config(TSRMLS_D)
 		zend_llist_element *element;
 		int l, total_l = 0;
 
-		/* Reset active ini section */
-		RESET_ACTIVE_INI_HASH();
-
 		if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
 			zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
 			memset(&fh, 0, sizeof(fh));
@@ -642,6 +666,9 @@ int php_init_config(TSRMLS_D)
 					free(namelist[i]);
 					continue;
 				}
+				/* Reset active ini section */
+				RESET_ACTIVE_INI_HASH();
+
 				if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) {
 					snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name);
 				} else {
diff --git a/main/php_streams.h b/main/php_streams.h
index 2da3a5f..c496781 100755
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_streams.h 305108 2010-11-05 18:53:48Z cataphract $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -416,8 +416,8 @@ END_EXTERN_C()
 #define PHP_STREAM_OPTION_RETURN_ERR		-1 /* problem setting option */
 #define PHP_STREAM_OPTION_RETURN_NOTIMPL	-2 /* underlying stream does not implement; streams can handle it instead */
 
-/* copy up to maxlen bytes from src to dest.  If maxlen is PHP_STREAM_COPY_ALL, copy until eof(src).
- * Uses mmap if the src is a plain file and at offset 0 */
+/* copy up to maxlen bytes from src to dest.  If maxlen is PHP_STREAM_COPY_ALL,
+ * copy until eof(src). */
 #define PHP_STREAM_COPY_ALL		((size_t)-1)
 
 BEGIN_EXTERN_C()
@@ -428,8 +428,8 @@ PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, s
 #define php_stream_copy_to_stream_ex(src, dest, maxlen, len)	_php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC)
 
 
-/* read all data from stream and put into a buffer. Caller must free buffer when done.
- * The copy will use mmap if available. */
+/* read all data from stream and put into a buffer. Caller must free buffer
+ * when done. */
 PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen,
 		int persistent STREAMS_DC TSRMLS_DC);
 #define php_stream_copy_to_mem(src, buf, maxlen, persistent) _php_stream_copy_to_mem((src), (buf), (maxlen), (persistent) STREAMS_CC TSRMLS_CC)
diff --git a/main/php_version.h b/main/php_version.h
index 7be2a1b..75b2a8d 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -2,7 +2,7 @@
 /* edit configure.in to change version number */
 #define PHP_MAJOR_VERSION 5
 #define PHP_MINOR_VERSION 3
-#define PHP_RELEASE_VERSION 3
+#define PHP_RELEASE_VERSION 5
 #define PHP_EXTRA_VERSION ""
-#define PHP_VERSION "5.3.3"
-#define PHP_VERSION_ID 50303
+#define PHP_VERSION "5.3.5"
+#define PHP_VERSION_ID 50305
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 351c54f..f10395d 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: rfc1867.c 296362 2010-03-18 22:37:25Z andrei $ */
+/* $Id: rfc1867.c 303970 2010-10-04 01:27:33Z cataphract $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1011,16 +1011,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 			}
 
 			total_bytes = cancel_upload = 0;
-
-			if (!skip_upload) {
-				/* Handle file */
-				fd = php_open_temporary_fd_ex(PG(upload_tmp_dir), "php", &temp_filename, 1 TSRMLS_CC);
-				upload_cnt--;
-				if (fd == -1) {
-					sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
-					cancel_upload = UPLOAD_ERROR_E;
-				}
-			}
+			temp_filename = NULL;
+			fd = -1;
 
 			if (!skip_upload && php_rfc1867_callback != NULL) {
 				multipart_event_file_start event_file_start;
@@ -1029,13 +1021,6 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 				event_file_start.name = param;
 				event_file_start.filename = &filename;
 				if (php_rfc1867_callback(MULTIPART_EVENT_FILE_START, &event_file_start, &event_extra_data TSRMLS_CC) == FAILURE) {
-					if (temp_filename) {
-						if (cancel_upload != UPLOAD_ERROR_E) { /* file creation failed */
-							close(fd);
-							unlink(temp_filename);
-						}
-						efree(temp_filename);
-					}
 					temp_filename = "";
 					efree(param);
 					efree(filename);
@@ -1058,7 +1043,26 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 
 			offset = 0;
 			end = 0;
-			while (!cancel_upload && (blen = multipart_buffer_read(mbuff, buff, sizeof(buff), &end TSRMLS_CC)))
+			
+			if (!cancel_upload) {
+				/* only bother to open temp file if we have data */
+				blen = multipart_buffer_read(mbuff, buff, sizeof(buff), &end TSRMLS_CC);
+#if DEBUG_FILE_UPLOAD
+				if (blen > 0) {
+#else
+				/* in non-debug mode we have no problem with 0-length files */
+				{
+#endif
+					fd = php_open_temporary_fd_ex(PG(upload_tmp_dir), "php", &temp_filename, 1 TSRMLS_CC);
+					upload_cnt--;
+					if (fd == -1) {
+						sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
+						cancel_upload = UPLOAD_ERROR_E;
+					}
+				}
+			}
+
+			while (!cancel_upload && (blen > 0))
 			{
 				if (php_rfc1867_callback != NULL) {
 					multipart_event_file_data event_file_data;
@@ -1103,10 +1107,15 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
 					}
 					offset += wlen;
 				}
+
+				/* read data for next iteration */
+				blen = multipart_buffer_read(mbuff, buff, sizeof(buff), &end TSRMLS_CC);
 			}
+
 			if (fd != -1) { /* may not be initialized if file could not be created */
 				close(fd);
 			}
+
 			if (!cancel_upload && !end) {
 #if DEBUG_FILE_UPLOAD
 				sapi_module.sapi_error(E_NOTICE, "Missing mime boundary at the end of the data for file %s", strlen(filename) > 0 ? filename : "");
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 9117466..85136f0 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cast.c 293732 2010-01-19 13:44:08Z jani $ */
+/* $Id: cast.c 305108 2010-11-05 18:53:48Z cataphract $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -144,6 +144,50 @@ static COOKIE_IO_FUNCTIONS_T stream_cookie_functions =
 #endif
 /* }}} */
 
+/* {{{ php_stream_mode_sanitize_fdopen_fopencookie
+ * Result should have at least size 5, e.g. to write wbx+\0 */
+void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result)
+{
+	/* replace modes not supported by fdopen and fopencookie, but supported 
+	 * by PHP's fread(), so that their calls won't fail */
+	const char *cur_mode = stream->mode;
+	int         has_plus = 0,
+		        has_bin  = 0,
+				i,
+				res_curs = 0;
+
+	if (cur_mode[0] == 'r' || cur_mode[0] == 'w' || cur_mode[0] == 'a') {
+		result[res_curs++] = cur_mode[0];
+	} else {
+		/* assume cur_mode[0] is 'c' or 'x'; substitute by 'w', which should not
+		 * truncate anything in fdopen/fopencookie */
+		result[res_curs++] = 'w';
+
+		/* x is allowed (at least by glibc & compat), but not as the 1st mode
+		 * as in PHP and in any case is (at best) ignored by fdopen and fopencookie */
+	}
+	
+	/* assume current mode has at most length 4 (e.g. wbn+) */
+	for (i = 1; i < 4 && cur_mode[i] != '\0'; i++) {
+		if (cur_mode[i] == 'b') {
+			has_bin = 1;
+		} else if (cur_mode[i] == '+') {
+			has_plus = 1;
+		}
+		/* ignore 'n', 't' or other stuff */
+	}
+
+	if (has_bin) {
+		result[res_curs++] = 'b';
+	}
+	if (has_plus) {
+		result[res_curs++] = '+';
+	}
+
+	result[res_curs] = '\0';
+}
+/* }}} */
+
 /* {{{ php_stream_cast */
 PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show_err TSRMLS_DC)
 {
@@ -187,7 +231,11 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
 			goto exit_success;
 		}
 
-		*(FILE**)ret = fopencookie(stream, stream->mode, PHP_STREAM_COOKIE_FUNCTIONS);
+		{
+			char fixed_mode[5];
+			php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode);
+			*(FILE**)ret = fopencookie(stream, fixed_mode, PHP_STREAM_COOKIE_FUNCTIONS);
+		}
 
 		if (*ret != NULL) {
 			off_t pos;
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index cf59767..e3c31ad 100755
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: glob_wrapper.c 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: glob_wrapper.c 303265 2010-09-10 21:33:50Z felipe $ */
 
 #include "php.h"
 #include "php_streams_int.h"
@@ -29,6 +29,7 @@
 # endif
 #endif
 
+#ifdef HAVE_GLOB
 #ifndef GLOB_ONLYDIR
 #define GLOB_ONLYDIR (1<<30)
 #define GLOB_FLAGMASK (~GLOB_ONLYDIR)
@@ -278,6 +279,7 @@ php_stream_wrapper  php_glob_stream_wrapper = {
 	NULL,
 	0
 };
+#endif /* HAVE_GLOB */
 
 /*
  * Local variables:
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index 113c518..e972477 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_streams_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: php_streams_int.h 305108 2010-11-05 18:53:48Z cataphract $ */
 
 
 #if ZEND_DEBUG
@@ -59,6 +59,13 @@
 #define S_ISREG(mode)	(((mode)&S_IFMT) == S_IFREG)
 #endif
 
+/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
+ * and strips any subsequent chars except '+' and 'b'.
+ * Use this to sanitize stream->mode if you call e.g. fdopen, fopencookie or
+ * any other function that expects standard modes and you allow non-standard
+ * ones. result should be a char[5]. */
+void php_stream_mode_sanitize_fdopen_fopencookie(php_stream *stream, char *result);
+
 void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC);
 void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC);
 
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 2087505..6cd8559 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: plain_wrapper.c 295308 2010-02-21 17:44:25Z pajoye $ */
+/* $Id: plain_wrapper.c 305108 2010-11-05 18:53:48Z cataphract $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -490,7 +490,9 @@ static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
 				if (data->file == NULL) {
 					/* we were opened as a plain file descriptor, so we
 					 * need fdopen now */
-					data->file = fdopen(data->fd, stream->mode);
+					char fixed_mode[5];
+					php_stream_mode_sanitize_fdopen_fopencookie(stream, fixed_mode);
+					data->file = fdopen(data->fd, fixed_mode);
 					if (data->file == NULL) {
 						return FAILURE;
 					}
@@ -1017,10 +1019,18 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, in
 		return -1;
 	}
 
-#ifdef HAVE_SYMLINK
+#ifdef PHP_WIN32
+	if (EG(windows_version_info).dwMajorVersion >= 5) {
+		if (flags & PHP_STREAM_URL_STAT_LINK) {
+			return VCWD_LSTAT(url, &ssb->sb);
+		}
+	}
+#else
+# ifdef HAVE_SYMLINK
 	if (flags & PHP_STREAM_URL_STAT_LINK) {
 		return VCWD_LSTAT(url, &ssb->sb);
 	} else
+# endif
 #endif
 		return VCWD_STAT(url, &ssb->sb);
 }
@@ -1139,7 +1149,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
 #else
 		php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
 #endif
-        return 0;
+		return 0;
 	}
 
 	/* Clear stat cache (and realpath cache) */
@@ -1221,7 +1231,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod
 				if (*p == '\0') {
 					*p = DEFAULT_SLASH;
 					if ((*(p+1) != '\0') &&
-					    (ret = VCWD_MKDIR(buf, (mode_t)mode)) < 0) {
+						(ret = VCWD_MKDIR(buf, (mode_t)mode)) < 0) {
 						if (options & REPORT_ERRORS) {
 							php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
 						}
@@ -1298,7 +1308,6 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
 	char *pathbuf, *ptr, *end;
 	char *exec_fname;
 	char trypath[MAXPATHLEN];
-	struct stat sb;
 	php_stream *stream;
 	int path_length;
 	int filename_length;
@@ -1440,6 +1449,8 @@ not_relative_path:
 		}
 		
 		if (PG(safe_mode)) {
+			struct stat sb;
+
 			if (VCWD_STAT(trypath, &sb) == 0) {
 				/* file exists ... check permission */
 				if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) ||
diff --git a/main/streams/streams.c b/main/streams/streams.c
index e3f7981..e194306 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c 299466 2010-05-18 19:39:39Z pajoye $ */
+/* $Id: streams.c 305379 2010-11-15 18:22:52Z cataphract $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -1093,12 +1093,17 @@ PHPAPI off_t _php_stream_tell(php_stream *stream TSRMLS_DC)
 
 PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
 {
+	if (stream->fclose_stdiocast == PHP_STREAM_FCLOSE_FOPENCOOKIE) {
+		/* flush to commit data written to the fopencookie FILE* */
+		fflush(stream->stdiocast);
+	}
+
 	/* handle the case where we are in the buffer */
 	if ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) == 0) {
 		switch(whence) {
 			case SEEK_CUR:
-				if (offset > 0 && offset < stream->writepos - stream->readpos) {
-					stream->readpos += offset;
+				if (offset > 0 && offset <= stream->writepos - stream->readpos) {
+					stream->readpos += offset; /* if offset = ..., then readpos = writepos */
 					stream->position += offset;
 					stream->eof = 0;
 					return 0;
@@ -1106,7 +1111,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_
 				break;
 			case SEEK_SET:
 				if (offset > stream->position &&
-						offset < stream->position + stream->writepos - stream->readpos) {
+						offset <= stream->position + stream->writepos - stream->readpos) {
 					stream->readpos += offset - stream->position;
 					stream->position = offset;
 					stream->eof = 0;
@@ -1149,14 +1154,12 @@ PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_
 	/* emulate forward moving seeks with reads */
 	if (whence == SEEK_CUR && offset > 0) {
 		char tmp[1024];
-		while(offset >= sizeof(tmp)) {
-			if (php_stream_read(stream, tmp, sizeof(tmp)) == 0) {
+		size_t didread;
+		while(offset > 0) {
+			if ((didread = php_stream_read(stream, tmp, MIN(offset, sizeof(tmp)))) == 0) {
 				return -1;
 			}
-			offset -= sizeof(tmp);
-		}
-		if (offset && (php_stream_read(stream, tmp, offset) == 0)) {
-			return -1;
+			offset -= didread;
 		}
 		stream->eof = 0;
 		return 0;
diff --git a/main/win95nt.h b/main/win95nt.h
index d88f063..bfca2d5 100644
--- a/main/win95nt.h
+++ b/main/win95nt.h
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: win95nt.h 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: win95nt.h 305778 2010-11-26 18:25:13Z pajoye $ */
 
 /* Defines and types for Windows 95/NT */
 #define HAVE_DECLARED_TIMEZONE
@@ -33,7 +33,7 @@
 typedef int uid_t;
 typedef int gid_t;
 typedef char * caddr_t;
-#define lstat(x, y) stat(x, y)
+#define lstat(x, y) php_sys_lstat(x, y)
 #define		_IFIFO	0010000	/* fifo */
 #define		_IFBLK	0060000	/* block special */
 #define		_IFLNK	0120000	/* symbolic link */
@@ -47,7 +47,7 @@ typedef char * caddr_t;
 #define mkdir(a, b)	_mkdir(a)
 #define rmdir(a)	_rmdir(a)
 #define getpid		_getpid
-#define php_sleep(t)	Sleep(t*1000)
+#define php_sleep(t)	SleepEx(t*1000, TRUE)
 #ifndef getcwd
 # define getcwd(a, b)		_getcwd(a, b)
 #endif
diff --git a/php.ini-development b/php.ini-development
index 60d1000..c8a7a1f 100644
--- a/php.ini-development
+++ b/php.ini-development
@@ -946,8 +946,6 @@ default_socket_timeout = 60
 ;
 ;extension=php_bz2.dll
 ;extension=php_curl.dll
-;extension=php_dba.dll
-;extension=php_exif.dll
 ;extension=php_fileinfo.dll
 ;extension=php_gd2.dll
 ;extension=php_gettext.dll
@@ -957,8 +955,7 @@ default_socket_timeout = 60
 ;extension=php_interbase.dll
 ;extension=php_ldap.dll
 ;extension=php_mbstring.dll
-;extension=php_ming.dll
-;extension=php_mssql.dll
+;extension=php_exif.dll      ; Must be after mbstring as it depends on it
 ;extension=php_mysql.dll
 ;extension=php_mysqli.dll
 ;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
@@ -1101,7 +1098,8 @@ smtp_port = 25
 ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
 mail.add_x_header = On
 
-; Log all mail() calls including the full path of the script, line #, to address and headers
+; The path to a log file that will log all mail() calls. Log entries include
+; the full path of the script, line number, To address and headers.
 ;mail.log =
 
 [SQL]
@@ -1547,7 +1545,7 @@ session.gc_maxlifetime = 1440
 ;       collection through a shell script, cron entry, or some other method.
 ;       For example, the following script would is the equivalent of
 ;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
-;          cd /path/to/sessions; find -cmin +24 | xargs rm
+;          find /path/to/sessions -cmin +24 | xargs rm
 
 ; PHP 4.2 and less have an undocumented feature/bug that allows you to
 ; to initialize a session variable in the global scope, even when register_globals
diff --git a/php.ini-production b/php.ini-production
index 5ace330..fb31d73 100644
--- a/php.ini-production
+++ b/php.ini-production
@@ -946,8 +946,6 @@ default_socket_timeout = 60
 ;
 ;extension=php_bz2.dll
 ;extension=php_curl.dll
-;extension=php_dba.dll
-;extension=php_exif.dll
 ;extension=php_fileinfo.dll
 ;extension=php_gd2.dll
 ;extension=php_gettext.dll
@@ -957,8 +955,7 @@ default_socket_timeout = 60
 ;extension=php_interbase.dll
 ;extension=php_ldap.dll
 ;extension=php_mbstring.dll
-;extension=php_ming.dll
-;extension=php_mssql.dll
+;extension=php_exif.dll      ; Must be after mbstring as it depends on it
 ;extension=php_mysql.dll
 ;extension=php_mysqli.dll
 ;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
@@ -972,7 +969,6 @@ default_socket_timeout = 60
 ;extension=php_pdo_pgsql.dll
 ;extension=php_pdo_sqlite.dll
 ;extension=php_pgsql.dll
-;extension=php_phar.dll
 ;extension=php_pspell.dll
 ;extension=php_shmop.dll
 ;extension=php_snmp.dll
@@ -1101,7 +1097,8 @@ smtp_port = 25
 ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
 mail.add_x_header = On
 
-; Log all mail() calls including the full path of the script, line #, to address and headers
+; The path to a log file that will log all mail() calls. Log entries include
+; the full path of the script, line number, To address and headers.
 ;mail.log =
 
 [SQL]
@@ -1555,7 +1552,7 @@ session.gc_maxlifetime = 1440
 ;       collection through a shell script, cron entry, or some other method.
 ;       For example, the following script would is the equivalent of
 ;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
-;          cd /path/to/sessions; find -cmin +24 | xargs rm
+;          find /path/to/sessions -cmin +24 | xargs rm
 
 ; PHP 4.2 and less have an undocumented feature/bug that allows you to
 ; to initialize a session variable in the global scope, even when register_globals
diff --git a/run-tests.php b/run-tests.php
index 3eeba95..f98190f 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -24,7 +24,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: run-tests.php 293036 2010-01-03 09:23:27Z sebastian $ */
+/* $Id: run-tests.php 305310 2010-11-13 10:18:35Z jani $ */
 
 /* Sanity check to ensure that pcre extension needed by this script is available.
  * In the event it is not, print a nice error message indicating that this script will
@@ -197,7 +197,7 @@ function verify_config()
 if (getenv('TEST_PHP_LOG_FORMAT')) {
 	$log_format = strtoupper(getenv('TEST_PHP_LOG_FORMAT'));
 } else {
-	$log_format = 'LEOD';
+	$log_format = 'LEODS';
 }
 
 // Check whether a detailed log is wanted.
@@ -572,7 +572,7 @@ if (isset($argc) && $argc > 1) {
 					if (!$valgrind_header) {
 						error("Valgrind returned no version info, cannot proceed.\nPlease check if Valgrind is installed.");
 					} else {
-						$valgrind_version = preg_replace("/valgrind-([0-9])\.([0-9])\.([0-9]+)([.-]\w+)?(\s+)/", '$1$2$3', $valgrind_header, 1, $replace_count);
+						$valgrind_version = preg_replace("/valgrind-([0-9])\.([0-9])\.([0-9]+)([.-\w]+)?(\s+)/", '$1$2$3', $valgrind_header, 1, $replace_count);
 						if ($replace_count != 1 || !is_numeric($valgrind_version)) {
 							error("Valgrind returned invalid version info (\"$valgrind_header\"), cannot proceed.");
 						}
@@ -641,7 +641,7 @@ if (isset($argc) && $argc > 1) {
 					$html_output = is_resource($html_file);
 					break;
 				case '--version':
-					echo '$Revision: 293036 $' . "\n";
+					echo '$Revision: 305310 $' . "\n";
 					exit(1);
 
 				default:
@@ -1352,6 +1352,7 @@ TEST $file
 	$exp_filename      = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
 	$output_filename   = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
 	$memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
+	$sh_filename       = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh';
 	$temp_file         = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
 	$test_file         = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
 	$temp_skipif       = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
@@ -1382,6 +1383,7 @@ TEST $file
 			'exp'  => $exp_filename,
 			'out'  => $output_filename,
 			'mem'  => $memcheck_filename,
+			'sh'   => $sh_filename,
 			'php'  => $temp_file,
 			'skip' => $temp_skipif,
 			'clean'=> $temp_clean);
@@ -1398,6 +1400,7 @@ TEST $file
 	@unlink($exp_filename);
 	@unlink($output_filename);
 	@unlink($memcheck_filename);
+	@unlink($sh_filename);
 	@unlink($temp_file);
 	@unlink($test_file);
 	@unlink($temp_skipif);
@@ -1959,6 +1962,15 @@ COMMAND $cmd
 			error("Cannot create test diff - $diff_filename");
 		}
 
+		// write .sh
+		if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, b"#!/bin/sh
+
+{$cmd}
+", FILE_BINARY) === false) {
+			error("Cannot create test shell script - $sh_filename");
+		}
+		chmod($sh_filename, 0755);
+
 		// write .log
 		if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, b"
 ---- EXPECTED OUTPUT
@@ -2161,7 +2173,17 @@ function settings2params(&$ini_settings)
 				$settings .= " -d \"$name=$val\"";
 			}
 		} else {
-			$value = addslashes($value);
+			if (substr(PHP_OS, 0, 3) == "WIN" && !empty($value) && $value{0} == '"') {
+				$len = strlen($value);
+
+				if ($value{$len - 1} == '"') {
+					$value{0} = "'";
+					$value{$len - 1} = "'";
+				}
+			} else {
+				$value = addslashes($value);
+			}
+
 			$settings .= " -d \"$name=$value\"";
 		}
 	}
diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32
index cd106f1..1a210ab 100644
--- a/sapi/cli/config.w32
+++ b/sapi/cli/config.w32
@@ -1,8 +1,8 @@
 // vim:ft=javascript
-// $Id: config.w32 243567 2007-10-05 16:00:30Z rrichards $
+// $Id: config.w32 302123 2010-08-11 22:38:15Z kalle $
 
 ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes');
-ARG_ENABLE('crt-debug', 'Extra CRT debugging', 'no');
+ARG_ENABLE('crt-debug', 'Enable CRT memory dumps for debugging sent to STDERR', 'no');
 ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
 
 if (PHP_CLI == "yes") {
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index cdc3ecf..dced263 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c 300854 2010-06-29 11:37:13Z felipe $ */
+/* $Id: php_cli.c 303357 2010-09-14 10:36:21Z pajoye $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -100,6 +100,7 @@
 #endif
 
 PHPAPI extern char *php_ini_opened_path;
+PHPAPI extern char *php_ini_scanned_path;
 PHPAPI extern char *php_ini_scanned_files;
 
 #ifndef O_BINARY
diff --git a/sapi/fpm/Makefile.frag b/sapi/fpm/Makefile.frag
index 0f1964e..0859ef1 100644
--- a/sapi/fpm/Makefile.frag
+++ b/sapi/fpm/Makefile.frag
@@ -22,7 +22,7 @@ install-fpm: install-sapi
 
 	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default || :
 
-	@echo "Installing PHP FPM man page:      $(INSTALL_ROOT)$(mandir)/man1/"
-	@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
-	@$(INSTALL_DATA) sapi/fpm/php-fpm.1 $(INSTALL_ROOT)$(mandir)/man1/php-fpm$(program_suffix).1
+	@echo "Installing PHP FPM man page:      $(INSTALL_ROOT)$(mandir)/man8/"
+	@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8
+	@$(INSTALL_DATA) sapi/fpm/php-fpm.8 $(INSTALL_ROOT)$(mandir)/man8/php-fpm$(program_suffix).8
 
diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4
index 0cefd96..6899ea7 100644
--- a/sapi/fpm/config.m4
+++ b/sapi/fpm/config.m4
@@ -2,225 +2,13 @@ dnl
 dnl $Id$
 dnl
 
-fpm_version="0.6.5"
-minimum_libevent_version="1.4.11"
-
 PHP_ARG_ENABLE(fpm,,
 [  --enable-fpm              EXPERIMENTAL: Enable building of the fpm SAPI executable], no, no)
 
-dnl libevent check function {{{
-dnl @synopsis AC_LIB_EVENT([MINIMUM-VERSION])
-dnl
-dnl Test for the libevent library of a particular version (or newer).
-dnl Source: http://svn.apache.org/repos/asf/incubator/thrift/trunk/aclocal/ax_lib_event.m4
-dnl Modified: This file was modified for autoconf-2.13 and the PHP_ARG_WITH macro.
-dnl
-dnl If no path to the installed libevent is given, the macro will first try
-dnl using no -I or -L flags, then searches under /usr, /usr/local, /opt,
-dnl and /opt/libevent.
-dnl If these all fail, it will try the $LIBEVENT_ROOT environment variable.
-dnl
-dnl This macro requires that #include <sys/types.h> works and defines u_char.
-dnl
-dnl This macro calls:
-dnl   AC_SUBST(LIBEVENT_CFLAGS)
-dnl   AC_SUBST(LIBEVENT_LIBS)
-dnl
-dnl And (if libevent is found):
-dnl   AC_DEFINE(HAVE_LIBEVENT)
-dnl
-dnl It also leaves the shell variables "success" and "ac_have_libevent"
-dnl set to "yes" or "no".
-dnl
-dnl NOTE: This macro does not currently work for cross-compiling,
-dnl       but it can be easily modified to allow it.  (grep "cross").
-dnl
-dnl @category InstalledPackages
-dnl @category C
-dnl @version 2007-09-12
-dnl @license AllPermissive
-dnl
-dnl Copyright (C) 2009 David Reiss
-dnl Copying and distribution of this file, with or without modification,
-dnl are permitted in any medium without royalty provided the copyright
-dnl notice and this notice are preserved.
-
-AC_DEFUN([AC_LIB_EVENT_DO_CHECK],
-[
-# Save our flags.
-CPPFLAGS_SAVED="$CPPFLAGS"
-LDFLAGS_SAVED="$LDFLAGS"
-LIBS_SAVED="$LIBS"
-LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
-
-# Set our flags if we are checking a specific directory.
-if test -n "$ac_libevent_path" ; then
-  LIBEVENT_CPPFLAGS="-I$ac_libevent_path/include"
- 
-  if test -z "$PHP_LIBDIR"; then
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/lib"
-  else 
-    LIBEVENT_LDFLAGS="-L$ac_libevent_path/$PHP_LIBDIR"
-  fi
-
-  LD_LIBRARY_PATH="$ac_libevent_path/lib:$LD_LIBRARY_PATH"
-else
-  LIBEVENT_CPPFLAGS=""
-  LIBEVENT_LDFLAGS=""
-fi
-
-# Required flag for libevent.
-LIBEVENT_LIBS="-levent"
-
-# Prepare the environment for compilation.
-CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
-LIBS="$LIBS $LIBEVENT_LIBS"
-export CPPFLAGS
-export LDFLAGS
-export LIBS
-export LD_LIBRARY_PATH
-
-success=no
-
-# Compile, link, and run the program.  This checks:
-# - event.h is available for including.
-# - event_get_version() is available for linking.
-# - The event version string is lexicographically greater
-#   than the required version.
-AC_TRY_RUN([
-#include <sys/types.h>
-#include <event.h>
-
-int main(int argc, char *argv[])
-{
-	const char* lib_version = event_get_version();
-	const char* wnt_version = "$WANT_LIBEVENT_VERSION";
-	for (;;) {
-		/* If we reached the end of the want version.  We have it. */
-		if (*wnt_version == '\0' || *wnt_version == '-') {
-			return 0;
-		}
-		/* If the want version continues but the lib version does not, */
-		/* we are missing a letter.  We don't have it. */
-		if (*lib_version == '\0' || *lib_version == '-') {
-			return 1;
-		}
-
-		/* In the 1.4 version numbering style, if there are more digits */
-		/* in one version than the other, that one is higher. */
-		int lib_digits;
-		for (lib_digits = 0;
-		lib_version[lib_digits] >= '0' &&
-		lib_version[lib_digits] <= '9';
-		lib_digits++)
-		;
-		int wnt_digits;
-		for (wnt_digits = 0;
-		wnt_version[wnt_digits] >= '0' &&
-		wnt_version[wnt_digits] <= '9';
-		wnt_digits++)
-		;
-		if (lib_digits > wnt_digits) {
-			return 0;
-		}
-		if (lib_digits < wnt_digits) {
-			return 1;
-		}
-		/* If we have greater than what we want.  We have it. */
-		if (*lib_version > *wnt_version) {
-			return 0;
-		}
-		/* If we have less, we don't. */
-		if (*lib_version < *wnt_version) {
-			return 1;
-		}
-		lib_version++;
-		wnt_version++;
-	}
-	return 0;
-}
-],[
-success=yes
-])
-
-# Restore flags.
-CPPFLAGS="$CPPFLAGS_SAVED"
-LDFLAGS="$LDFLAGS_SAVED"
-LIBS="$LIBS_SAVED"
-LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
-])
-
-AC_DEFUN([AC_LIB_EVENT],
-[
-
-PHP_ARG_WITH(libevent-dir,,
-[  --with-libevent-dir[=PATH]  libevent install prefix, for fpm SAPI. (default: /usr/local)], /usr/local, yes)
-
-if test "$PHP_LIBEVENT_DIR" != "no"; then
-  WANT_LIBEVENT_VERSION=ifelse([$1], ,1.2,$1)
-
-  AC_MSG_CHECKING(for libevent >= $WANT_LIBEVENT_VERSION install prefix)
-
-  libevent_prefix=$ac_default_prefix
-  if test $prefix != "NONE" -a $prefix != "" -a $prefix != "no" ; then 
-    libevent_prefix=$prefix
-  fi
-
-  if test "$PHP_LIBEVENT_DIR" = "yes"; then
-    PHP_LIBEVENT_DIR=$libevent_prefix
-  fi
-
-  if test "$PHP_LIBEVENT_DIR" != "yes" && test "$PHP_LIBEVENT_DIR" != "/usr/local"; then
-    dnl don't try to be too smart, check only $PHP_LIBEVENT_DIR if specified
-    ac_libevent_path=$PHP_LIBEVENT_DIR
-    AC_LIB_EVENT_DO_CHECK
-    if test "$success" = "no"; then
-      AC_MSG_ERROR([Could not find libevent >= $WANT_LIBEVENT_VERSION in $PHP_LIBEVENT_DIR])
-    fi
-   else 
-    dnl check default prefixes then
-    for ac_libevent_path in "" $PHP_LIBEVENT_DIR /usr /usr/local /opt /opt/local /opt/libevent ; do
-      AC_LIB_EVENT_DO_CHECK
-      if test "$success" = "yes"; then
-        break;
-      fi
-    done
-  fi
-
-  if test "$success" != "yes" ; then
-    AC_MSG_RESULT(no)
-    ac_have_libevent=no
-    AC_MSG_ERROR([libevent >= $WANT_LIBEVENT_VERSION could not be found])
-  else
-    AC_MSG_RESULT($ac_libevent_path)
-    ac_have_libevent=yes
-    AC_DEFINE(HAVE_LIBEVENT, 1, [define if libevent is available])
-  fi
-
-  LIBEVENT_LIBS="-levent"
-
-  if test -n "$ac_libevent_path"; then
-    LIBEVENT_CFLAGS="-I$ac_libevent_path/include"
-    LIBEVENT_LIBS="-L$ac_libevent_path/$PHP_LIBDIR $LIBEVENT_LIBS"
-    LIBEVENT_PATH="$ac_libevent_path/$PHP_LIBDIR"
-  fi
-
-  AC_SUBST(LIBEVENT_CFLAGS)
-  AC_SUBST(LIBEVENT_LIBS)
-  AC_SUBST(LIBEVENT_PATH)
-
-else
-  AC_MSG_ERROR([FPM requires libevent >= $WANT_LIBEVENT_VERSION. Please specify libevent install prefix with --with-libevent-dir=yes])
-fi
-
-])
-dnl }}}
-
 dnl configure checks {{{
 AC_DEFUN([AC_FPM_STDLIBS],
 [
-  AC_CHECK_FUNCS(setenv clearenv)
+  AC_CHECK_FUNCS(setenv clearenv setproctitle)
 
   AC_SEARCH_LIBS(socket, socket)
   AC_SEARCH_LIBS(inet_addr, nsl)
@@ -499,25 +287,69 @@ AC_DEFUN([AC_FPM_TRACE],
   fi
   
 ])
+
+AC_DEFUN([AC_FPM_BUILTIN_ATOMIC],
+[
+  AC_MSG_CHECKING([if gcc supports __sync_bool_compare_and_swap])
+  AC_TRY_LINK(,
+  [
+    int variable = 1;
+    return (__sync_bool_compare_and_swap(&variable, 1, 2)
+           && __sync_add_and_fetch(&variable, 1)) ? 1 : 0;
+  ],
+  [
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.])
+  ],
+  [
+    AC_MSG_RESULT([no])
+  ])
+])
+
+AC_DEFUN([AC_FPM_LQ],
+[
+  have_lq=no
+
+  AC_MSG_CHECKING([for TCP_INFO])
+
+  AC_TRY_COMPILE([ #include <netinet/tcp.h> ], [struct tcp_info ti; int x = TCP_INFO;], [
+    have_lq=tcp_info
+    AC_MSG_RESULT([yes])
+  ], [
+    AC_MSG_RESULT([no])
+  ])
+
+  if test "$have_lq" = "tcp_info"; then
+    AC_DEFINE([HAVE_LQ_TCP_INFO], 1, [do we have TCP_INFO?])
+  fi
+
+  if test "$have_lq" = "no" ; then
+    AC_MSG_CHECKING([for SO_LISTENQLEN])
+
+    AC_TRY_COMPILE([ #include <sys/socket.h> ], [int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;], [
+      have_lq=so_listenq
+      AC_MSG_RESULT([yes])
+    ], [
+      AC_MSG_RESULT([no])
+    ])
+
+    if test "$have_lq" = "tcp_info"; then
+      AC_DEFINE([HAVE_LQ_SO_LISTENQ], 1, [do we have SO_LISTENQxxx?])
+    fi
+  fi
+])
 dnl }}}
 
 AC_MSG_CHECKING(for FPM build)
 if test "$PHP_FPM" != "no"; then
   AC_MSG_RESULT($PHP_FPM)
 
-  AC_LIB_EVENT([$minimum_libevent_version])
-
-  PHP_ADD_LIBRARY_WITH_PATH(event, $LIBEVENT_PATH)
-
-  PHP_TEST_BUILD(event_init, [ ], [
-    AC_MSG_RESULT(no)
-    AC_MSG_ERROR([build test failed. Please check the config.log for details.])
-  ], $LIBEVENT_LIBS)
-
   AC_FPM_STDLIBS
   AC_FPM_PRCTL
   AC_FPM_CLOCK
   AC_FPM_TRACE
+  AC_FPM_BUILTIN_ATOMIC
+  AC_FPM_LQ
 
   PHP_ARG_WITH(fpm-user,,
   [  --with-fpm-user[=USER]  Set the user for php-fpm to run as. (default: nobody)], nobody, no)
@@ -538,19 +370,19 @@ if test "$PHP_FPM" != "no"; then
     php_fpm_group="$PHP_FPM_GROUP"
   fi
 
-  PHP_SUBST_OLD(fpm_version)
   PHP_SUBST_OLD(php_fpm_user)
   PHP_SUBST_OLD(php_fpm_group)
   php_fpm_sysconfdir=`eval echo $sysconfdir`
   PHP_SUBST_OLD(php_fpm_sysconfdir)
   php_fpm_localstatedir=`eval echo $localstatedir`
   PHP_SUBST_OLD(php_fpm_localstatedir)
+  php_fpm_prefix=`eval echo $prefix`
+  PHP_SUBST_OLD(php_fpm_prefix)
 
-  AC_DEFINE_UNQUOTED(PHP_FPM_VERSION, "$fpm_version", [fpm version])
   AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name])
   AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name])
 
-  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.1)
+  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.8)
   PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag], [$abs_srcdir/sapi/fpm], [sapi/fpm])
 
   SAPI_FPM_PATH=sapi/fpm/php-fpm
@@ -560,10 +392,7 @@ if test "$PHP_FPM" != "no"; then
     PHP_FPM_TRACE_FILES="fpm/fpm_trace.c fpm/fpm_trace_$fpm_trace_type.c"
   fi
   
-  PHP_FPM_CFLAGS="$LIBEVENT_CFLAGS -I$abs_srcdir/sapi/fpm"
-
-  SAPI_EXTRA_LIBS="$LIBEVENT_LIBS"
-  PHP_SUBST(SAPI_EXTRA_LIBS)
+  PHP_FPM_CFLAGS="-I$abs_srcdir/sapi/fpm"
  
   INSTALL_IT=":"
   PHP_FPM_FILES="fpm/fastcgi.c \
diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c
index 34292b5..17a215c 100644
--- a/sapi/fpm/fpm/fpm.c
+++ b/sapi/fpm/fpm/fpm.c
@@ -23,23 +23,26 @@
 
 struct fpm_globals_s fpm_globals;
 
-int fpm_init(int argc, char **argv, char *config, struct event_base **base) /* {{{ */
+int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) /* {{{ */
 {
 	fpm_globals.argc = argc;
 	fpm_globals.argv = argv;
-	fpm_globals.config = config;
+	if (config && *config) {
+		fpm_globals.config = strdup(config);
+	}
+	fpm_globals.prefix = prefix;
 
-	if (0 > fpm_php_init_main()            ||
+	if (0 > fpm_php_init_main()              ||
 		0 > fpm_stdio_init_main()            ||
-		0 > fpm_conf_init_main()             ||
+		0 > fpm_conf_init_main(test_conf)    ||
 		0 > fpm_unix_init_main()             ||
+		0 > fpm_pctl_init_main()             ||
 		0 > fpm_env_init_main()              ||
 		0 > fpm_signals_init_main()          ||
-		0 > fpm_pctl_init_main()             ||
 		0 > fpm_children_init_main()         ||
 		0 > fpm_sockets_init_main()          ||
 		0 > fpm_worker_pool_init_main()      ||
-		0 > fpm_event_init_main(base)) {
+		0 > fpm_event_init_main()) {
 		return -1;
 	}
 
@@ -47,7 +50,8 @@ int fpm_init(int argc, char **argv, char *config, struct event_base **base) /* {
 		return -1;
 	}
 
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);
+	fpm_stdio_init_final();
+	zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);
 
 	return 0;
 }
@@ -55,7 +59,7 @@ int fpm_init(int argc, char **argv, char *config, struct event_base **base) /* {
 
 /*	children: return listening socket
 	parent: never return */
-int fpm_run(int *max_requests, struct event_base *base) /* {{{ */
+int fpm_run(int *max_requests) /* {{{ */
 {
 	struct fpm_worker_pool_s *wp;
 
@@ -63,7 +67,7 @@ int fpm_run(int *max_requests, struct event_base *base) /* {{{ */
 	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
 		int is_parent;
 
-		is_parent = fpm_children_create_initial(wp, base);
+		is_parent = fpm_children_create_initial(wp);
 
 		if (!is_parent) {
 			goto run_child;
@@ -71,7 +75,7 @@ int fpm_run(int *max_requests, struct event_base *base) /* {{{ */
 	}
 
 	/* run event loop forever */
-	fpm_event_loop(base);
+	fpm_event_loop();
 
 run_child: /* only workers reach this point */
 
diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h
index ba43904..63e3bac 100644
--- a/sapi/fpm/fpm/fpm.h
+++ b/sapi/fpm/fpm/fpm.h
@@ -6,17 +6,16 @@
 #define FPM_H 1
 
 #include <unistd.h>
-#include <sys/types.h> /* for event.h below */
-#include <event.h>
 
-int fpm_run(int *max_requests, struct event_base *base);
-int fpm_init(int argc, char **argv, char *config, struct event_base **base);
+int fpm_run(int *max_requests);
+int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf);
 
 struct fpm_globals_s {
 	pid_t parent_pid;
 	int argc;
 	char **argv;
 	char *config;
+	char *prefix;
 	int running_children;
 	int error_log_fd;
 	int log_level;
diff --git a/sapi/fpm/fpm/fpm_atomic.h b/sapi/fpm/fpm/fpm_atomic.h
index 8c287dd..638bafd 100644
--- a/sapi/fpm/fpm/fpm_atomic.h
+++ b/sapi/fpm/fpm/fpm_atomic.h
@@ -12,7 +12,19 @@
 #endif
 #include <sched.h>
 
-#if ( __i386__ || __i386 )
+#ifdef HAVE_BUILTIN_ATOMIC
+
+/**
+ * all the cases below (as provided by upstream) define:
+ * word as atomic_int_t, and
+ * unsigned word as atomic_uint_t
+ * and only use volatile atomic_uint_t as atomic_t
+ */
+
+typedef volatile unsigned long atomic_t;
+#define atomic_cmp_set(a,b,c) __sync_bool_compare_and_swap(a,b,c)
+
+#elif ( __i386__ || __i386 )
 
 typedef int32_t                     atomic_int_t;
 typedef uint32_t                    atomic_uint_t;
@@ -83,6 +95,8 @@ typedef uint32_t                    atomic_uint_t;
 
 #elif ( __sparc__ || __sparc ) /* Marcin Ochab */
 
+#if (__sparcv9 || __sparcv9__)
+
 #if (__arch64__ || __arch64)
 typedef uint64_t                    atomic_uint_t;
 typedef volatile atomic_uint_t      atomic_t;
@@ -119,9 +133,13 @@ static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, at
 /* }}} */
 #endif
 
+#else /* #if (__sparcv9 || __sparcv9__) */
+#error Sparc v8 and predecessors are not and will not be supported (see bug report 53310)
+#endif /* #if (__sparcv9 || __sparcv9__) */
+
 #else
 
-#error unsupported processor. please write a patch and send it to me
+#error Unsupported processor. Please open a bug report (bugs.php.net).
 
 #endif
 
diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c
index d303cfb..499ad08 100644
--- a/sapi/fpm/fpm/fpm_children.c
+++ b/sapi/fpm/fpm/fpm_children.c
@@ -152,7 +152,7 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp) /* {{{ */
 		0 > fpm_env_init_child(wp) ||
 		0 > fpm_php_init_child(wp)) {
 
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
+		zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
 		exit(255);
 	}
 }
@@ -171,7 +171,7 @@ int fpm_children_free(struct fpm_child_s *child) /* {{{ */
 }
 /* }}} */
 
-void fpm_children_bury(struct event_base *base) /* {{{ */
+void fpm_children_bury() /* {{{ */
 {
 	int status;
 	pid_t pid;
@@ -201,18 +201,18 @@ void fpm_children_bury(struct event_base *base) /* {{{ */
 
 		} else if (WIFSIGNALED(status)) {
 			const char *signame = fpm_signal_names[WTERMSIG(status)];
-			const char *have_core = WCOREDUMP(status) ? " (core dumped)" : "";
+			const char *have_core = WCOREDUMP(status) ? " - core dumped" : "";
 
 			if (signame == NULL) {
 				signame = "";
 			}
 
-			snprintf(buf, sizeof(buf), "on signal %d %s%s", WTERMSIG(status), signame, have_core);
+			snprintf(buf, sizeof(buf), "on signal %d (%s%s)", WTERMSIG(status), signame, have_core);
 
 			/* if it's been killed because of dynamic process management
 			 * don't restart it automaticaly
 			 */
-			if (child && child->idle_kill && WTERMSIG(status) == SIGTERM) {
+			if (child && child->idle_kill && WTERMSIG(status) == SIGQUIT) {
 				restart_child = 0;
 			}
 
@@ -221,7 +221,7 @@ void fpm_children_bury(struct event_base *base) /* {{{ */
 			}
 		} else if (WIFSTOPPED(status)) {
 
-			zlog(ZLOG_STUFF, ZLOG_NOTICE, "child %d stopped for tracing", (int) pid);
+			zlog(ZLOG_NOTICE, "child %d stopped for tracing", (int) pid);
 
 			if (child && child->tracer) {
 				child->tracer(child);
@@ -246,9 +246,9 @@ void fpm_children_bury(struct event_base *base) /* {{{ */
 				if (!fpm_pctl_can_spawn_children()) {
 					severity = ZLOG_DEBUG;
 				}
-				zlog(ZLOG_STUFF, severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", child->wp->config->name, (int) pid, buf, tv2.tv_sec, (int) tv2.tv_usec);
+				zlog(severity, "[pool %s] child %d exited %s after %ld.%06d seconds from start", child->wp->config->name, (int) pid, buf, tv2.tv_sec, (int) tv2.tv_usec);
 			} else {
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] child %d has been killed by the process managment after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec);
+				zlog(ZLOG_DEBUG, "[pool %s] child %d has been killed by the process managment after %ld.%06d seconds from start", child->wp->config->name, (int) pid, tv2.tv_sec, (int) tv2.tv_usec);
 			}
 
 			fpm_child_close(child, 1 /* in event_loop */);
@@ -275,21 +275,21 @@ void fpm_children_bury(struct event_base *base) /* {{{ */
 
 				if (restart_condition) {
 
-					zlog(ZLOG_STUFF, ZLOG_WARNING, "failed processes threshold (%d in %d sec) is reached, initiating reload", fpm_global_config.emergency_restart_threshold, fpm_global_config.emergency_restart_interval);
+					zlog(ZLOG_WARNING, "failed processes threshold (%d in %d sec) is reached, initiating reload", fpm_global_config.emergency_restart_threshold, fpm_global_config.emergency_restart_interval);
 
-					fpm_pctl(FPM_PCTL_STATE_RELOADING, FPM_PCTL_ACTION_SET, base);
+					fpm_pctl(FPM_PCTL_STATE_RELOADING, FPM_PCTL_ACTION_SET);
 				}
 			}
 
 			if (restart_child) {
-				fpm_children_make(wp, 1 /* in event loop */, 1, 0, base);
+				fpm_children_make(wp, 1 /* in event loop */, 1, 0);
 
 				if (fpm_globals.is_child) {
 					break;
 				}
 			}
 		} else {
-			zlog(ZLOG_STUFF, ZLOG_ALERT, "oops, unknown child exited %s", buf);
+			zlog(ZLOG_ALERT, "oops, unknown child (%d) exited %s", pid, buf);
 		}
 	}
 }
@@ -302,7 +302,7 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp) /
 	c = fpm_child_alloc();
 
 	if (!c) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] malloc failed", wp->config->name);
+		zlog(ZLOG_ERROR, "[pool %s] malloc failed", wp->config->name);
 		return 0;
 	}
 
@@ -340,15 +340,15 @@ static void fpm_child_resources_use(struct fpm_child_s *child) /* {{{ */
 }
 /* }}} */
 
-static void fpm_parent_resources_use(struct fpm_child_s *child, struct event_base *base) /* {{{ */
+static void fpm_parent_resources_use(struct fpm_child_s *child) /* {{{ */
 {
 	fpm_shm_slots_parent_use_slot(child);
-	fpm_stdio_parent_use_pipes(child, base);
+	fpm_stdio_parent_use_pipes(child);
 	fpm_child_link(child);
 }
 /* }}} */
 
-int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug, struct event_base *base) /* {{{ */
+int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug) /* {{{ */
 {
 	int enough = 0;
 	pid_t pid;
@@ -378,17 +378,13 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
 		switch (pid) {
 
 			case 0 :
-				event_reinit(base); /* reinitialize event base after fork() */
 				fpm_child_resources_use(child);
 				fpm_globals.is_child = 1;
-				if (in_event_loop) {
-					fpm_event_exit_loop(base);
-				}
 				fpm_child_init(wp);
 				return 0;
 
 			case -1 :
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "fork() failed");
+				zlog(ZLOG_SYSERROR, "fork() failed");
 				enough = 1;
 
 				fpm_resources_discard(child);
@@ -398,9 +394,9 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
 			default :
 				child->pid = pid;
 				fpm_clock_get(&child->started);
-				fpm_parent_resources_use(child, base);
+				fpm_parent_resources_use(child);
 
-				zlog(ZLOG_STUFF, is_debug ? ZLOG_DEBUG : ZLOG_NOTICE, "[pool %s] child %d started", wp->config->name, (int) pid);
+				zlog(is_debug ? ZLOG_DEBUG : ZLOG_NOTICE, "[pool %s] child %d started", wp->config->name, (int) pid);
 		}
 
 	}
@@ -409,9 +405,9 @@ int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to
 }
 /* }}} */
 
-int fpm_children_create_initial(struct fpm_worker_pool_s *wp, struct event_base *base) /* {{{ */
+int fpm_children_create_initial(struct fpm_worker_pool_s *wp) /* {{{ */
 {
-	return fpm_children_make(wp, 0 /* not in event loop yet */, 0, 1, base);
+	return fpm_children_make(wp, 0 /* not in event loop yet */, 0, 1);
 }
 /* }}} */
 
diff --git a/sapi/fpm/fpm/fpm_children.h b/sapi/fpm/fpm/fpm_children.h
index d881842..4010a4f 100644
--- a/sapi/fpm/fpm/fpm_children.h
+++ b/sapi/fpm/fpm/fpm_children.h
@@ -7,15 +7,15 @@
 
 #include <sys/time.h>
 #include <sys/types.h>
-#include <event.h>
 
 #include "fpm_worker_pool.h"
+#include "fpm_events.h"
 
-int fpm_children_create_initial(struct fpm_worker_pool_s *wp, struct event_base *base);
+int fpm_children_create_initial(struct fpm_worker_pool_s *wp);
 int fpm_children_free(struct fpm_child_s *child);
-void fpm_children_bury(struct event_base *base);
+void fpm_children_bury();
 int fpm_children_init_main();
-int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug, struct event_base *base);
+int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop, int nb_to_spawn, int is_debug);
 
 struct fpm_child_s;
 
@@ -23,7 +23,7 @@ struct fpm_child_s {
 	struct fpm_child_s *prev, *next;
 	struct timeval started;
 	struct fpm_worker_pool_s *wp;
-	struct event ev_stdout, ev_stderr;
+	struct fpm_event_s ev_stdout, ev_stderr;
 	int shm_slot_i;
 	int fd_stdout, fd_stderr;
 	void (*tracer)(struct fpm_child_s *);
diff --git a/sapi/fpm/fpm/fpm_clock.c b/sapi/fpm/fpm/fpm_clock.c
index 3eb5159..66751b8 100644
--- a/sapi/fpm/fpm/fpm_clock.c
+++ b/sapi/fpm/fpm/fpm_clock.c
@@ -37,7 +37,7 @@ int fpm_clock_get(struct timeval *tv) /* {{{ */
 		struct timespec ts;
 
 		if (0 > clock_gettime(CLOCK_MONOTONIC, &ts)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "clock_gettime() failed");
+			zlog(ZLOG_SYSERROR, "clock_gettime() failed");
 			return -1;
 		}
 
@@ -69,7 +69,7 @@ int fpm_clock_init() /* {{{ */
 	ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &mach_clock);
 
 	if (ret != KERN_SUCCESS) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "host_get_clock_service() failed: %s", mach_error_string(ret));
+		zlog(ZLOG_ERROR, "host_get_clock_service() failed: %s", mach_error_string(ret));
 		return -1;
 	}
 
@@ -77,7 +77,7 @@ int fpm_clock_init() /* {{{ */
 	ret = clock_get_time(mach_clock, &aTime);
 
 	if (ret != KERN_SUCCESS) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
+		zlog(ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
 		return -1;
 	}
 
@@ -93,7 +93,7 @@ int fpm_clock_get(struct timeval *tv) /* {{{ */
 	ret = clock_get_time(mach_clock, &aTime);
 
 	if (ret != KERN_SUCCESS) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
+		zlog(ZLOG_ERROR, "clock_get_time() failed: %s", mach_error_string(ret));
 		return -1;
 	}
 
diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c
index 4590155..f38227c 100644
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -52,50 +52,54 @@ static char *fpm_conf_set_log_level(zval *value, void **config, intptr_t offset)
 static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset);
 static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset);
 
-struct fpm_global_config_s fpm_global_config = { 0, 0, 0, 1, NULL, NULL};
+struct fpm_global_config_s fpm_global_config = { .daemonize = 1 };
 static struct fpm_worker_pool_s *current_wp = NULL;
 static int ini_recursion = 0;
 static char *ini_filename = NULL;
 static int ini_lineno = 0;
 static char *ini_include = NULL;
 
+#define GO(field) offsetof(struct fpm_global_config_s, field)
+#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
+
 static struct ini_value_parser_s ini_fpm_global_options[] = {
-	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	offsetof(struct fpm_global_config_s, emergency_restart_threshold) },
-	{ "emergency_restart_interval",		&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, emergency_restart_interval) },
-	{ "process_control_timeout",			&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, process_control_timeout) },
-	{ "daemonize",										&fpm_conf_set_boolean,	offsetof(struct fpm_global_config_s, daemonize) },
-	{ "pid",													&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, pid_file) },
-	{ "error_log",										&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, error_log) },
+	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	GO(emergency_restart_threshold) },
+	{ "emergency_restart_interval",		&fpm_conf_set_time,			GO(emergency_restart_interval) },
+	{ "process_control_timeout",			&fpm_conf_set_time,			GO(process_control_timeout) },
+	{ "daemonize",										&fpm_conf_set_boolean,	GO(daemonize) },
+	{ "pid",													&fpm_conf_set_string,		GO(pid_file) },
+	{ "error_log",										&fpm_conf_set_string,		GO(error_log) },
 	{ "log_level",										&fpm_conf_set_log_level,	0 },
 	{ 0, 0, 0 }
 };
 
 static struct ini_value_parser_s ini_fpm_pool_options[] = {
-	{ "user", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, user) },
-	{ "group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, group) },
-	{ "chroot", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chroot) },
-	{ "chdir", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chdir) },
-	{ "request_terminate_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_terminate_timeout) },
-	{ "request_slowlog_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_slowlog_timeout) },
-	{ "slowlog", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, slowlog) },
-	{ "rlimit_files", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, rlimit_files) },
-	{ "rlimit_core", &fpm_conf_set_rlimit_core, offsetof(struct fpm_worker_pool_config_s, rlimit_core) },
-	{ "catch_workers_output", &fpm_conf_set_boolean, offsetof(struct fpm_worker_pool_config_s, catch_workers_output) },
-	{ "listen", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_address) },
-	{ "listen.owner", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_owner) },
-	{ "listen.group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_group) },
-	{ "listen.mode", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_mode) },
-	{ "listen.backlog", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, listen_backlog) },
-	{ "listen.allowed_clients", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_allowed_clients) },
-	{ "pm", &fpm_conf_set_pm, offsetof(struct fpm_worker_pool_config_s, pm) },
-	{ "pm.max_requests", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_requests) },
-	{ "pm.max_children", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_children) },
-	{ "pm.start_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_start_servers) },
-	{ "pm.min_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_min_spare_servers) },
-	{ "pm.max_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_spare_servers) },
-	{ "pm.status_path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, pm_status_path) },
-	{ "ping.path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_path) },
-	{ "ping.response", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_response) },
+	{ "prefix", &fpm_conf_set_string, WPO(prefix) },
+	{ "user", &fpm_conf_set_string, WPO(user) },
+	{ "group", &fpm_conf_set_string, WPO(group) },
+	{ "chroot", &fpm_conf_set_string, WPO(chroot) },
+	{ "chdir", &fpm_conf_set_string, WPO(chdir) },
+	{ "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
+	{ "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
+	{ "slowlog", &fpm_conf_set_string, WPO(slowlog) },
+	{ "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
+	{ "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
+	{ "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
+	{ "listen", &fpm_conf_set_string, WPO(listen_address) },
+	{ "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
+	{ "listen.group", &fpm_conf_set_string, WPO(listen_group) },
+	{ "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
+	{ "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
+	{ "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
+	{ "pm", &fpm_conf_set_pm, WPO(pm) },
+	{ "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
+	{ "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
+	{ "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
+	{ "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
+	{ "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
+	{ "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
+	{ "ping.path", &fpm_conf_set_string, WPO(ping_path) },
+	{ "ping.response", &fpm_conf_set_string, WPO(ping_response) },
 	{ 0, 0, 0 }
 };
 
@@ -111,11 +115,34 @@ static int fpm_conf_is_dir(char *path) /* {{{ */
 }
 /* }}} */
 
+static int fpm_conf_expand_pool_name(char **value) {
+	char *token;
+
+	if (!value || !*value) {
+		return 0;
+	}
+
+	while ((token = strstr(*value, "$pool"))) {
+		char *buf;
+		char *p1 = *value;
+		char *p2 = token + strlen("$pool");
+		if (!current_wp || !current_wp->config  || !current_wp->config->name) {
+			return -1;
+		}
+		token[0] = '\0';
+		spprintf(&buf, 0, "%s%s%s", p1, current_wp->config->name, p2);
+		*value = strdup(buf);
+		efree(buf);
+	}
+
+	return 0;
+}
+
 static char *fpm_conf_set_boolean(zval *value, void **config, intptr_t offset) /* {{{ */
 {
 	char *val = Z_STRVAL_P(value);
-	long value_y = !strcasecmp(val, "yes") || !strcmp(val,  "1") || !strcasecmp(val, "on") || !strcasecmp(val, "true");
-	long value_n = !strcasecmp(val, "no")  || !strcmp(val,  "0") || !strcasecmp(val, "off") || !strcasecmp(val, "false");
+	long value_y = !strcasecmp(val, "1");
+	long value_n = !strcasecmp(val, "");
 
 	if (!value_y && !value_n) {
 		return "invalid boolean value";
@@ -138,6 +165,9 @@ static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset) /*
 	if (!new) {
 		return "fpm_conf_set_string(): strdup() failed";
 	}
+	if (fpm_conf_expand_pool_name(&new) == -1) {
+		return "Can't use '$pool' when the pool is not defined";
+	}
 
 	*old = new;
 	return NULL;
@@ -146,17 +176,17 @@ static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset) /*
 
 static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /* {{{ */
 {
-	int i;
 	char *val = Z_STRVAL_P(value);
+	char *p;
 
-	for (i=0; i<strlen(val); i++) {
-		if ( i == 0 && val[i] == '-' ) continue;
-		if (val[i] < '0' || val[i] > '9') {
-			return("is not a valid number (greater or equal than zero");
+	for(p=val; *p; p++) {
+		if ( p == val && *p == '-' ) continue;
+		if (*p < '0' || *p > '9') {
+			return "is not a valid number (greater or equal than zero)";
 		}
 	}
 	* (int *) ((char *) *config + offset) = atoi(val);
-	return(NULL);
+	return NULL;
 }
 /* }}} */
 
@@ -204,7 +234,7 @@ static char *fpm_conf_set_log_level(zval *value, void **config, intptr_t offset)
 {
 	char *val = Z_STRVAL_P(value);
 
-	if (!strcmp(val, "debug")) {
+	if (!strcasecmp(val, "debug")) {
 		fpm_globals.log_level = ZLOG_DEBUG;
 	} else if (!strcasecmp(val, "notice")) {
 		fpm_globals.log_level = ZLOG_NOTICE;
@@ -227,7 +257,7 @@ static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offse
 	char *val = Z_STRVAL_P(value);
 	struct fpm_worker_pool_config_s *c = *config;
 
-	if (!strcmp(val, "unlimited")) {
+	if (!strcasecmp(val, "unlimited")) {
 		c->rlimit_core = -1;
 	} else {
 		int int_value;
@@ -255,9 +285,9 @@ static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset) /* {{{
 {
 	char *val = Z_STRVAL_P(value);
 	struct fpm_worker_pool_config_s  *c = *config;
-	if (!strcmp(val, "static")) {
+	if (!strcasecmp(val, "static")) {
 		c->pm = PM_STYLE_STATIC;
-	} else if (!strcmp(val, "dynamic")) {
+	} else if (!strcasecmp(val, "dynamic")) {
 		c->pm = PM_STYLE_DYNAMIC;
 	} else {
 		return "invalid process manager (static or dynamic)";
@@ -288,10 +318,13 @@ static char *fpm_conf_set_array(zval *key, zval *value, void **config, int conve
 
 	if (convert_to_bool) {
 		char *err = fpm_conf_set_boolean(value, &subconf, 0);
-		if (err) return(err);
+		if (err) return err;
 		kv->value = strdup(b ? "On" : "Off");
 	} else {
 		kv->value = strdup(Z_STRVAL_P(value));
+		if (fpm_conf_expand_pool_name(&kv->value) == -1) {
+			return "Can't use '$pool' when the pool is not defined";
+		}
 	}
 
 	if (!kv->value) {
@@ -322,7 +355,7 @@ static void *fpm_worker_pool_config_alloc() /* {{{ */
 	}
 
 	memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s));
-	wp->config->listen_backlog = -1;
+	wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
 
 	if (!fpm_worker_all_pools) {
 		fpm_worker_all_pools = wp;
@@ -378,27 +411,68 @@ int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc) /* {{{ */
 	free(wpc->chroot);
 	free(wpc->chdir);
 	free(wpc->slowlog);
+	free(wpc->prefix);
 
 	return 0;
 }
 /* }}} */
 
-static int fpm_evaluate_full_path(char **path) /* {{{ */
+static int fpm_evaluate_full_path(char **path, struct fpm_worker_pool_s *wp, char *default_prefix, int expand) /* {{{ */
 {
-	if (**path != '/') {
-		char *full_path;
+	char *prefix = NULL;
+	char *full_path;
 
-		full_path = malloc(sizeof(PHP_PREFIX) + strlen(*path) + 1);
+	if (!path || !*path || **path == '/') {
+		return 0;
+	}
 
-		if (!full_path) { 
-			return -1;
+	if (wp && wp->config) {
+		prefix = wp->config->prefix;
+	}
+
+	/* if the wp prefix is not set */
+	if (prefix == NULL) {
+		prefix = fpm_globals.prefix;
+	}
+
+	/* if the global prefix is not set */
+	if (prefix == NULL) {
+		prefix = default_prefix ? default_prefix : PHP_PREFIX;
+	}
+
+	if (expand) {
+		char *tmp;
+		tmp = strstr(*path, "$prefix");
+		if (tmp != NULL) {
+
+			if (tmp != *path) {
+				zlog(ZLOG_ERROR, "'$prefix' must be use at the begining of the value");
+				return -1;
+			}
+
+			if (strlen(*path) > strlen("$prefix")) {
+				free(*path);
+				tmp = strdup((*path) + strlen("$prefix"));
+				*path = tmp;
+			} else {
+				free(*path);
+				*path = NULL;
+			}
 		}
+	}
 
-		sprintf(full_path, "%s/%s", PHP_PREFIX, *path);
+	if (*path) {
+		spprintf(&full_path, 0, "%s/%s", prefix, *path);
 		free(*path);
-		*path = full_path;
+		*path = strdup(full_path);
+		efree(full_path);
+	} else {
+		*path = strdup(prefix);
 	}
 
+	if (**path != '/' && wp != NULL && wp->config) {
+		return fpm_evaluate_full_path(path, NULL, default_prefix, expand);
+	}
 	return 0;
 }
 /* }}} */
@@ -408,35 +482,44 @@ static int fpm_conf_process_all_pools() /* {{{ */
 	struct fpm_worker_pool_s *wp;
 
 	if (!fpm_worker_all_pools) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "at least one pool section must be specified in config file");
+		zlog(ZLOG_ERROR, "at least one pool section must be specified in config file");
 		return -1;
 	}
 
 	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
 
+		if (wp->config->prefix && *wp->config->prefix) {
+			fpm_evaluate_full_path(&wp->config->prefix, NULL, NULL, 0);
+
+			if (!fpm_conf_is_dir(wp->config->prefix)) {
+				zlog(ZLOG_ERROR, "[pool %s] the prefix '%s' does not exist or is not a directory", wp->config->name, wp->config->prefix);
+				return -1;
+			}
+		}
+
 		if (wp->config->listen_address && *wp->config->listen_address) {
 			wp->listen_address_domain = fpm_sockets_domain_from_address(wp->config->listen_address);
 
 			if (wp->listen_address_domain == FPM_AF_UNIX && *wp->config->listen_address != '/') {
-				fpm_evaluate_full_path(&wp->config->listen_address);
+				fpm_evaluate_full_path(&wp->config->listen_address, wp, NULL, 0);
 			}
 		} else {
-			zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] no listen address have been defined!", wp->config->name);
+			zlog(ZLOG_ALERT, "[pool %s] no listen address have been defined!", wp->config->name);
 			return -1;
 		}
 
 		if (!wp->config->user) {
-			zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] user has not been defined", wp->config->name);
+			zlog(ZLOG_ALERT, "[pool %s] user has not been defined", wp->config->name);
 			return -1;
 		}
 
 		if (wp->config->pm != PM_STYLE_STATIC && wp->config->pm != PM_STYLE_DYNAMIC) {
-			zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] the process manager is missing (static or dynamic)", wp->config->name);
+			zlog(ZLOG_ALERT, "[pool %s] the process manager is missing (static or dynamic)", wp->config->name);
 			return -1;
 		}
 
 		if (wp->config->pm_max_children < 1) {
-			zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.max_children must be a positive value", wp->config->name);
+			zlog(ZLOG_ALERT, "[pool %s] pm.max_children must be a positive value", wp->config->name);
 			return -1;
 		}
 
@@ -444,66 +527,65 @@ static int fpm_conf_process_all_pools() /* {{{ */
 			struct fpm_worker_pool_config_s *config = wp->config;
 
 			if (config->pm_min_spare_servers <= 0) {
-				zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) must be a positive value", wp->config->name, config->pm_min_spare_servers);
+				zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) must be a positive value", wp->config->name, config->pm_min_spare_servers);
 				return -1;
 			}
 
 			if (config->pm_max_spare_servers <= 0) {
-				zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.max_spare_servers(%d) must be a positive value", wp->config->name, config->pm_max_spare_servers);
+				zlog(ZLOG_ALERT, "[pool %s] pm.max_spare_servers(%d) must be a positive value", wp->config->name, config->pm_max_spare_servers);
 				return -1;
 			}
 
 			if (config->pm_min_spare_servers > config->pm_max_children ||
 					config->pm_max_spare_servers > config->pm_max_children) {
-				zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)",
+				zlog(ZLOG_ALERT, "[pool %s] pm.min_spare_servers(%d) and pm.max_spare_servers(%d) cannot be greater than pm.max_children(%d)",
 						wp->config->name, config->pm_min_spare_servers, config->pm_max_spare_servers, config->pm_max_children);
 				return -1;
 			}
 
 			if (config->pm_max_spare_servers < config->pm_min_spare_servers) {
-				zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.max_spare_servers(%d) must not be less than pm.min_spare_servers(%d)", wp->config->name, config->pm_max_spare_servers, config->pm_min_spare_servers);
+				zlog(ZLOG_ALERT, "[pool %s] pm.max_spare_servers(%d) must not be less than pm.min_spare_servers(%d)", wp->config->name, config->pm_max_spare_servers, config->pm_min_spare_servers);
 				return -1;
 			}
 
 			if (config->pm_start_servers <= 0) {
 				config->pm_start_servers = config->pm_min_spare_servers + ((config->pm_max_spare_servers - config->pm_min_spare_servers) / 2);
-				zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers);
+				zlog(ZLOG_WARNING, "[pool %s] pm.start_servers is not set. It's been set to %d.", wp->config->name, config->pm_start_servers);
 			} else if (config->pm_start_servers < config->pm_min_spare_servers || config->pm_start_servers > config->pm_max_spare_servers) {
-				zlog(ZLOG_STUFF, ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers);
+				zlog(ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers);
 				return -1;
 			}
 
 		}
 
+		if (wp->config->slowlog && *wp->config->slowlog) {
+			fpm_evaluate_full_path(&wp->config->slowlog, wp, NULL, 0);
+		}
 
 		if (wp->config->request_slowlog_timeout) {
 #if HAVE_FPM_TRACE
 			if (! (wp->config->slowlog && *wp->config->slowlog)) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] 'slowlog' must be specified for use with 'request_slowlog_timeout'", wp->config->name);
+				zlog(ZLOG_ERROR, "[pool %s] 'slowlog' must be specified for use with 'request_slowlog_timeout'", wp->config->name);
 				return -1;
 			}
 #else
 			static int warned = 0;
 
 			if (!warned) {
-				zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] 'request_slowlog_timeout' is not supported on your system",	wp->config->name);
+				zlog(ZLOG_WARNING, "[pool %s] 'request_slowlog_timeout' is not supported on your system",	wp->config->name);
 				warned = 1;
 			}
 
 			wp->config->request_slowlog_timeout = 0;
 #endif
-		}
 
-		if (wp->config->request_slowlog_timeout && wp->config->slowlog && *wp->config->slowlog) {
-			int fd;
+			if (wp->config->slowlog && *wp->config->slowlog) {
+				int fd;
 
-			fpm_evaluate_full_path(&wp->config->slowlog);
-
-			if (wp->config->request_slowlog_timeout) {
 				fd = open(wp->config->slowlog, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
 
 				if (0 > fd) {
-					zlog(ZLOG_STUFF, ZLOG_SYSERROR, "open(%s) failed", wp->config->slowlog);
+					zlog(ZLOG_SYSERROR, "open(%s) failed", wp->config->slowlog);
 					return -1;
 				}
 				close(fd);
@@ -515,18 +597,18 @@ static int fpm_conf_process_all_pools() /* {{{ */
 			int i;
 
 			if (*ping != '/') {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the ping path '%s' must start with a '/'", wp->config->name, ping);
+				zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must start with a '/'", wp->config->name, ping);
 				return -1;
 			}
 
 			if (strlen(ping) < 2) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the ping path '%s' is not long enough", wp->config->name, ping);
+				zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' is not long enough", wp->config->name, ping);
 				return -1;
 			}
 
 			for (i=0; i<strlen(ping); i++) {
 				if (!isalnum(ping[i]) && ping[i] != '/' && ping[i] != '-' && ping[i] != '_' && ping[i] != '.') {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the ping path '%s' must containt only the following characters '[alphanum]/_-.'", wp->config->name, ping);
+					zlog(ZLOG_ERROR, "[pool %s] the ping path '%s' must containt only the following characters '[alphanum]/_-.'", wp->config->name, ping);
 					return -1;
 				}
 			}
@@ -535,7 +617,7 @@ static int fpm_conf_process_all_pools() /* {{{ */
 				wp->config->ping_response = strdup("pong");
 			} else {
 				if (strlen(wp->config->ping_response) < 1) {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the ping response page '%s' is not long enough", wp->config->name, wp->config->ping_response);
+					zlog(ZLOG_ERROR, "[pool %s] the ping response page '%s' is not long enough", wp->config->name, wp->config->ping_response);
 					return -1;
 				}
 			}
@@ -552,73 +634,95 @@ static int fpm_conf_process_all_pools() /* {{{ */
 			/* struct fpm_status_s fpm_status; */
 
 			if (*status != '/') {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
+				zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must start with a '/'", wp->config->name, status);
 				return -1;
 			}
 
 			if (strlen(status) < 2) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the status path '%s' is not long enough", wp->config->name, status);
+				zlog(ZLOG_ERROR, "[pool %s] the status path '%s' is not long enough", wp->config->name, status);
 				return -1;
 			}
 
 			for (i=0; i<strlen(status); i++) {
 				if (!isalnum(status[i]) && status[i] != '/' && status[i] != '-' && status[i] != '_' && status[i] != '.') {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
+					zlog(ZLOG_ERROR, "[pool %s] the status path '%s' must contain only the following characters '[alphanum]/_-.'", wp->config->name, status);
 					return -1;
 				}
 			}
 			wp->shm_status = fpm_shm_alloc(sizeof(struct fpm_status_s));
 			if (!wp->shm_status) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to allocate shared memory for status page '%s'", wp->config->name, status);
+				zlog(ZLOG_ERROR, "[pool %s] unable to allocate shared memory for status page '%s'", wp->config->name, status);
 				return -1;
 			}
 			fpm_status_update_accepted_conn(wp->shm_status, 0);
-			fpm_status_update_activity(wp->shm_status, -1, -1, -1, 1);
+			fpm_status_update_activity(wp->shm_status, -1, -1, -1, 0, -1, 1);
+			fpm_status_update_max_children_reached(wp->shm_status, 0);
 			fpm_status_set_pm(wp->shm_status, wp->config->pm);
 			/* memset(&fpm_status.last_update, 0, sizeof(fpm_status.last_update)); */
 		}
 
 		if (wp->config->chroot && *wp->config->chroot) {
+
+			fpm_evaluate_full_path(&wp->config->chroot, wp, NULL, 1);
+
 			if (*wp->config->chroot != '/') {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the chroot path '%s' must start with a '/'", wp->config->name, wp->config->chroot);
+				zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' must start with a '/'", wp->config->name, wp->config->chroot);
 				return -1;
 			}
 			if (!fpm_conf_is_dir(wp->config->chroot)) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the chroot path '%s' does not exist or is not a directory", wp->config->name, wp->config->chroot);
+				zlog(ZLOG_ERROR, "[pool %s] the chroot path '%s' does not exist or is not a directory", wp->config->name, wp->config->chroot);
 				return -1;
 			}
 		}
 
 		if (wp->config->chdir && *wp->config->chdir) {
+
+			fpm_evaluate_full_path(&wp->config->chdir, wp, NULL, 0);
+
 			if (*wp->config->chdir != '/') {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the chdir path '%s' must start with a '/'", wp->config->name, wp->config->chdir);
+				zlog(ZLOG_ERROR, "[pool %s] the chdir path '%s' must start with a '/'", wp->config->name, wp->config->chdir);
 				return -1;
 			}
 
 			if (wp->config->chroot) {
 				char *buf;
-				size_t len;
 
-				len = strlen(wp->config->chroot) + strlen(wp->config->chdir) + 1;
-				buf = malloc(sizeof(char) * len);
-				if (!buf) {
-					zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] malloc() failed", wp->config->name);
-					return -1;
-				}
-				snprintf(buf, len, "%s%s", wp->config->chroot, wp->config->chdir);
+				spprintf(&buf, 0, "%s/%s", wp->config->chroot, wp->config->chdir);
+
 				if (!fpm_conf_is_dir(buf)) {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the chdir path '%s' within the chroot path '%s' ('%s') does not exist or is not a directory", wp->config->name, wp->config->chdir, wp->config->chroot, buf);
-					free(buf);
+					zlog(ZLOG_ERROR, "[pool %s] the chdir path '%s' within the chroot path '%s' ('%s') does not exist or is not a directory", wp->config->name, wp->config->chdir, wp->config->chroot, buf);
+					efree(buf);
 					return -1;
 				}
-				free(buf);
+
+				efree(buf);
 			} else {
 				if (!fpm_conf_is_dir(wp->config->chdir)) {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] the chdir path '%s' does not exist or is not a directory", wp->config->name, wp->config->chdir);
+					zlog(ZLOG_ERROR, "[pool %s] the chdir path '%s' does not exist or is not a directory", wp->config->name, wp->config->chdir);
 					return -1;
 				}
 			}
 		}
+		if (!wp->config->chroot) {
+			struct key_value_s *kv;
+			char *options[] = FPM_PHP_INI_TO_EXPAND;
+			char **p;
+
+			for (kv = wp->config->php_values; kv; kv = kv->next) {
+				for (p=options; *p; p++) {
+					if (!strcasecmp(kv->key, *p)) {
+						fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
+					}
+				}
+			}
+			for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
+				for (p=options; *p; p++) {
+					if (!strcasecmp(kv->key, *p)) {
+						fpm_evaluate_full_path(&kv->value, wp, NULL, 0);
+					}
+				}
+			}
+		}
 	}
 	return 0;
 }
@@ -628,7 +732,7 @@ int fpm_conf_unlink_pid() /* {{{ */
 {
 	if (fpm_global_config.pid_file) {
 		if (0 > unlink(fpm_global_config.pid_file)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "unlink(\"%s\") failed", fpm_global_config.pid_file);
+			zlog(ZLOG_SYSERROR, "unlink(\"%s\") failed", fpm_global_config.pid_file);
 			return -1;
 		}
 	}
@@ -648,14 +752,14 @@ int fpm_conf_write_pid() /* {{{ */
 		fd = creat(fpm_global_config.pid_file, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
 		if (fd < 0) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "creat(\"%s\") failed", fpm_global_config.pid_file);
+			zlog(ZLOG_SYSERROR, "creat(\"%s\") failed", fpm_global_config.pid_file);
 			return -1;
 		}
 
 		len = sprintf(buf, "%d", (int) fpm_globals.parent_pid);
 
 		if (len != write(fd, buf, len)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "write() failed");
+			zlog(ZLOG_SYSERROR, "write() failed");
 			return -1;
 		}
 		close(fd);
@@ -667,18 +771,14 @@ int fpm_conf_write_pid() /* {{{ */
 static int fpm_conf_post_process() /* {{{ */
 {
 	if (fpm_global_config.pid_file) {
-		fpm_evaluate_full_path(&fpm_global_config.pid_file);
+		fpm_evaluate_full_path(&fpm_global_config.pid_file, NULL, PHP_LOCALSTATEDIR, 0);
 	}
 
 	if (!fpm_global_config.error_log) {
-		char *tmp_log_path;
-
-		spprintf(&tmp_log_path, 0, "%s/log/php-fpm.log", PHP_LOCALSTATEDIR);
-		fpm_global_config.error_log = strdup(tmp_log_path);
-		efree(tmp_log_path);
+		fpm_global_config.error_log = strdup("log/php-fpm.log");
 	}
 
-	fpm_evaluate_full_path(&fpm_global_config.error_log);
+	fpm_evaluate_full_path(&fpm_global_config.error_log, NULL, PHP_LOCALSTATEDIR, 0);
 
 	if (0 > fpm_stdio_open_error_log(0)) {
 		return -1;
@@ -694,6 +794,7 @@ static void fpm_conf_cleanup(int which, void *arg) /* {{{ */
 	free(fpm_global_config.error_log);
 	fpm_global_config.pid_file = 0;
 	fpm_global_config.error_log = 0;
+	free(fpm_globals.config);
 }
 /* }}} */
 
@@ -714,12 +815,14 @@ static void fpm_conf_ini_parser_include(char *inc, void *arg TSRMLS_DC) /* {{{ *
 		if ((i = glob(inc, GLOB_ERR | GLOB_MARK | GLOB_NOSORT, NULL, &g)) != 0) {
 #ifdef GLOB_NOMATCH
 			if (i == GLOB_NOMATCH) {
-				zlog(ZLOG_STUFF, ZLOG_WARNING, "Nothing matches the include pattern '%s' from %s at line %d.", inc, filename, ini_lineno);
+				zlog(ZLOG_WARNING, "Nothing matches the include pattern '%s' from %s at line %d.", inc, filename, ini_lineno);
+				efree(filename);
 				return;
 			} 
 #endif /* GLOB_NOMATCH */
-			zlog(ZLOG_STUFF, ZLOG_ERROR, "Unable to globalize '%s' (ret=%d) from %s at line %d.", inc, i, filename, ini_lineno);
+			zlog(ZLOG_ERROR, "Unable to globalize '%s' (ret=%d) from %s at line %d.", inc, i, filename, ini_lineno);
 			*error = 1;
+			efree(filename);
 			return;
 		}
 
@@ -728,8 +831,9 @@ static void fpm_conf_ini_parser_include(char *inc, void *arg TSRMLS_DC) /* {{{ *
 			if (len < 1) continue;
 			if (g.gl_pathv[i][len - 1] == '/') continue; /* don't parse directories */
 			if (0 > fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
+				zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
 				*error = 1;
+				efree(filename);
 				return;
 			}
 		}
@@ -737,11 +841,14 @@ static void fpm_conf_ini_parser_include(char *inc, void *arg TSRMLS_DC) /* {{{ *
 	}
 #else /* HAVE_GLOB */
 	if (0 > fpm_conf_load_ini_file(inc TSRMLS_CC)) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, ini_lineno);
+		zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, ini_lineno);
 		*error = 1;
+		efree(filename);
 		return;
 	}
 #endif /* HAVE_GLOB */
+
+	efree(filename);
 }
 /* }}} */
 
@@ -770,13 +877,13 @@ static void fpm_conf_ini_parser_section(zval *section, void *arg TSRMLS_DC) /* {
 	/* it's a new pool */
 	config = (struct fpm_worker_pool_config_s *)fpm_worker_pool_config_alloc();
 	if (!current_wp || !config) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] Unable to alloc a new WorkerPool for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
+		zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc a new WorkerPool for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
 		*error = 1;
 		return;
 	}
 	config->name = strdup(Z_STRVAL_P(section));
 	if (!config->name) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] Unable to alloc memory for configuration name for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
+		zlog(ZLOG_ERROR, "[%s:%d] Unable to alloc memory for configuration name for worker '%s'", ini_filename, ini_lineno, Z_STRVAL_P(section));
 		*error = 1;
 		return;
 	}
@@ -790,14 +897,14 @@ static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg TSRMLS_
 
 	int *error = (int *)arg;
 	if (!value) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] value is NULL for a ZEND_INI_PARSER_ENTRY", ini_filename, ini_lineno);
+		zlog(ZLOG_ERROR, "[%s:%d] value is NULL for a ZEND_INI_PARSER_ENTRY", ini_filename, ini_lineno);
 		*error = 1;
 		return;
 	}
 
 	if (!strcmp(Z_STRVAL_P(name), "include")) {
 		if (ini_include) {
-			zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] two includes at the same time !", ini_filename, ini_lineno);
+			zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time !", ini_filename, ini_lineno);
 			*error = 1;
 			return;
 		}
@@ -817,14 +924,14 @@ static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg TSRMLS_
 		if (!strcasecmp(parser->name, Z_STRVAL_P(name))) {
 			char *ret;
 			if (!parser->parser) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] the parser for entry '%s' is not defined", ini_filename, ini_lineno, parser->name);
+				zlog(ZLOG_ERROR, "[%s:%d] the parser for entry '%s' is not defined", ini_filename, ini_lineno, parser->name);
 				*error = 1;
 				return;
 			}
 
 			ret = parser->parser(value, &config, parser->offset);
 			if (ret) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, parser->name, ret);
+				zlog(ZLOG_ERROR, "[%s:%d] unable to parse value for entry '%s': %s", ini_filename, ini_lineno, parser->name, ret);
 				*error = 1;
 				return;
 			}
@@ -835,7 +942,7 @@ static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg TSRMLS_
 	}
 
 	/* nothing has been found if we got here */
-	zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] unknown entry '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
+	zlog(ZLOG_ERROR, "[%s:%d] unknown entry '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
 	*error = 1;
 }
 /* }}} */
@@ -846,45 +953,60 @@ static void fpm_conf_ini_parser_array(zval *name, zval *key, zval *value, void *
 	char *err = NULL;
 	void *config;
 
-	if (!Z_STRVAL_P(key) || !Z_STRVAL_P(value) || !*Z_STRVAL_P(key) || !*Z_STRVAL_P(value)) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] Mispell array ?", ini_filename, ini_lineno);
+	if (!Z_STRVAL_P(key) || !Z_STRVAL_P(value) || !*Z_STRVAL_P(key)) {
+		zlog(ZLOG_ERROR, "[%s:%d] Misspelled  array ?", ini_filename, ini_lineno);
 		*error = 1;
 		return;
 	}
 	if (!current_wp || !current_wp->config) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] Array are not allowed in the global section", ini_filename, ini_lineno);
+		zlog(ZLOG_ERROR, "[%s:%d] Array are not allowed in the global section", ini_filename, ini_lineno);
 		*error = 1;
 		return;
 	}
 
 	if (!strcmp("env", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, env);
+		if (!*Z_STRVAL_P(value)) {
+			zlog(ZLOG_ERROR, "[%s:%d] empty value", ini_filename, ini_lineno);
+			*error = 1;
+			return;
+		}
+		config = (char *)current_wp->config + WPO(env);
 		err = fpm_conf_set_array(key, value, &config, 0);
 
 	} else if (!strcmp("php_value", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		if (!*Z_STRVAL_P(value)) {
+			zlog(ZLOG_ERROR, "[%s:%d] empty value", ini_filename, ini_lineno);
+			*error = 1;
+			return;
+		}
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 0);
 
 	} else if (!strcmp("php_admin_value", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		if (!*Z_STRVAL_P(value)) {
+			zlog(ZLOG_ERROR, "[%s:%d] empty value", ini_filename, ini_lineno);
+			*error = 1;
+			return;
+		}
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 0);
 
 	} else if (!strcmp("php_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 1);
 
 	} else if (!strcmp("php_admin_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 1);
 
 	} else {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] unknown directive '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
+		zlog(ZLOG_ERROR, "[%s:%d] unknown directive '%s'", ini_filename, ini_lineno, Z_STRVAL_P(name));
 		*error = 1;
 		return;
 	}
 
 	if (err) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] error while parsing '%s[%s]' : %s", ini_filename, ini_lineno, Z_STRVAL_P(name), Z_STRVAL_P(key), err);
+		zlog(ZLOG_ERROR, "[%s:%d] error while parsing '%s[%s]' : %s", ini_filename, ini_lineno, Z_STRVAL_P(name), Z_STRVAL_P(key), err);
 		*error = 1;
 		return;
 	}
@@ -910,7 +1032,7 @@ static void fpm_conf_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback
 			fpm_conf_ini_parser_array(arg1, arg3, arg2, error TSRMLS_CC);
 			break;;
 		default:
-			zlog(ZLOG_STUFF, ZLOG_ERROR, "[%s:%d] Unknown INI syntax", ini_filename, ini_lineno);
+			zlog(ZLOG_ERROR, "[%s:%d] Unknown INI syntax", ini_filename, ini_lineno);
 			*error = 1;
 			break;;
 	}
@@ -928,18 +1050,18 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
 	int ret = 1;
 
 	if (!filename || !filename[0]) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "Configuration file is empty");
+		zlog(ZLOG_ERROR, "Configuration file is empty");
 		return -1;
 	}
 
 	fd = open(filename, O_RDONLY, 0);
 	if (fd < 0) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
+		zlog(ZLOG_ERROR, "Unable to open file '%s', errno=%d", filename, errno);
 		return -1;
 	}
 
 	if (ini_recursion++ > 4) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "You can include more than 5 files recusively");
+		zlog(ZLOG_ERROR, "You can include more than 5 files recusively");
 		return -1;
 	}
 
@@ -953,7 +1075,7 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
 		buf[n++] = '\n';
 		ini_lineno++;
 		ini_filename = filename;
-		tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
+		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);
@@ -964,7 +1086,7 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
 		if (ini_include) {
 			char *tmp = ini_include;
 			ini_include = NULL;
-			fpm_evaluate_full_path(&tmp);
+			fpm_evaluate_full_path(&tmp, NULL, NULL, 0);
 			fpm_conf_ini_parser_include(tmp, &error TSRMLS_CC);
 			if (error) {
 				free(tmp);
@@ -983,30 +1105,119 @@ int fpm_conf_load_ini_file(char *filename TSRMLS_DC) /* {{{ */
 }
 /* }}} */
 
-int fpm_conf_init_main() /* {{{ */
+static void fpm_conf_dump() /* {{{ */
+{
+	struct fpm_worker_pool_s *wp;
+
+	zlog(ZLOG_NOTICE, "[General]");
+	zlog(ZLOG_NOTICE, "\tpid = %s", STR2STR(fpm_global_config.pid_file));
+	zlog(ZLOG_NOTICE, "\tdaemonize = %s", BOOL2STR(fpm_global_config.daemonize));
+	zlog(ZLOG_NOTICE, "\terror_log = %s", STR2STR(fpm_global_config.error_log));
+	zlog(ZLOG_NOTICE, "\tlog_level = %s", zlog_get_level_name());
+	zlog(ZLOG_NOTICE, "\tprocess_control_timeout = %ds", fpm_global_config.process_control_timeout);
+	zlog(ZLOG_NOTICE, "\temergency_restart_interval = %ds", fpm_global_config.emergency_restart_interval);
+	zlog(ZLOG_NOTICE, "\temergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold);
+	zlog(ZLOG_NOTICE, " ");
+
+	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
+		struct key_value_s *kv;
+		if (!wp->config) continue;
+		zlog(ZLOG_NOTICE, "[%s]", STR2STR(wp->config->name));
+		zlog(ZLOG_NOTICE, "\tprefix = %s", STR2STR(wp->config->prefix));
+		zlog(ZLOG_NOTICE, "\tuser = %s", STR2STR(wp->config->user));
+		zlog(ZLOG_NOTICE, "\tgroup = %s", STR2STR(wp->config->group));
+		zlog(ZLOG_NOTICE, "\tchroot = %s", STR2STR(wp->config->chroot));
+		zlog(ZLOG_NOTICE, "\tchdir = %s", STR2STR(wp->config->chdir));
+		zlog(ZLOG_NOTICE, "\tlisten = %s", STR2STR(wp->config->listen_address));
+		zlog(ZLOG_NOTICE, "\tlisten.backlog = %d", wp->config->listen_backlog);
+		zlog(ZLOG_NOTICE, "\tlisten.owner = %s", STR2STR(wp->config->listen_owner));
+		zlog(ZLOG_NOTICE, "\tlisten.group = %s", STR2STR(wp->config->listen_group));
+		zlog(ZLOG_NOTICE, "\tlisten.mode = %s", STR2STR(wp->config->listen_mode));
+		zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s", STR2STR(wp->config->listen_allowed_clients));
+		zlog(ZLOG_NOTICE, "\tpm = %s", PM2STR(wp->config->pm));
+		zlog(ZLOG_NOTICE, "\tpm.max_children = %d", wp->config->pm_max_children);
+		zlog(ZLOG_NOTICE, "\tpm.max_requests = %d", wp->config->pm_max_requests);
+		zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers);
+		zlog(ZLOG_NOTICE, "\tpm.min_spare_servers = %d", wp->config->pm_min_spare_servers);
+		zlog(ZLOG_NOTICE, "\tpm.max_spare_servers = %d", wp->config->pm_max_spare_servers);
+		zlog(ZLOG_NOTICE, "\tpm.status_path = %s", STR2STR(wp->config->pm_status_path));
+		zlog(ZLOG_NOTICE, "\tping.path = %s", STR2STR(wp->config->ping_path));
+		zlog(ZLOG_NOTICE, "\tping.response = %s", STR2STR(wp->config->ping_response));
+		zlog(ZLOG_NOTICE, "\tcatch_workers_output = %s", BOOL2STR(wp->config->catch_workers_output));
+		zlog(ZLOG_NOTICE, "\trequest_terminate_timeout = %ds", wp->config->request_terminate_timeout);
+		zlog(ZLOG_NOTICE, "\trequest_slowlog_timeout = %ds", wp->config->request_slowlog_timeout);
+		zlog(ZLOG_NOTICE, "\tslowlog = %s", STR2STR(wp->config->slowlog));
+		zlog(ZLOG_NOTICE, "\trlimit_files = %d", wp->config->rlimit_files);
+		zlog(ZLOG_NOTICE, "\trlimit_core = %d", wp->config->rlimit_core);
+
+		for (kv = wp->config->env; kv; kv = kv->next) {
+			zlog(ZLOG_NOTICE, "\tenv[%s] = %s", kv->key, kv->value);
+		}
+
+		for (kv = wp->config->php_values; kv; kv = kv->next) {
+			zlog(ZLOG_NOTICE, "\tphp_value[%s] = %s", kv->key, kv->value);
+		}
+
+		for (kv = wp->config->php_admin_values; kv; kv = kv->next) {
+			zlog(ZLOG_NOTICE, "\tphp_admin_value[%s] = %s", kv->key, kv->value);
+		}
+		zlog(ZLOG_NOTICE, " ");
+	}
+}
+/* }}} */
+
+int fpm_conf_init_main(int test_conf) /* {{{ */
 {
-	char *filename = fpm_globals.config;
-	int free = 0;
 	int ret;
 	TSRMLS_FETCH();
 
-	if (filename == NULL) {
-		spprintf(&filename, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
-		free = 1;
+	if (fpm_globals.prefix && *fpm_globals.prefix) {
+		if (!fpm_conf_is_dir(fpm_globals.prefix)) {
+			zlog(ZLOG_ERROR, "the global prefix '%s' does not exist or is not a directory", fpm_globals.prefix);
+			return -1;
+		}
 	}
 
-	ret = fpm_conf_load_ini_file(filename TSRMLS_CC);
+	if (fpm_globals.config == NULL) {
+		char *tmp;
+
+		if (fpm_globals.prefix == NULL) {
+			spprintf(&tmp, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
+		} else {
+			spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
+		}
+
+		if (!tmp) {
+			zlog(ZLOG_SYSERROR, "spprintf() failed (tmp for fpm_globals.config)");
+			return -1;
+		}
+
+		fpm_globals.config = strdup(tmp);
+		efree(tmp);
+
+		if (!fpm_globals.config) {
+			zlog(ZLOG_SYSERROR, "spprintf() failed (fpm_globals.config)");
+			return -1;
+		}
+	}
+
+	ret = fpm_conf_load_ini_file(fpm_globals.config TSRMLS_CC);
 
 	if (0 > ret) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "failed to load configuration file '%s'", filename);
-		if (free) efree(filename);
+		zlog(ZLOG_ERROR, "failed to load configuration file '%s'", fpm_globals.config);
 		return -1;
 	}
 
-	if (free) efree(filename);
-
 	if (0 > fpm_conf_post_process()) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "failed to post process the configuration");
+		zlog(ZLOG_ERROR, "failed to post process the configuration");
+		return -1;
+	}
+
+	if (test_conf) {
+		if (test_conf > 1) {
+			fpm_conf_dump();
+		}
+		zlog(ZLOG_NOTICE, "configuration file %s test is successful\n", fpm_globals.config);
 		return -1;
 	}
 
diff --git a/sapi/fpm/fpm/fpm_conf.h b/sapi/fpm/fpm/fpm_conf.h
index aace781..ac38ee2 100644
--- a/sapi/fpm/fpm/fpm_conf.h
+++ b/sapi/fpm/fpm/fpm_conf.h
@@ -10,6 +10,10 @@
 
 #define FPM_CONF_MAX_PONG_LENGTH 64
 
+#define STR2STR(a) (a ? a : "undefined")
+#define BOOL2STR(a) (a ? "yes" : "no")
+#define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : "dynamic")
+
 struct key_value_s;
 
 struct key_value_s {
@@ -31,6 +35,7 @@ extern struct fpm_global_config_s fpm_global_config;
 
 struct fpm_worker_pool_config_s {
 	char *name;
+	char *prefix;
 	char *user;
 	char *group;
 	char *chroot;
@@ -69,7 +74,7 @@ struct ini_value_parser_s {
 
 enum { PM_STYLE_STATIC = 1, PM_STYLE_DYNAMIC = 2 };
 
-int fpm_conf_init_main();
+int fpm_conf_init_main(int test_conf);
 int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc);
 int fpm_conf_write_pid();
 int fpm_conf_unlink_pid();
diff --git a/sapi/fpm/fpm/fpm_config.h b/sapi/fpm/fpm/fpm_config.h
index 165bd7d..3637f37 100644
--- a/sapi/fpm/fpm/fpm_config.h
+++ b/sapi/fpm/fpm/fpm_config.h
@@ -1,44 +1,83 @@
-
-	/* $Id: fpm_config.h,v 1.16 2008/05/25 00:30:43 anight Exp $ */
-	/* (c) 2007,2008 Andrei Nigmatulin */
+/* $Id: fpm_config.h,v 1.16 2008/05/25 00:30:43 anight Exp $ */
+/* (c) 2007,2008 Andrei Nigmatulin */
 
 #include <php_config.h>
+
 #ifdef FPM_AUTOCONFIG_H
-#include <fpm_autoconfig.h>
+# include <fpm_autoconfig.h>
 #endif
 
 /* Solaris does not have it */
 #ifndef INADDR_NONE
-#define INADDR_NONE (-1)
+# define INADDR_NONE (-1)
 #endif
 
 
 /* If we're not using GNU C, elide __attribute__ */
 #ifndef __GNUC__
-#  define  __attribute__(x)  /*NOTHING*/
+# define __attribute__(x)  /*NOTHING*/
 #endif
 
+/* Missing timer* macros (for solaris) */
+#ifndef timerisset
+# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#endif
+
+#ifndef timerclear
+# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#endif
 
-/* Solaris does not have it */
 #ifndef timersub
-#define	timersub(tvp, uvp, vvp)						\
-	do {								\
-		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
-		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
-		if ((vvp)->tv_usec < 0) {				\
-			(vvp)->tv_sec--;				\
-			(vvp)->tv_usec += 1000000;			\
-		}							\
+# define timersub(tvp, uvp, vvp)                          \
+	do {                                                  \
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;    \
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+		if ((vvp)->tv_usec < 0) {                         \
+			(vvp)->tv_sec--;                              \
+			(vvp)->tv_usec += 1000000;                    \
+		}                                                 \
+	} while (0)
+#endif
+
+#ifndef timeradd
+# define timeradd(a, b, result)                          \
+	do {                                                 \
+		(result)->tv_sec = (a)->tv_sec + (b)->tv_sec;    \
+		(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+		if ((result)->tv_usec >= 1000000)                \
+		{                                                \
+			++(result)->tv_sec;                          \
+			(result)->tv_usec -= 1000000;                \
+		}                                                \
 	} while (0)
 #endif
 
+#ifndef timercmp
+/* does not work for >= and <= */
+# define timercmp(a, b, CMP)         \
+  (((a)->tv_sec == (b)->tv_sec) ?    \
+  ((a)->tv_usec CMP (b)->tv_usec) :  \
+    ((a)->tv_sec CMP (b)->tv_sec))
+#endif
+/* endof timer* macros */
+
 #ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
+# define MIN(a,b) (((a)<(b))?(a):(b))
+#endif
+
+#ifndef MAX
+# define MAX(a,b) (((a)>(b))?(a):(b))
 #endif
 
 #if defined(HAVE_PTRACE) || defined(PROC_MEM_FILE) || defined(HAVE_MACH_VM_READ)
-#define HAVE_FPM_TRACE 1
+# define HAVE_FPM_TRACE 1
+#else
+# define HAVE_FPM_TRACE 0
+#endif
+
+#if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_SO_LISTENQ)
+# define HAVE_FPM_LQ 1
 #else
-#define HAVE_FPM_TRACE 0
+# define HAVE_FPM_LQ 0
 #endif
 
diff --git a/sapi/fpm/fpm/fpm_env.c b/sapi/fpm/fpm/fpm_env.c
index ddc4705..aa647d1 100644
--- a/sapi/fpm/fpm/fpm_env.c
+++ b/sapi/fpm/fpm/fpm_env.c
@@ -12,8 +12,16 @@
 #include <string.h>
 
 #include "fpm_env.h"
+#include "fpm.h"
 #include "zlog.h"
 
+#ifndef HAVE_SETPROCTITLE
+#ifdef __linux__
+static char **fpm_env_argv = NULL;
+static size_t fpm_env_argv_len = 0;
+#endif
+#endif
+
 #ifndef HAVE_SETENV
 # ifdef (__sparc__ || __sparc)
 int setenv(char *name, char *value, int clobber) /* {{{ */
@@ -111,9 +119,30 @@ static char * nvmatch(char *s1, char *s2) /* {{{ */
 /* }}} */
 #endif
 
+void fpm_env_setproctitle(char *title) /* {{{ */
+{
+#ifdef HAVE_SETPROCTITLE
+	setproctitle("%s", title);
+#else
+#ifdef __linux__
+	if (fpm_env_argv != NULL && fpm_env_argv_len > strlen(SETPROCTITLE_PREFIX) + 3) {
+		memset(fpm_env_argv[0], 0, fpm_env_argv_len);
+		strncpy(fpm_env_argv[0], SETPROCTITLE_PREFIX, fpm_env_argv_len - 2);
+		strncpy(fpm_env_argv[0] + strlen(SETPROCTITLE_PREFIX), title, fpm_env_argv_len - strlen(SETPROCTITLE_PREFIX) - 2);
+		fpm_env_argv[1] = NULL;
+	}
+#endif
+#endif
+}
+/* }}} */
+
 int fpm_env_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 {
 	struct key_value_s *kv;
+	char *title;
+	spprintf(&title, 0, "pool %s", wp->config->name);
+	fpm_env_setproctitle(title); 
+	efree(title);
 
 	clearenv();
 
@@ -169,12 +198,79 @@ static int fpm_env_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
 int fpm_env_init_main() /* {{{ */
 {
 	struct fpm_worker_pool_s *wp;
+	int i;
+	char *first = NULL;
+	char *last = NULL;
+	char *title;
 
 	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
 		if (0 > fpm_env_conf_wp(wp)) {
 			return -1;
 		}
 	}
+#ifndef HAVE_SETPROCTITLE
+#ifdef __linux__
+	/*
+	 * This piece of code has been inspirated from nginx and pureftpd code, whic
+	 * are under BSD licence.
+	 *
+	 * To change the process title in Linux we have to set argv[1] to NULL
+	 * and to copy the title to the same place where the argv[0] points to.
+	 * However, argv[0] may be too small to hold a new title.  Fortunately, Linux
+	 * store argv[] and environ[] one after another.  So we should ensure that is
+	 * the continuous memory and then we allocate the new memory for environ[]
+	 * and copy it.  After this we could use the memory starting from argv[0] for
+	 * our process title.
+	 */
+
+	for (i = 0; i < fpm_globals.argc; i++) {
+		if (first == NULL) {
+			first = fpm_globals.argv[i];
+		}
+		if (last == NULL || fpm_globals.argv[i] == last + 1) {
+			last = fpm_globals.argv[i] + strlen(fpm_globals.argv[i]);
+		}
+	}
+	if (environ) {
+		for (i = 0; environ[i]; i++) {
+			if (first == NULL) {
+				first = environ[i];
+			}
+			if (last == NULL || environ[i] == last + 1) {
+				last = environ[i] + strlen(environ[i]);
+			}
+		}
+	}
+	if (first == NULL || last == NULL) {
+		return 0;
+	}
+
+	fpm_env_argv_len = last - first;
+	fpm_env_argv = fpm_globals.argv;
+	if (environ != NULL) {
+		char **new_environ;
+		unsigned int env_nb = 0U;
+
+		while (environ[env_nb]) {
+			env_nb++;
+		}
+
+		if ((new_environ = malloc((1U + env_nb) * sizeof (char *))) == NULL) {
+			return -1;
+		}
+		new_environ[env_nb] = NULL;
+		while (env_nb > 0U) {
+			env_nb--;
+			new_environ[env_nb] = strdup(environ[env_nb]);
+		}
+		environ = new_environ;
+	}
+#endif
+#endif
+
+	spprintf(&title, 0, "master process (%s)", fpm_globals.config);
+	fpm_env_setproctitle(title); 
+	efree(title);
 	return 0;
 }
 /* }}} */
diff --git a/sapi/fpm/fpm/fpm_env.h b/sapi/fpm/fpm/fpm_env.h
index 0f79ed7..bf47236 100644
--- a/sapi/fpm/fpm/fpm_env.h
+++ b/sapi/fpm/fpm/fpm_env.h
@@ -7,8 +7,11 @@
 
 #include "fpm_worker_pool.h"
 
+#define SETPROCTITLE_PREFIX "php-fpm: "
+
 int fpm_env_init_child(struct fpm_worker_pool_s *wp);
 int fpm_env_init_main();
+void fpm_env_setproctitle(char *title);
 
 extern char **environ;
 
diff --git a/sapi/fpm/fpm/fpm_events.c b/sapi/fpm/fpm/fpm_events.c
index aa4086d..66ff393 100644
--- a/sapi/fpm/fpm/fpm_events.c
+++ b/sapi/fpm/fpm/fpm_events.c
@@ -9,6 +9,9 @@
 #include <stdlib.h> /* for putenv */
 #include <string.h>
 
+#include <php.h>
+#include <php_network.h>
+
 #include "fpm.h"
 #include "fpm_process_ctl.h"
 #include "fpm_events.h"
@@ -17,19 +20,43 @@
 #include "fpm_signals.h"
 #include "fpm_children.h"
 #include "zlog.h"
+#include "fpm_clock.h"
+
+#define fpm_event_set_timeout(ev, now) timeradd(&(now), &(ev)->frequency, &(ev)->timeout);
+
+typedef struct fpm_event_queue_s {
+	struct fpm_event_queue_s *prev;
+	struct fpm_event_queue_s *next;
+	struct fpm_event_s *ev;
+} fpm_event_queue;
+
+static void fpm_event_cleanup(int which, void *arg);
+static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg);
+static struct fpm_event_s *fpm_event_queue_isset(struct fpm_event_queue_s *queue, struct fpm_event_s *ev);
+static int fpm_event_queue_add(struct fpm_event_queue_s **queue, struct fpm_event_s *ev);
+static int fpm_event_queue_del(struct fpm_event_queue_s **queue, struct fpm_event_s *ev);
+static void fpm_event_queue_destroy(struct fpm_event_queue_s **queue);
+
+static int fpm_event_nfds_max;
+static struct fpm_event_queue_s *fpm_event_queue_timer = NULL;
+static struct fpm_event_queue_s *fpm_event_queue_fd = NULL;
+static php_pollfd *fpm_event_ufds = NULL;
 
 static void fpm_event_cleanup(int which, void *arg) /* {{{ */
 {
-	struct event_base *base = (struct event_base *)arg;
-	event_base_free(base);
+	if (fpm_event_ufds) {
+		free(fpm_event_ufds);
+	}
+	fpm_event_queue_destroy(&fpm_event_queue_timer);
+	fpm_event_queue_destroy(&fpm_event_queue_fd);
 }
 /* }}} */
 
-static void fpm_got_signal(int fd, short ev, void *arg) /* {{{ */
+static void fpm_got_signal(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
 {
 	char c;
 	int res;
-	struct event_base *base = (struct event_base *)arg;
+	int fd = ev->fd;;
 
 	do {
 		do {
@@ -38,43 +65,43 @@ static void fpm_got_signal(int fd, short ev, void *arg) /* {{{ */
 
 		if (res <= 0) {
 			if (res < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "read() failed");
+				zlog(ZLOG_SYSERROR, "read() failed");
 			}
 			return;
 		}
 
 		switch (c) {
 			case 'C' :                  /* SIGCHLD */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGCHLD");
-				fpm_children_bury(base);
+				zlog(ZLOG_DEBUG, "received SIGCHLD");
+				fpm_children_bury();
 				break;
 			case 'I' :                  /* SIGINT  */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGINT");
-				zlog(ZLOG_STUFF, ZLOG_NOTICE, "Terminating ...");
-				fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET, base);
+				zlog(ZLOG_DEBUG, "received SIGINT");
+				zlog(ZLOG_NOTICE, "Terminating ...");
+				fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
 				break;
 			case 'T' :                  /* SIGTERM */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGTERM");
-				zlog(ZLOG_STUFF, ZLOG_NOTICE, "Terminating ...");
-				fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET, base);
+				zlog(ZLOG_DEBUG, "received SIGTERM");
+				zlog(ZLOG_NOTICE, "Terminating ...");
+				fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
 				break;
 			case 'Q' :                  /* SIGQUIT */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGQUIT");
-				zlog(ZLOG_STUFF, ZLOG_NOTICE, "Finishing ...");
-				fpm_pctl(FPM_PCTL_STATE_FINISHING, FPM_PCTL_ACTION_SET, base);
+				zlog(ZLOG_DEBUG, "received SIGQUIT");
+				zlog(ZLOG_NOTICE, "Finishing ...");
+				fpm_pctl(FPM_PCTL_STATE_FINISHING, FPM_PCTL_ACTION_SET);
 				break;
 			case '1' :                  /* SIGUSR1 */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGUSR1");
+				zlog(ZLOG_DEBUG, "received SIGUSR1");
 				if (0 == fpm_stdio_open_error_log(1)) {
-					zlog(ZLOG_STUFF, ZLOG_NOTICE, "log file re-opened");
+					zlog(ZLOG_NOTICE, "log file re-opened");
 				} else {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "unable to re-opened log file");
+					zlog(ZLOG_ERROR, "unable to re-opened log file");
 				}
 				break;
 			case '2' :                  /* SIGUSR2 */
-				zlog(ZLOG_STUFF, ZLOG_DEBUG, "received SIGUSR2");
-				zlog(ZLOG_STUFF, ZLOG_NOTICE, "Reloading in progress ...");
-				fpm_pctl(FPM_PCTL_STATE_RELOADING, FPM_PCTL_ACTION_SET, base);
+				zlog(ZLOG_DEBUG, "received SIGUSR2");
+				zlog(ZLOG_NOTICE, "Reloading in progress ...");
+				fpm_pctl(FPM_PCTL_STATE_RELOADING, FPM_PCTL_ACTION_SET);
 				break;
 		}
 
@@ -86,57 +113,335 @@ static void fpm_got_signal(int fd, short ev, void *arg) /* {{{ */
 }
 /* }}} */
 
-int fpm_event_init_main(struct event_base **base) /* {{{ */
+static struct fpm_event_s *fpm_event_queue_isset(struct fpm_event_queue_s *queue, struct fpm_event_s *ev) /* {{{ */
+{
+	if (!ev) {
+		return NULL;
+	}
+
+	while (queue) {
+		if (queue->ev == ev) {
+			return ev;
+		}
+		queue = queue->next;
+	}
+
+	return NULL;
+}
+/* }}} */
+
+static int fpm_event_queue_add(struct fpm_event_queue_s **queue, struct fpm_event_s *ev) /* {{{ */
 {
-	*base = event_base_new();
+	struct fpm_event_queue_s *elt;
 
-	zlog(ZLOG_STUFF, ZLOG_DEBUG, "libevent: using %s", event_base_get_method(*base));
+	if (!queue || !ev) {
+		return -1;
+	}
 
-	if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_event_cleanup, *base)) {
+	if (fpm_event_queue_isset(*queue, ev)) {
+		return 0;
+	}
+
+	if (!(elt = malloc(sizeof(struct fpm_event_queue_s)))) {
+		zlog(ZLOG_SYSERROR, "malloc() failed");
 		return -1;
 	}
-	return 0;
+	elt->prev = NULL;
+	elt->next = NULL;
+	elt->ev = ev;
+
+	if (*queue) {
+		(*queue)->prev = elt;
+		elt->next = *queue;
+	}
+	*queue = elt;
+
+	return 0;	
+}
+/* }}} */
+
+static int fpm_event_queue_del(struct fpm_event_queue_s **queue, struct fpm_event_s *ev) /* {{{ */
+{
+	struct fpm_event_queue_s *q;
+	if (!queue || !ev) {
+		return -1;
+	}
+	q = *queue;
+	while (q) {
+		if (q->ev == ev) {
+			if (q->prev) {
+				q->prev->next = q->next;
+			}
+			if (q->next) {
+				q->next->prev = q->prev;
+			}
+			if (q == *queue) {
+				*queue = q->next;
+				(*queue)->prev = NULL;
+			}
+			free(q);
+			return 0;
+		}
+		q = q->next;
+	}
+	return -1;
+}
+/* }}} */
+
+static void fpm_event_queue_destroy(struct fpm_event_queue_s **queue) /* {{{ */
+{
+	struct fpm_event_queue_s *q, *tmp;
+
+	if (!queue) {
+		return;
+	}
+	q = *queue;
+	while (q) {
+		tmp = q;
+		q = q->next;
+		/* q->prev = NULL */
+		free(tmp);
+	}
+	*queue = NULL;
 }
 /* }}} */
 
-int fpm_event_loop(struct event_base *base) /* {{{ */
+int fpm_event_init_main() /* {{{ */
 {
-	static struct event signal_fd_event;
-
-	event_set(&signal_fd_event, fpm_signals_get_fd(), EV_PERSIST | EV_READ, &fpm_got_signal, base);
-	event_base_set(base, &signal_fd_event);
-	event_add(&signal_fd_event, 0);
-	fpm_pctl_heartbeat(-1, 0, base);
-	fpm_pctl_perform_idle_server_maintenance_heartbeat(-1, 0, base);
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "ready to handle connections");
-	event_base_dispatch(base);
+	struct fpm_worker_pool_s *wp;
+
+	/* count the max number of necessary fds for polling */
+	fpm_event_nfds_max = 1; /* only one FD is necessary at startup for the master process signal pipe */
+	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
+		if (!wp->config) continue;
+		if (wp->config->catch_workers_output && wp->config->pm_max_children > 0) {
+			fpm_event_nfds_max += (wp->config->pm_max_children * 2);
+		}
+	}
+
+	/* malloc the max number of necessary fds for polling */
+	fpm_event_ufds = malloc(sizeof(php_pollfd) * fpm_event_nfds_max);
+	if (!fpm_event_ufds) {
+		zlog(ZLOG_SYSERROR, "malloc() failed");
+		return -1;
+	}
+
+	zlog(ZLOG_DEBUG, "%d fds have been reserved", fpm_event_nfds_max);
+
+	if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_event_cleanup, NULL)) {
+		return -1;
+	}
 	return 0;
 }
 /* }}} */
 
-int fpm_event_add(int fd, struct event_base *base, struct event *ev, void (*callback)(int, short, void *), void *arg) /* {{{ */
+void fpm_event_loop() /* {{{ */
+{
+	static struct fpm_event_s signal_fd_event;
+
+	/* sanity check */
+	if (fpm_globals.parent_pid != getpid()) {
+		return;
+	}
+
+	fpm_event_set(&signal_fd_event, fpm_signals_get_fd(), FPM_EV_READ, &fpm_got_signal, NULL);
+	fpm_event_add(&signal_fd_event, 0);
+
+	/* add timers */
+	fpm_pctl_heartbeat(NULL, 0, NULL);
+	fpm_pctl_perform_idle_server_maintenance_heartbeat(NULL, 0, NULL);
+
+	zlog(ZLOG_NOTICE, "ready to handle connections");
+
+	while (1) {
+		struct fpm_event_queue_s *q, *q2;
+		struct timeval ms;
+		struct timeval tmp;
+		struct timeval now;
+		unsigned long int timeout;
+		int i, ret;
+
+		/* sanity check */
+		if (fpm_globals.parent_pid != getpid()) {
+			return;
+		}
+
+		fpm_clock_get(&now);
+		timerclear(&ms);
+
+		/* search in the timeout queue for the next timer to trigger */
+		q = fpm_event_queue_timer;
+		while (q) {
+			if (!timerisset(&ms)) {
+				ms = q->ev->timeout;
+			} else {
+				if (timercmp(&q->ev->timeout, &ms, <)) {
+					ms = q->ev->timeout;
+				}
+			}
+			q = q->next;
+		}
+
+		/* 1s timeout if none has been set */
+		if (!timerisset(&ms) || timercmp(&ms, &now, <) || timercmp(&ms, &now, ==)) {
+			timeout = 1000;
+		} else {
+			timersub(&ms, &now, &tmp);
+			timeout = (tmp.tv_sec * 1000) + (tmp.tv_usec / 1000) + 1;
+		}
+
+		/* init fpm_event_ufds for php_poll2 */
+		memset(fpm_event_ufds, 0, sizeof(php_pollfd) * fpm_event_nfds_max);
+		i = 0;
+		q = fpm_event_queue_fd;
+		while (q && i < fpm_event_nfds_max) {
+			fpm_event_ufds[i].fd = q->ev->fd;
+			fpm_event_ufds[i].events = POLLIN;
+			q->ev->index = i++;
+			q = q->next;
+		}
+
+		/* wait for inconming event or timeout */
+		if ((ret = php_poll2(fpm_event_ufds, i, timeout)) == -1) {
+			if (errno != EINTR) {
+				zlog(ZLOG_WARNING, "php_poll2() returns %d", errno);
+			}
+		} else if (ret > 0) {
+
+			/* trigger POLLIN events */
+			q = fpm_event_queue_fd;
+			while (q) {
+				if (q->ev && q->ev->index >= 0 && q->ev->index < fpm_event_nfds_max) {
+					if (q->ev->fd == fpm_event_ufds[q->ev->index].fd) {
+						if (fpm_event_ufds[q->ev->index].revents & POLLIN) {
+							fpm_event_fire(q->ev);
+							/* sanity check */
+							if (fpm_globals.parent_pid != getpid()) {
+								return;
+							}
+						}
+					}
+					q->ev->index = -1;
+				}
+				q = q->next;
+			}
+		}
+
+		/* trigger timers */
+		q = fpm_event_queue_timer;
+		while (q) {
+			fpm_clock_get(&now);
+			if (q->ev) {
+				if (timercmp(&now, &q->ev->timeout, >) || timercmp(&now, &q->ev->timeout, ==)) {
+					fpm_event_fire(q->ev);
+					/* sanity check */
+					if (fpm_globals.parent_pid != getpid()) {
+						return;
+					}
+					if (q->ev->flags & FPM_EV_PERSIST) {
+						fpm_event_set_timeout(q->ev, now);
+					} else { /* delete the event */
+						q2 = q;
+						if (q->prev) {
+							q->prev->next = q->next;
+						}
+						if (q->next) {
+							q->next->prev = q->prev;
+						}
+						if (q == fpm_event_queue_timer) {
+							fpm_event_queue_timer = q->next;
+							fpm_event_queue_timer->prev = NULL;
+						}
+						q = q->next;
+						free(q2);
+						continue;
+					}
+				}
+			}
+			q = q->next;
+		}
+	}
+}
+/* }}} */
+
+void fpm_event_fire(struct fpm_event_s *ev) /* {{{ */
 {
-	event_set(ev, fd, EV_PERSIST | EV_READ, callback, arg);
-	event_base_set(base, ev);
-	return event_add(ev, 0);
+	if (!ev || !ev->callback) {
+		return;
+	}
+
+	(*ev->callback)( (struct fpm_event_s *) ev, ev->which, ev->arg);	
 }
 /* }}} */
 
-int fpm_event_del(struct event *ev) /* {{{ */
+int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void (*callback)(struct fpm_event_s *, short, void *), void *arg) /* {{{ */
 {
-	return event_del(ev);
+	if (!ev || !callback || fd < -1) {
+		return -1;
+	}
+	memset(ev, 0, sizeof(struct fpm_event_s));
+	ev->fd = fd;
+	ev->callback = callback;
+	ev->arg = arg;
+	ev->flags = flags;
+	return 0;
 }
 /* }}} */
 
-void fpm_event_exit_loop(struct event_base *base) /* {{{ */
+int fpm_event_add(struct fpm_event_s *ev, unsigned long int frequency) /* {{{ */
 {
-	event_base_loopbreak(base);
+	struct timeval now;
+	struct timeval tmp;
+
+	if (!ev) {
+		return -1;
+	}
+
+	ev->index = -1;
+
+	/* it's a triggered event on incoming data */
+	if (ev->flags & FPM_EV_READ) {
+		ev->which = FPM_EV_READ;
+		if (fpm_event_queue_add(&fpm_event_queue_fd, ev) != 0) {
+			return -1;
+		}
+		return 0;
+	}
+
+	/* it's a timer event */
+	ev->which = FPM_EV_TIMEOUT;
+
+	fpm_clock_get(&now);
+	if (frequency >= 1000) {
+		tmp.tv_sec = frequency / 1000;
+		tmp.tv_usec = (frequency % 1000) * 1000;
+	} else {
+		tmp.tv_sec = 0;
+		tmp.tv_usec = frequency * 1000;
+	}
+	ev->frequency = tmp;
+	fpm_event_set_timeout(ev, now);
+
+	if (fpm_event_queue_add(&fpm_event_queue_timer, ev) != 0) {
+		return -1;
+	}
+
+	return 0;
 }
 /* }}} */
 
-void fpm_event_fire(struct event *ev) /* {{{ */
+int fpm_event_del(struct fpm_event_s *ev) /* {{{ */
 {
-	(*ev->ev_callback)( (int) ev->ev_fd, (short) ev->ev_res, ev->ev_arg);	
+	if (fpm_event_queue_del(&fpm_event_queue_fd, ev) != 0) {
+		return -1;
+	}
+
+	if (fpm_event_queue_del(&fpm_event_queue_timer, ev) != 0) {
+		return -1;
+	}
+
+	return 0;
 }
 /* }}} */
 
+/* }}} */
diff --git a/sapi/fpm/fpm/fpm_events.h b/sapi/fpm/fpm/fpm_events.h
index 7a5a9a5..bec13ba 100644
--- a/sapi/fpm/fpm/fpm_events.h
+++ b/sapi/fpm/fpm/fpm_events.h
@@ -5,12 +5,28 @@
 #ifndef FPM_EVENTS_H
 #define FPM_EVENTS_H 1
 
-void fpm_event_exit_loop(struct event_base *base);
-int fpm_event_loop(struct event_base *base);
-int fpm_event_add(int fd, struct event_base *base, struct event *ev, void (*callback)(int, short, void *), void *arg);
-int fpm_event_del(struct event *ev);
-void fpm_event_fire(struct event *ev);
-int fpm_event_init_main(struct event_base **base);
+#define FPM_EV_TIMEOUT  (1 << 0)
+#define FPM_EV_READ     (1 << 1)
+#define FPM_EV_PERSIST  (1 << 2)
 
+#define fpm_event_set_timer(ev, flags, cb, arg) fpm_event_set((ev), -1, (flags), (cb), (arg))
+
+struct fpm_event_s {
+	int fd;                   /* not set with FPM_EV_TIMEOUT */
+	struct timeval timeout;   /* next time to trigger */
+	struct timeval frequency;
+	void (*callback)(struct fpm_event_s *, short, void *);
+	void *arg;
+	int flags;
+	int index;                /* index of the fd in the ufds array */
+	short which;              /* type of event */
+};
+
+void fpm_event_loop();
+void fpm_event_fire(struct fpm_event_s *ev);
+int fpm_event_init_main();
+int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void (*callback)(struct fpm_event_s *, short, void *), void *arg);
+int fpm_event_add(struct fpm_event_s *ev, unsigned long int timeout);
+int fpm_event_del(struct fpm_event_s *ev);
 
 #endif
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 2ee4539..8f0d760 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -152,6 +152,8 @@ static const opt_struct OPTIONS[] = {
 	{'?', 0, "usage"},/* help alias (both '?' and 'usage') */
 	{'v', 0, "version"},
 	{'y', 1, "fpm-config"},
+	{'t', 0, "test"},
+	{'p', 1, "prefix"},
 	{'-', 0, NULL} /* end of args */
 };
 
@@ -166,7 +168,6 @@ typedef struct _php_cgi_globals_struct {
 	HashTable user_config_cache;
 	char *error_header;
 	char *fpm_config;
-	struct event_base *event_base;
 } php_cgi_globals_struct;
 
 /* {{{ user_config_cache
@@ -959,7 +960,7 @@ static void php_cgi_usage(char *argv0)
 		prog = "php";
 	}
 
-	php_printf(	"Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-c <file>] [-d foo[=bar]] [-y <file>]\n"
+	php_printf(	"Usage: %s [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix> ] [-c <file>] [-d foo[=bar]] [-y <file>]\n"
 				"  -c <path>|<file> Look for php.ini file in this directory\n"
 				"  -n               No php.ini file will be used\n"
 				"  -d foo[=bar]     Define INI entry foo with value 'bar'\n"
@@ -968,9 +969,12 @@ static void php_cgi_usage(char *argv0)
 				"  -i               PHP information\n"
 				"  -m               Show compiled in modules\n"
 				"  -v               Version number\n"
+				"  -p, --prefix <dir>\n"
+				"                   Specify alternative prefix path to FastCGI process manager (default: %s).\n"
 				"  -y, --fpm-config <file>\n"
-				"                   Specify alternative path to FastCGI process manager config file.\n",
-				prog);
+				"                   Specify alternative path to FastCGI process manager config file.\n"
+				"  -t, --test       Test FPM configuration and exit\n",
+				prog, PHP_PREFIX);
 }
 /* }}} */
 
@@ -1372,7 +1376,7 @@ static void init_request_info(TSRMLS_D)
 		int mode = ZEND_INI_USER;
 		char *tmp;
 		spprintf(&tmp, 0, "%s\n", ini);
-		zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC);
+		zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC);
 		efree(tmp);
 	}
 
@@ -1381,7 +1385,7 @@ static void init_request_info(TSRMLS_D)
 		int mode = ZEND_INI_SYSTEM;
 		char *tmp;
 		spprintf(&tmp, 0, "%s\n", ini);
-		zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC);
+		zend_parse_ini_string(tmp, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fastcgi_ini_parser, &mode TSRMLS_CC);
 		efree(tmp);
 	}
 }
@@ -1406,7 +1410,7 @@ static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_
 		return;
 	}
 
-	if (!value || strlen(value) < 1) {
+	if (!value) {
 		fprintf(stderr, "Passing INI directive through FastCGI: empty value for key '%s'\n", key);
 		return;
 	}
@@ -1480,7 +1484,6 @@ static PHP_MINFO_FUNCTION(cgi)
 {
 	php_info_print_table_start();
 	php_info_print_table_row(2, "php-fpm", "active");
-	php_info_print_table_row(2, "php-fpm version", PHP_FPM_VERSION);
 	php_info_print_table_end();
 
 	DISPLAY_INI_ENTRIES();
@@ -1548,6 +1551,8 @@ int main(int argc, char *argv[])
 	int fcgi_fd = 0;
 	fcgi_request request;
 	char *fpm_config = NULL;
+	char *fpm_prefix = NULL;
+	int test_conf = 0;
 
 	fcgi_init();
 
@@ -1585,9 +1590,11 @@ int main(int argc, char *argv[])
 				}
 				cgi_sapi_module.php_ini_path_override = strdup(php_optarg);
 				break;
+
 			case 'n':
 				cgi_sapi_module.php_ini_ignore = 1;
 				break;
+
 			case 'd': {
 				/* define ini entries on command line */
 				int len = strlen(php_optarg);
@@ -1619,14 +1626,23 @@ int main(int argc, char *argv[])
 				}
 				break;
 			}
+
 			case 'y':
 				fpm_config = php_optarg;
 				break;
 
+			case 'p':
+				fpm_prefix = php_optarg;
+				break;
+
 			case 'e': /* enable extended info output */
 				CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
 				break;
 
+			case 't': 
+				test_conf++;
+				break;
+
 			case 'm': /* list compiled in modules */
 				cgi_sapi_module.startup(&cgi_sapi_module);
 				php_output_startup();
@@ -1763,11 +1779,11 @@ consult the installation file that came with this distribution, or visit \n\
 		}
 	}
 
-	if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), &CGIG(event_base))) {
+	if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, test_conf)) {
 		return FAILURE;
 	}
 
-	fcgi_fd = fpm_run(&max_requests, CGIG(event_base));
+	fcgi_fd = fpm_run(&max_requests);
 	parent = 0;
 	fcgi_set_is_fastcgi(1);
 
@@ -1920,8 +1936,10 @@ fastcgi_request_done:
 out:
 
 	SG(server_context) = NULL;
-	php_module_shutdown(TSRMLS_C);
-	sapi_shutdown();
+	if (parent) {
+		php_module_shutdown(TSRMLS_C);
+		sapi_shutdown();
+	}
 
 #ifdef ZTS
 	tsrm_shutdown();
diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c
index ce5dac4..eeba713 100644
--- a/sapi/fpm/fpm/fpm_php.c
+++ b/sapi/fpm/fpm/fpm_php.c
@@ -139,6 +139,7 @@ static int fpm_php_set_allowed_clients(struct fpm_worker_pool_s *wp) /* {{{ */
 }
 /* }}} */
 
+#if 0 /* Comment out this non used function. It could be used later. */
 static int fpm_php_set_fcgi_mgmt_vars(struct fpm_worker_pool_s *wp) /* {{{ */
 {
 	char max_workers[10 + 1]; /* 4294967295 */
@@ -151,6 +152,7 @@ static int fpm_php_set_fcgi_mgmt_vars(struct fpm_worker_pool_s *wp) /* {{{ */
 	return 0;
 }
 /* }}} */
+#endif
 
 char *fpm_php_script_filename(TSRMLS_D) /* {{{ */
 {
diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h
index 8c4b58c..81e5332 100644
--- a/sapi/fpm/fpm/fpm_php.h
+++ b/sapi/fpm/fpm/fpm_php.h
@@ -11,6 +11,26 @@
 #include "build-defs.h" /* for PHP_ defines */
 #include "fpm/fpm_conf.h"
 
+#define FPM_PHP_INI_TO_EXPAND \
+	{ \
+		"error_log", \
+		"extension_dir", \
+		"mime_magic.magicfile", \
+		"sendmail_path", \
+		"session.cookie_path", \
+		"session_pgsql.sem_file_name", \
+		"soap.wsdl_cache_dir", \
+		"uploadprogress.file.filename_template", \
+		"xdebug.output_dir", \
+		"xdebug.profiler_output_dir", \
+		"xdebug.trace_output_dir", \
+		"xmms.path", \
+		"axis2.client_home", \
+		"blenc.key_file", \
+		"coin_acceptor.device", \
+		NULL \
+	}
+
 struct fpm_worker_pool_s;
 
 int fpm_php_init_child(struct fpm_worker_pool_s *wp);
diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c
index 306a592..0387458 100644
--- a/sapi/fpm/fpm/fpm_php_trace.c
+++ b/sapi/fpm/fpm/fpm_php_trace.c
@@ -139,12 +139,12 @@ void fpm_php_trace(struct fpm_child_s *child) /* {{{ */
 	TSRMLS_FETCH();
 	FILE *slowlog;
 
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "about to trace %d", (int) child->pid);
+	zlog(ZLOG_NOTICE, "about to trace %d", (int) child->pid);
 
 	slowlog = fopen(child->wp->config->slowlog, "a+");
 
 	if (!slowlog) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "fopen(%s) failed", child->wp->config->slowlog);
+		zlog(ZLOG_SYSERROR, "fopen(%s) failed", child->wp->config->slowlog);
 		goto done0;
 	}
 
@@ -167,7 +167,7 @@ done0:
 	fpm_pctl_kill(child->pid, FPM_PCTL_CONT);
 	child->tracer = 0;
 
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "finished trace of %d", (int) child->pid);
+	zlog(ZLOG_NOTICE, "finished trace of %d", (int) child->pid);
 }
 /* }}} */
 
diff --git a/sapi/fpm/fpm/fpm_process_ctl.c b/sapi/fpm/fpm/fpm_process_ctl.c
index b24f950..badda14 100644
--- a/sapi/fpm/fpm/fpm_process_ctl.c
+++ b/sapi/fpm/fpm/fpm_process_ctl.c
@@ -19,6 +19,7 @@
 #include "fpm_request.h"
 #include "fpm_worker_pool.h"
 #include "fpm_status.h"
+#include "fpm_sockets.h"
 #include "zlog.h"
 
 
@@ -48,36 +49,25 @@ static void fpm_pctl_cleanup(int which, void *arg) /* {{{ */
 }
 /* }}} */
 
-static struct event pctl_event;
+static struct fpm_event_s pctl_event;
 
-static void fpm_pctl_action(int fd, short which, void *arg) /* {{{ */
+static void fpm_pctl_action(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
 {
-	struct event_base *base = (struct event_base *)arg;
-
-	evtimer_del(&pctl_event);
-	memset(&pctl_event, 0, sizeof(pctl_event));
-	fpm_pctl(FPM_PCTL_STATE_UNSPECIFIED, FPM_PCTL_ACTION_TIMEOUT, base);
+	fpm_pctl(FPM_PCTL_STATE_UNSPECIFIED, FPM_PCTL_ACTION_TIMEOUT);
 }
 /* }}} */
 
-static int fpm_pctl_timeout_set(int sec, struct event_base *base) /* {{{ */
+static int fpm_pctl_timeout_set(int sec) /* {{{ */
 {
-	struct timeval tv = { .tv_sec = sec, .tv_usec = 0 };
-
-	if (evtimer_initialized(&pctl_event)) {
-		evtimer_del(&pctl_event);
-	}
-
-	evtimer_set(&pctl_event, &fpm_pctl_action, base);
-	event_base_set(base, &pctl_event);
-	evtimer_add(&pctl_event, &tv);
+	fpm_event_set_timer(&pctl_event, 0, &fpm_pctl_action, NULL);
+	fpm_event_add(&pctl_event, sec * 1000);
 	return 0;
 }
 /* }}} */
 
 static void fpm_pctl_exit() /* {{{ */
 {
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "exiting, bye-bye!");
+	zlog(ZLOG_NOTICE, "exiting, bye-bye!");
 
 	fpm_conf_unlink_pid();
 	fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT_MAIN);
@@ -90,7 +80,7 @@ static void fpm_pctl_exit() /* {{{ */
 static void fpm_pctl_exec() /* {{{ */
 {
 
-	zlog(ZLOG_STUFF, ZLOG_NOTICE, "reloading: execvp(\"%s\", {\"%s\""
+	zlog(ZLOG_NOTICE, "reloading: execvp(\"%s\", {\"%s\""
 			"%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s"
 			"%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s" "%s%s%s"
 		"})",
@@ -109,7 +99,7 @@ static void fpm_pctl_exec() /* {{{ */
 
 	fpm_cleanups_run(FPM_CLEANUP_PARENT_EXEC);
 	execvp(saved_argv[0], saved_argv);
-	zlog(ZLOG_STUFF, ZLOG_SYSERROR, "execvp() failed");
+	zlog(ZLOG_SYSERROR, "execvp() failed");
 	exit(1);
 }
 /* }}} */
@@ -143,6 +133,9 @@ int fpm_pctl_kill(pid_t pid, int how) /* {{{ */
 		case FPM_PCTL_CONT :
 			s = SIGCONT;
 			break;
+		case FPM_PCTL_QUIT :
+			s = SIGQUIT;
+			break;
 		default :
 			break;
 	}
@@ -161,7 +154,7 @@ static void fpm_pctl_kill_all(int signo) /* {{{ */
 		for (child = wp->children; child; child = child->next) {
 			int res = kill(child->pid, signo);
 
-			zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] sending signal %d %s to child %d",
+			zlog(ZLOG_DEBUG, "[pool %s] sending signal %d %s to child %d",
 				child->wp->config->name, signo,
 				fpm_signal_names[signo] ? fpm_signal_names[signo] : "", (int) child->pid);
 
@@ -172,12 +165,12 @@ static void fpm_pctl_kill_all(int signo) /* {{{ */
 	}
 
 	if (alive_children) {
-		zlog(ZLOG_STUFF, ZLOG_DEBUG, "%d child(ren) still alive", alive_children);
+		zlog(ZLOG_DEBUG, "%d child(ren) still alive", alive_children);
 	}
 }
 /* }}} */
 
-static void fpm_pctl_action_next(struct event_base *base) /* {{{ */
+static void fpm_pctl_action_next() /* {{{ */
 {
 	int sig, timeout;
 
@@ -203,11 +196,11 @@ static void fpm_pctl_action_next(struct event_base *base) /* {{{ */
 
 	fpm_pctl_kill_all(sig);
 	fpm_signal_sent = sig;
-	fpm_pctl_timeout_set(timeout, base);
+	fpm_pctl_timeout_set(timeout);
 }
 /* }}} */
 
-void fpm_pctl(int new_state, int action, struct event_base *base) /* {{{ */
+void fpm_pctl(int new_state, int action) /* {{{ */
 {
 	switch (action) {
 		case FPM_PCTL_ACTION_SET :
@@ -227,7 +220,7 @@ void fpm_pctl(int new_state, int action, struct event_base *base) /* {{{ */
 					if (new_state == FPM_PCTL_STATE_TERMINATING) break;
 				case FPM_PCTL_STATE_TERMINATING :
 					/* nothing can override 'terminating' state */
-					zlog(ZLOG_STUFF, ZLOG_DEBUG, "not switching to '%s' state, because already in '%s' state",
+					zlog(ZLOG_DEBUG, "not switching to '%s' state, because already in '%s' state",
 						fpm_state_names[new_state], fpm_state_names[fpm_state]);
 					return;
 			}
@@ -235,11 +228,11 @@ void fpm_pctl(int new_state, int action, struct event_base *base) /* {{{ */
 			fpm_signal_sent = 0;
 			fpm_state = new_state;
 
-			zlog(ZLOG_STUFF, ZLOG_DEBUG, "switching to '%s' state", fpm_state_names[fpm_state]);
+			zlog(ZLOG_DEBUG, "switching to '%s' state", fpm_state_names[fpm_state]);
 			/* fall down */
 
 		case FPM_PCTL_ACTION_TIMEOUT :
-			fpm_pctl_action_next(base);
+			fpm_pctl_action_next();
 			break;
 		case FPM_PCTL_ACTION_LAST_CHILD_EXITED :
 			fpm_pctl_action_last();
@@ -255,14 +248,14 @@ int fpm_pctl_can_spawn_children() /* {{{ */
 }
 /* }}} */
 
-int fpm_pctl_child_exited(struct event_base *base) /* {{{ */
+int fpm_pctl_child_exited() /* {{{ */
 {
 	if (fpm_state == FPM_PCTL_STATE_NORMAL) {
 		return 0;
 	}
 
 	if (!fpm_globals.running_children) {
-		fpm_pctl(FPM_PCTL_STATE_UNSPECIFIED, FPM_PCTL_ACTION_LAST_CHILD_EXITED, base);
+		fpm_pctl(FPM_PCTL_STATE_UNSPECIFIED, FPM_PCTL_ACTION_LAST_CHILD_EXITED);
 	}
 	return 0;
 }
@@ -314,51 +307,49 @@ static void fpm_pctl_check_request_timeout(struct timeval *now) /* {{{ */
 }
 /* }}} */
 
-static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct event_base *base) /* {{{ */
+static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now) /* {{{ */
 {
 	struct fpm_worker_pool_s *wp;
-	struct fpm_child_s *last_idle_child = NULL;
-	int i;
 
 	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
 		struct fpm_child_s *child;
+		struct fpm_child_s *last_idle_child = NULL;
 		int idle = 0;
 		int active = 0;
+		int children_to_fork;
+		unsigned cur_lq;
 
 		if (wp->config == NULL) continue;
 
 		for (child = wp->children; child; child = child->next) {
-			int ret = fpm_request_is_idle(child);
-			if (ret == 1) {
+			if (fpm_request_is_idle(child)) {
 				if (last_idle_child == NULL) {
 					last_idle_child = child;
 				} else {
-					if (child->started.tv_sec < last_idle_child->started.tv_sec) {
+					if (timercmp(&child->started, &last_idle_child->started, <)) {
 						last_idle_child = child;
 					}
 				}
 				idle++;
-			} else if (ret == 0) {
+			} else {
 				active++;
 			}
 		}
 
-		if ((active + idle) != wp->running_children) {
-			zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to retrieve process activity of one or more child(ren). Will try again later.", wp->config->name);
-			continue;
-		}
-
 		/* update status structure for all PMs */
-		fpm_status_update_activity(wp->shm_status, idle, active, idle + active, 0);
+		if (0 > fpm_socket_get_listening_queue(wp, &cur_lq, NULL)) {
+			cur_lq = 0;
+		}
+		fpm_status_update_activity(wp->shm_status, idle, active, idle + active, cur_lq, wp->listening_queue_len, 0);
 
 		/* the rest is only used by PM_STYLE_DYNAMIC */
 		if (wp->config->pm != PM_STYLE_DYNAMIC) continue;
 
-		zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] currently %d active children, %d spare children, %d running children. Spawning rate %d", wp->config->name, active, idle, wp->running_children, wp->idle_spawn_rate);
+		zlog(ZLOG_DEBUG, "[pool %s] currently %d active children, %d spare children, %d running children. Spawning rate %d", wp->config->name, active, idle, wp->running_children, wp->idle_spawn_rate);
 
 		if (idle > wp->config->pm_max_spare_servers && last_idle_child) {
 			last_idle_child->idle_kill = 1;
-			fpm_pctl_kill(last_idle_child->pid, FPM_PCTL_TERM);
+			fpm_pctl_kill(last_idle_child->pid, FPM_PCTL_QUIT);
 			wp->idle_spawn_rate = 1;
 			continue;
 		}
@@ -366,7 +357,8 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
 		if (idle < wp->config->pm_min_spare_servers) {
 			if (wp->running_children >= wp->config->pm_max_children) {
 				if (!wp->warn_max_children) {
-					zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
+					fpm_status_increment_max_children_reached(wp->shm_status);
+					zlog(ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
 					wp->warn_max_children = 1;
 				}
 				wp->idle_spawn_rate = 1;
@@ -374,17 +366,18 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
 			}
 
 			if (wp->idle_spawn_rate >= 8) {
-				zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] seems busy (you may need to increase start_servers, or min/max_spare_servers), spawning %d children, there are %d idle, and %d total children", wp->config->name, wp->idle_spawn_rate, idle, wp->running_children);
+				zlog(ZLOG_WARNING, "[pool %s] seems busy (you may need to increase start_servers, or min/max_spare_servers), spawning %d children, there are %d idle, and %d total children", wp->config->name, wp->idle_spawn_rate, idle, wp->running_children);
 			}
 
 			/* compute the number of idle process to spawn */
-			i = MIN(wp->idle_spawn_rate, wp->config->pm_min_spare_servers - idle);
+			children_to_fork = MIN(wp->idle_spawn_rate, wp->config->pm_min_spare_servers - idle);
 
 			/* get sure it won't exceed max_children */
-			i = MIN(i, wp->config->pm_max_children - wp->running_children);
-			if (i <= 0) {
+			children_to_fork = MIN(children_to_fork, wp->config->pm_max_children - wp->running_children);
+			if (children_to_fork <= 0) {
 				if (!wp->warn_max_children) {
-					zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
+					fpm_status_increment_max_children_reached(wp->shm_status);
+					zlog(ZLOG_WARNING, "[pool %s] server reached max_children setting (%d), consider raising it", wp->config->name, wp->config->pm_max_children);
 					wp->warn_max_children = 1;
 				}
 				wp->idle_spawn_rate = 1;
@@ -392,7 +385,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
 			}
 			wp->warn_max_children = 0;
 
-			fpm_children_make(wp, 1, i, 1, base);
+			fpm_children_make(wp, 1, children_to_fork, 1);
 
 			/* if it's a child, stop here without creating the next event
 			 * this event is reserved to the master process
@@ -401,7 +394,7 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
 				return;
 			}
 
-			zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] %d child(ren) have been created dynamically", wp->config->name, i);	
+			zlog(ZLOG_DEBUG, "[pool %s] %d child(ren) have been created dynamically", wp->config->name, children_to_fork);	
 
 			/* Double the spawn rate for the next iteration */
 			if (wp->idle_spawn_rate < FPM_MAX_SPAWN_RATE) {
@@ -414,37 +407,40 @@ static void fpm_pctl_perform_idle_server_maintenance(struct timeval *now, struct
 }
 /* }}} */
 
-void fpm_pctl_heartbeat(int fd, short which, void *arg) /* {{{ */
+void fpm_pctl_heartbeat(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
 {
-	static struct event heartbeat;
-	struct timeval tv = { .tv_sec = 0, .tv_usec = 130000 };
+	static struct fpm_event_s heartbeat;
 	struct timeval now;
-	struct event_base *base = (struct event_base *)arg;
 
-	if (which == EV_TIMEOUT) {
-		evtimer_del(&heartbeat);
+	if (fpm_globals.parent_pid != getpid()) {
+		return; /* sanity check */
+	}
+
+	if (which == FPM_EV_TIMEOUT) {
 		fpm_clock_get(&now);
 		fpm_pctl_check_request_timeout(&now);
+		return;
 	}
 
-	evtimer_set(&heartbeat, &fpm_pctl_heartbeat, base);
-	event_base_set(base, &heartbeat);
-	evtimer_add(&heartbeat, &tv);
+	/* first call without setting to initialize the timer */
+	fpm_event_set_timer(&heartbeat, FPM_EV_PERSIST, &fpm_pctl_heartbeat, NULL);
+	fpm_event_add(&heartbeat, FPM_PCTL_HEARTBEAT);
 }
 /* }}} */
 
-void fpm_pctl_perform_idle_server_maintenance_heartbeat(int fd, short which, void *arg) /* {{{ */
+void fpm_pctl_perform_idle_server_maintenance_heartbeat(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
 {
-	static struct event heartbeat;
-	struct timeval tv = { .tv_sec = 0, .tv_usec = FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT };
+	static struct fpm_event_s heartbeat;
 	struct timeval now;
-	struct event_base *base = (struct event_base *)arg;
 
-	if (which == EV_TIMEOUT) {
-		evtimer_del(&heartbeat);
+	if (fpm_globals.parent_pid != getpid()) {
+		return; /* sanity check */
+	}
+
+	if (which == FPM_EV_TIMEOUT) {
 		fpm_clock_get(&now);
 		if (fpm_pctl_can_spawn_children()) {
-			fpm_pctl_perform_idle_server_maintenance(&now, base);
+			fpm_pctl_perform_idle_server_maintenance(&now);
 
 			/* if it's a child, stop here without creating the next event
 			 * this event is reserved to the master process
@@ -453,11 +449,12 @@ void fpm_pctl_perform_idle_server_maintenance_heartbeat(int fd, short which, voi
 				return;
 			}
 		}
+		return;
 	}
 
-	evtimer_set(&heartbeat, &fpm_pctl_perform_idle_server_maintenance_heartbeat, base);
-	event_base_set(base, &heartbeat);
-	evtimer_add(&heartbeat, &tv);
+	/* first call without setting which to initialize the timer */
+	fpm_event_set_timer(&heartbeat, FPM_EV_PERSIST, &fpm_pctl_perform_idle_server_maintenance_heartbeat, NULL);
+	fpm_event_add(&heartbeat, FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT);
 }
 /* }}} */
 
diff --git a/sapi/fpm/fpm/fpm_process_ctl.h b/sapi/fpm/fpm/fpm_process_ctl.h
index 8834d5f..3657709 100644
--- a/sapi/fpm/fpm/fpm_process_ctl.h
+++ b/sapi/fpm/fpm/fpm_process_ctl.h
@@ -5,18 +5,22 @@
 #ifndef FPM_PROCESS_CTL_H
 #define FPM_PROCESS_CTL_H 1
 
+#include "fpm_events.h"
+
 /* spawn max 32 children at once */
 #define FPM_MAX_SPAWN_RATE (32)
-/* 1s (in µs here)  heatbeat for idle server maintenance */
-#define FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT (1000000)
+/* 1s (in ms) heartbeat for idle server maintenance */
+#define FPM_IDLE_SERVER_MAINTENANCE_HEARTBEAT (1000)
+/* 130ms heartbeat for pctl */
+#define FPM_PCTL_HEARTBEAT (130)
 
 struct fpm_child_s;
 
-void fpm_pctl(int new_state, int action, struct event_base *base);
+void fpm_pctl(int new_state, int action);
 int fpm_pctl_can_spawn_children();
 int fpm_pctl_kill(pid_t pid, int how);
-void fpm_pctl_heartbeat(int fd, short which, void *arg);
-void fpm_pctl_perform_idle_server_maintenance_heartbeat(int fd, short which, void *arg);
+void fpm_pctl_heartbeat(struct fpm_event_s *ev, short which, void *arg);
+void fpm_pctl_perform_idle_server_maintenance_heartbeat(struct fpm_event_s *ev, short which, void *arg);
 int fpm_pctl_child_exited();
 int fpm_pctl_init_main();
 
@@ -38,7 +42,8 @@ enum {
 enum {
 	FPM_PCTL_TERM,
 	FPM_PCTL_STOP,
-	FPM_PCTL_CONT
+	FPM_PCTL_CONT,
+	FPM_PCTL_QUIT
 };
 
 #endif
diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c
index 8fff8be..590548e 100644
--- a/sapi/fpm/fpm/fpm_request.c
+++ b/sapi/fpm/fpm/fpm_request.c
@@ -136,7 +136,7 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now,
 
 			fpm_trace_signal(child->pid);
 
-			zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d, script '%s' executing too slow (%d.%06d sec), logging",
+			zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' executing too slow (%d.%06d sec), logging",
 				child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec);
 		}
 		else
@@ -145,7 +145,7 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now,
 			str_purify_filename(purified_script_filename, slot_c.script_filename, sizeof(slot_c.script_filename));
 			fpm_pctl_kill(child->pid, FPM_PCTL_TERM);
 
-			zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d, script '%s' execution timed out (%d.%06d sec), terminating",
+			zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' execution timed out (%d.%06d sec), terminating",
 				child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec);
 		}
 	}
@@ -154,16 +154,11 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now,
 
 int fpm_request_is_idle(struct fpm_child_s *child) /* {{{ */
 {
-	struct fpm_shm_slot_s *slot;
-	struct fpm_shm_slot_s slot_c;
+	struct fpm_shm_slot_s slot;
 
-	slot = fpm_shm_slot(child);
-	if (!fpm_shm_slots_acquire(slot, 1)) {
-		return -1;
-	}
+	/* no need in atomicity here */
+	slot = *fpm_shm_slot(child);
 
-	slot_c = *slot;
-	fpm_shm_slots_release(slot);
-	return(!slot_c.accepted.tv_sec && !slot_c.accepted.tv_usec ? 1 : 0);
+	return slot.request_stage == FPM_REQUEST_ACCEPTING;
 }
 /* }}} */
diff --git a/sapi/fpm/fpm/fpm_shm.c b/sapi/fpm/fpm/fpm_shm.c
index cfacde2..5f40409 100644
--- a/sapi/fpm/fpm/fpm_shm.c
+++ b/sapi/fpm/fpm/fpm_shm.c
@@ -30,7 +30,7 @@ struct fpm_shm_s *fpm_shm_alloc(size_t sz) /* {{{ */
 	shm->mem = mmap(0, sz, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
 
 	if (!shm->mem) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "mmap(MAP_ANONYMOUS | MAP_SHARED) failed");
+		zlog(ZLOG_SYSERROR, "mmap(MAP_ANONYMOUS | MAP_SHARED) failed");
 		free(shm);
 		return 0;
 	}
diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c
index eb2528b..aea6975 100644
--- a/sapi/fpm/fpm/fpm_signals.c
+++ b/sapi/fpm/fpm/fpm_signals.c
@@ -182,17 +182,17 @@ int fpm_signals_init_main() /* {{{ */
 	struct sigaction act;
 
 	if (0 > socketpair(AF_UNIX, SOCK_STREAM, 0, sp)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "socketpair() failed");
+		zlog(ZLOG_SYSERROR, "socketpair() failed");
 		return -1;
 	}
 
 	if (0 > fd_set_blocked(sp[0], 0) || 0 > fd_set_blocked(sp[1], 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "fd_set_blocked() failed");
+		zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
 		return -1;
 	}
 
 	if (0 > fcntl(sp[0], F_SETFD, FD_CLOEXEC) || 0 > fcntl(sp[1], F_SETFD, FD_CLOEXEC)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "fcntl(F_SETFD, FD_CLOEXEC) failed");
+		zlog(ZLOG_SYSERROR, "fcntl(F_SETFD, FD_CLOEXEC) failed");
 		return -1;
 	}
 
@@ -207,7 +207,7 @@ int fpm_signals_init_main() /* {{{ */
 		0 > sigaction(SIGCHLD,  &act, 0) ||
 		0 > sigaction(SIGQUIT,  &act, 0)) {
 
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "sigaction() failed");
+		zlog(ZLOG_SYSERROR, "sigaction() failed");
 		return -1;
 	}
 	return 0;
@@ -236,7 +236,7 @@ int fpm_signals_init_child() /* {{{ */
 		0 > sigaction(SIGCHLD,  &act_dfl,  0) ||
 		0 > sigaction(SIGQUIT,  &act,      0)) {
 
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "sigaction() failed");
+		zlog(ZLOG_SYSERROR, "sigaction() failed");
 		return -1;
 	}
 	return 0;
diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c
index 21baf05..baa9f98 100644
--- a/sapi/fpm/fpm/fpm_sockets.c
+++ b/sapi/fpm/fpm/fpm_sockets.c
@@ -49,7 +49,7 @@ static int fpm_sockets_resolve_af_inet(char *node, char *service, struct sockadd
 	ret = getaddrinfo(node, service, &hints, &res);
 
 	if (ret != 0) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "can't resolve hostname '%s%s%s': getaddrinfo said: %s%s%s\n",
+		zlog(ZLOG_ERROR, "can't resolve hostname '%s%s%s': getaddrinfo said: %s%s%s\n",
 					node, service ? ":" : "", service ? service : "",
 					gai_strerror(ret), ret == EAI_SYSTEM ? ", system error: " : "", ret == EAI_SYSTEM ? strerror(errno) : "");
 		return -1;
@@ -65,7 +65,7 @@ enum { FPM_GET_USE_SOCKET = 1, FPM_STORE_SOCKET = 2, FPM_STORE_USE_SOCKET = 3 };
 
 static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
 {
-	int i;
+	unsigned i;
 	char *env_value = 0;
 	int p = 0;
 	struct listening_socket_s *ls = sockets_list.data;
@@ -124,7 +124,7 @@ static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int typ
 
 		case FPM_GET_USE_SOCKET :
 		{
-			int i;
+			unsigned i;
 			struct listening_socket_s *ls = sockets_list.data;
 
 			for (i = 0; i < sockets_list.used; i++, ls++) {
@@ -171,7 +171,7 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
 	sock = socket(sa->sa_family, SOCK_STREAM, 0);
 
 	if (0 > sock) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "socket() failed");
+		zlog(ZLOG_SYSERROR, "socket() failed");
 		return -1;
 	}
 
@@ -179,28 +179,32 @@ static int fpm_sockets_new_listening_socket(struct fpm_worker_pool_s *wp, struct
 
 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		unlink( ((struct sockaddr_un *) sa)->sun_path);
+		saved_umask = umask(0777 ^ wp->socket_mode);
 	}
 
-	saved_umask = umask(0777 ^ wp->socket_mode);
-
 	if (0 > bind(sock, sa, socklen)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
+		zlog(ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
+		if (wp->listen_address_domain == FPM_AF_UNIX) {
+			umask(saved_umask);
+		}
 		return -1;
 	}
 
 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		char *path = ((struct sockaddr_un *) sa)->sun_path;
+
+		umask(saved_umask);
+
 		if (wp->socket_uid != -1 || wp->socket_gid != -1) {
 			if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
+				zlog(ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
 				return -1;
 			}
 		}
 	}
-	umask(saved_umask);
 
 	if (0 > listen(sock, wp->config->listen_backlog)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
+		zlog(ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
 		return -1;
 	}
 	return sock;
@@ -253,7 +257,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
 	}
 
 	if (port == 0) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "invalid port value '%s'", port_str);
+		zlog(ZLOG_ERROR, "invalid port value '%s'", port_str);
 		return -1;
 	}
 
@@ -265,7 +269,7 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
 			if (0 > fpm_sockets_resolve_af_inet(addr, NULL, &sa_in)) {
 				return -1;
 			}
-			zlog(ZLOG_STUFF, ZLOG_NOTICE, "address '%s' resolved as %u.%u.%u.%u", addr, IPQUAD(&sa_in.sin_addr));
+			zlog(ZLOG_NOTICE, "address '%s' resolved as %u.%u.%u.%u", addr, IPQUAD(&sa_in.sin_addr));
 		}
 	} else {
 		sa_in.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -290,7 +294,7 @@ static int fpm_socket_af_unix_listening_socket(struct fpm_worker_pool_s *wp) /*
 
 int fpm_sockets_init_main() /* {{{ */
 {
-	int i;
+	unsigned i;
 	struct fpm_worker_pool_s *wp;
 	char *inherited = getenv("FPM_SOCKETS");
 	struct listening_socket_s *ls;
@@ -314,7 +318,7 @@ int fpm_sockets_init_main() /* {{{ */
 			*eq = '\0';
 			fd_no = atoi(eq + 1);
 			type = fpm_sockets_domain_from_address(inherited);
-			zlog(ZLOG_STUFF, ZLOG_NOTICE, "using inherited socket fd=%d, \"%s\"", fd_no, inherited);
+			zlog(ZLOG_NOTICE, "using inherited socket fd=%d, \"%s\"", fd_no, inherited);
 			fpm_sockets_hash_op(fd_no, 0, inherited, type, FPM_STORE_SOCKET);
 		}
 
@@ -340,6 +344,10 @@ int fpm_sockets_init_main() /* {{{ */
 				break;
 		}
 
+		if (0 > fpm_socket_get_listening_queue(wp, NULL, (unsigned *) &wp->listening_queue_len)) {
+			wp->listening_queue_len = -1;
+		}
+
 		if (wp->listening_socket == -1) {
 			return -1;
 		}
@@ -369,3 +377,76 @@ int fpm_sockets_init_main() /* {{{ */
 }
 /* }}} */
 
+#if HAVE_FPM_LQ
+
+#ifdef HAVE_LQ_TCP_INFO
+
+#include <netinet/tcp.h>
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+	if (wp->listen_address_domain != FPM_AF_INET) {
+		return -1;
+	}
+
+	struct tcp_info info;
+	socklen_t len = sizeof(info);
+
+	if (0 > getsockopt(wp->listening_socket, IPPROTO_TCP, TCP_INFO, &info, &len)) {
+		return -1;
+	}
+
+	/* kernel >= 2.6.24 return non-zero here, that means operation is supported */
+	if (info.tcpi_sacked == 0) {
+		return -1;
+	}
+
+	if (cur_lq) {
+		*cur_lq = info.tcpi_unacked;
+	}
+
+	if (max_lq) {
+		*max_lq = info.tcpi_sacked;
+	}
+
+	return 0;
+}
+
+#endif
+
+#ifdef HAVE_LQ_SO_LISTENQ
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+	int val;
+	socklen_t len = sizeof(val);
+
+	if (cur_lq) {
+		if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLEN, &val, &len)) {
+			return -1;
+		}
+
+		*cur_lq = val;
+	}
+
+	if (max_lq) {
+		if (0 > getsockopt(wp->listening_socket, SOL_SOCKET, SO_LISTENQLIMIT, &val, &len)) {
+			return -1;
+		}
+
+		*max_lq = val;
+	}
+
+	return 0;
+}
+
+#endif
+
+#else
+
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq)
+{
+	return -1;
+}
+
+#endif
diff --git a/sapi/fpm/fpm/fpm_sockets.h b/sapi/fpm/fpm/fpm_sockets.h
index d9e283d..b74fc23 100644
--- a/sapi/fpm/fpm/fpm_sockets.h
+++ b/sapi/fpm/fpm/fpm_sockets.h
@@ -10,8 +10,18 @@
 
 #include "fpm_worker_pool.h"
 
+/*
+  On FreeBSD and OpenBSD, backlog negative values are truncated to SOMAXCONN
+*/
+#if (__FreeBSD__) || (__OpenBSD__)
+#define FPM_BACKLOG_DEFAULT -1
+#else
+#define FPM_BACKLOG_DEFAULT 128
+#endif
+
 enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
 int fpm_sockets_init_main();
+int fpm_socket_get_listening_queue(struct fpm_worker_pool_s *wp, unsigned *cur_lq, unsigned *max_lq);
 
 
 static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c
index ebc73cd..76daf7d 100644
--- a/sapi/fpm/fpm/fpm_status.c
+++ b/sapi/fpm/fpm/fpm_status.c
@@ -1,5 +1,5 @@
 
-	/* $Id: fpm_status.c 298380 2010-04-23 15:09:28Z fat $ */
+	/* $Id: fpm_status.c 305281 2010-11-11 21:38:18Z fat $ */
 	/* (c) 2009 Jerome Loyet */
 
 #include "php.h"
@@ -20,13 +20,13 @@ static char *fpm_status_pong= NULL;
 int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 {
 	if (!wp || !wp->config) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
+		zlog(ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
 		return -1;
 	}
 	if (wp->config->pm_status_path || wp->config->ping_path) {
 		if (wp->config->pm_status_path) {
 			if (!wp->shm_status) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to init fpm_status because the dedicated SHM has not been set", wp->config->name);
+				zlog(ZLOG_ERROR, "[pool %s] unable to init fpm_status because the dedicated SHM has not been set", wp->config->name);
 				return -1;
 			}
 			fpm_status_shm = wp->shm_status;
@@ -37,7 +37,7 @@ int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 		}
 		if (wp->config->ping_path) {
 			if (!wp->config->ping_response) {
-				zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
+				zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
 				return -1;
 			}
 			fpm_status_ping = strdup(wp->config->ping_path);
@@ -99,7 +99,41 @@ void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int ac
 }
 /* }}} */
 
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update) /* {{{ */
+void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm) /* {{{ */
+{
+	struct fpm_status_s status;
+
+	if (!shm) shm = fpm_status_shm;
+	if (!shm || !shm->mem) return;
+
+	/* one shot operation */
+	status = *(struct fpm_status_s *)shm->mem;
+
+	status.max_children_reached++;
+
+	/* one shot operation */
+	*(struct fpm_status_s *)shm->mem = status;
+}
+/* }}} */
+
+void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached) /* {{{ */
+{
+	struct fpm_status_s status;
+
+	if (!shm) shm = fpm_status_shm;
+	if (!shm || !shm->mem) return;
+
+	/* one shot operation */
+	status = *(struct fpm_status_s *)shm->mem;
+
+	status.max_children_reached = max_children_reached;
+
+	/* one shot operation */
+	*(struct fpm_status_s *)shm->mem = status;
+}
+/* }}} */
+
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update) /* {{{ */
 {
 	struct fpm_status_s status;
 
@@ -112,6 +146,8 @@ void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int
 	status.idle = idle;
 	status.active = active;
 	status.total = total;
+	status.cur_lq = cur_lq;
+	status.max_lq = max_lq;
 	if (clear_last_update) {
 		memset(&status.last_update, 0, sizeof(status.last_update));
 	} else {
@@ -130,15 +166,30 @@ static void fpm_status_handle_status_txt(struct fpm_status_s *status, char **out
 	}
 
 	spprintf(output, 0, 
-		"accepted conn:   %lu\n"
-		"pool:             %s\n"
-		"process manager:  %s\n"
-		"idle processes:   %d\n"
-		"active processes: %d\n"
-		"total processes:  %d\n",
-		status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
-
-	spprintf(content_type, 0, "text/plain");
+		"pool:                 %s\n"
+		"process manager:      %s\n"
+		"accepted conn:        %lu\n"
+#if HAVE_FPM_LQ
+		"listen queue len:     %u\n"
+		"max listen queue len: %d\n"
+#endif
+		"idle processes:       %d\n"
+		"active processes:     %d\n"
+		"total processes:      %d\n"
+		"max children reached: %u\n",
+		fpm_status_pool,
+		status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+		status->accepted_conn,
+#if HAVE_FPM_LQ
+		status->cur_lq,
+		status->max_lq,
+#endif
+		status->idle,
+		status->active,
+		status->total,
+		status->max_children_reached);
+
+	spprintf(content_type, 0, "Content-Type: text/plain");
 }
 /* }}} */
 
@@ -150,16 +201,31 @@ static void fpm_status_handle_status_html(struct fpm_status_s *status, char **ou
 
 	spprintf(output, 0, 
 		"<table>\n"
-		"<tr><th>accepted conn</th><td>%lu</td></tr>\n"
 		"<tr><th>pool</th><td>%s</td></tr>\n"
 		"<tr><th>process manager</th><td>%s</td></tr>\n"
+		"<tr><th>accepted conn</th><td>%lu</td></tr>\n"
+#if HAVE_FPM_LQ
+		"<tr><th>listen queue len</th><td>%u</td></tr>\n"
+		"<tr><th>max listen queue len</th><td>%d</td></tr>\n"
+#endif
 		"<tr><th>idle processes</th><td>%d</td></tr>\n"
 		"<tr><th>active processes</th><td>%d</td></tr>\n"
 		"<tr><th>total processes</th><td>%d</td></tr>\n"
+		"<tr><th>max children reached</th><td>%u</td></tr>\n"
 		"</table>",
-		status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
-
-	spprintf(content_type, 0, "text/html");
+		fpm_status_pool,
+		status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+		status->accepted_conn,
+#if HAVE_FPM_LQ
+		status->cur_lq,
+		status->max_lq,
+#endif
+		status->idle,
+		status->active,
+		status->total,
+		status->max_children_reached);
+
+	spprintf(content_type, 0, "Content-Type: text/html");
 }
 /* }}} */
 
@@ -171,16 +237,31 @@ static void fpm_status_handle_status_json(struct fpm_status_s *status, char **ou
 
 	spprintf(output, 0, 
 		"{"
-		"\"accepted conn\":%lu,"
 		"\"pool\":\"%s\","
 		"\"process manager\":\"%s\","
+		"\"accepted conn\":%lu,"
+#if HAVE_FPM_LQ
+		"\"listen queue len\":%u,"
+		"\"max listen queue len\":%d,"
+#endif
 		"\"idle processes\":%d,"
 		"\"active processes\":%d,"
-		"\"total processes\":%d"
+		"\"total processes\":%d,"
+		"\"max children reached\":%u"
 		"}",
-		status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
-
-	spprintf(content_type, 0, "application/jsonrequest");
+		fpm_status_pool,
+		status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
+		status->accepted_conn,
+#if HAVE_FPM_LQ
+		status->cur_lq,
+		status->max_lq,
+#endif
+		status->idle,
+		status->active,
+		status->total,
+		status->max_children_reached);
+
+	spprintf(content_type, 0, "Content-Type: application/json");
 }
 /* }}} */
 
@@ -226,7 +307,7 @@ int fpm_status_handle_status(char *uri, char *query_string, char **output, char
 	}
 
 	if (!*output || !content_type) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to allocate status ouput buffer", fpm_status_pool);
+		zlog(ZLOG_ERROR, "[pool %s] unable to allocate status ouput buffer", fpm_status_pool);
 		return 1;
 	}
 
diff --git a/sapi/fpm/fpm/fpm_status.h b/sapi/fpm/fpm/fpm_status.h
index a079bd0..4e9c507 100644
--- a/sapi/fpm/fpm/fpm_status.h
+++ b/sapi/fpm/fpm/fpm_status.h
@@ -1,5 +1,5 @@
 
-	/* $Id: fpm_status.h 298380 2010-04-23 15:09:28Z fat $ */
+	/* $Id: fpm_status.h 305267 2010-11-11 02:34:47Z fat $ */
 	/* (c) 2009 Jerome Loyet */
 
 #ifndef FPM_STATUS_H
@@ -14,15 +14,20 @@ struct fpm_status_s {
 	int idle;
 	int active;
 	int total;
+	unsigned cur_lq;
+	int max_lq;
 	unsigned long int accepted_conn;
+	unsigned int max_children_reached;
 	struct timeval last_update;
 };
 
 int fpm_status_init_child(struct fpm_worker_pool_s *wp);
-void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update);
+void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update);
 void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int accepted_conn);
 void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm);
 void fpm_status_set_pm(struct fpm_shm_s *shm, int pm);
+void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached);
+void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm);
 int fpm_status_handle_status(char *uri, char *query_string, char **output, char **content_type);
 char* fpm_status_handle_ping(char *uri);
 
diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c
index d18e1d5..571f307 100644
--- a/sapi/fpm/fpm/fpm_stdio.c
+++ b/sapi/fpm/fpm/fpm_stdio.c
@@ -26,12 +26,12 @@ int fpm_stdio_init_main() /* {{{ */
 	int fd = open("/dev/null", O_RDWR);
 
 	if (0 > fd) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "open(\"/dev/null\") failed");
+		zlog(ZLOG_SYSERROR, "open(\"/dev/null\") failed");
 		return -1;
 	}
 
 	if (0 > dup2(fd, STDIN_FILENO) || 0 > dup2(fd, STDOUT_FILENO)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "dup2() failed");
+		zlog(ZLOG_SYSERROR, "dup2() failed");
 		return -1;
 	}
 	close(fd);
@@ -41,17 +41,16 @@ int fpm_stdio_init_main() /* {{{ */
 
 int fpm_stdio_init_final() /* {{{ */
 {
-	zlog_set_level(fpm_globals.log_level);
 	if (fpm_global_config.daemonize) {
 		if (fpm_globals.error_log_fd != STDERR_FILENO) {
 			/* there might be messages to stderr from libevent, we need to log them all */
 			if (0 > dup2(fpm_globals.error_log_fd, STDERR_FILENO)) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "dup2() failed");
+				zlog(ZLOG_SYSERROR, "dup2() failed");
 				return -1;
 			}
 		}
-		zlog_set_fd(fpm_globals.error_log_fd);
 	}
+	zlog_set_launched();
 	return 0;
 }
 /* }}} */
@@ -64,7 +63,7 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 
 	if (wp->listening_socket != STDIN_FILENO) {
 		if (0 > dup2(wp->listening_socket, STDIN_FILENO)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "dup2() failed");
+			zlog(ZLOG_SYSERROR, "dup2() failed");
 			return -1;
 		}
 	}
@@ -72,18 +71,30 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 }
 /* }}} */
 
-static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
+static void fpm_stdio_child_said(struct fpm_event_s *ev, short which, void *arg) /* {{{ */
 {
 	static const int max_buf_size = 1024;
+	int fd = ev->fd;
 	char buf[max_buf_size];
-	struct fpm_child_s *child = arg;
-	int is_stdout = fd == child->fd_stdout;
-	struct event *ev = is_stdout ? &child->ev_stdout : &child->ev_stderr;
+	struct fpm_child_s *child;
+	int is_stdout;
+	struct fpm_event_s *event;
 	int fifo_in = 1, fifo_out = 1;
 	int is_last_message = 0;
 	int in_buf = 0;
 	int res;
 
+	if (!arg) {
+		return;
+	}
+	child = (struct fpm_child_s *)arg;
+	is_stdout = (fd == child->fd_stdout);
+	if (is_stdout) {
+		event = &child->ev_stdout;
+	} else {
+		event = &child->ev_stderr;
+	}
+
 	while (fifo_in || fifo_out) {
 		if (fifo_in) {
 			res = read(fd, buf + in_buf, max_buf_size - 1 - in_buf);
@@ -94,10 +105,10 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
 				} else { /* error or pipe is closed */
 
 					if (res < 0) { /* error */
-						zlog(ZLOG_STUFF, ZLOG_SYSERROR, "read() failed");
+						zlog(ZLOG_SYSERROR, "read() failed");
 					}
 
-					fpm_event_del(ev);
+					fpm_event_del(event);
 					is_last_message = 1;
 
 					if (is_stdout) {
@@ -140,7 +151,7 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
 						*nl = '\0';
 					}
 
-					zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] child %d said into %s: \"%s\"%s", child->wp->config->name,
+					zlog(ZLOG_WARNING, "[pool %s] child %d said into %s: \"%s\"%s", child->wp->config->name,
 					  (int) child->pid, is_stdout ? "stdout" : "stderr", buf, is_last_message ? ", pipe is closed" : "");
 
 					if (nl) {
@@ -164,18 +175,18 @@ int fpm_stdio_prepare_pipes(struct fpm_child_s *child) /* {{{ */
 	}
 
 	if (0 > pipe(fd_stdout)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "pipe() failed");
+		zlog(ZLOG_SYSERROR, "pipe() failed");
 		return -1;
 	}
 
 	if (0 > pipe(fd_stderr)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "pipe() failed");
+		zlog(ZLOG_SYSERROR, "pipe() failed");
 		close(fd_stdout[0]); close(fd_stdout[1]);
 		return -1;
 	}
 
 	if (0 > fd_set_blocked(fd_stdout[0], 0) || 0 > fd_set_blocked(fd_stderr[0], 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "fd_set_blocked() failed");
+		zlog(ZLOG_SYSERROR, "fd_set_blocked() failed");
 		close(fd_stdout[0]); close(fd_stdout[1]);
 		close(fd_stderr[0]); close(fd_stderr[1]);
 		return -1;
@@ -184,7 +195,7 @@ int fpm_stdio_prepare_pipes(struct fpm_child_s *child) /* {{{ */
 }
 /* }}} */
 
-int fpm_stdio_parent_use_pipes(struct fpm_child_s *child, struct event_base *base) /* {{{ */
+int fpm_stdio_parent_use_pipes(struct fpm_child_s *child) /* {{{ */
 {
 	if (0 == child->wp->config->catch_workers_output) { /* not required */
 		return 0;
@@ -196,8 +207,11 @@ int fpm_stdio_parent_use_pipes(struct fpm_child_s *child, struct event_base *bas
 	child->fd_stdout = fd_stdout[0];
 	child->fd_stderr = fd_stderr[0];
 
-	fpm_event_add(child->fd_stdout, base, &child->ev_stdout, fpm_stdio_child_said, child);
-	fpm_event_add(child->fd_stderr, base, &child->ev_stderr, fpm_stdio_child_said, child);
+	fpm_event_set(&child->ev_stdout, child->fd_stdout, FPM_EV_READ, fpm_stdio_child_said, child);
+	fpm_event_add(&child->ev_stdout, 0);
+
+	fpm_event_set(&child->ev_stderr, child->fd_stderr, FPM_EV_READ, fpm_stdio_child_said, child);
+	fpm_event_add(&child->ev_stderr, 0);
 	return 0;
 }
 /* }}} */
@@ -237,7 +251,7 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */
 
 	fd = open(fpm_global_config.error_log, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
 	if (0 > fd) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
+		zlog(ZLOG_SYSERROR, "open(\"%s\") failed", fpm_global_config.error_log);
 		return -1;
 	}
 
@@ -251,6 +265,9 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */
 		fd = fpm_globals.error_log_fd; /* for FD_CLOSEXEC to work */
 	} else {
 		fpm_globals.error_log_fd = fd;
+		if (fpm_global_config.daemonize) {
+			zlog_set_fd(fpm_globals.error_log_fd);
+		}
 	}
 	fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
 	return 0;
diff --git a/sapi/fpm/fpm/fpm_stdio.h b/sapi/fpm/fpm/fpm_stdio.h
index 5d53a26..d3d61e4 100644
--- a/sapi/fpm/fpm/fpm_stdio.h
+++ b/sapi/fpm/fpm/fpm_stdio.h
@@ -12,7 +12,7 @@ int fpm_stdio_init_final();
 int fpm_stdio_init_child(struct fpm_worker_pool_s *wp);
 int fpm_stdio_prepare_pipes(struct fpm_child_s *child);
 void fpm_stdio_child_use_pipes(struct fpm_child_s *child);
-int fpm_stdio_parent_use_pipes(struct fpm_child_s *child, struct event_base *base);
+int fpm_stdio_parent_use_pipes(struct fpm_child_s *child);
 int fpm_stdio_discard_pipes(struct fpm_child_s *child);
 int fpm_stdio_open_error_log(int reopen);
 
diff --git a/sapi/fpm/fpm/fpm_trace_mach.c b/sapi/fpm/fpm/fpm_trace_mach.c
index 47b44ff..fe26fd9 100644
--- a/sapi/fpm/fpm/fpm_trace_mach.c
+++ b/sapi/fpm/fpm/fpm_trace_mach.c
@@ -37,7 +37,7 @@ static int fpm_mach_vm_read_page(vm_offset_t page) /* {{{ */
 
 	kr = mach_vm_read(target, page, fpm_pagesize, &local_page, &local_size);
 	if (kr != KERN_SUCCESS) {
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "mach_vm_read() failed: %s (%d)", mach_error_string(kr), kr);
+		zlog(ZLOG_ERROR, "mach_vm_read() failed: %s (%d)", mach_error_string(kr), kr);
 		return -1;
 	}
 	return 0;
@@ -47,7 +47,7 @@ static int fpm_mach_vm_read_page(vm_offset_t page) /* {{{ */
 int fpm_trace_signal(pid_t pid) /* {{{ */
 {
 	if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "kill(SIGSTOP) failed");
+		zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
 		return -1;
 	}
 	return 0;
@@ -65,7 +65,7 @@ int fpm_trace_ready(pid_t pid) /* {{{ */
 		if (kr == KERN_FAILURE) {
 			msg = " It seems that master process does not have enough privileges to trace processes.";
 		}
-		zlog(ZLOG_STUFF, ZLOG_ERROR, "task_for_pid() failed: %s (%d)%s", mach_error_string(kr), kr, msg);
+		zlog(ZLOG_ERROR, "task_for_pid() failed: %s (%d)%s", mach_error_string(kr), kr, msg);
 		return -1;
 	}
 	return 0;
diff --git a/sapi/fpm/fpm/fpm_trace_pread.c b/sapi/fpm/fpm/fpm_trace_pread.c
index d2f7e5a..eda8492 100644
--- a/sapi/fpm/fpm/fpm_trace_pread.c
+++ b/sapi/fpm/fpm/fpm_trace_pread.c
@@ -26,7 +26,7 @@ static int mem_file = -1;
 int fpm_trace_signal(pid_t pid) /* {{{ */
 {
 	if (0 > fpm_pctl_kill(pid, FPM_PCTL_STOP)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "kill(SIGSTOP) failed");
+		zlog(ZLOG_SYSERROR, "kill(SIGSTOP) failed");
 		return -1;
 	}
 	return 0;
@@ -40,7 +40,7 @@ int fpm_trace_ready(pid_t pid) /* {{{ */
 	sprintf(buf, "/proc/%d/" PROC_MEM_FILE, (int) pid);
 	mem_file = open(buf, O_RDONLY);
 	if (0 > mem_file) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "open(%s) failed", buf);
+		zlog(ZLOG_SYSERROR, "open(%s) failed", buf);
 		return -1;
 	}
 	return 0;
@@ -58,7 +58,7 @@ int fpm_trace_close(pid_t pid) /* {{{ */
 int fpm_trace_get_long(long addr, long *data) /* {{{ */
 {
 	if (sizeof(*data) != pread(mem_file, (void *) data, sizeof(*data), (uintptr_t) addr)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "pread() failed");
+		zlog(ZLOG_SYSERROR, "pread() failed");
 		return -1;
 	}
 	return 0;
diff --git a/sapi/fpm/fpm/fpm_trace_ptrace.c b/sapi/fpm/fpm/fpm_trace_ptrace.c
index 86cf528..395c1ac 100644
--- a/sapi/fpm/fpm/fpm_trace_ptrace.c
+++ b/sapi/fpm/fpm/fpm_trace_ptrace.c
@@ -29,7 +29,7 @@ static pid_t traced_pid;
 int fpm_trace_signal(pid_t pid) /* {{{ */
 {
 	if (0 > ptrace(PTRACE_ATTACH, pid, 0, 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "ptrace(ATTACH) failed");
+		zlog(ZLOG_SYSERROR, "ptrace(ATTACH) failed");
 		return -1;
 	}
 	return 0;
@@ -46,7 +46,7 @@ int fpm_trace_ready(pid_t pid) /* {{{ */
 int fpm_trace_close(pid_t pid) /* {{{ */
 {
 	if (0 > ptrace(PTRACE_DETACH, pid, (void *) 1, 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "ptrace(DETACH) failed");
+		zlog(ZLOG_SYSERROR, "ptrace(DETACH) failed");
 		return -1;
 	}
 	traced_pid = 0;
@@ -65,14 +65,14 @@ int fpm_trace_get_long(long addr, long *data) /* {{{ */
 	};
 
 	if (0 > ptrace(PT_IO, traced_pid, (void *) &ptio, 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "ptrace(PT_IO) failed");
+		zlog(ZLOG_SYSERROR, "ptrace(PT_IO) failed");
 		return -1;
 	}
 #else
 	errno = 0;
 	*data = ptrace(PTRACE_PEEKDATA, traced_pid, (void *) addr, 0);
 	if (errno) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "ptrace(PEEKDATA) failed");
+		zlog(ZLOG_SYSERROR, "ptrace(PEEKDATA) failed");
 		return -1;
 	}
 #endif
diff --git a/sapi/fpm/fpm/fpm_unix.c b/sapi/fpm/fpm/fpm_unix.c
index 395d703..d63ea4d 100644
--- a/sapi/fpm/fpm/fpm_unix.c
+++ b/sapi/fpm/fpm/fpm_unix.c
@@ -45,7 +45,7 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
 
 		pwd = getpwnam(c->listen_owner);
 		if (!pwd) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, c->listen_owner);
+			zlog(ZLOG_SYSERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, c->listen_owner);
 			return -1;
 		}
 
@@ -58,7 +58,7 @@ int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
 
 		grp = getgrnam(c->listen_group);
 		if (!grp) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, c->listen_group);
+			zlog(ZLOG_SYSERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, c->listen_group);
 			return -1;
 		}
 		wp->socket_gid = grp->gr_gid;
@@ -84,7 +84,7 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
 
 				pwd = getpwnam(wp->config->user);
 				if (!pwd) {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, wp->config->user);
+					zlog(ZLOG_ERROR, "[pool %s] cannot get uid for user '%s'", wp->config->name, wp->config->user);
 					return -1;
 				}
 
@@ -104,7 +104,7 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
 
 				grp = getgrnam(wp->config->group);
 				if (!grp) {
-					zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, wp->config->group);
+					zlog(ZLOG_ERROR, "[pool %s] cannot get gid for group '%s'", wp->config->name, wp->config->group);
 					return -1;
 				}
 				wp->set_gid = grp->gr_gid;
@@ -113,19 +113,19 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
 
 #ifndef I_REALLY_WANT_ROOT_PHP
 		if (wp->set_uid == 0 || wp->set_gid == 0) {
-			zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name);
+			zlog(ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name);
 			return -1;
 		}
 #endif
 	} else { /* not root */
 		if (wp->config->user && *wp->config->user) {
-			zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
+			zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored", wp->config->name);
 		}
 		if (wp->config->group && *wp->config->group) {
-			zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
+			zlog(ZLOG_WARNING, "[pool %s] 'group' directive is ignored", wp->config->name);
 		}
 		if (wp->config->chroot && *wp->config->chroot) {
-			zlog(ZLOG_STUFF, ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
+			zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored", wp->config->name);
 		}
 
 		{ /* set up HOME and USER anyway */
@@ -153,7 +153,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 		r.rlim_max = r.rlim_cur = (rlim_t) wp->config->rlimit_files;
 
 		if (0 > setrlimit(RLIMIT_NOFILE, &r)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
+			zlog(ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_NOFILE, %d) failed (%d)", wp->config->name, wp->config->rlimit_files, errno);
 		}
 	}
 
@@ -163,13 +163,13 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 		r.rlim_max = r.rlim_cur = wp->config->rlimit_core == -1 ? (rlim_t) RLIM_INFINITY : (rlim_t) wp->config->rlimit_core;
 
 		if (0 > setrlimit(RLIMIT_CORE, &r)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
+			zlog(ZLOG_SYSERROR, "[pool %s] setrlimit(RLIMIT_CORE, %d) failed (%d)", wp->config->name, wp->config->rlimit_core, errno);
 		}
 	}
 
 	if (is_root && wp->config->chroot && *wp->config->chroot) {
 		if (0 > chroot(wp->config->chroot)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] chroot(%s) failed",  wp->config->name, wp->config->chroot);
+			zlog(ZLOG_SYSERROR, "[pool %s] chroot(%s) failed",  wp->config->name, wp->config->chroot);
 			return -1;
 		}
 		made_chroot = 1;
@@ -177,7 +177,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 
 	if (wp->config->chdir && *wp->config->chdir) {
 		if (0 > chdir(wp->config->chdir)) {
-			zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] chdir(%s) failed", wp->config->name, wp->config->chdir);
+			zlog(ZLOG_SYSERROR, "[pool %s] chdir(%s) failed", wp->config->name, wp->config->chdir);
 			return -1;
 		}
 	} else if (made_chroot) {
@@ -187,17 +187,17 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 	if (is_root) {
 		if (wp->set_gid) {
 			if (0 > setgid(wp->set_gid)) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setgid(%d) failed", wp->config->name, wp->set_gid);
+				zlog(ZLOG_SYSERROR, "[pool %s] setgid(%d) failed", wp->config->name, wp->set_gid);
 				return -1;
 			}
 		}
 		if (wp->set_uid) {
 			if (0 > initgroups(wp->config->user, wp->set_gid)) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] initgroups(%s, %d) failed", wp->config->name, wp->config->user, wp->set_gid);
+				zlog(ZLOG_SYSERROR, "[pool %s] initgroups(%s, %d) failed", wp->config->name, wp->config->user, wp->set_gid);
 				return -1;
 			}
 			if (0 > setuid(wp->set_uid)) {
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] setuid(%d) failed", wp->config->name, wp->set_uid);
+				zlog(ZLOG_SYSERROR, "[pool %s] setuid(%d) failed", wp->config->name, wp->set_uid);
 				return -1;
 			}
 		}
@@ -205,7 +205,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
 
 #ifdef HAVE_PRCTL
 	if (0 > prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)) {
-		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "[pool %s] prctl(PR_SET_DUMPABLE) failed", wp->config->name);
+		zlog(ZLOG_SYSERROR, "[pool %s] prctl(PR_SET_DUMPABLE) failed", wp->config->name);
 	}
 #endif
 
@@ -224,7 +224,7 @@ int fpm_unix_init_main() /* {{{ */
 	if (fpm_global_config.daemonize) {
 		switch (fork()) {
 			case -1 :
-				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "daemonized fork() failed");
+				zlog(ZLOG_SYSERROR, "daemonized fork() failed");
 				return -1;
 			case 0 :
 				break;
@@ -246,7 +246,7 @@ int fpm_unix_init_main() /* {{{ */
 		}
 	}
 
-	fpm_stdio_init_final();
+	zlog_set_level(fpm_globals.log_level);
 	return 0;
 }
 /* }}} */
diff --git a/sapi/fpm/fpm/fpm_worker_pool.h b/sapi/fpm/fpm/fpm_worker_pool.h
index 63aff9a..7f240a2 100644
--- a/sapi/fpm/fpm/fpm_worker_pool.h
+++ b/sapi/fpm/fpm/fpm_worker_pool.h
@@ -25,6 +25,7 @@ struct fpm_worker_pool_s {
 	char *user, *home;									/* for setting env USER and HOME */
 	enum fpm_address_domain listen_address_domain;
 	int listening_socket;
+	int listening_queue_len;
 	int set_uid, set_gid;								/* config uid and gid */
 	int socket_uid, socket_gid, socket_mode;
 
diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c
index fc3c016..b99ad85 100644
--- a/sapi/fpm/fpm/zlog.c
+++ b/sapi/fpm/fpm/zlog.c
@@ -18,6 +18,7 @@
 
 static int zlog_fd = -1;
 static int zlog_level = ZLOG_NOTICE;
+static int launched = 0;
 
 static const char *level_names[] = {
 	[ZLOG_DEBUG]		= "DEBUG",
@@ -27,6 +28,16 @@ static const char *level_names[] = {
 	[ZLOG_ALERT]		= "ALERT",
 };
 
+const char *zlog_get_level_name() /* {{{ */
+{
+	return level_names[zlog_level];
+}
+/* }}} */
+
+void zlog_set_launched(void) {
+	launched = 1;
+}
+
 size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len) /* {{{ */
 {
 	struct tm t;
@@ -58,7 +69,7 @@ int zlog_set_level(int new_value) /* {{{ */
 }
 /* }}} */
 
-void zlog(const char *function, int line, int flags, const char *fmt, ...) /* {{{ */
+void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* {{{ */
 {
 	struct timeval tv;
 	char buf[MAX_LINE_LENGTH];
@@ -110,6 +121,9 @@ void zlog(const char *function, int line, int flags, const char *fmt, ...) /* {{
 
 	buf[len++] = '\n';
 	write(zlog_fd > -1 ? zlog_fd : STDERR_FILENO, buf, len);
+	if (zlog_fd != STDERR_FILENO && zlog_fd > -1 && !launched && (flags & ZLOG_LEVEL_MASK) >= ZLOG_NOTICE) {
+		write(STDERR_FILENO, buf, len);
+	}
 }
 /* }}} */
 
diff --git a/sapi/fpm/fpm/zlog.h b/sapi/fpm/fpm/zlog.h
index b5ac3d9..598c075 100644
--- a/sapi/fpm/fpm/zlog.h
+++ b/sapi/fpm/fpm/zlog.h
@@ -5,16 +5,18 @@
 #ifndef ZLOG_H
 #define ZLOG_H 1
 
-#define ZLOG_STUFF		__func__, __LINE__
+#define zlog(flags,...) zlog_ex(__func__, __LINE__, flags, __VA_ARGS__)
 
 struct timeval;
 
 int zlog_set_fd(int new_fd);
 int zlog_set_level(int new_value);
+const char *zlog_get_level_name();
+void zlog_set_launched(void);
 
 size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len);
 
-void zlog(const char *function, int line, int flags, const char *fmt, ...)
+void zlog_ex(const char *function, int line, int flags, const char *fmt, ...)
 		__attribute__ ((format(printf,4,5)));
 
 enum {
diff --git a/sapi/fpm/init.d.php-fpm.in b/sapi/fpm/init.d.php-fpm.in
index dfeb69a..766d102 100644
--- a/sapi/fpm/init.d.php-fpm.in
+++ b/sapi/fpm/init.d.php-fpm.in
@@ -2,8 +2,8 @@
 
 ### BEGIN INIT INFO
 # Provides:          php-fpm
-# Required-Start:    $all
-# Required-Stop:     $all
+# Required-Start:    $remote_fs $network
+# Required-Stop:     $remote_fs $network
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: starts php-fpm
diff --git a/sapi/fpm/php-fpm.1.in b/sapi/fpm/php-fpm.1.in
deleted file mode 100644
index 3e940da..0000000
--- a/sapi/fpm/php-fpm.1.in
+++ /dev/null
@@ -1,186 +0,0 @@
-.TH PHP-FPM 1 "2009" "The PHP Group" "Scripting Language"
-.SH NAME
-.TP 15
-php-fpm \- PHP FastCGI Process Manager 'PHP-FPM'
-.SH SYNOPSIS
-.B php-fpm
-[options]
-.LP
-.SH DESCRIPTION
-\fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for 
-Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to @php_fpm_localstatedir@/log/php-fpm.log.
-.LP
-Most options are set in the configuration file. The configuration file is @php_fpm_sysconfdir@/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for '.php' files to port 9000 and you should edit your webserver configuration file appropriately.
-.SH OPTIONS
-.TP 15
-.B \-C
-Do not chdir to the script's directory
-.TP
-.PD 0
-.B \-\-php\-ini \fIpath\fP|\fIfile\fP
-.TP
-.PD 1
-.B \-c \fIpath\fP|\fIfile\fP
-Look for 
-.B php.ini 
-file in the directory
-.IR path
-or use the specified
-.IR file
-.TP
-.PD 0
-.B \-\-no\-php\-ini
-.TP
-.PD 1
-.B \-n
-No 
-.B php.ini 
-file will be used
-.TP
-.PD 0
-.B \-\-define \fIfoo\fP[=\fIbar\fP]
-.TP
-.PD 1
-.B \-d \fIfoo\fP[=\fIbar\fP]
-Define INI entry 
-.IR foo 
-with value
-.IR bar
-.TP
-.B \-e
-Generate extended information for debugger/profiler
-.TP
-.PD 0
-.B \-\-help
-.TP
-.PD 1
-.B \-h
-This help
-.TP
-.PD 0
-.B \-\-info
-.TP
-.PD 1
-.B \-i
-PHP information and configuration
-.TP
-.PD 0
-.B \-\-modules
-.TP
-.PD 1
-.B \-m
-Show compiled in modules
-.TP
-.PD 0
-.B \-\-version
-.TP
-.PD 1
-.B \-v
-Version number
-.TP
-.PD 0
-.B \-\-fpm\-config \fIfile\fP
-.TP
-.PD 1
-.B \-\-y
-Specify alternative path to FastCGI process manager configuration file (the default is @php_fpm_sysconfdir@/php-fpm.conf)
-.TP
-.PD 0
-.B \-\-zend\-extension \fIfile\fP
-.TP
-.PD 1
-.B \-z \fIfile\fP
-Load Zend extension 
-.IR file
-.SH FILES
-.TP 15
-.B php-fpm.conf
-The configuration file for the php-fpm daemon.
-.TP
-.B php.ini
-The standard php configuration file.
-.SH EXAMPLES
-You should use the init script provided to start and stop the php-fpm daemon. This situation applies for any unix systems which use init.d for their main process manager.
-.P
-.PD 1
-.RS
-sudo /etc/init.d/php-fpm start
-.RE
-.TP
-If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @php_fpm_localstatedir@/run/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals:
-.P
-.PD 0
-.RS
-.B SIGINT,SIGTERM 	\fPimmediate termination
-.TP
-.B SIGQUIT 			\fPgraceful stop
-.TP
-.B SIGUSR1 			\fPre-open log file
-.TP
-.B SIGUSR2 			\fPgraceful reload of all workers + reload of fpm conf/binary
-.RE
-.PD 1
-.P
-.SH TIPS
-The PHP-FPM CGI daemon will work well with most popular webservers, including Apache2, lighttpd and nginx.
-.PD 1
-.P
-.SH SEE ALSO
-The PHP-FPM website:
-.PD 0
-.P
-.B http://php-fpm.org
-.PD 1
-.P
-For a more or less complete description of PHP look here:
-.PD 0
-.P
-.B http://www.php.net/manual/
-.PD 1
-.P
-A nice introduction to PHP by Stig Bakken can be found here:
-.PD 0
-.P
-.B http://www.zend.com/zend/art/intro.php
-.PD 1
-.SH BUGS
-You can view the list of known bugs or report any new bug you
-found at:
-.PD 0
-.P
-.B http://bugs.php.net
-.PD 1
-.SH AUTHORS
-PHP-FPM SAPI was written by Andrei Nigmatulin. The mailing-lists are highload-php-en (English) and highload-php-ru (Russian).
-.P
-The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
-.P
-A List of active developers can be found here:
-.PD 0
-.P
-.B http://www.php.net/credits.php
-.PD 1
-.P
-And last but not least PHP was developed with the help of a huge amount of 
-contributors all around the world.
-.SH VERSION INFORMATION
-This manpage describes \fBphp\fP, version @PHP_VERSION@, \fBfpm\fP, version @fpm_version at .
-.SH COPYRIGHT
-Copyright \(co 1997\-2009 The PHP Group
-.PD 0
-.P
-Copyright (c) 2007-2009, Andrei Nigmatulin
-.PD 1
-.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
-available through the world-wide-web at the following url:
-.PD 0
-.P
-.B http://www.php.net/license/3_01.txt
-.PD 1
-.P
-If you did not receive a copy of the PHP license and are unable to
-obtain it through the world-wide-web, please send a note to
-.B license at php.net
-so we can mail you a copy immediately.
diff --git a/sapi/fpm/php-fpm.8.in b/sapi/fpm/php-fpm.8.in
new file mode 100644
index 0000000..6c9c6d6
--- /dev/null
+++ b/sapi/fpm/php-fpm.8.in
@@ -0,0 +1,199 @@
+.TH PHP-FPM 8 "2009" "The PHP Group" "Scripting Language"
+.SH NAME
+.TP 15
+php-fpm \- PHP FastCGI Process Manager 'PHP-FPM'
+.SH SYNOPSIS
+.B php-fpm
+[options]
+.LP
+.SH DESCRIPTION
+\fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for 
+Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to @php_fpm_localstatedir@/log/php-fpm.log.
+.LP
+Most options are set in the configuration file. The configuration file is @php_fpm_sysconfdir@/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for '.php' files to port 9000 and you should edit your webserver configuration file appropriately.
+.SH OPTIONS
+.TP 15
+.B \-C
+Do not chdir to the script's directory
+.TP
+.PD 0
+.B \-\-php\-ini \fIpath\fP|\fIfile\fP
+.TP
+.PD 1
+.B \-c \fIpath\fP|\fIfile\fP
+Look for 
+.B php.ini 
+file in the directory
+.IR path
+or use the specified
+.IR file
+.TP
+.PD 0
+.B \-\-no\-php\-ini
+.TP
+.PD 1
+.B \-n
+No 
+.B php.ini 
+file will be used
+.TP
+.PD 0
+.B \-\-define \fIfoo\fP[=\fIbar\fP]
+.TP
+.PD 1
+.B \-d \fIfoo\fP[=\fIbar\fP]
+Define INI entry 
+.IR foo 
+with value
+.IR bar
+.TP
+.B \-e
+Generate extended information for debugger/profiler
+.TP
+.PD 0
+.B \-\-help
+.TP
+.PD 1
+.B \-h
+This help
+.TP
+.PD 0
+.B \-\-info
+.TP
+.PD 1
+.B \-i
+PHP information and configuration
+.TP
+.PD 0
+.B \-\-modules
+.TP
+.PD 1
+.B \-m
+Show compiled in modules
+.TP
+.PD 0
+.B \-\-version
+.TP
+.PD 1
+.B \-v
+Version number
+.B \-\-prefix \fIpath\fP
+.TP
+.PD 1
+.B \-p
+Specify alternative prefix path (the default is @php_fpm_prefix@)
+.TP
+.PD 0
+.B \-\-fpm\-config \fIfile\fP
+.TP
+.PD 1
+.B \-y
+Specify alternative path to FastCGI process manager configuration file (the default is @php_fpm_sysconfdir@/php-fpm.conf)
+.TP
+.PD 0
+.B \-\-test
+.TP
+.PD 1
+.B \-t
+Test FPM configuration file and exit
+If called twice (-tt), the configuration is dumped before exiting.
+.TP
+.PD 0
+.B \-\-zend\-extension \fIfile\fP
+.TP
+.PD 1
+.B \-z \fIfile\fP
+Load Zend extension 
+.IR file
+.SH FILES
+.TP 15
+.B php-fpm.conf
+The configuration file for the php-fpm daemon.
+.TP
+.B php.ini
+The standard php configuration file.
+.SH EXAMPLES
+You should use the init script provided to start and stop the php-fpm daemon. This situation applies for any unix systems which use init.d for their main process manager.
+.P
+.PD 1
+.RS
+sudo /etc/init.d/php-fpm start
+.RE
+.TP
+If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @php_fpm_localstatedir@/run/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals:
+.P
+.PD 0
+.RS
+.B SIGINT,SIGTERM 	\fPimmediate termination
+.TP
+.B SIGQUIT 			\fPgraceful stop
+.TP
+.B SIGUSR1 			\fPre-open log file
+.TP
+.B SIGUSR2 			\fPgraceful reload of all workers + reload of fpm conf/binary
+.RE
+.PD 1
+.P
+.SH TIPS
+The PHP-FPM CGI daemon will work well with most popular webservers, including Apache2, lighttpd and nginx.
+.PD 1
+.P
+.SH SEE ALSO
+The PHP-FPM website:
+.PD 0
+.P
+.B http://php-fpm.org
+.PD 1
+.P
+For a more or less complete description of PHP look here:
+.PD 0
+.P
+.B http://www.php.net/manual/
+.PD 1
+.P
+A nice introduction to PHP by Stig Bakken can be found here:
+.PD 0
+.P
+.B http://www.zend.com/zend/art/intro.php
+.PD 1
+.SH BUGS
+You can view the list of known bugs or report any new bug you
+found at:
+.PD 0
+.P
+.B http://bugs.php.net
+.PD 1
+.SH AUTHORS
+PHP-FPM SAPI was written by Andrei Nigmatulin. The mailing-lists are highload-php-en (English) and highload-php-ru (Russian).
+.P
+The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
+.P
+A List of active developers can be found here:
+.PD 0
+.P
+.B http://www.php.net/credits.php
+.PD 1
+.P
+And last but not least PHP was developed with the help of a huge amount of 
+contributors all around the world.
+.SH VERSION INFORMATION
+This manpage describes \fBphp-fpm\fP, version @PHP_VERSION at .
+.SH COPYRIGHT
+Copyright \(co 1997\-2009 The PHP Group
+.PD 0
+.P
+Copyright (c) 2007-2009, Andrei Nigmatulin
+.PD 1
+.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
+available through the world-wide-web at the following url:
+.PD 0
+.P
+.B http://www.php.net/license/3_01.txt
+.PD 1
+.P
+If you did not receive a copy of the PHP license and are unable to
+obtain it through the world-wide-web, please send a note to
+.B license at php.net
+so we can mail you a copy immediately.
diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in
index 1502498..314b7e5 100644
--- a/sapi/fpm/php-fpm.conf.in
+++ b/sapi/fpm/php-fpm.conf.in
@@ -3,12 +3,16 @@
 ;;;;;;;;;;;;;;;;;;;;;
 
 ; All relative paths in this configuration file are relative to PHP's install
-; prefix.
+; prefix (@prefix@). This prefix can be dynamicaly changed by using the
+; '-p' argument from the command line.
 
 ; Include one or more files. If glob(3) exists, it is used to include a bunch of
 ; files from a glob(3) pattern. This directive can be used everywhere in the
 ; file.
-;include=@EXPANDED_SYSCONFDIR@/fpm.d/*.conf
+; Relative path can also be used. They will be prefixed by:
+;  - the global prefix if it's been set (-p arguement)
+;  - @prefix@ otherwise
+;include=etc/fpm.d/*.conf
 
 ;;;;;;;;;;;;;;;;;;
 ; Global Options ;
@@ -16,12 +20,14 @@
 
 [global]
 ; Pid file
+; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
 ; Default Value: none
-;pid = @EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid
+;pid = run/php-fpm.pid
 
 ; Error log file
-; Default Value: @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log
-;error_log = @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log
+; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
+; Default Value: log/php-fpm.log
+;error_log = log/php-fpm.log
 
 ; Log level
 ; Possible Values: alert, error, warning, notice, debug
@@ -62,8 +68,23 @@
 ; FPM can handle. Your system will tell you anyway :)
 
 ; Start a new pool named 'www'.
+; the variable $pool can we used in any directive and will be replaced by the
+; pool name ('www' here)
 [www]
 
+; Per pool prefix
+; It only applies on the following directives:
+; - 'slowlog'
+; - 'listen' (unixsocket)
+; - 'chroot'
+; - 'chdir'
+; - 'php_values'
+; - 'php_admin_values'
+; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
+; Note: This directive can also be relative to the global prefix.
+; Default Value: none
+;prefix = /path/to/pools/$pool
+
 ; The address on which to accept FastCGI requests.
 ; Valid syntaxes are:
 ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
@@ -75,7 +96,7 @@
 listen = 127.0.0.1:9000
 
 ; Set listen(2) backlog. A value of '-1' means unlimited.
-; Default Value: -1
+; Default Value: 128 (-1 on FreeBSD and OpenBSD)
 ;listen.backlog = -1
  
 ; List of ipv4 addresses of FastCGI clients which are allowed to connect.
@@ -154,21 +175,25 @@ pm.max_children = 50
 ; The URI to view the FPM status page. If this value is not set, no URI will be
 ; recognized as a status page. By default, the status page shows the following
 ; information:
-;   accepted conn    - the number of request accepted by the pool;
-;   pool             - the name of the pool;
-;   process manager  - static or dynamic;
-;   idle processes   - the number of idle processes;
-;   active processes - the number of active processes;
-;   total processes  - the number of idle + active processes.
+;   accepted conn        - the number of request accepted by the pool;
+;   pool                 - the name of the pool;
+;   process manager      - static or dynamic;
+;   idle processes       - the number of idle processes;
+;   active processes     - the number of active processes;
+;   total processes      - the number of idle + active processes.
+;   max children reached - number of times, the process limit has been reached,
+;                          when pm tries to start more children (works only for
+;                          pm 'dynamic')
 ; The values of 'idle processes', 'active processes' and 'total processes' are
 ; updated each second. The value of 'accepted conn' is updated in real time.
 ; Example output:
-;   accepted conn:   12073
-;   pool:             www
-;   process manager:  static
-;   idle processes:   35
-;   active processes: 65
-;   total processes:  100
+;   accepted conn:        12073
+;   pool:                 www
+;   process manager:      static
+;   idle processes:       35
+;   active processes:     65
+;   total processes:      100
+;   max children reached: 1
 ; By default the status page output is formatted as text/plain. Passing either
 ; 'html' or 'json' as a query string will return the corresponding output
 ; syntax. Example:
@@ -212,8 +237,9 @@ pm.max_children = 50
 ;request_slowlog_timeout = 0
  
 ; The log file for slow requests
-; Default Value: @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log.slow
-;slowlog = @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log.slow
+; Default Value: not set
+; Note: slowlog is mandatory if request_slowlog_timeout is set
+;slowlog = log/$pool.log.slow
  
 ; Set open file descriptor rlimit.
 ; Default Value: system defined value
@@ -226,18 +252,24 @@ pm.max_children = 50
  
 ; Chroot to this directory at the start. This value must be defined as an
 ; absolute path. When this value is not set, chroot is not used.
+; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
+; of its subdirectories. If the pool prefix is not set, the global prefix
+; will be used instead.
 ; Note: chrooting is a great security feature and should be used whenever 
 ;       possible. However, all PHP paths will be relative to the chroot
 ;       (error_log, sessions.save_path, ...).
 ; Default Value: not set
 ;chroot = 
  
-; Chdir to this directory at the start. This value must be an absolute path.
+; Chdir to this directory at the start.
+; Note: relative path can be used.
 ; Default Value: current directory or / when chroot
 ;chdir = /var/www
  
 ; Redirect worker stdout and stderr into main error log. If not set, stdout and
 ; stderr will be redirected to /dev/null according to FastCGI specs.
+; Note: on highloaded environement, this can cause some delay in the page
+; process time (several ms).
 ; Default Value: no
 ;catch_workers_output = yes
  
@@ -264,6 +296,9 @@ pm.max_children = 50
 ; overwrite previously defined php.ini values, but will append the new value
 ; instead.
 
+; Note: path INI options can be relative and will be expanded with the prefix
+; (pool, global or @prefix@)
+
 ; Default Value: nothing is defined by default except the values in php.ini and
 ;                specified at startup with the -d argument
 ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www at my.domain.com
diff --git a/scripts/phpize.m4 b/scripts/phpize.m4
index 07e6037..e3a30a5 100644
--- a/scripts/phpize.m4
+++ b/scripts/phpize.m4
@@ -111,7 +111,7 @@ if test "$PHP_DEBUG" = "yes"; then
   dnl add -O0 only if GCC or ICC is used
   if test "$GCC" = "yes" || test "$ICC" = "yes"; then
     CFLAGS="$CFLAGS -O0"
-    CXXFLAGS="$CXXFLAGS -O0"
+    CXXFLAGS="$CXXFLAGS -g -O0"
   fi
   if test "$SUNCC" = "yes"; then
     if test -n "$auto_cflags"; then
diff --git a/tests/basic/021.phpt b/tests/basic/021.phpt
index bce6bb3..e79ac7d 100644
--- a/tests/basic/021.phpt
+++ b/tests/basic/021.phpt
@@ -1,7 +1,7 @@
 --TEST--
 Bug #37276 (problems witch $_POST array)
 --INI--
-file_upload=1
+file_uploads=1
 --POST_RAW--
 Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
 -----------------------------20896060251896012921717172737
diff --git a/tests/basic/bug46313-win.phpt b/tests/basic/bug46313-win.phpt
index 1971e80..87786d4 100644
--- a/tests/basic/bug46313-win.phpt
+++ b/tests/basic/bug46313-win.phpt
@@ -28,6 +28,8 @@ var_dump($GLOBALS["o1\'file"]);
 var_dump($GLOBALS["o1\'file"] === $_FILES["o1\'file"]["tmp_name"]);
 ?>
 --EXPECTF--
+Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
+Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
 array(2) {
   ["o1\'file"]=>
   array(5) {
@@ -60,6 +62,3 @@ string(12) "o1"
 bool(true)
 string(%d) "%s"
 bool(true)
-Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0
-Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
-
diff --git a/tests/basic/bug51709_1.phpt b/tests/basic/bug51709_1.phpt
index e929df3..8abb925 100644
--- a/tests/basic/bug51709_1.phpt
+++ b/tests/basic/bug51709_1.phpt
@@ -13,4 +13,4 @@ class foo {
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
-Parse error: syntax error, unexpected T_FOR, expecting T_STRING in %s/bug51709_1.php on line %d
+Parse error: syntax error, unexpected T_FOR, expecting T_STRING in %sbug51709_1.php on line %d
diff --git a/tests/basic/bug51709_2.phpt b/tests/basic/bug51709_2.phpt
index b6224ab..7763caf 100644
--- a/tests/basic/bug51709_2.phpt
+++ b/tests/basic/bug51709_2.phpt
@@ -13,4 +13,4 @@ class foo {
 ===DONE===
 <?php exit(0); ?>
 --EXPECTF--
-Parse error: syntax error, unexpected T_GOTO, expecting T_STRING in %s/bug51709_2.php on line %d
+Parse error: syntax error, unexpected T_GOTO, expecting T_STRING in %sbug51709_2.php on line %d
diff --git a/tests/basic/bug53180.phpt b/tests/basic/bug53180.phpt
new file mode 100644
index 0000000..5c2eb76
--- /dev/null
+++ b/tests/basic/bug53180.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #53180 (post_max_size=0 partly not working)
+--INI--
+post_max_size=0
+--POST--
+email=foo&password=bar&submit=Log+on
+--FILE--
+<?php
+var_dump($_POST);
+?>
+--EXPECT--
+array(3) {
+  ["email"]=>
+  string(3) "foo"
+  ["password"]=>
+  string(3) "bar"
+  ["submit"]=>
+  string(6) "Log on"
+}
diff --git a/tests/basic/rfc1867_max_file_uploads_empty_files.phpt b/tests/basic/rfc1867_max_file_uploads_empty_files.phpt
new file mode 100644
index 0000000..76327fd
--- /dev/null
+++ b/tests/basic/rfc1867_max_file_uploads_empty_files.phpt
@@ -0,0 +1,101 @@
+--TEST--
+rfc1867 max_file_uploads - empty files shouldn't count (non-debug version)
+--SKIPIF--
+<?php if(function_exists("leak")) print "skip only for non-debug builds"; ?>
+--INI--
+file_uploads=1
+error_reporting=E_ALL
+max_file_uploads=2
+--POST_RAW--
+Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file2"; filename=""
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file3"; filename=""
+Content-Type: text/plain-file
+
+33
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file4"; filename="file4.txt"
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+if (is_uploaded_file($_FILES["file1"]["tmp_name"])) {
+	var_dump(file_get_contents($_FILES["file1"]["tmp_name"]));
+}
+if (is_uploaded_file($_FILES["file4"]["tmp_name"])) {
+	var_dump(file_get_contents($_FILES["file4"]["tmp_name"]));
+}
+?>
+--EXPECTF--
+array(4) {
+  ["file2"]=>
+  array(5) {
+    ["name"]=>
+    string(0) ""
+    ["type"]=>
+    string(0) ""
+    ["tmp_name"]=>
+    string(0) ""
+    ["error"]=>
+    int(4)
+    ["size"]=>
+    int(0)
+  }
+  ["file3"]=>
+  array(5) {
+    ["name"]=>
+    string(0) ""
+    ["type"]=>
+    string(0) ""
+    ["tmp_name"]=>
+    string(0) ""
+    ["error"]=>
+    int(4)
+    ["size"]=>
+    int(0)
+  }
+  ["file4"]=>
+  array(5) {
+    ["name"]=>
+    string(9) "file4.txt"
+    ["type"]=>
+    string(15) "text/plain-file"
+    ["tmp_name"]=>
+    string(%d) "%s"
+    ["error"]=>
+    int(0)
+    ["size"]=>
+    int(0)
+  }
+  ["file1"]=>
+  array(5) {
+    ["name"]=>
+    string(9) "file1.txt"
+    ["type"]=>
+    string(15) "text/plain-file"
+    ["tmp_name"]=>
+    string(%d) "%s"
+    ["error"]=>
+    int(0)
+    ["size"]=>
+    int(1)
+  }
+}
+array(0) {
+}
+string(1) "1"
+string(0) ""
diff --git a/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt b/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt
new file mode 100644
index 0000000..279851c
--- /dev/null
+++ b/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt
@@ -0,0 +1,102 @@
+--TEST--
+rfc1867 max_file_uploads - empty files shouldn't count (debug version)
+--SKIPIF--
+<?php if(!function_exists("leak")) print "skip only for debug builds"; ?>
+--INI--
+file_uploads=1
+error_reporting=E_ALL
+max_file_uploads=1
+--POST_RAW--
+Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file2"; filename=""
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file3"; filename=""
+Content-Type: text/plain-file
+
+33
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file4"; filename="file4.txt"
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+if (is_uploaded_file($_FILES["file1"]["tmp_name"])) {
+	var_dump(file_get_contents($_FILES["file1"]["tmp_name"]));
+}
+?>
+--EXPECTF--
+Notice: No file uploaded in Unknown on line 0
+
+Notice: No file uploaded in Unknown on line 0
+
+Warning: Uploaded file size 0 - file [file4=file4.txt] not saved in Unknown on line 0
+array(4) {
+  ["file2"]=>
+  array(5) {
+    ["name"]=>
+    string(0) ""
+    ["type"]=>
+    string(0) ""
+    ["tmp_name"]=>
+    string(0) ""
+    ["error"]=>
+    int(4)
+    ["size"]=>
+    int(0)
+  }
+  ["file3"]=>
+  array(5) {
+    ["name"]=>
+    string(0) ""
+    ["type"]=>
+    string(0) ""
+    ["tmp_name"]=>
+    string(0) ""
+    ["error"]=>
+    int(4)
+    ["size"]=>
+    int(0)
+  }
+  ["file4"]=>
+  array(5) {
+    ["name"]=>
+    string(9) "file4.txt"
+    ["type"]=>
+    string(0) ""
+    ["tmp_name"]=>
+    string(0) ""
+    ["error"]=>
+    int(5)
+    ["size"]=>
+    int(0)
+  }
+  ["file1"]=>
+  array(5) {
+    ["name"]=>
+    string(9) "file1.txt"
+    ["type"]=>
+    string(15) "text/plain-file"
+    ["tmp_name"]=>
+    string(%d) "%s"
+    ["error"]=>
+    int(0)
+    ["size"]=>
+    int(1)
+  }
+}
+array(0) {
+}
+string(1) "1"
diff --git a/tests/classes/constants_error_004.phpt b/tests/classes/constants_error_004.phpt
index 732c530..03e6725 100644
--- a/tests/classes/constants_error_004.phpt
+++ b/tests/classes/constants_error_004.phpt
@@ -10,4 +10,4 @@ Class constant whose initial value refereces a non-existent class
   $a = new C();
 ?>
 --EXPECTF--
-Fatal error: Undefined class constant 'D::hello' in %s on line %d
+Fatal error: Class 'D' not found in %s on line %d
diff --git a/tests/output/bug46897.phpt b/tests/output/bug46897.phpt
index 6cfb102..a77db91 100644
--- a/tests/output/bug46897.phpt
+++ b/tests/output/bug46897.phpt
@@ -18,10 +18,10 @@ echo 'Done';
 ?>
 --EXPECTF--
 [callback:1]Attempt to flush unerasable buffer - should fail...
-Notice: ob_flush(): failed to flush buffer callback. in %s on line %d
+Notice: ob_flush(): failed to flush buffer callback in %s on line %d
 bool(false)
 string(%d) "Attempt to flush unerasable buffer - should fail...
-Notice: ob_flush(): failed to flush buffer callback. in %s on line %d
+Notice: ob_flush(): failed to flush buffer callback in %s on line %d
 bool(false)
 "
 Done
diff --git a/tests/output/ob_clean_basic_001.phpt b/tests/output/ob_clean_basic_001.phpt
index c93bea3..afaa7e2 100644
--- a/tests/output/ob_clean_basic_001.phpt
+++ b/tests/output/ob_clean_basic_001.phpt
@@ -29,8 +29,8 @@ echo "Done";
 
 -- Testing ob_clean() function with Zero arguments --
 
-Notice: ob_clean(): failed to delete buffer. No buffer to delete. in %s on line 12
+Notice: ob_clean(): failed to delete buffer. No buffer to delete in %s on line 12
 bool(false)
 string(61) "bool(true)
 Ensure the buffer is still active after the clean."
-Done
\ No newline at end of file
+Done
diff --git a/tests/output/ob_end_clean_basic_001.phpt b/tests/output/ob_end_clean_basic_001.phpt
index 0b694e3..54e840b 100644
--- a/tests/output/ob_end_clean_basic_001.phpt
+++ b/tests/output/ob_end_clean_basic_001.phpt
@@ -21,11 +21,11 @@ var_dump(ob_end_clean());
 ?>
 --EXPECTF--
 
-Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in %s on line 7
+Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in %s on line 7
 bool(false)
 bool(true)
 bool(true)
 
-Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in %s on line 16
+Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in %s on line 16
 bool(false)
 
diff --git a/tests/output/ob_end_flush_basic_001.phpt b/tests/output/ob_end_flush_basic_001.phpt
index 7515fac..cba7802 100644
--- a/tests/output/ob_end_flush_basic_001.phpt
+++ b/tests/output/ob_end_flush_basic_001.phpt
@@ -30,12 +30,12 @@ echo "Done";
 
 -- Testing ob_end_flush() function with Zero arguments --
 
-Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 12
+Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 12
 bool(false)
 bool(true)
 Hello
 bool(true)
 
-Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 21
+Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 21
 bool(false)
-Done
\ No newline at end of file
+Done
diff --git a/tests/output/ob_flush_basic_001.phpt b/tests/output/ob_flush_basic_001.phpt
index 91fb695..57de5e3 100644
--- a/tests/output/ob_flush_basic_001.phpt
+++ b/tests/output/ob_flush_basic_001.phpt
@@ -30,10 +30,10 @@ echo "Done";
 
 -- Testing ob_flush() function with Zero arguments --
 
-Notice: ob_flush(): failed to flush buffer. No buffer to flush. in %s on line 12
+Notice: ob_flush(): failed to flush buffer. No buffer to flush in %s on line 12
 bool(false)
 This should get flushed.
 bool(true)
 Ensure the buffer is still active after the flush.
 bool(true)
-Done
\ No newline at end of file
+Done
diff --git a/tests/output/ob_get_level_basic_001.phpt b/tests/output/ob_get_level_basic_001.phpt
index 78217e4..65f3291 100644
--- a/tests/output/ob_get_level_basic_001.phpt
+++ b/tests/output/ob_get_level_basic_001.phpt
@@ -42,6 +42,6 @@ int(2)
 int(1)
 int(0)
 
-Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 26
+Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 26
 int(0)
-Done
\ No newline at end of file
+Done
diff --git a/tests/output/ob_start_basic_unerasable_002.phpt b/tests/output/ob_start_basic_unerasable_002.phpt
index 2ffcbb9..3b8bd63 100644
--- a/tests/output/ob_start_basic_unerasable_002.phpt
+++ b/tests/output/ob_start_basic_unerasable_002.phpt
@@ -21,13 +21,13 @@ var_dump(ob_get_level());
 --EXPECTF--
 [callback:1]All of the following calls will fail to clean/remove the topmost buffer:
 
-Notice: ob_clean(): failed to delete buffer callback. in %s on line 11
+Notice: ob_clean(): failed to delete buffer callback in %s on line 11
 bool(false)
 
-Notice: ob_end_clean(): failed to delete buffer callback. in %s on line 12
+Notice: ob_end_clean(): failed to delete buffer callback in %s on line 12
 bool(false)
 
-Notice: ob_end_flush(): failed to delete buffer callback. in %s on line 13
+Notice: ob_end_flush(): failed to delete buffer callback in %s on line 13
 bool(false)
 The OB nesting will still be 1 level deep:
-int(1)
\ No newline at end of file
+int(1)
diff --git a/tests/output/ob_start_basic_unerasable_003.phpt b/tests/output/ob_start_basic_unerasable_003.phpt
index d201414..e35902c 100644
--- a/tests/output/ob_start_basic_unerasable_003.phpt
+++ b/tests/output/ob_start_basic_unerasable_003.phpt
@@ -17,5 +17,5 @@ var_dump($str);
 --EXPECTF--
 [callback:1]This call will fail to obtain the content, since it is also requesting a clean:
 
-Notice: ob_get_clean(): failed to delete buffer callback. in %s on line 11
-bool(false)
\ No newline at end of file
+Notice: ob_get_clean(): failed to delete buffer callback in %s on line 11
+bool(false)
diff --git a/tests/output/ob_start_basic_unerasable_004.phpt b/tests/output/ob_start_basic_unerasable_004.phpt
index 6669856..081875a 100644
--- a/tests/output/ob_start_basic_unerasable_004.phpt
+++ b/tests/output/ob_start_basic_unerasable_004.phpt
@@ -17,5 +17,5 @@ var_dump($str);
 --EXPECTF--
 [callback:1]This call will fail to flush and fail to obtain the content:
 
-Notice: ob_get_flush(): failed to delete buffer callback. in %s on line 11
+Notice: ob_get_flush(): failed to delete buffer callback in %s on line 11
 bool(false)
diff --git a/tests/output/ob_start_basic_unerasable_005.phpt b/tests/output/ob_start_basic_unerasable_005.phpt
index 7be71e5..f1af201 100644
--- a/tests/output/ob_start_basic_unerasable_005.phpt
+++ b/tests/output/ob_start_basic_unerasable_005.phpt
@@ -17,9 +17,9 @@ var_dump(ob_get_contents());
 ?>
 --EXPECTF--
 [callback:1]Attempt to flush unerasable buffer - should fail... 
-Notice: ob_flush(): failed to flush buffer callback. in %s on line 11
+Notice: ob_flush(): failed to flush buffer callback in %s on line 11
 bool(false)
 string(%d) "Attempt to flush unerasable buffer - should fail... 
-Notice: ob_flush(): failed to flush buffer callback. in %s on line 11
+Notice: ob_flush(): failed to flush buffer callback in %s on line 11
 bool(false)
 "
diff --git a/tests/output/ob_start_callbacks.phpt b/tests/output/ob_start_callbacks.phpt
new file mode 100644
index 0000000..da52d85
--- /dev/null
+++ b/tests/output/ob_start_callbacks.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test ob_start() with callbacks in variables
+--FILE--
+<?php 
+
+// Closure in variable
+$a = function ($s) { return strtoupper($s); };
+ob_start($a);
+echo 'closure in variable', "\n";
+ob_end_flush();
+
+// Object (array) in variable
+class foo {
+	static function out($foo) {
+		return strtoupper($foo);
+	}
+}
+$a = array('foo', 'out');
+ob_start($a);
+echo 'object in variable', "\n";
+ob_end_flush();
+
+// Object with static array
+ob_start(array('foo', 'out'));
+echo 'object via static array', "\n";
+ob_end_flush();
+
+function my_strtoupper($foo, $bar) {
+	return strtoupper($foo);
+}
+$a = 'my_strtoupper';
+ob_start($a);
+echo 'function via variable', "\n";
+ob_end_flush();
+--EXPECT--
+CLOSURE IN VARIABLE
+OBJECT IN VARIABLE
+OBJECT VIA STATIC ARRAY
+FUNCTION VIA VARIABLE
diff --git a/tests/security/bug53226.phpt b/tests/security/bug53226.phpt
new file mode 100644
index 0000000..9556e46
--- /dev/null
+++ b/tests/security/bug53226.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #53226 (file_exists fails on big filenames)
+--INI--
+open_basedir=.
+--FILE--
+<?php
+require_once "open_basedir.inc";
+create_directories();
+
+var_dump(file_exists('./test/ok/ok.txt'));
+var_dump(file_exists('./test/foo'));
+
+$file = str_repeat('x', 2 * PHP_MAXPATHLEN);
+var_dump(file_exists("./test/$file"));
+?>
+--CLEAN--
+<?php
+require_once "open_basedir.inc";
+delete_directories();
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+
+Warning: file_exists(): File name is longer than the maximum allowed path length on this platform (%d): %s in %s on line %d
+bool(false)
diff --git a/win32/build/Makefile b/win32/build/Makefile
index 837fcc8..998724a 100644
--- a/win32/build/Makefile
+++ b/win32/build/Makefile
@@ -14,10 +14,10 @@
 #  | Author: Wez Furlong <wez at thebrainroom.com>                           |
 #  +----------------------------------------------------------------------+
 #
-# $Id: Makefile 289763 2009-10-19 19:02:12Z pajoye $
+# $Id: Makefile 302247 2010-08-15 03:38:08Z pajoye $
 # This is the makefile template for the win32 build
 
-CC="$(CL)"
+CC="$(PHP_CL)"
 LD="$(LINK)"
 MC="$(MC)"
 MT="$(MT)"
@@ -146,7 +146,7 @@ dist: all build-dist
 snap: build-snap build-dist
 
 $(BUILD_DIR)\deplister.exe:	win32\build\deplister.c
-	$(CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
+	$(PHP_CL) /Fo$(BUILD_DIR)\ /Fd$(BUILD_DIR)\ /Fp$(BUILD_DIR)\ /FR$(BUILD_DIR) /Fe$(BUILD_DIR)\deplister.exe win32\build\deplister.c imagehlp.lib
 
 msi-installer: dist
 	$(BUILD_DIR)\php.exe ..\php-installer\build-installer.php "$(BUILD_DIR)" "$(PHPDLL)" "$(SAPI_TARGETS)" "$(EXT_TARGETS)" "$(PECL_TARGETS)"
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index 5f10c7e..a4e768f 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -1,11 +1,11 @@
 // vim:ft=javascript
-// $Id: config.w32 291639 2009-12-03 11:50:32Z kalle $
+// $Id: config.w32 305923 2010-12-02 23:23:14Z pajoye $
 // "Master" config file; think of it as a configure.in
 // equivalent.
 
 ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin');
-CL = PATH_PROG('cl');
-if (!CL) {
+PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
+if (!PHP_CL) {
 	ERROR("MS C++ compiler is required");
 }
 
@@ -17,14 +17,14 @@ if (!CL) {
 // 1500 is vs.net 2008
 // 1600 is vs.net 2010
 // Which version of the compiler do we have?
-VCVERS = probe_binary(CL).substr(0, 5).replace('.', '');
+VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
 STDOUT.WriteLine("  Detected compiler " + VC_VERSIONS[VCVERS]);
 AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
 DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
 AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
 
 // do we use x64 or 80x86 version of compiler?
-X64 = probe_binary(CL, 64);
+X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
 if (X64) {
 	STDOUT.WriteLine("  Detected 64-bit compiler");
 } else {
@@ -104,7 +104,7 @@ ARG_ENABLE('zts', 'Thread safety', 'yes');
 // Configures the hard-coded installation dir
 ARG_ENABLE('prefix', 'where PHP will be installed', '');
 if (PHP_PREFIX == '') {
-	PHP_PREFIX = "C:\\php" + PHP_VERSION;
+	PHP_PREFIX = "C:\\php";
 	if (PHP_DEBUG == "yes")
 		PHP_PREFIX += "\\debug";
 }
@@ -349,7 +349,7 @@ ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c
 	userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c");
 
 ADD_SOURCES("win32", "glob.c readdir.c \
-	registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c globals.c");
+	registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c");
 
 STDOUT.WriteBlankLines(1);
 
diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in
index 27ff052..4c16b1a 100644
--- a/win32/build/config.w32.h.in
+++ b/win32/build/config.w32.h.in
@@ -1,6 +1,6 @@
 /*
 	Build Configuration Template for Win32.
-	$Id: config.w32.h.in 291951 2009-12-10 14:08:19Z pajoye $
+	$Id: config.w32.h.in 305778 2010-11-26 18:25:13Z pajoye $
 */
 
 /* Define the minimum supported version */
@@ -58,6 +58,7 @@
 /* its in win32/time.c */
 #define HAVE_USLEEP 1
 #define HAVE_NANOSLEEP 1
+#define PHP_SLEEP_NON_VOID 1
 
 #define HAVE_GETHOSTNAME 1
 #define HAVE_GETCWD 1
diff --git a/win32/build/template.rc b/win32/build/template.rc
index 98c2bcb..58cbb99 100644
--- a/win32/build/template.rc
+++ b/win32/build/template.rc
@@ -1,5 +1,5 @@
 /* This is a template RC file.
- * $Id: template.rc 281570 2009-06-03 01:14:58Z kalle $
+ * $Id: template.rc 302265 2010-08-15 13:40:29Z pajoye $
  * Do not edit with MSVC */
 #ifdef APSTUDIO_INVOKED
 # error dont edit with MSVC
@@ -65,7 +65,7 @@ BEGIN
 #endif
             VALUE "FileVersion", EXT_VERSION
             VALUE "InternalName", INTERNAL_NAME
-            VALUE "LegalCopyright", "Copyright © 1997-2009 The PHP Group"
+            VALUE "LegalCopyright", "Copyright © 1997-2010 The PHP Group"
             VALUE "LegalTrademarks", "PHP"
             VALUE "OriginalFilename", FILE_NAME
             VALUE "ProductName", "PHP"
diff --git a/win32/glob.c b/win32/glob.c
index 0d290c6..15be8ff 100644
--- a/win32/glob.c
+++ b/win32/glob.c
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: glob.c 272473 2009-01-01 12:32:49Z pajoye $ */
+/* $Id: glob.c 303317 2010-09-13 11:17:40Z pajoye $ */
 
 /*
  * glob(3) -- a superset of the one defined in POSIX 1003.2.
@@ -146,12 +146,11 @@ static int	 g_stat(Char *, struct stat *, 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 *,
-		    glob_t *, size_t *);
+				glob_t *, size_t *);
 static int	 glob3(Char *, Char *, Char *, Char *, Char *, Char *,
-		    Char *, Char *, glob_t *, size_t *);
+				Char *, Char *, glob_t *, size_t *);
 static int	 globextend(const Char *, glob_t *, size_t *);
-static const Char *
-		 globtilde(const Char *, Char *, size_t, glob_t *);
+static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
 static int	 globexp1(const Char *, glob_t *);
 static int	 globexp2(const Char *, const Char *, glob_t *, int *);
 static int	 match(Char *, Char *, Char *);
@@ -370,7 +369,7 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
 	/* Copy up to the end of the string or / */
 	eb = &patbuf[patbuf_len - 1];
 	for (p = pattern + 1, h = (char *) patbuf;
-	    h < (char *)eb && *p && *p != SLASH; *h++ = (char) *p++)
+		h < (char *)eb && *p && *p != SLASH; *h++ = (char) *p++)
 		;
 
 	*h = EOS;
@@ -451,7 +450,7 @@ glob0(pattern, pglob)
 			if (c == NOT)
 				++qpatnext;
 			if (*qpatnext == EOS ||
-			    g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
+				g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
 				*bufnext++ = LBRACKET;
 				if (c == NOT)
 					--qpatnext;
@@ -464,7 +463,7 @@ glob0(pattern, pglob)
 			do {
 				*bufnext++ = CHAR(c);
 				if (*qpatnext == RANGE &&
-				    (c = qpatnext[1]) != RBRACKET) {
+					(c = qpatnext[1]) != RBRACKET) {
 					*bufnext++ = M_RNG;
 					*bufnext++ = CHAR(c);
 					qpatnext += 2;
@@ -506,21 +505,20 @@ glob0(pattern, pglob)
 	 */
 	if (pglob->gl_pathc == oldpathc) {
 		if ((pglob->gl_flags & GLOB_NOCHECK) ||
-		    ((pglob->gl_flags & GLOB_NOMAGIC) &&
-		    !(pglob->gl_flags & GLOB_MAGCHAR)))
+			((pglob->gl_flags & GLOB_NOMAGIC) &&
+			!(pglob->gl_flags & GLOB_MAGCHAR)))
 			return(globextend(pattern, pglob, &limit));
 		else
 			return(GLOB_NOMATCH);
 	}
 	if (!(pglob->gl_flags & GLOB_NOSORT))
 		qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
-			pglob->gl_pathc - oldpathc, sizeof(char *), (const void *) compare);
+			pglob->gl_pathc - oldpathc, sizeof(char *), compare);
 	return(0);
 }
 
 static int
-compare(p, q)
-	const void *p, *q;
+compare(const void *p, const void *q)
 {
 	return(strcmp(*(char **)p, *(char **)q));
 }
@@ -537,8 +535,8 @@ glob1(pattern, pattern_last, pglob, limitp)
 	if (*pattern == EOS)
 		return(0);
 	return(glob2(pathbuf, pathbuf+MAXPATHLEN-1,
-	    pathbuf, pathbuf+MAXPATHLEN-1,
-	    pattern, pattern_last, pglob, limitp));
+		pathbuf, pathbuf+MAXPATHLEN-1,
+		pattern, pattern_last, pglob, limitp));
 }
 
 /*
@@ -548,7 +546,7 @@ glob1(pattern, pattern_last, pglob, limitp)
  */
 static int
 glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
-    pattern_last, pglob, limitp)
+		pattern_last, pglob, limitp)
 	Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
 	Char *pattern, *pattern_last;
 	glob_t *pglob;
@@ -569,10 +567,10 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
 				return(0);
 
 			if (((pglob->gl_flags & GLOB_MARK) &&
-			    !IS_SLASH(pathend[-1])) && (S_ISDIR(sb.st_mode) ||
-			    (S_ISLNK(sb.st_mode) &&
-			    (g_stat(pathbuf, &sb, pglob) == 0) &&
-			    S_ISDIR(sb.st_mode)))) {
+				!IS_SLASH(pathend[-1])) && (S_ISDIR(sb.st_mode) ||
+				(S_ISLNK(sb.st_mode) &&
+				(g_stat(pathbuf, &sb, pglob) == 0) &&
+				S_ISDIR(sb.st_mode)))) {
 				if (pathend+1 > pathend_last)
 					return (1);
 				*pathend++ = SEP;
@@ -604,15 +602,15 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
 		} else
 			/* Need expansion, recurse. */
 			return(glob3(pathbuf, pathbuf_last, pathend,
-			    pathend_last, pattern, pattern_last,
-			    p, pattern_last, pglob, limitp));
+				pathend_last, pattern, pattern_last,
+				p, pattern_last, pglob, limitp));
 	}
 	/* NOTREACHED */
 }
 
 static int
 glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
-    restpattern, restpattern_last, pglob, limitp)
+	restpattern, restpattern_last, pglob, limitp)
 	Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
 	Char *pattern, *pattern_last, *restpattern, *restpattern_last;
 	glob_t *pglob;
@@ -642,7 +640,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
 			if (g_Ctoc(pathbuf, buf, sizeof(buf)))
 				return(GLOB_ABORTED);
 			if (pglob->gl_errfunc(buf, errno) ||
-			    pglob->gl_flags & GLOB_ERR)
+				pglob->gl_flags & GLOB_ERR)
 				return(GLOB_ABORTED);
 		}
 		return(0);
@@ -677,7 +675,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
 			continue;
 		}
 		err = glob2(pathbuf, pathbuf_last, --dc, pathend_last,
-		    restpattern, restpattern_last, pglob, limitp);
+			restpattern, restpattern_last, pglob, limitp);
 		if (err)
 			break;
 	}
@@ -718,7 +716,7 @@ globextend(path, pglob, limitp)
 
 	newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
 	pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
-	    malloc(newsize);
+		malloc(newsize);
 	if (pathv == NULL) {
 		if (pglob->gl_pathv) {
 			free(pglob->gl_pathv);
@@ -749,7 +747,7 @@ globextend(path, pglob, limitp)
 	pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
 
 	if ((pglob->gl_flags & GLOB_LIMIT) &&
-	    newsize + *limitp >= ARG_MAX) {
+		newsize + *limitp >= ARG_MAX) {
 		errno = 0;
 		return(GLOB_NOSPACE);
 	}
@@ -776,8 +774,8 @@ match(name, pat, patend)
 			if (pat == patend)
 				return(1);
 			do
-			    if (match(name, pat, patend))
-				    return(1);
+				if (match(name, pat, patend))
+					return(1);
 			while (*name++ != EOS)
 				;
 			return(0);
@@ -860,7 +858,7 @@ g_lstat(fn, sb, pglob)
 		return(-1);
 	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
 		return((*pglob->gl_lstat)(buf, sb));
-	return(lstat(buf, sb));
+	return(php_sys_lstat(buf, sb));
 }
 
 static int
@@ -875,7 +873,7 @@ g_stat(fn, sb, pglob)
 		return(-1);
 	if (pglob->gl_flags & GLOB_ALTDIRFUNC)
 		return((*pglob->gl_stat)(buf, sb));
-	return(stat(buf, sb));
+	return(php_sys_stat(buf, sb));
 }
 
 static Char *
diff --git a/win32/php5dll.dsp b/win32/php5dll.dsp
index b0fad66..335a0d8 100644
--- a/win32/php5dll.dsp
+++ b/win32/php5dll.dsp
@@ -1564,10 +1564,6 @@ SOURCE=..\ext\com\VARIANT.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\win32\wfile.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\win32\winutil.c
 # End Source File
 # Begin Source File
diff --git a/win32/php5dllts.dsp b/win32/php5dllts.dsp
index 250d450..8471418 100644
--- a/win32/php5dllts.dsp
+++ b/win32/php5dllts.dsp
@@ -2403,10 +2403,6 @@ SOURCE=..\win32\time.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\win32\wfile.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\win32\winutil.c
 # End Source File
 # Begin Source File
diff --git a/win32/time.c b/win32/time.c
index cfd4394..0c3ccf0 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -11,7 +11,7 @@
  *
  *****************************************************************************/
 
-/* $Id: time.c 273823 2009-01-19 02:35:22Z pajoye $ */
+/* $Id: time.c 305298 2010-11-12 18:37:02Z cataphract $ */
 
  /**
   *
@@ -105,7 +105,7 @@ PHPAPI int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Inf
                     dt = (double)timer/PW32G(freq);
                     time_Info->tv_sec = PW32G(starttime).tv_sec + (int)dt;
                     time_Info->tv_usec = PW32G(starttime).tv_usec + (int)((dt-(int)dt)*1000000);
-                    if (time_Info->tv_usec > 1000000) {
+                    if (time_Info->tv_usec >= 1000000) {
                         time_Info->tv_usec -= 1000000;
                         ++time_Info->tv_sec;
                     }
diff --git a/win32/wfile.c b/win32/wfile.c
deleted file mode 100644
index 3a5118e..0000000
--- a/win32/wfile.c
+++ /dev/null
@@ -1,17 +0,0 @@
-
-/* Function borrowed from the Downhill Project */
-#include "wfile.h"
-#include "direct.h"
-
-int readlink(char *file_Name, char *buf_Mem, int buf_Size)
-{
-	/* See if the file exists */
-	if (access(file_Name, WFILE_EXISTS) == -1) {
-		errno = ENOENT;
-	} else {
-		errno = EINVAL;
-	}
-
-	/* Either way, it's not a link */
-	return -1;
-}
diff --git a/win32/wfile.h b/win32/wfile.h
deleted file mode 100644
index 0105e76..0000000
--- a/win32/wfile.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#include  <io.h>
-#include  <stdio.h>
-#include  <stdlib.h>
-#include  <errno.h>
-
-#define access _access
-#define WFILE_EXISTS	0
-#ifndef ENOENT
-#define ENOENT	136
-#endif
-#ifndef EINVAL
-#define EINVAL	131
-#endif
-
-int readlink(char *, char *, int);
-int checkroot(char *path);
diff --git a/win32/winutil.c b/win32/winutil.c
index 0dbcddf..bc20f78 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: winutil.c 300273 2010-06-08 13:00:11Z pajoye $ */
+/* $Id: winutil.c 305778 2010-11-26 18:25:13Z pajoye $ */
 
 #include "php.h"
 #include <wincrypt.h>
@@ -70,13 +70,10 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) {  /* {{{
 	ret = CryptGenRandom(hCryptProv, size, buf);
 	CryptReleaseContext(hCryptProv, 0);
 	if (ret) {
-		while (i < size && buf[i] != 0) {
-			i++;
-		}
-		if (i == size) {
-			return SUCCESS;
-		}
-   }
-	return FAILURE;
+		return SUCCESS;
+	} else {
+		return FAILURE;
+	}
 }
 /* }}} */
+
-- 
1.7.1




More information about the Pkg-php-commits mailing list